Added gfw with new devdi concept

This commit is contained in:
Dirk Alders 2025-08-28 15:42:18 +02:00
parent 158c41ef0e
commit 75a29a3c32
5 changed files with 135 additions and 217 deletions

2
devdi

@ -1 +1 @@
Subproject commit f13cdfdcb7dcc543d3a882351bd817fa2da5fe01 Subproject commit 881bc13c5a454407deeaf9f3303852e55412ac0d

View File

@ -50,6 +50,7 @@ from function.videv import videv_switching_timer as videv_sw_tm
from function.videv import videv_heating as videv_hea from function.videv import videv_heating as videv_hea
from function.videv import videv_pure_switch from function.videv import videv_pure_switch
from function.videv import videv_multistate from function.videv import videv_multistate
from function.videv import videv_audio_player
try: try:
from config import APP_NAME as ROOT_LOGGER_NAME from config import APP_NAME as ROOT_LOGGER_NAME

View File

@ -34,7 +34,7 @@ class all_functions(room_collection):
# stairway # stairway
self.stw = stairway(self.mqtt_client, pd) self.stw = stairway(self.mqtt_client, pd)
# ground floor west # ground floor west
self.gfw = ground_floor_west(self.mqtt_client, pd) self.gfw = ground_floor_west(self.mqtt_client)
# first floor west # first floor west
self.ffw = first_floor_west(self.mqtt_client) self.ffw = first_floor_west(self.mqtt_client)
# first floor east # first floor east
@ -52,7 +52,7 @@ class all_functions(room_collection):
def init_cross_room_interactions(self): def init_cross_room_interactions(self):
# shelly dirk input 1 # shelly dirk input 1
self.last_gfw_dirk_input_1 = None self.last_gfw_dirk_input_1 = None
self.gfw.dirk.main_light_shelly.add_callback(self.gfw.dirk.main_light_shelly.KEY_INPUT_1, None, self.gfw_dirk_input_1) self.gfw.dirk.switch_main_light.add_callback(self.gfw.dirk.switch_main_light.KEY_INPUT_1, None, self.gfw_dirk_input_1)
# tradfri button ffe_sleep right click # tradfri button ffe_sleep right click
self.ffe.sleep.input_device.add_callback(self.ffe.sleep.input_device.KEY_ACTION, self.ffe.sleep.input_device.add_callback(self.ffe.sleep.input_device.KEY_ACTION,
self.ffe.sleep.input_device.ACTION_RIGHT, self.ffe.floor.switch_main_light.toggle_output_0_mcb) self.ffe.sleep.input_device.ACTION_RIGHT, self.ffe.floor.switch_main_light.toggle_output_0_mcb)

View File

