From be3b31bf6057004dff42b6a2b3d0281053d01dbe Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Sat, 24 Dec 2022 12:08:08 +0100 Subject: [PATCH] christmas tree added --- .vscode/launch.json | 16 ++++++++++++++++ function/first_floor_east.py | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..09d8a83 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + // Verwendet IntelliSense zum Ermitteln möglicher Attribute. + // Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen. + // Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Main File execution", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}/smart_brain.py", + "console": "integratedTerminal", + "justMyCode": true + } + ] +} \ No newline at end of file diff --git a/function/first_floor_east.py b/function/first_floor_east.py index 81c2233..ea71364 100644 --- a/function/first_floor_east.py +++ b/function/first_floor_east.py @@ -180,6 +180,8 @@ class first_floor_east_living(room_shelly_tradfri_light): for i in range(1, 7): setattr(self, 'floorlamp_tradfri_%d' % i, devices.tradfri_light(mqtt_client, topic="zigbee_og_e/light/living_floorlamp_%d" % i)) + if config.CHRISTMAS: + self.powerplug_xmas_tree = devices.silvercrest_powerplug(mqtt_client, "zigbee_og_e/powerplug/xmas-tree") # self.gui_switch_floorlamp = devices.nodered_gui(mqtt_client, topic="gui/ffe_sw_living_floorlamp") self.gui_brightness_floorlamp = devices.nodered_gui(mqtt_client, "gui/ffe_br_livingroom_floorlamp") @@ -189,6 +191,9 @@ class first_floor_east_living(room_shelly_tradfri_light): self.gui_color_temp_floorlamp.enable(False) self.gui_color_temp_floorlamp.set_feedback(0) # + if config.CHRISTMAS: + self.gui_switch_xmas_tree = devices.nodered_gui(mqtt_client, "gui/ffe_sw_livingroom_xmas_tree") + # # Callback initialisation # self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.floorlamp_synchronisation) @@ -204,6 +209,11 @@ class first_floor_east_living(room_shelly_tradfri_light): self.gui_color_temp_floorlamp.add_callback( devices.nodered_gui.KEY_COLOR_TEMP, None, self.set_color_temp_floorlamp) # + if config.CHRISTMAS: + self.powerplug_xmas_tree.add_callback( + devices.silvercrest_powerplug.KEY_OUTPUT_0, None, self.powerplug_xmas_action) + self.gui_switch_xmas_tree.add_callback(devices.nodered_gui.KEY_STATE, None, self.gui_switch_command_xmas) + # self.cvi = changed_value_indicator() def all_off(self, device=None, key=None, data=None): @@ -254,3 +264,10 @@ 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) + + def powerplug_xmas_action(self, device, key, data): + self.gui_switch_xmas_tree.set_feedback(data) + + def gui_switch_command_xmas(self, device, key, data): + logger.info("Switching \"%s\" xmas-tree: %s", type(self).__name__, data) + self.powerplug_xmas_tree.set_output_0(data)