123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- import config
- from __simulation__.devices import shelly, silvercrest_powerplug, tradfri_light, my_powerplug, brennenstuhl_heating_valve
- from __simulation__.devices import videv_light
- import inspect
-
-
- class base(object):
- def getmembers(self, prefix=''):
- rv = []
- for name, obj in inspect.getmembers(self):
- if prefix:
- full_name = prefix + '.' + name
- else:
- full_name = name
- if not name.startswith('_'):
- try:
- if obj.__module__.endswith('devices'):
- rv.append(full_name)
- else:
- rv.extend(obj.getmembers(full_name))
- except AttributeError:
- pass
- return rv
-
- def getobjbyname(self, name):
- obj = self
- for subname in name.split('.'):
- obj = getattr(obj, subname)
- return obj
-
- def command(self, full_command):
- try:
- parameter = " " + full_command.split(' ')[1]
- except IndexError:
- parameter = ""
- command = full_command.split(' ')[0].split('.')[-1] + parameter
- device_name = '.'.join(full_command.split(' ')[0].split('.')[:-1])
- self.getobjbyname(device_name).command(command)
-
-
- class gfw_floor(base):
- def __init__(self, mqtt_client):
- self.main_light = shelly(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
- self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
- self.main_light_zigbee = tradfri_light(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_ZIGBEE % 1, True, True, True, False)
- self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_on, True)
- self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_off, False)
- self.main_light_zigbee_2 = tradfri_light(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_ZIGBEE % 2, True, True, True, False)
- self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee_2.power_on, True)
- self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee_2.power_off, False)
-
- #
- self.videv_main_light = videv_light(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_VIDEV, True, True, True)
-
-
- class gfw_marion(base):
- def __init__(self, mqtt_client):
- self.main_light = shelly(mqtt_client, config.TOPIC_GFW_MARION_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
- self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
-
- self.heating_valve = brennenstuhl_heating_valve(mqtt_client, config.TOPIC_GFW_MARION_HEATING_VALVE_ZIGBEE)
-
- #
- self.videv_main_light = videv_light(mqtt_client, config.TOPIC_GFW_MARION_MAIN_LIGHT_VIDEV, True, False, False)
-
-
- class gfw_dirk(base):
- def __init__(self, mqtt_client):
- self.main_light = shelly(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
- self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
- self.main_light_zigbee = tradfri_light(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_ZIGBEE, True, True, True)
- self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_on, True)
- self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_off, False)
-
- self.amplifier = my_powerplug(mqtt_client, config.TOPIC_GFW_DIRK_POWERPLUG, 0)
- self.amplifier.add_channel_name(my_powerplug.KEY_OUTPUT_0, "Amplifier")
- self.desk_light = my_powerplug(mqtt_client, config.TOPIC_GFW_DIRK_POWERPLUG, 1)
- self.desk_light.add_channel_name(my_powerplug.KEY_OUTPUT_0, "Desk Light")
- self.cd_player = my_powerplug(mqtt_client, config.TOPIC_GFW_DIRK_POWERPLUG, 2)
- self.cd_player.add_channel_name(my_powerplug.KEY_OUTPUT_0, "CD_Player")
- self.pc_dock = my_powerplug(mqtt_client, config.TOPIC_GFW_DIRK_POWERPLUG, 3)
- self.pc_dock.add_channel_name(my_powerplug.KEY_OUTPUT_0, "PC_Dock")
- self.desk_light_zigbee = tradfri_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_ZIGBEE, True, True, True)
- self.desk_light.add_callback(my_powerplug.KEY_OUTPUT_0, self.desk_light_zigbee.power_on, True)
- self.desk_light.add_callback(my_powerplug.KEY_OUTPUT_0, self.desk_light_zigbee.power_off, False)
-
- self.heating_valve = brennenstuhl_heating_valve(mqtt_client, config.TOPIC_GFW_DIRK_HEATING_VALVE_ZIGBEE)
-
- #
- self.videv_main_light = videv_light(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_VIDEV, True, True, True)
- self.videv_amplifier = videv_light(mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_VIDEV, True, False, False)
- self.videv_desk_light = videv_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_VIDEV, True, True, True)
- self.videv_cd_player = videv_light(mqtt_client, config.TOPIC_GFW_DIRK_CD_PLAYER_VIDEV, True, False, False)
- self.videv_pc_dock = videv_light(mqtt_client, config.TOPIC_GFW_DIRK_PC_DOCK_VIDEV, True, False, False)
-
-
- class gfw(base):
- def __init__(self, mqtt_client):
- self.floor = gfw_floor(mqtt_client)
- self.marion = gfw_marion(mqtt_client)
- self.dirk = gfw_dirk(mqtt_client)
-
-
- class ffw_julian(base):
- def __init__(self, mqtt_client):
- self.main_light = shelly(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
- self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
- self.main_light_zigbee = tradfri_light(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_ZIGBEE, True, True, True)
- self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_on, True)
- self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_off, False)
-
- #
- self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_VIDEV, True, True, True)
-
-
- class ffw_livingroom(base):
- def __init__(self, mqtt_client):
- self.main_light = shelly(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
- self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
- self.main_light_zigbee = tradfri_light(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_ZIGBEE, True, True, True)
- self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_on, True)
- self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_off, False)
-
- #
- self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_VIDEV, True, True, True)
-
-
- class ffw_sleep(base):
- def __init__(self, mqtt_client):
- self.main_light = shelly(mqtt_client, config.TOPIC_FFW_SLEEP_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
- self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
- self.main_light_zigbee = tradfri_light(mqtt_client, config.TOPIC_FFW_SLEEP_MAIN_LIGHT_ZIGBEE, True, True, True)
- self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_on, True)
- self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_off, False)
-
- #
- self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFW_SLEEP_MAIN_LIGHT_VIDEV, True, True, False)
-
-
- class ffw_bath(base):
- def __init__(self, mqtt_client):
- self.heating_valve = brennenstuhl_heating_valve(mqtt_client, config.TOPIC_FFW_BATH_HEATING_VALVE_ZIGBEE)
-
-
- class ffw(base):
- def __init__(self, mqtt_client):
- self.julian = ffw_julian(mqtt_client)
- self.livingroom = ffw_livingroom(mqtt_client)
- self.sleep = ffw_sleep(mqtt_client)
- self.bath = ffw_bath(mqtt_client)
-
-
- class ffe_floor(base):
- def __init__(self, mqtt_client):
- self.main_light = shelly(mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
- self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
-
- #
- self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_VIDEV, True, False, False)
-
-
- class ffe_kitchen(base):
- def __init__(self, mqtt_client):
- self.main_light = shelly(mqtt_client, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
- self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
-
- self.circulation_pump = shelly(mqtt_client, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_SHELLY,
- input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER, output_0_auto_off=10*60)
- self.circulation_pump.add_channel_name(shelly.KEY_OUTPUT_0, "Circulation Pump")
-
- #
- self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_VIDEV, True, False, False)
- self.videv_circulation_pump = videv_light(mqtt_client, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_VIDEV, True, False, False, True)
-
-
- class ffe_diningroom(base):
- def __init__(self, mqtt_client):
- self.main_light = shelly(mqtt_client, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
- self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
-
- self.floor_lamp = silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_POWERPLUG)
- self.floor_lamp.add_channel_name(silvercrest_powerplug.KEY_OUTPUT_0, "Floor Lamp")
-
- if config.CHRISTMAS:
- self.garland = silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_DININGROOM_GARLAND_POWERPLUG)
- self.garland.add_channel_name(silvercrest_powerplug, "Garland")
-
- #
- self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_VIDEV, True, False, False)
- self.videv_floor_lamp = videv_light(mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_VIDEV, True, False, False)
- if config.CHRISTMAS:
- self.videv_garland = videv_light(mqtt_client, config.TOPIC_FFE_DININGROOM_GARLAND_VIDEV, True, False, False)
-
-
- class ffe_sleep(base):
- def __init__(self, mqtt_client):
- self.main_light = shelly(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
- self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
- self.main_light_zigbee = tradfri_light(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_ZIGBEE, True, True, True)
- self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_on, True)
- self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_off, False)
-
- self.bed_light_di_zigbee = tradfri_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_ZIGBEE, True, True, False)
- self.bed_light_ma = silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_MA_POWERPLUG)
-
- self.heating_valve = brennenstuhl_heating_valve(mqtt_client, config.TOPIC_FFE_SLEEP_HEATING_VALVE_ZIGBEE)
-
- #
- self.videv_bed_light_ma = videv_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_MA_VIDEV, True, False, False)
- self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_VIDEV, True, True, True)
- self.videv_bed_light_di = videv_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_VIDEV, True, True, False)
- self.videv_bed_light_ma = videv_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_MA_VIDEV, True, False, False)
-
-
- class ffe_livingroom(base):
- def __init__(self, mqtt_client):
- self.main_light = shelly(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
- self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
- self.main_light_zigbee = tradfri_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_ZIGBEE, True, True, True)
- self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_on, True)
- self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_off, False)
-
- self.floor_lamp_zigbee = tradfri_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_ZIGBEE % 1, True, True, True)
- for i in range(2, 7):
- setattr(self, "floor_lamp_zigbee_%d" % i, tradfri_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_ZIGBEE % i, True, True, True))
-
- if config.CHRISTMAS:
- self.xmas_tree = silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_POWERPLUG)
- self.xmas_tree.add_channel_name(silvercrest_powerplug, "Xmas-Tree")
- self.xmas_star = silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_STAR_POWERPLUG)
- self.xmas_star.add_channel_name(silvercrest_powerplug, "Xmas-Star")
-
- #
- self.videv_main_light = videv_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_VIDEV, True, True, True)
- self.videv_floor_lamp = videv_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_VIDEV, True, True, True)
- if config.CHRISTMAS:
- self.videv_xmas_tree = videv_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_VIDEV)
-
-
- class ffe(base):
- def __init__(self, mqtt_client):
- self.floor = ffe_floor(mqtt_client)
- self.kitchen = ffe_kitchen(mqtt_client)
- self.diningroom = ffe_diningroom(mqtt_client)
- self.sleep = ffe_sleep(mqtt_client)
- self.livingroom = ffe_livingroom(mqtt_client)
-
-
- class stairway(base):
- def __init__(self, mqtt_client):
- self.main_light = shelly(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
- self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
-
- #
- self.videv_main_light = videv_light(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_VIDEV, True, False, False, True)
-
-
- class house(base):
- def __init__(self, mqtt_client):
- self.gfw = gfw(mqtt_client)
- self.ffw = ffw(mqtt_client)
- self.ffe = ffe(mqtt_client)
- self.stairway = stairway(mqtt_client)
|