@ -3,6 +3,7 @@
# #
import config import config
from devdi import rooms
from devdi import topic as props from devdi import topic as props
from function.db import get_radiator_data, set_radiator_data from function.db import get_radiator_data, set_radiator_data
from function.modules import brightness_choose_n_action, heating_function, switched_light from function.modules import brightness_choose_n_action, heating_function, switched_light
@ -21,91 +22,14 @@ loc = props.LOC_GFW
class ground_floor_west(room_collection): class ground_floor_west(room_collection):
def __init__(self, mqtt_client, pd): def __init__(self, mqtt_client):
super().__init__(mqtt_client) super().__init__(mqtt_client)
self.dirk = ground_floor_west_dirk(mqtt_client, pd) self.dirk = ground_floor_west_dirk(mqtt_client)
self.floor = ground_floor_west_floor(mqtt_client, pd) self.floor = ground_floor_west_floor(mqtt_client)
self.marion = ground_floor_west_marion(mqtt_client, pd) self.marion = ground_floor_west_marion(mqtt_client)
class ground_floor_west_floor(room): class ground_floor_west_dirk(rooms.gfw_dirk, room):
def __init__(self, mqtt_client, pd):
roo = props.ROO_FLO
#
# Device initialisation
#
# http://shelly1l-84CCA8AD1148
self.main_light_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light_tradfri = pd.get(props.STG_ZGW, loc, roo, props.FUN_MAL)
super().__init__(mqtt_client)
#
# Functionality initialisation
#
# Request silvercrest data of lead light after power on
switched_light(self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0, self.main_light_tradfri)
#
# Virtual Device Interface
#
self.main_light_videv = videv_switch_brightness_color_temp(
mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_VIDEV,
self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0,
self.main_light_tradfri, self.main_light_tradfri.KEY_BRIGHTNESS,
self.main_light_tradfri, self.main_light_tradfri.KEY_COLOR_TEMP
)
class ground_floor_west_marion(room):
def __init__(self, mqtt_client, pd):
roo = props.ROO_MAR
#
# Device initialisation
#
# http://shelly1l-E8DB84A1E067
# main light
self.main_light_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
# heating function
self.heating_valve = pd.get(props.STG_ZGW, loc, roo, props.FUN_HEA)
# window light
self.window_light = pd.get(props.STG_ZGW, loc, roo, props.FUN_WIL)
super().__init__(mqtt_client)
#
# Functionality initialisation
#
# heating function
self.heating_function = heating_function(
self.heating_valve,
config.DEFAULT_TEMPERATURE,
**get_radiator_data(self.heating_valve.topic)
)
self.heating_function.add_callback(None, None, set_radiator_data, True)
# main light
self.main_light_shelly.add_callback(self.main_light_shelly.KEY_OUTPUT_0, None, self.window_light.set_output_0_mcb, True)
#
# Virtual Device Interface
#
self.main_light_videv = videv_switching(
mqtt_client, config.TOPIC_GFW_MARION_MAIN_LIGHT_VIDEV,
self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0
)
self.heating_function_videv = videv_heating(
mqtt_client, config.TOPIC_GFW_MARION_HEATING_VALVE_VIDEV,
self.heating_function
)
# window lamp
self.windowlamp_videv = videv_switch_brightness_color_temp(
mqtt_client, config.TOPIC_GFW_MARION_WINDOW_LAMP_VIDEV,
self.window_light, self.window_light.KEY_OUTPUT_0,
self.window_light, self.window_light.KEY_BRIGHTNESS,
self.window_light, self.window_light.KEY_COLOR_TEMP
)
class ground_floor_west_dirk(room):
STATE_ACTIVE_DEVICE_MAIN_LIGHT = 0 STATE_ACTIVE_DEVICE_MAIN_LIGHT = 0
STATE_ACTIVE_DEVICE_DESK_LIGHT = 1 STATE_ACTIVE_DEVICE_DESK_LIGHT = 1
STATE_ACTIVE_DEVICE_AMPLIFIER = 2 STATE_ACTIVE_DEVICE_AMPLIFIER = 2
@ -117,167 +41,155 @@ class ground_floor_west_dirk(room):
AUDIO_SOURCE_BT = 3 AUDIO_SOURCE_BT = 3
AUDIO_SOURCE_PHONO = 4 AUDIO_SOURCE_PHONO = 4
def __init__(self, mqtt_client, pd): def __init__(self, mqtt_client):
roo = props.ROO_DIR
#
# Device initialisation
#
# http://shelly1l-3C6105E44F27
# main light
self.main_light_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
self.main_light_tradfri = pd.get(props.STG_ZGW, loc, roo, props.FUN_MAL)
# powerplug
self.powerplug_common = pd.get(props.STG_MYA, loc, roo, props.FUN_MPP)
self.KEY_POWERPLUG_AMPLIFIER = self.powerplug_common.KEY_OUTPUT_0
self.KEY_POWERPLUG_PHONO = self.powerplug_common.KEY_OUTPUT_1
self.KEY_POWERPLUG_CD_PLAYER = self.powerplug_common.KEY_OUTPUT_2
self.KEY_POWERPLUG_BT = self.powerplug_common.KEY_OUTPUT_3
# dock
self.dock_tradfri = pd.get(props.STG_ZGW, loc, roo, props.FUN_DCK)
# desk light
self.desk_light_tradfri = pd.get(props.STG_ZGW, loc, roo, props.FUN_DEL)
# button
self.button_tradfri = pd.get(props.STG_ZGW, loc, roo, props.FUN_INP)
# hifi
self.remote_amplifier = pd.get(props.STG_MYA, loc, roo, props.FUN_RCA)
self.spotify_state = pd.get(props.STG_MYA, loc, roo, props.FUN_ASS)
self.mpd_state = pd.get(props.STG_MYA, loc, roo, props.FUN_ASM)
self.bt_state = pd.get(props.STG_MYA, loc, roo, props.FUN_ASB)
# heating function
self.heating_valve = pd.get(props.STG_ZGW, loc, roo, props.FUN_HEA)
super().__init__(mqtt_client) super().__init__(mqtt_client)
room.__init__(self, mqtt_client)
# #
# Functionality initialisation # light <-> videv
self.videv_main_light.connect_sw_device(self.switch_main_light, self.switch_main_light.KEY_OUTPUT_0)
self.videv_main_light.connect_br_device(self.light_main_light, self.light_main_light.KEY_BRIGHTNESS)
self.videv_main_light.connect_ct_device(self.light_main_light, self.light_main_light.KEY_COLOR_TEMP)
# #
# Button - Brightness functionality self.videv_desk_light.connect_sw_device(self.light_desk_light, self.light_desk_light.KEY_OUTPUT_0)
self.brightness_functions = brightness_choose_n_action(self.button_tradfri) self.videv_desk_light.connect_br_device(self.light_desk_light, self.light_desk_light.KEY_BRIGHTNESS)
self.brightness_functions.add(self.main_light_tradfri, self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0) self.videv_desk_light.connect_ct_device(self.light_desk_light, self.light_desk_light.KEY_COLOR_TEMP)
self.brightness_functions.add(self.desk_light_tradfri, self.desk_light_tradfri, self.desk_light_tradfri.KEY_OUTPUT_0) #
self.brightness_functions.add(self.remote_amplifier, self.powerplug_common, self.KEY_POWERPLUG_AMPLIFIER) self.videv_amplifier.connect_sw_device(self.switch_powerplug_4, self.KEY_POWERPLUG_AMPLIFIER)
# Button - Main light self.videv_bluetooth.connect_sw_device(self.switch_powerplug_4, self.KEY_POWERPLUG_BT)
self.button_tradfri.add_callback(self.button_tradfri.KEY_ACTION, self.button_tradfri.ACTION_TOGGLE, self.videv_cd_player.connect_sw_device(self.switch_powerplug_4, self.KEY_POWERPLUG_CD_PLAYER)
self.main_light_shelly.toggle_output_0_mcb) self.videv_phono.connect_sw_device(self.switch_powerplug_4, self.KEY_POWERPLUG_PHONO)
# Button - Desk light #
self.button_tradfri.add_callback(self.button_tradfri.KEY_ACTION, self.button_tradfri.ACTION_RIGHT, self.videv_pc_dock.connect_sw_device(self.switch_pc_dock, self.switch_pc_dock.KEY_OUTPUT_0)
self.desk_light_tradfri.toggle_output_0_mcb)
# Button - Amplifier
self.button_tradfri.add_callback(self.button_tradfri.KEY_ACTION, self.button_tradfri.ACTION_LEFT_LONG,
self.powerplug_common.toggle_output_0_mcb)
# Button - CD player
self.button_tradfri.add_callback(self.button_tradfri.KEY_ACTION, self.button_tradfri.ACTION_RIGHT_LONG,
self.powerplug_common.toggle_output_2_mcb)
# Button - PC dock
self.button_tradfri.add_callback(self.button_tradfri.KEY_ACTION, self.button_tradfri.ACTION_LEFT,
self.dock_tradfri.toggle_output_0_mcb)
# Mediaplayer - Amplifier auto on # amplifier on, if playing device on
self.powerplug_common.add_callback(self.KEY_POWERPLUG_PHONO, None, self.powerplug_common.set_output_0_mcb, True) self.switch_powerplug_4.add_callback(self.KEY_POWERPLUG_PHONO, None, self.switch_powerplug_4.set_output_0_mcb, True)
self.powerplug_common.add_callback(self.KEY_POWERPLUG_CD_PLAYER, None, self.powerplug_common.set_output_0_mcb, True) self.switch_powerplug_4.add_callback(self.KEY_POWERPLUG_CD_PLAYER, None, self.switch_powerplug_4.set_output_0_mcb, True)
self.powerplug_common.add_callback(self.KEY_POWERPLUG_BT, None, self.powerplug_common.set_output_0_mcb, True) self.switch_powerplug_4.add_callback(self.KEY_POWERPLUG_BT, None, self.switch_powerplug_4.set_output_0_mcb, True)
self.spotify_state.add_callback(self.spotify_state.KEY_STATE, None, self.powerplug_common.set_output_0_mcb, True) # amplifier on, if player on
self.mpd_state.add_callback(self.mpd_state.KEY_STATE, None, self.powerplug_common.set_output_0_mcb, True) self.audio_status_bluetooth.add_callback(self.audio_status_bluetooth.KEY_STATE, None, self.switch_powerplug_4.set_output_0_mcb, True)
self.bt_state.add_callback(self.bt_state.KEY_STATE, None, self.powerplug_common.set_output_0_mcb, True) self.audio_status_mpd.add_callback(self.audio_status_mpd.KEY_STATE, None, self.switch_powerplug_4.set_output_0_mcb, True)
# Mediaplayer - Audio source selection self.audio_status_spotify.add_callback(self.audio_status_spotify.KEY_STATE, None, self.switch_powerplug_4.set_output_0_mcb, True)
self.powerplug_common.add_callback(self.KEY_POWERPLUG_AMPLIFIER, True, self.audio_source_selector, True)
self.powerplug_common.add_callback(self.KEY_POWERPLUG_CD_PLAYER, True, self.audio_source_selector, True) # Audio source selection
self.powerplug_common.add_callback(self.KEY_POWERPLUG_BT, True, self.audio_source_selector, True) self.switch_powerplug_4.add_callback(self.KEY_POWERPLUG_AMPLIFIER, True, self.audio_source_selector, True)
self.powerplug_common.add_callback(self.KEY_POWERPLUG_PHONO, True, self.audio_source_selector, True) self.switch_powerplug_4.add_callback(self.KEY_POWERPLUG_CD_PLAYER, True, self.audio_source_selector, True)
self.spotify_state.add_callback(self.spotify_state.KEY_STATE, True, self.audio_source_selector, True) self.switch_powerplug_4.add_callback(self.KEY_POWERPLUG_BT, True, self.audio_source_selector, True)
self.mpd_state.add_callback(self.mpd_state.KEY_STATE, True, self.audio_source_selector, True) self.switch_powerplug_4.add_callback(self.KEY_POWERPLUG_PHONO, True, self.audio_source_selector, True)
self.bt_state.add_callback(self.bt_state.KEY_STATE, True, self.audio_source_selector, True) self.audio_status_bluetooth.add_callback(self.audio_status_bluetooth.KEY_STATE, True, self.audio_source_selector, True)
self.audio_status_mpd.add_callback(self.audio_status_mpd.KEY_STATE, True, self.audio_source_selector, True)
self.audio_status_spotify.add_callback(self.audio_status_spotify.KEY_STATE, True, self.audio_source_selector, True)
self.audio_source = self.AUDIO_SOURCE_PC self.audio_source = self.AUDIO_SOURCE_PC
self.delayed_task_remote = task.delayed(1.0, self.send_audio_source)
# input device functions
# Brightness functionality
self.brightness_functions = brightness_choose_n_action(self.input_device)
self.brightness_functions.add(self.light_main_light, self.switch_main_light, self.switch_main_light.KEY_OUTPUT_0)
self.brightness_functions.add(self.light_desk_light, self.light_desk_light, self.light_desk_light.KEY_OUTPUT_0)
self.brightness_functions.add(self.remote_ctrl, self.switch_powerplug_4, self.KEY_POWERPLUG_AMPLIFIER)
# Button - Main light
self.input_device.add_callback(self.input_device.KEY_ACTION, self.input_device.ACTION_TOGGLE,
self.switch_main_light.toggle_output_0_mcb)
# Button - Desk light
self.input_device.add_callback(self.input_device.KEY_ACTION, self.input_device.ACTION_RIGHT,
self.light_desk_light.toggle_output_0_mcb)
# Button - Amplifier
self.input_device.add_callback(self.input_device.KEY_ACTION, self.input_device.ACTION_LEFT_LONG,
self.switch_powerplug_4.toggle_output_0_mcb)
# Button - CD player
self.input_device.add_callback(self.input_device.KEY_ACTION, self.input_device.ACTION_RIGHT_LONG,
self.switch_powerplug_4.toggle_output_2_mcb)
# Button - PC dock
self.input_device.add_callback(self.input_device.KEY_ACTION, self.input_device.ACTION_LEFT,
self.switch_pc_dock.toggle_output_0_mcb)
# additional videv connections
self.videv_multistate.connect_br_function(self.brightness_functions, brightness_choose_n_action.KEY_ACTIVE_DEVICE, 3)
#
self.videv_audio_player.connect_audio_device(self.audio_status_bluetooth)
self.videv_audio_player.connect_audio_device(self.audio_status_mpd)
self.videv_audio_player.connect_audio_device(self.audio_status_spotify)
# heating function # heating function
self.heating_function = heating_function( self.heating_function = heating_function(
self.heating_valve, self.valve_heating,
config.DEFAULT_TEMPERATURE, config.DEFAULT_TEMPERATURE,
**get_radiator_data(self.heating_valve.topic) **get_radiator_data(self.valve_heating.topic)
) )
self.heating_function.add_callback(None, None, set_radiator_data, True) self.heating_function.add_callback(None, None, set_radiator_data, True)
# heating function <-> videv
# self.videv_heating.connect_heating_function(self.heating_function)
# Virtual Device Interface
#
self.main_light_videv = videv_switch_brightness_color_temp(
mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_VIDEV,
self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0,
self.main_light_tradfri, self.main_light_tradfri.KEY_BRIGHTNESS,
self.main_light_tradfri, self.main_light_tradfri.KEY_COLOR_TEMP
)
self.desk_light_videv = videv_switch_brightness_color_temp(
mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_VIDEV,
self.desk_light_tradfri, self.desk_light_tradfri.KEY_OUTPUT_0,
self.desk_light_tradfri, self.desk_light_tradfri.KEY_BRIGHTNESS,
self.desk_light_tradfri, self.desk_light_tradfri.KEY_COLOR_TEMP
)
self.amplifier_videv = videv_switching(
mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_VIDEV,
self.powerplug_common, self.KEY_POWERPLUG_AMPLIFIER
)
self.phono_videv = videv_switching(
mqtt_client, config.TOPIC_GFW_DIRK_PHONO_VIDEV,
self.powerplug_common, self.KEY_POWERPLUG_PHONO
)
self.cd_player_videv = videv_switching(
mqtt_client, config.TOPIC_GFW_DIRK_CD_PLAYER_VIDEV,
self.powerplug_common, self.KEY_POWERPLUG_CD_PLAYER
)
self.bt_videv = videv_switching(
mqtt_client, config.TOPIC_GFW_DIRK_BT_VIDEV,
self.powerplug_common, self.KEY_POWERPLUG_BT
)
self.pc_dock_videv = videv_switching(
mqtt_client, config.TOPIC_GFW_DIRK_PC_DOCK_VIDEV,
self.dock_tradfri, self.dock_tradfri.KEY_OUTPUT_0
)
self.heating_function_videv = videv_heating(
mqtt_client, config.TOPIC_GFW_DIRK_HEATING_VALVE_VIDEV,
self.heating_function
)
self.brightness_functions_device_videv = videv_multistate(
mqtt_client, config.TOPIC_GFW_DIRK_ACTIVE_BRIGHTNESS_DEVICE_VIDEV,
brightness_choose_n_action.KEY_ACTIVE_DEVICE, self.brightness_functions, 3
)
self.audio_player_videv = videv_audio_player(
mqtt_client, config.TOPIC_GFW_DIRK_AUDIO_PLAYER_VIDEV,
self.spotify_state, self.mpd_state, self.bt_state
)
#
# Other stuff
#
self.delayed_task_remote = task.delayed(1.0, self.send_audio_source)
def audio_source_selector(self, device, key, data): def audio_source_selector(self, device, key, data):
if device == self.powerplug_common and key == self.KEY_POWERPLUG_CD_PLAYER: if device == self.switch_powerplug_4 and key == self.KEY_POWERPLUG_CD_PLAYER:
# switch on of cd player # switch on of cd player
self.audio_source = self.AUDIO_SOURCE_CD self.audio_source = self.AUDIO_SOURCE_CD
elif device == self.powerplug_common and key == self.KEY_POWERPLUG_BT: elif device == self.switch_powerplug_4 and key == self.KEY_POWERPLUG_BT:
# switch on of bluetooth # switch on of bluetooth
self.audio_source = self.AUDIO_SOURCE_BT self.audio_source = self.AUDIO_SOURCE_BT
elif device == self.powerplug_common and key == self.KEY_POWERPLUG_PHONO: elif device == self.switch_powerplug_4 and key == self.KEY_POWERPLUG_PHONO:
# switch on of bluetooth # switch on of bluetooth
self.audio_source = self.AUDIO_SOURCE_PHONO self.audio_source = self.AUDIO_SOURCE_PHONO
elif device in [self.spotify_state, self.mpd_state, self.bt_state]: elif device in [self.audio_status_spotify, self.audio_status_mpd, self.audio_status_bluetooth]:
# switch on raspi-source # switch on raspi-source
self.audio_source = self.AUDIO_SOURCE_RASPI self.audio_source = self.AUDIO_SOURCE_RASPI
elif device == self.powerplug_common and key == self.KEY_POWERPLUG_AMPLIFIER: elif device == self.switch_powerplug_4 and key == self.KEY_POWERPLUG_AMPLIFIER:
# switch on of amplifier -> select source and reset stored source value # switch on of amplifier -> select source and reset stored source value
self.delayed_task_remote.run() self.delayed_task_remote.run()
def send_audio_source(self): def send_audio_source(self):
if self.audio_source == self.AUDIO_SOURCE_PC: if self.audio_source == self.AUDIO_SOURCE_PC:
logger.info("Sending IR command to change audio source to pc") logger.info("Sending IR command to change audio source to pc")
self.remote_amplifier.set_line3() self.remote_ctrl.set_line3()
elif self.audio_source == self.AUDIO_SOURCE_CD: elif self.audio_source == self.AUDIO_SOURCE_CD:
logger.info("Sending IR command to change audio source to cd") logger.info("Sending IR command to change audio source to cd")
self.remote_amplifier.set_cd() self.remote_ctrl.set_cd()
elif self.audio_source == self.AUDIO_SOURCE_BT: elif self.audio_source == self.AUDIO_SOURCE_BT:
logger.info("Sending IR command to change audio source to bluetooth") logger.info("Sending IR command to change audio source to bluetooth")
self.remote_amplifier.set_line2() self.remote_ctrl.set_line2()
elif self.audio_source == self.AUDIO_SOURCE_PHONO: elif self.audio_source == self.AUDIO_SOURCE_PHONO:
logger.info("Sending IR command to change audio source to phono") logger.info("Sending IR command to change audio source to phono")
self.remote_amplifier.set_phono() self.remote_ctrl.set_phono()
elif self.audio_source == self.AUDIO_SOURCE_RASPI: elif self.audio_source == self.AUDIO_SOURCE_RASPI:
logger.info("Sending IR command to change audio source to raspi") logger.info("Sending IR command to change audio source to raspi")
self.remote_amplifier.set_line1() self.remote_ctrl.set_line1()
self.audio_source = self.AUDIO_SOURCE_PC self.audio_source = self.AUDIO_SOURCE_PC
class ground_floor_west_floor(rooms.gfw_floor, room):
def __init__(self, mqtt_client):
super().__init__(mqtt_client)
room.__init__(self, mqtt_client)
#
# Request silvercrest data of lead light after power on
switched_light(self.switch_main_light, self.switch_main_light.KEY_OUTPUT_0, self.light_main_light)
# light <-> videv
self.videv_main_light.connect_sw_device(self.switch_main_light, self.switch_main_light.KEY_OUTPUT_0)
self.videv_main_light.connect_br_device(self.light_main_light, self.light_main_light.KEY_BRIGHTNESS)
self.videv_main_light.connect_ct_device(self.light_main_light, self.light_main_light.KEY_COLOR_TEMP)
class ground_floor_west_marion(rooms.gfw_marion, room):
def __init__(self, mqtt_client):
super().__init__(mqtt_client)
room.__init__(self, mqtt_client)
#
# light <-> videv
self.videv_main_light.connect_sw_device(self.switch_main_light, self.switch_main_light.KEY_OUTPUT_0)
#
self.videv_window_light.connect_sw_device(self.light_window_light, self.light_window_light.KEY_OUTPUT_0)
self.videv_window_light.connect_br_device(self.light_window_light, self.light_window_light.KEY_BRIGHTNESS)
self.videv_window_light.connect_ct_device(self.light_window_light, self.light_window_light.KEY_COLOR_TEMP)
# main light -> window_light
self.switch_main_light.add_callback(self.switch_main_light.KEY_OUTPUT_0, None, self.light_window_light.set_output_0_mcb, True)
# heating function
self.heating_function = heating_function(
self.valve_heating,
config.DEFAULT_TEMPERATURE,
**get_radiator_data(self.valve_heating.topic)
)
self.heating_function.add_callback(None, None, set_radiator_data, True)
# heating function <-> videv
self.videv_heating.connect_heating_function(self.heating_function)

View File

@ -157,11 +157,16 @@ class videv_audio_player(videv_base):
def __init__(self, mqtt_client, topic, *args): def __init__(self, mqtt_client, topic, *args):
super().__init__(mqtt_client, topic) super().__init__(mqtt_client, topic)
for i, device in enumerate(args): self.__device_cnt__ = 0
self.add_display(self.KEY_ACTIVE_PLAYER % i, device, device.KEY_STATE)
# #
for audio_device in args: # TODO: Remove the following code and the parameters from __init__
audio_device.add_callback(audio_device.KEY_TITLE, None, self.__title_rx__, True) for device in args:
self.connect_audio_device(device)
def connect_audio_device(self, device):
self.add_display(self.KEY_ACTIVE_PLAYER % self.__device_cnt__, device, device.KEY_STATE)
device.add_callback(device.KEY_TITLE, None, self.__title_rx__, True)
self.__device_cnt__ += 1
def __title_rx__(self, device, key, data): def __title_rx__(self, device, key, data):
self.__tx__(self.KEY_TITLE, data or self.NO_TITLE) self.__tx__(self.KEY_TITLE, data or self.NO_TITLE)