221 lines
13 KiB
Python
Raw Normal View History

2023-01-04 01:21:03 +01:00
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_timer, gui_radiator_valve
2023-01-04 01:21:03 +01:00
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")
2023-01-04 01:21:03 +01:00
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")
2023-01-04 01:21:03 +01:00
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")
2023-01-04 01:21:03 +01:00
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)
2023-01-04 01:21:03 +01:00
#
self.remote = remote(mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_REMOTE)
#
2023-01-04 01:21:03 +01:00
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")
2023-01-04 01:21:03 +01:00
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")
2023-01-04 01:21:03 +01:00
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")
2023-01-04 01:21:03 +01:00
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")
2023-01-04 01:21:03 +01:00
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")
self.gui_timer_circulation_pump = gui_timer(mqtt_client, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_GUI_TIMER)
2023-01-04 01:21:03 +01:00
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)
2023-01-04 01:21:03 +01:00
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")
2023-01-04 01:21:03 +01:00
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")
2023-01-04 01:21:03 +01:00
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)
2023-01-04 01:21:03 +01:00
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.heating_valve = brennenstuhl_radiator_valve(mqtt_client, config.TOPIC_FFE_SLEEP_RADIATOR_VALVE_ZIGBEE)
self.gui_heating_valve = gui_radiator_valve(mqtt_client, "gui/ffe_ts_sleep_madi")
self.gui_heating_valve_boost_led = gui_radiator_valve(mqtt_client, "gui/ffe_bl_sleep_madi")
self.gui_heating_valve_boost_button = gui_radiator_valve(mqtt_client, "gui/ffe_bo_sleep_madi")
2023-01-04 01:21:03 +01:00
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")
2023-01-04 01:21:03 +01:00
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")
2023-01-04 01:21:03 +01:00
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.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")
2023-01-04 01:21:03 +01:00
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)