From 249112b3512ef0c8be7dd155e555bfeaecda09ff Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Tue, 20 Dec 2022 10:18:32 +0100 Subject: [PATCH] added first floor west functionality --- devices/__init__.py | 3 +- function/__init__.py | 116 ++++++++++++++++++++++++------------------- 2 files changed, 67 insertions(+), 52 deletions(-) diff --git a/devices/__init__.py b/devices/__init__.py index c7cc070..3b6306f 100644 --- a/devices/__init__.py +++ b/devices/__init__.py @@ -199,7 +199,8 @@ class shelly(base): RX_KEYS = [KEY_OUTPUT_0, KEY_OUTPUT_1, KEY_INPUT_0, KEY_INPUT_1, KEY_OVERTEMPERATURE, KEY_TEMPERATURE] RX_IGNORE_TOPICS = [KEY_OUTPUT_0 + '/' + TX_TOPIC, KEY_OUTPUT_1 + '/' + TX_TOPIC, - KEY_OUTPUT_0 + '/' + "energy", KEY_OUTPUT_1 + '/' + "energy"] + KEY_OUTPUT_0 + '/' + "energy", KEY_OUTPUT_1 + '/' + "energy", + 'input_event/0', 'input_event/1'] RX_IGNORE_KEYS = ['temperature_f'] RX_FILTER_DATA_KEYS = [KEY_INPUT_0, KEY_INPUT_1, KEY_OUTPUT_0, KEY_OUTPUT_1, KEY_OVERTEMPERATURE] diff --git a/function/__init__.py b/function/__init__.py index ecda923..ad4321b 100644 --- a/function/__init__.py +++ b/function/__init__.py @@ -6,13 +6,12 @@ import devices import inspect import logging -# TODO: implement first floor west and dirk (ground floor west) # TODO: implement bed light dirk fading by input device # TODO: implement heating function sleep_madi -# TODO: implement garland # TODO: implement circulation pump # TODO: implement switch off functionality (except of switch off button transportation) -# TODO: WARNING - Got a message from "shellies/floor_eg_w"with unparsed content "event" and "event_cnt" +# TODO: implement garland (incl. day events like sunset, sunrise, ...) +# TODO: implement existing nodered functionality "dirk" (ground floor west) # TODO: implement warning message (incl. fixing all_functions.devicelist try: @@ -27,6 +26,17 @@ class all_functions(object): self.rooms = {} self.__devices__ = None # + # ground floor west + # + self.gfw_floor = ground_floor_west_floor(mqtt_client) + self.gfw_marion = ground_floor_west_marion(mqtt_client) + self.gfw_dirk = ground_floor_west_dirk(mqtt_client) + # + # first floor west + # + self.ffw_julian = first_floor_west_julian(mqtt_client) + self.ffw_living = first_floor_west_living(mqtt_client) + # # first floor east # self.ffe_floor = first_floor_east_floor(mqtt_client) @@ -35,18 +45,9 @@ class all_functions(object): self.ffe_sleep_madi = first_floor_east_sleep_madi(mqtt_client) self.ffe_living = first_floor_east_living(mqtt_client) # - # ground floor west - # - self.gfw_floor = ground_floor_west_floor(mqtt_client) - self.gfw_marion = ground_floor_west_marion(mqtt_client) - self.gfw_dirk = ground_floor_west_dirk(mqtt_client) - # - # Input devices and Off Buttons + # Input devices sleep_madi # self.ffe_button_tradfri_sleep = devices.tradfri_button(mqtt_client, topic="zigbee_og_e/input_device/og_east") - # - # Callback initialisation - # self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, "toggle", self.ffe_sleep_madi.toggle_main_light) self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, "brightness_up_click", @@ -161,6 +162,57 @@ class room_shelly_silvercrest_light(room_shelly_tradfri_light): self.main_light_tradfri.mqtt_client.send(self.main_light_tradfri.topic + "/get", '{"state": ""}') +class ground_floor_west_floor(room_shelly_silvercrest_light): + # https://shelly1l-84CCA8AD1148 + def __init__(self, mqtt_client): + super().__init__(mqtt_client, "shellies/floor_eg_w", "gui/gfw_sw_floor", + "zigbee_eg_w/light/floor_eg_w/a", "gui/gfw_br_floor", "gui/gfw_ct_floor") + # + # Callback initialisation + # + self.main_light_tradfri_2 = devices.tradfri_light(mqtt_client, "zigbee_eg_w/light/floor_eg_w/b") + self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, + None, self.sync_brightness_main_light) + self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, + None, self.sync_color_temp_main_light) + + def send_init_message_main_light(self): + return super().send_init_message_main_light() + self.main_light_tradfri_2.mqtt_client.send(self.main_light_tradfri_2.topic + "/get", '{"state": ""}') + + def sync_brightness_main_light(self, device, key, data): + self.main_light_tradfri_2.set_brightness(data) + + def sync_color_temp_main_light(self, device, key, data): + self.main_light_tradfri_2.set_color_temp(data) + + +class ground_floor_west_marion(room_shelly): + # https://shelly1l-E8DB84A1E067 + def __init__(self, mqtt_client): + super().__init__(mqtt_client, "shellies/marion", "gui/gfw_sw_marion") + + +class ground_floor_west_dirk(room_shelly_tradfri_light): + # https://shelly1l-3C6105E44F27 + def __init__(self, mqtt_client): + super().__init__(mqtt_client, "shellies/dirk", "gui/gfw_sw_dirk", + "zigbee_eg_w/light/dirk", "gui/gfw_br_dirk", "gui/gfw_ct_dirk") + + +class first_floor_west_julian(room_shelly_tradfri_light): + # http://shelly1l-3C6105E43452 + def __init__(self, mqtt_client): + super().__init__(mqtt_client, "shellies/julian", "gui/ffw_sw_julian", + "zigbee_og_e/light/julian", "gui/ffw_br_julian", "gui/ffw_ct_julian") + + +class first_floor_west_living(room_shelly): + # http://shelly1l-84CCA8ACE6A1 + def __init__(self, mqtt_client): + super().__init__(mqtt_client, "shellies/living_mika", "gui/ffw_sw_living") + + class first_floor_east_floor(room_shelly): def __init__(self, mqtt_client): # http://shelly1l-3C6105E4E629 @@ -341,41 +393,3 @@ class first_floor_east_living(room_shelly_tradfri_light): logger.info("Setting color_temp \"%s\" floorlamp: %.1f", type(self).__name__, data) for device in self.__floorlamp_devices__(): device.set_color_temp(data * 10) - - -class ground_floor_west_floor(room_shelly_silvercrest_light): - # https://shelly1l-84CCA8AD1148 - def __init__(self, mqtt_client): - super().__init__(mqtt_client, "shellies/floor_eg_w", "gui/gfw_sw_floor", - "zigbee_eg_w/light/floor_eg_w/a", "gui/gfw_br_floor", "gui/gfw_ct_floor") - # - # Callback initialisation - # - self.main_light_tradfri_2 = devices.tradfri_light(mqtt_client, "zigbee_eg_w/light/floor_eg_w/b") - self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, - None, self.sync_brightness_main_light) - self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, - None, self.sync_color_temp_main_light) - - def send_init_message_main_light(self): - return super().send_init_message_main_light() - self.main_light_tradfri_2.mqtt_client.send(self.main_light_tradfri_2.topic + "/get", '{"state": ""}') - - def sync_brightness_main_light(self, device, key, data): - self.main_light_tradfri_2.set_brightness(data) - - def sync_color_temp_main_light(self, device, key, data): - self.main_light_tradfri_2.set_color_temp(data) - - -class ground_floor_west_marion(room_shelly): - # https://shelly1l-E8DB84A1E067 - def __init__(self, mqtt_client): - super().__init__(mqtt_client, "shellies/marion", "gui/gfw_sw_marion") - - -class ground_floor_west_dirk(room_shelly_tradfri_light): - # https://shelly1l-3C6105E44F27 - def __init__(self, mqtt_client): - super().__init__(mqtt_client, "shellies/dirk", "gui/gfw_sw_dirk", - "zigbee_eg_w/light/dirk", "gui/gfw_br_dirk", "gui/gfw_ct_dirk")