import config from .topic import get_topic import logging # from devdi import topic as props from mqtt import mqtt_client """ In this module we initialse the smartzhome devices for all rooms. These rooms can be used in the different project for smarthome. The device names in the room classes follow this definition: switch_main_light light_main_light motion_main_light_xx (xx: gf, ff) videv_main_light switch_desk_light light_desk_light videv_desk_light switch_floor_light light_floor_light videv_floor_light switch_window_light light_window_light videv_window_light switch_wardrobe_light light_wardrobe_light videv_wardrobe_light switch_bed_dirk_light light_bed_dirk_light videv_bed_dirk_light switch_bed_marion_light light_bed_marion_light videv_bed_marion_light switch_window_light light_window_light videv_window_light switch_garland_light videv_garland_light switch_repeater videv_repeater switch_xmas_tree_light videv_xmas_tree_light switch_xmas_star_light videv_xmas_star_light switch_circulation_pump videv_circulation_pump switch_powerplug_4 videv_amplifier videv_cd_player videv_bluetooth videv_phono switch_pc_dock videv_pc_dock remote_ctrl audio_status_spotify audio_status_mpd audio_status_bluetooth valve_heating ambient_info videv_heating videv_multistate videv_mode input_device The following devices are already in use and have to be defined in devices.xxx """ from devices import group from devices import shelly_sw1 from devices import hue_sw_br_ct from devices import tradfri_sw from devices import tradfri_sw_br from devices import tradfri_sw_br_ct from devices import tradfri_button from devices import livarno_sw_br_ct from devices import brennenstuhl_heatingvalve from devices import silvercrest_powerplug from devices import silvercrest_motion_sensor from devices import my_powerplug from devices import audio_status from devices import remote from devices import my_ambient # from devices import videv_sw from devices import videv_sw_br from devices import videv_sw_br_ct from devices import videv_sw_tm from devices import videv_sw_mo from devices import videv_hea from devices import videv_pure_switch from devices import videv_multistate from devices import videv_audio_player # # try: from config import APP_NAME as ROOT_LOGGER_NAME except ImportError: ROOT_LOGGER_NAME = 'root' logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__) class base_room(object): def __get_group__(self, class_type, mqtt_client, stg, loc, roo, fun, num): dg = [] topic = get_topic(stg, loc, roo, fun) for i in range(1, num + 1): device_topic = topic + '_%d' % i dg.append(class_type(mqtt_client, device_topic)) this_device = group(*dg) return this_device # # FFE ############################################################################################# # class ffe_floor(base_room): def __init__(self, mqtt_client: mqtt_client): loc = props.LOC_FFE roo = props.ROO_FLO # # http://shelly1l-3C6105E4E629 self.switch_main_light = shelly_sw1(mqtt_client, get_topic(props.STG_SHE, loc, roo, props.FUN_MAL)) self.videv_main_light = videv_sw(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_MAL)) class ffe_diningroom(base_room): def __init__(self, mqtt_client: mqtt_client): loc = props.LOC_FFE roo = props.ROO_DIN # # http://shelly1l-84CCA8ADD055 self.switch_main_light = shelly_sw1(mqtt_client, get_topic(props.STG_SHE, loc, roo, props.FUN_MAL)) self.videv_main_light = videv_sw(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_MAL)) self.switch_floor_light = silvercrest_powerplug(mqtt_client, get_topic(props.STG_ZFE, loc, roo, props.FUN_FLL)) self.videv_floor_light = videv_sw(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_FLL)) self.valve_heating = brennenstuhl_heatingvalve(mqtt_client, get_topic(props.STG_ZFE, loc, roo, props.FUN_HEA)) self.videv_heating = videv_hea(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_HEA)) if config.CHRISTMAS: self.switch_garland_light = silvercrest_powerplug(mqtt_client, get_topic(props.STG_ZFE, loc, roo, props.FUN_GAR)) self.videv_garland_light = videv_sw(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_GAR)) class ffe_kitchen(base_room): def __init__(self, mqtt_client: mqtt_client): loc = props.LOC_FFE roo = props.ROO_KIT # # http://shelly1l-8CAAB5616C01 self.switch_main_light = shelly_sw1(mqtt_client, get_topic(props.STG_SHE, loc, roo, props.FUN_MAL)) self.light_main_light: hue_sw_br_ct = self.__get_group__(hue_sw_br_ct, mqtt_client, props.STG_ZFE, loc, roo, props.FUN_MAL, 2) self.videv_main_light = videv_sw_br_ct(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_MAL)) # http://shelly1-e89f6d85a466 self.switch_circulation_pump = shelly_sw1(mqtt_client, get_topic(props.STG_SHE, loc, roo, props.FUN_CIR)) self.videv_circulation_pump = videv_sw_tm(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_CIR)) self.valve_heating = brennenstuhl_heatingvalve(mqtt_client, get_topic(props.STG_ZFE, loc, roo, props.FUN_HEA)) self.videv_heating = videv_hea(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_HEA)) class ffe_livingroom(base_room): def __init__(self, mqtt_client: mqtt_client): loc = props.LOC_FFE roo = props.ROO_LIV # # http://shelly1l-3C6105E3F910 self.switch_main_light = shelly_sw1(mqtt_client, get_topic(props.STG_SHE, loc, roo, props.FUN_MAL)) self.light_main_light = tradfri_sw_br_ct(mqtt_client, get_topic(props.STG_ZFE, loc, roo, props.FUN_MAL)) self.videv_main_light = videv_sw_br_ct(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_MAL)) self.light_floor_light: tradfri_sw_br_ct = self.__get_group__(tradfri_sw_br_ct, mqtt_client, props.STG_ZFE, loc, roo, props.FUN_FLL, 6) self.videv_floor_light = videv_sw_br_ct(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_FLL)) self.valve_heating = brennenstuhl_heatingvalve(mqtt_client, get_topic(props.STG_ZFE, loc, roo, props.FUN_HEA)) self.videv_heating = videv_hea(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_HEA)) self.ambient_info = my_ambient(mqtt_client, get_topic(props.STG_MYA, loc, roo, props.FUN_AMB)) if config.CHRISTMAS: self.switch_xmas_tree_light = silvercrest_powerplug(mqtt_client, get_topic(props.STG_ZFE, loc, roo, props.FUN_XTR)) self.videv_xmas_tree_light = videv_sw(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_XTR)) self.switch_xmas_star_light = silvercrest_powerplug(mqtt_client, get_topic(props.STG_ZFE, loc, roo, props.FUN_XST)) self.videv_xmas_star_light = videv_sw(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_XST)) class ffe_sleep(base_room): def __init__(self, mqtt_client: mqtt_client): loc = props.LOC_FFE roo = props.ROO_SLP # # http://shelly1l-E8DB84A254C7 self.switch_main_light = shelly_sw1(mqtt_client, get_topic(props.STG_SHE, loc, roo, props.FUN_MAL)) self.light_main_light = tradfri_sw_br_ct(mqtt_client, get_topic(props.STG_ZFE, loc, roo, props.FUN_MAL)) self.videv_main_light = videv_sw_br_ct(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_MAL)) self.input_device = tradfri_button(mqtt_client, get_topic(props.STG_ZFE, loc, roo, props.FUN_INP)) self.light_bed_dirk_light = tradfri_sw_br(mqtt_client, get_topic(props.STG_ZFE, loc, roo, props.FUN_BLD)) self.videv_bed_dirk_light = videv_sw_br(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_BLD)) self.switch_bed_marion_light = silvercrest_powerplug(mqtt_client, get_topic(props.STG_ZFE, loc, roo, props.FUN_BLM)) self.videv_bed_marion_light = videv_sw(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_BLM)) self.light_wardrobe_light = tradfri_sw_br(mqtt_client, get_topic(props.STG_ZFE, loc, roo, props.FUN_WLI)) self.videv_wardrobe_light = videv_sw_br(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_WLI)) self.valve_heating = brennenstuhl_heatingvalve(mqtt_client, get_topic(props.STG_ZFE, loc, roo, props.FUN_HEA)) self.videv_heating = videv_hea(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_HEA)) self.videv_multistate = videv_multistate(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_VMS)) # # FFW ############################################################################################# # class ffw_bath(base_room): def __init__(self, mqtt_client: mqtt_client): loc = props.LOC_FFW roo = props.ROO_BAT # # http://shelly1-58BF25D84219 self.switch_main_light = shelly_sw1(mqtt_client, get_topic(props.STG_SHE, loc, roo, props.FUN_MAL)) self.videv_main_light = videv_sw(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_MAL)) self.valve_heating = brennenstuhl_heatingvalve(mqtt_client, get_topic(props.STG_ZFW, loc, roo, props.FUN_HEA)) self.videv_heating = videv_hea(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_HEA)) class ffw_floor(base_room): def __init__(self, mqtt_client: mqtt_client): loc = props.LOC_FFW roo = props.ROO_FLO # # http://shelly1-58BF25D848EA self.switch_main_light = shelly_sw1(mqtt_client, get_topic(props.STG_SHE, loc, roo, props.FUN_MAL)) self.videv_main_light = videv_sw(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_MAL)) class ffw_julian(base_room): def __init__(self, mqtt_client: mqtt_client): loc = props.LOC_FFW roo = props.ROO_JUL # # http://shelly1l-3C6105E43452 self.switch_main_light = shelly_sw1(mqtt_client, get_topic(props.STG_SHE, loc, roo, props.FUN_MAL)) self.light_main_light = tradfri_sw_br_ct(mqtt_client, get_topic(props.STG_ZFW, loc, roo, props.FUN_MAL)) self.videv_main_light = videv_sw_br_ct(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_MAL)) self.valve_heating = brennenstuhl_heatingvalve(mqtt_client, get_topic(props.STG_ZFW, loc, roo, props.FUN_HEA)) self.videv_heating = videv_hea(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_HEA)) class ffw_livingroom(base_room): def __init__(self, mqtt_client: mqtt_client): loc = props.LOC_FFW roo = props.ROO_LIV # # http://shelly1l-84CCA8ACE6A1 self.switch_main_light = shelly_sw1(mqtt_client, get_topic(props.STG_SHE, loc, roo, props.FUN_MAL)) self.light_main_light = tradfri_sw_br_ct(mqtt_client, get_topic(props.STG_ZFW, loc, roo, props.FUN_MAL)) self.videv_main_light = videv_sw_br_ct(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_MAL)) self.valve_heating = brennenstuhl_heatingvalve(mqtt_client, get_topic(props.STG_ZFW, loc, roo, props.FUN_HEA)) self.videv_heating = videv_hea(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_HEA)) class ffw_sleep(base_room): def __init__(self, mqtt_client: mqtt_client): loc = props.LOC_FFW roo = props.ROO_SLP # # http://shelly1-3494546A51F2 self.switch_main_light = shelly_sw1(mqtt_client, get_topic(props.STG_SHE, loc, roo, props.FUN_MAL)) self.light_main_light = tradfri_sw_br(mqtt_client, get_topic(props.STG_ZFW, loc, roo, props.FUN_MAL)) self.videv_main_light = videv_sw_br(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_MAL)) self.light_window_light = tradfri_sw_br_ct(mqtt_client, get_topic(props.STG_ZFW, loc, roo, props.FUN_WIL)) self.videv_window_light = videv_sw_br_ct(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_WIL)) self.valve_heating = brennenstuhl_heatingvalve(mqtt_client, get_topic(props.STG_ZFW, loc, roo, props.FUN_HEA)) self.videv_heating = videv_hea(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_HEA)) # # GAR ############################################################################################# # class gar_garden(base_room): def __init__(self, mqtt_client: mqtt_client): loc = props.LOC_GAR roo = props.ROO_GAR # self.switch_garland_light = silvercrest_powerplug(mqtt_client, get_topic(props.STG_ZGW, loc, roo, props.FUN_GAR)) self.videv_garland_light = videv_sw(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_GAR)) self.switch_repeater = silvercrest_powerplug(mqtt_client, get_topic(props.STG_ZGW, loc, roo, props.FUN_REP)) self.videv_repeater = videv_sw(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_REP)) self.videv_mode = videv_pure_switch(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_MOD)) # # GFW ############################################################################################# # class gfw_dirk(base_room): def __init__(self, mqtt_client: mqtt_client): loc = props.LOC_GFW roo = props.ROO_DIR # # http://shelly1l-3C6105E44F27 self.switch_main_light = shelly_sw1(mqtt_client, get_topic(props.STG_SHE, loc, roo, props.FUN_MAL)) self.light_main_light = tradfri_sw_br_ct(mqtt_client, get_topic(props.STG_ZGW, loc, roo, props.FUN_MAL)) self.videv_main_light = videv_sw_br_ct(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_MAL)) self.input_device = tradfri_button(mqtt_client, get_topic(props.STG_ZGW, loc, roo, props.FUN_INP)) self.videv_multistate = videv_multistate(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_VMS)) self.switch_powerplug_4 = my_powerplug(mqtt_client, get_topic(props.STG_MYA, loc, roo, props.FUN_MPP)) self.KEY_POWERPLUG_AMPLIFIER = self.switch_powerplug_4.KEY_OUTPUT_0 self.KEY_POWERPLUG_PHONO = self.switch_powerplug_4.KEY_OUTPUT_1 self.KEY_POWERPLUG_CD_PLAYER = self.switch_powerplug_4.KEY_OUTPUT_2 self.KEY_POWERPLUG_BT = self.switch_powerplug_4.KEY_OUTPUT_3 self.switch_powerplug_4.set_ch_name(self.KEY_POWERPLUG_AMPLIFIER, "amplifier") self.switch_powerplug_4.set_ch_name(self.KEY_POWERPLUG_PHONO, "phono") self.switch_powerplug_4.set_ch_name(self.KEY_POWERPLUG_CD_PLAYER, "cd-player") self.switch_powerplug_4.set_ch_name(self.KEY_POWERPLUG_BT, "bluetooth") self.videv_amplifier = videv_sw(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_AMP)) self.videv_cd_player = videv_sw(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_CDP)) self.videv_bluetooth = videv_sw(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_BTP)) self.videv_phono = videv_sw(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_PHO)) self.light_desk_light = tradfri_sw_br_ct(mqtt_client, get_topic(props.STG_ZGW, loc, roo, props.FUN_DEL)) self.videv_desk_light = videv_sw_br_ct(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_DEL)) self.switch_pc_dock = silvercrest_powerplug(mqtt_client, get_topic(props.STG_ZGW, loc, roo, props.FUN_DCK)) self.videv_pc_dock = videv_sw(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_DCK)) self.remote_ctrl = remote(mqtt_client, get_topic(props.STG_MYA, loc, roo, props.FUN_RCA)) self.audio_status_spotify = audio_status(mqtt_client, get_topic(props.STG_MYA, loc, roo, props.FUN_ASS)) self.audio_status_mpd = audio_status(mqtt_client, get_topic(props.STG_MYA, loc, roo, props.FUN_ASM)) self.audio_status_bluetooth = audio_status(mqtt_client, get_topic(props.STG_MYA, loc, roo, props.FUN_ASB)) self.videv_audio_player = videv_audio_player(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_VAU)) self.valve_heating = brennenstuhl_heatingvalve(mqtt_client, get_topic(props.STG_ZGW, loc, roo, props.FUN_HEA)) self.ambient_info = my_ambient(mqtt_client, get_topic(props.STG_MYA, loc, roo, props.FUN_AMB)) self.videv_heating = videv_hea(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_HEA)) class gfw_floor(base_room): def __init__(self, mqtt_client: mqtt_client): loc = props.LOC_GFW roo = props.ROO_FLO # # http://shelly1l-84CCA8AD1148 self.switch_main_light = shelly_sw1(mqtt_client, get_topic(props.STG_SHE, loc, roo, props.FUN_MAL)) self.light_main_light: tradfri_sw_br_ct = self.__get_group__(tradfri_sw_br_ct, mqtt_client, props.STG_ZGW, loc, roo, props.FUN_MAL, 2) self.videv_main_light = videv_sw_br_ct(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_MAL)) class gfw_marion(base_room): def __init__(self, mqtt_client: mqtt_client): loc = props.LOC_GFW roo = props.ROO_MAR # http://shelly1l-E8DB84A1E067 self.switch_main_light = shelly_sw1(mqtt_client, get_topic(props.STG_SHE, loc, roo, props.FUN_MAL)) self.videv_main_light = videv_sw(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_MAL)) self.light_window_light = tradfri_sw_br_ct(mqtt_client, get_topic(props.STG_ZGW, loc, roo, props.FUN_WIL)) self.videv_window_light = videv_sw_br_ct(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_WIL)) self.valve_heating = brennenstuhl_heatingvalve(mqtt_client, get_topic(props.STG_ZGW, loc, roo, props.FUN_HEA)) self.videv_heating = videv_hea(mqtt_client, get_topic(props.STG_VDE, loc, roo, props.FUN_HEA)) # # STW ############################################################################################# # class stairway(base_room): def __init__(self, mqtt_client: mqtt_client): loc = props.LOC_STW # # http://shelly1-3494546A9364 self.switch_main_light = shelly_sw1(mqtt_client, get_topic(props.STG_SHE, loc, props.ROO_STF, props.FUN_MAL)) self.motion_main_light_gf = silvercrest_motion_sensor(mqtt_client, get_topic(props.STG_ZGW, loc, props.ROO_STG, props.FUN_MSE)) self.motion_main_light_ff = silvercrest_motion_sensor(mqtt_client, get_topic(props.STG_ZFE, loc, props.ROO_STF, props.FUN_MSE)) self.videv_main_light = videv_sw_mo(mqtt_client, get_topic(props.STG_VDE, loc, props.ROO_STF, props.FUN_MAL))