123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- import config
- from __simulation__.devices import shelly, silvercrest_powerplug, tradfri_light, tradfri_button, silvercrest_motion_sensor, my_powerplug, remote, brennenstuhl_radiator_valve
- from __simulation__.devices import gui_light, gui_led_array, gui_radiator_valve
- 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.gui_main_light = gui_light(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_GUI, True, True, True)
- 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_1 = tradfri_light(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_1_ZIGBEE, True, True, True, False)
- self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee_1.power_on, "on")
- self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee_1.power_off, "off")
- self.main_light_zigbee_2 = tradfri_light(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_2_ZIGBEE, True, True, True, False)
- self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee_2.power_on, "on")
- self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee_1.power_off, "off")
-
-
- class gfw_marion(base):
- def __init__(self, mqtt_client):
- self.gui_main_light = gui_light(mqtt_client, config.TOPIC_GFW_MARION_MAIN_LIGHT_GUI, True, False, False)
- 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")
-
-
- class gfw_dirk(base):
- def __init__(self, mqtt_client):
- self.gui_main_light = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_GUI, True, True, True)
- 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, "on")
- self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_off, "off")
- #
- self.powerplug = my_powerplug(mqtt_client, config.TOPIC_GFW_DIRK_POWERPLUG)
- self.powerplug.add_channel_name(my_powerplug.KEY_OUTPUT_0, "Amplifier")
- self.powerplug.add_channel_name(my_powerplug.KEY_OUTPUT_1, "Desk_Light")
- self.powerplug.add_channel_name(my_powerplug.KEY_OUTPUT_2, "CD_Player")
- self.powerplug.add_channel_name(my_powerplug.KEY_OUTPUT_3, "PC_Dock")
- self.gui_amplifier = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_GUI, True, False, False)
- self.gui_desk_light = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_GUI, True, True, True)
- self.desk_light_zigbee = tradfri_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_ZIGBEE, True, True, True)
- self.powerplug.add_callback(my_powerplug.KEY_OUTPUT_1, self.desk_light_zigbee.power_on, True)
- self.powerplug.add_callback(my_powerplug.KEY_OUTPUT_1, self.desk_light_zigbee.power_off, False)
- self.gui_cd_player = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_CD_PLAYER_GUI, True, False, False)
- self.gui_pc_dock = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_PC_DOCK_GUI, True, False, False)
- #
- self.remote = remote(mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_REMOTE)
- #
- self.input_device = tradfri_button(mqtt_client, config.TOPIC_GFW_DIRK_INPUT_DEVICE)
- self.led_array = gui_led_array(mqtt_client, config.TOPIC_GFW_DIRK_DEVICE_CHOOSER_LED)
- self.led_array.add_channel_name(gui_led_array.KEY_LED_0, "Main Light")
- self.led_array.add_channel_name(gui_led_array.KEY_LED_1, "Desk Light")
- self.led_array.add_channel_name(gui_led_array.KEY_LED_2, "Amplifier")
-
-
- 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.gui_main_light = gui_light(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_GUI, True, True, True)
- 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, "on")
- self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_off, "off")
-
-
- class ffw_livingroom(base):
- def __init__(self, mqtt_client):
- self.gui_main_light = gui_light(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_GUI, True, False, False)
- 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")
-
-
- class ffw(base):
- def __init__(self, mqtt_client):
- self.julian = ffw_julian(mqtt_client)
- self.livingroom = ffw_livingroom(mqtt_client)
-
-
- class ffe_floor(base):
- def __init__(self, mqtt_client):
- self.gui_main_light = gui_light(mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_GUI, True, False, False)
- 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")
-
-
- class ffe_kitchen(base):
- def __init__(self, mqtt_client):
- self.gui_main_light = gui_light(mqtt_client, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_GUI, True, False, False)
- 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.gui_circulation_pump = gui_light(mqtt_client, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_GUI, True, False, False)
- 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")
-
-
- class ffe_diningroom(base):
- def __init__(self, mqtt_client):
- self.gui_main_light = gui_light(mqtt_client, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_GUI, True, False, False)
- 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.gui_floor_lamp = gui_light(mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_GUI, True, False, False)
- 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")
-
-
- class ffe_sleep(base):
- def __init__(self, mqtt_client):
- self.gui_main_light = gui_light(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_GUI, True, True, True)
- 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, "on")
- self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_off, "off")
- #
- self.gui_bed_light_di = gui_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_GUI, True, True, False)
- self.bed_light_di_zigbee = tradfri_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_ZIGBEE, True, True, False)
- #
- self.input_device = tradfri_button(mqtt_client, config.TOPIC_FFE_SLEEP_INPUT_DEVICE)
- self.led_array = gui_led_array(mqtt_client, config.TOPIC_FFE_SLEEP_DEVICE_CHOOSER_LED)
- self.led_array.add_channel_name(gui_led_array.KEY_LED_0, "Main Light")
- self.led_array.add_channel_name(gui_led_array.KEY_LED_1, "Bed Light Dirk")
- #
- self.radiator_valve = brennenstuhl_radiator_valve(mqtt_client, config.TOPIC_FFE_SLEEP_RADIATOR_VALVE_ZIGBEE)
- self.gui_radiator_valve = gui_radiator_valve(mqtt_client, config.TOPIC_FFE_SLEEP_RADIATOR_VALVE_GUI)
-
-
- class ffe_livingroom(base):
- def __init__(self, mqtt_client):
- self.gui_main_light = gui_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_GUI, True, True, True)
- 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, "on")
- self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_off, "off")
- for i in range(1, 7):
- setattr(self, "floor_lamp_zigbee_%d" % i, tradfri_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_ZIGBEE % i, True, True, True))
- self.gui_floor_lamp = gui_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_GUI, 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.gui_xmas_tree = gui_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_GUI)
- self.xmas_star = silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_STAR_POWERPLUG)
- self.xmas_star.add_channel_name(silvercrest_powerplug, "Xmas-Star")
-
-
- 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.gui_main_light = gui_light(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_GUI, True, False, False)
- self.gui_main_light.add_led_name(self.gui_main_light.KEY_LED_X % 0, "Motion Ground Floor")
- self.gui_main_light.add_led_name(self.gui_main_light.KEY_LED_X % 1, "Motion First Floor")
- 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.motion_sensor_gf = silvercrest_motion_sensor(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_MOTION_SENSOR_GF)
- self.motion_sensor_ff = silvercrest_motion_sensor(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_MOTION_SENSOR_FF)
-
-
- 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)
|