Browse Source

old gui interface removed and clean up

videv_dev
Dirk Alders 1 year ago
parent
commit
5fc096c9c7

+ 2
- 140
function/first_floor_east.py View File

5
 import config
5
 import config
6
 import devices
6
 import devices
7
 from function.modules import brightness_choose_n_action, timer_on_activation, heating_function
7
 from function.modules import brightness_choose_n_action, timer_on_activation, heating_function
8
-import logging
9
 from function.rooms import room
8
 from function.rooms import room
10
 from function.videv import videv_switching, videv_switch_brightness, videv_switching_timer, videv_switch_brightness_color_temp, videv_heating, videv_multistate
9
 from function.videv import videv_switching, videv_switch_brightness, videv_switching_timer, videv_switch_brightness_color_temp, videv_heating, videv_multistate
10
+import logging
11
+
11
 try:
12
 try:
12
     from config import APP_NAME as ROOT_LOGGER_NAME
13
     from config import APP_NAME as ROOT_LOGGER_NAME
13
 except ImportError:
14
 except ImportError:
24
         self.main_light_shelly = devices.shelly(mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_SHELLY)
25
         self.main_light_shelly = devices.shelly(mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_SHELLY)
25
         super().__init__(mqtt_client)
26
         super().__init__(mqtt_client)
26
 
27
 
27
-        ##### TEMPORARY ###################################################################################################################
28
-        self.gui_main_light = devices.nodered_gui_light(mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_GUI)
29
-        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.main_light_shelly.set_output_0_mcb)
30
-        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_state_mcb)
31
-        ##### TEMPORARY ###################################################################################################################
32
-
33
         #
28
         #
34
         # Virtual Device Interface
29
         # Virtual Device Interface
35
         #
30
         #
57
         self.circulation_pump = timer_on_activation(self.circulation_pump_shelly, devices.shelly.KEY_OUTPUT_0, 10*60)
52
         self.circulation_pump = timer_on_activation(self.circulation_pump_shelly, devices.shelly.KEY_OUTPUT_0, 10*60)
58
         self.circulation_pump_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, True, self.main_light_shelly.flash_0_mcb, True)
53
         self.circulation_pump_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, True, self.main_light_shelly.flash_0_mcb, True)
59
 
54
 
60
-        ##### TEMPORARY ###################################################################################################################
61
-        self.gui_main_light = devices.nodered_gui_light(mqtt_client, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_GUI)
62
-        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.main_light_shelly.set_output_0_mcb)
63
-        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_state_mcb)
64
-
65
-        self.gui_circulation_pump = devices.nodered_gui_light(mqtt_client, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_GUI)
66
-        self.gui_circulation_pump.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.circulation_pump_shelly.set_output_0_mcb)
67
-        self.circulation_pump_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_circulation_pump.set_state_mcb)
68
-        self.circulation_pump.add_callback(timer_on_activation.KEY_TIMER, None, self.gui_circulation_pump.set_timer_mcb, True)
69
-        ##### TEMPORARY ###################################################################################################################
70
-
71
         #
55
         #
72
         # Virtual Device Interface
56
         # Virtual Device Interface
73
         #
57
         #
81
             self.circulation_pump, timer_on_activation.KEY_TIMER
65
             self.circulation_pump, timer_on_activation.KEY_TIMER
82
         )
66
         )
83
 
67
 
84
-    def all_off(self, device=None, key=None, data=None):
85
-        self.circulation_pump_shelly.set_output_0(False)
86
-        self.circulation_pump_shelly.set_output_1(False)
87
-        return super().all_off(device, key, data)
88
-
89
 
68
 
90
 class first_floor_east_dining(room):
69
 class first_floor_east_dining(room):
91
     def __init__(self, mqtt_client):
70
     def __init__(self, mqtt_client):
99
             self.garland_powerplug = devices.silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_DININGROOM_GARLAND_POWERPLUG)
78
             self.garland_powerplug = devices.silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_DININGROOM_GARLAND_POWERPLUG)
100
         super().__init__(mqtt_client)
79
         super().__init__(mqtt_client)
101
 
80
 
102
-        ##### TEMPORARY ###################################################################################################################
103
-        self.gui_main_light = devices.nodered_gui_light(mqtt_client, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_GUI)
104
-        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.main_light_shelly.set_output_0_mcb)
105
-        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_state_mcb)
106
-
107
-        self.gui_floorlamp = devices.nodered_gui_switch(mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_GUI)
108
-        self.gui_floorlamp.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.floorlamp_powerplug.set_output_0_mcb)
109
-        self.floorlamp_powerplug.add_callback(devices.silvercrest_powerplug.KEY_OUTPUT_0, None, self.gui_floorlamp.set_state_mcb)
110
-        ##### TEMPORARY ###################################################################################################################
111
-
112
         #
81
         #
113
         # Functionality initialisation
82
         # Functionality initialisation
114
         #
83
         #
131
                 self.garland_powerplug, devices.silvercrest_powerplug.KEY_OUTPUT_0
100
                 self.garland_powerplug, devices.silvercrest_powerplug.KEY_OUTPUT_0
132
             )
101
             )
133
 
102
 
134
-    def all_off(self, device=None, key=None, data=None):
135
-        super().all_off(device, key, data)
136
-        self.floorlamp_powerplug.set_output_0(False)
137
-        if config.CHRISTMAS:
138
-            self.garland_powerplug.set_output_0(False)
139
-
140
 
103
 
141
 class first_floor_east_sleep(room):
104
 class first_floor_east_sleep(room):
142
     def __init__(self, mqtt_client):
105
     def __init__(self, mqtt_client):
173
         # heating function
136
         # heating function
174
         self.heating_function = heating_function(self.heating_valve, config.DEFAULT_TEMPERATURE_FFE_SLEEP)
137
         self.heating_function = heating_function(self.heating_valve, config.DEFAULT_TEMPERATURE_FFE_SLEEP)
175
 
138
 
176
-        ##### TEMPORARY ###################################################################################################################
177
-        # main light
178
-        self.gui_main_light = devices.nodered_gui_light(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_GUI)
179
-        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.main_light_shelly.set_output_0_mcb)
180
-        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_state_mcb)
181
-
182
-        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_enable_mcb)
183
-        self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_main_light.set_brightness_mcb)
184
-        self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_main_light.set_color_temp_mcb)
185
-        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_BRIGHTNESS, None, self.main_light_tradfri.set_brightness_mcb)
186
-        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_COLOR_TEMP, None, self.main_light_tradfri.set_color_temp_mcb)
187
-        # bed light
188
-        self.gui_bed_light_di = devices.nodered_gui_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_GUI)
189
-        self.gui_bed_light_di.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.bed_light_di_tradfri.set_output_0_mcb)
190
-        self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_bed_light_di.set_state_mcb)
191
-        self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_bed_light_di.set_enable_mcb)
192
-        self.gui_bed_light_di.add_callback(devices.nodered_gui_light.KEY_BRIGHTNESS, None, self.bed_light_di_tradfri.set_brightness_mcb)
193
-        self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_bed_light_di.set_enable_mcb)
194
-        self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_bed_light_di.set_brightness_mcb)
195
-
196
-        self.gui_bed_light_ma = devices.nodered_gui_switch(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_MA_GUI)
197
-        self.gui_bed_light_ma.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.bed_light_ma_powerplug.set_output_0_mcb)
198
-        self.bed_light_ma_powerplug.add_callback(devices.silvercrest_powerplug.KEY_OUTPUT_0, None, self.gui_bed_light_ma.set_state_mcb)
199
-
200
-        # heating
201
-        self.gui_heating = devices.nodered_gui_radiator(mqtt_client, config.TOPIC_FFE_SLEEP_HEATING_VALVE_GUI)
202
-        self.heating_function.add_callback(heating_function.KEY_TEMPERATURE_CURRENT, None, self.gui_heating.set_temperature_mcb, True)
203
-
204
-        def set_heating_setpoint(device, key, data):
205
-            self.heating_function.set(heating_function.KEY_USER_TEMPERATURE_SETPOINT, data)
206
-        self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_SETPOINT_TEMP, None, set_heating_setpoint)
207
-        self.heating_function.add_callback(heating_function.KEY_TEMPERATURE_SETPOINT, None, self.gui_heating.set_setpoint_temperature_mcb, True)
208
-
209
-        def boost(device, key, data):
210
-            self.heating_function.set(heating_function.KEY_START_BOOST, data)
211
-        self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_BOOST, None, boost)
212
-
213
-        def setpoint_to_default(device, key, data):
214
-            self.heating_function.set(heating_function.KEY_SET_DEFAULT_TEMPERATURE, data)
215
-        self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_SETPOINT_TO_DEFAULT, None, setpoint_to_default)
216
-
217
-        def away_mode(device, key, data):
218
-            self.heating_function.set(heating_function.KEY_AWAY_MODE, data)
219
-        self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_AWAY, None, away_mode)
220
-        self.heating_function.add_callback(heating_function.KEY_AWAY_MODE, None, self.gui_heating.set_away_mcb)
221
-
222
-        def summer_mode(device, key, data):
223
-            self.heating_function.set(heating_function.KEY_SUMMER_MODE, data)
224
-        self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_SUMMER, None, summer_mode)
225
-        self.heating_function.add_callback(heating_function.KEY_SUMMER_MODE, None, self.gui_heating.set_summer_mcb)
226
-
227
-        self.heating_function.add_callback(heating_function.KEY_BOOST_TIMER, None, self.gui_heating.set_timer_mcb)
228
-
229
-        # active device led
230
-        self.gui_led_active_device = devices.nodered_gui_leds(mqtt_client, config.TOPIC_FFE_SLEEP_DEVICE_CHOOSER_LED)
231
-
232
-        def update_active_device_led(device, key, data):
233
-            for i in range(0, len(self.brightness_functions.brightness_device_list)):
234
-                self.gui_led_active_device.set_led(devices.nodered_gui_leds.KEY_LED_LIST[i], data == i)
235
-        self.brightness_functions.add_callback(brightness_choose_n_action.KEY_ACTIVE_DEVICE, None, update_active_device_led, True)
236
-        ##### TEMPORARY ###################################################################################################################
237
-
238
         #
139
         #
239
         # Virtual Device Interface
140
         # Virtual Device Interface
240
         #
141
         #
262
             brightness_choose_n_action.KEY_ACTIVE_DEVICE, self.brightness_functions, 2
163
             brightness_choose_n_action.KEY_ACTIVE_DEVICE, self.brightness_functions, 2
263
         )
164
         )
264
 
165
 
265
-    def all_off(self, device=None, key=None, data=None):
266
-        super().all_off(device, key, data)
267
-        self.bed_light_di_tradfri.set_output_0(False)
268
-        self.bed_light_ma_powerplug.set_output_0(False)
269
-
270
 
166
 
271
 class first_floor_east_living(room):
167
 class first_floor_east_living(room):
272
     def __init__(self, mqtt_client):
168
     def __init__(self, mqtt_client):
290
         # floor lamp synchronisation with main_light
186
         # floor lamp synchronisation with main_light
291
         self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.floorlamp_tradfri.set_output_0_mcb, True)
187
         self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.floorlamp_tradfri.set_output_0_mcb, True)
292
 
188
 
293
-        ##### TEMPORARY ###################################################################################################################
294
-        # main light
295
-        self.gui_main_light = devices.nodered_gui_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_GUI)
296
-        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.main_light_shelly.set_output_0_mcb)
297
-        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_state_mcb)
298
-        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_enable_mcb)
299
-        self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_main_light.set_brightness_mcb)
300
-        self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_main_light.set_color_temp_mcb)
301
-        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_BRIGHTNESS, None, self.main_light_tradfri.set_brightness_mcb)
302
-        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_COLOR_TEMP, None, self.main_light_tradfri.set_color_temp_mcb)
303
-
304
-        self.gui_floorlamp = devices.nodered_gui_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_GUI)
305
-        self.gui_floorlamp.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.floorlamp_tradfri.set_output_0_mcb)
306
-        self.gui_floorlamp.add_callback(devices.nodered_gui_light.KEY_BRIGHTNESS, None, self.floorlamp_tradfri.set_brightness_mcb)
307
-        self.gui_floorlamp.add_callback(devices.nodered_gui_light.KEY_COLOR_TEMP, None, self.floorlamp_tradfri.set_color_temp_mcb)
308
-        self.floorlamp_tradfri[0].add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_floorlamp.set_state_mcb)
309
-        self.floorlamp_tradfri[0].add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_floorlamp.set_enable_mcb)
310
-        self.floorlamp_tradfri[0].add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_floorlamp.set_brightness_mcb)
311
-        self.floorlamp_tradfri[0].add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_floorlamp.set_color_temp_mcb)
312
-
313
-        if config.CHRISTMAS:
314
-            self.gui_xmas_tree = devices.nodered_gui_switch(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_GUI)
315
-            self.powerplug_xmas_tree.add_callback(devices.silvercrest_powerplug.KEY_OUTPUT_0, None, self.powerplug_xmas_star.set_output_0_mcb)
316
-            self.powerplug_xmas_tree.add_callback(devices.silvercrest_powerplug.KEY_OUTPUT_0, None, self.gui_xmas_tree.set_state_mcb)
317
-            self.gui_xmas_tree.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_xmas_tree.set_output_0_mcb)
318
-        ##### TEMPORARY ###################################################################################################################
319
-
320
         #
189
         #
321
         # Virtual Device Interface
190
         # Virtual Device Interface
322
         #
191
         #
337
                 mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_VIDEV,
206
                 mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_VIDEV,
338
                 self.powerplug_xmas_tree, devices.silvercrest_powerplug.KEY_OUTPUT_0
207
                 self.powerplug_xmas_tree, devices.silvercrest_powerplug.KEY_OUTPUT_0
339
             )
208
             )
340
-
341
-    def all_off(self, device=None, key=None, data=None):
342
-        super().all_off(device, key, data)
343
-        self.floorlamp_tradfri.set_output_0(False)
344
-        if config.CHRISTMAS:
345
-            self.powerplug_xmas_tree.set_output_0(False)
346
-            self.powerplug_xmas_star.set_output_0(False)

+ 1
- 68
function/first_floor_west.py View File

4
 
4
 
5
 import config
5
 import config
6
 import devices
6
 import devices
7
-import logging
8
 from function.modules import heating_function
7
 from function.modules import heating_function
9
 from function.rooms import room
8
 from function.rooms import room
10
 from function.videv import videv_switch_brightness, videv_switch_brightness_color_temp, videv_heating
9
 from function.videv import videv_switch_brightness, videv_switch_brightness_color_temp, videv_heating
10
+import logging
11
 
11
 
12
 
12
 
13
 try:
13
 try:
27
         self.main_light_tradfri = devices.tradfri_light(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_ZIGBEE)
27
         self.main_light_tradfri = devices.tradfri_light(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_ZIGBEE)
28
         super().__init__(mqtt_client)
28
         super().__init__(mqtt_client)
29
 
29
 
30
-        ##### TEMPORARY ###################################################################################################################
31
-        self.gui_main_light = devices.nodered_gui_light(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_GUI)
32
-        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.main_light_shelly.set_output_0_mcb)
33
-        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_state_mcb)
34
-
35
-        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_enable_mcb)
36
-        self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_main_light.set_brightness_mcb)
37
-        self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_main_light.set_color_temp_mcb)
38
-        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_BRIGHTNESS, None, self.main_light_tradfri.set_brightness_mcb)
39
-        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_COLOR_TEMP, None, self.main_light_tradfri.set_color_temp_mcb)
40
-        ##### TEMPORARY ###################################################################################################################
41
-
42
         #
30
         #
43
         # Virtual Device Interface
31
         # Virtual Device Interface
44
         #
32
         #
63
         # heating function
51
         # heating function
64
         self.heating_function = heating_function(self.heating_valve, config.DEFAULT_TEMPERATURE_FFW_BATH)
52
         self.heating_function = heating_function(self.heating_valve, config.DEFAULT_TEMPERATURE_FFW_BATH)
65
 
53
 
66
-        ##### TEMPORARY ###################################################################################################################
67
-        self.gui_heating = devices.nodered_gui_radiator(mqtt_client, config.TOPIC_FFW_BATH_HEATING_VALVE_GUI)
68
-        self.heating_function.add_callback(heating_function.KEY_TEMPERATURE_CURRENT, None, self.gui_heating.set_temperature_mcb, True)
69
-
70
-        def set_heating_setpoint(device, key, data):
71
-            self.heating_function.set(heating_function.KEY_USER_TEMPERATURE_SETPOINT, data)
72
-        self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_SETPOINT_TEMP, None, set_heating_setpoint)
73
-        self.heating_function.add_callback(heating_function.KEY_TEMPERATURE_SETPOINT, None, self.gui_heating.set_setpoint_temperature_mcb, True)
74
-
75
-        def boost(device, key, data):
76
-            self.heating_function.set(heating_function.KEY_START_BOOST, data)
77
-        self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_BOOST, None, boost)
78
-
79
-        def setpoint_to_default(device, key, data):
80
-            self.heating_function.set(heating_function.KEY_SET_DEFAULT_TEMPERATURE, data)
81
-        self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_SETPOINT_TO_DEFAULT, None, setpoint_to_default)
82
-
83
-        def away_mode(device, key, data):
84
-            self.heating_function.set(heating_function.KEY_AWAY_MODE, data)
85
-        self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_AWAY, None, away_mode)
86
-        self.heating_function.add_callback(heating_function.KEY_AWAY_MODE, None, self.gui_heating.set_away_mcb)
87
-
88
-        def summer_mode(device, key, data):
89
-            self.heating_function.set(heating_function.KEY_SUMMER_MODE, data)
90
-        self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_SUMMER, None, summer_mode)
91
-        self.heating_function.add_callback(heating_function.KEY_SUMMER_MODE, None, self.gui_heating.set_summer_mcb)
92
-
93
-        self.heating_function.add_callback(heating_function.KEY_BOOST_TIMER, None, self.gui_heating.set_timer_mcb)
94
-        ##### TEMPORARY ###################################################################################################################
95
-
96
         #
54
         #
97
         # Virtual Device Interface
55
         # Virtual Device Interface
98
         #
56
         #
101
             self.heating_function
59
             self.heating_function
102
         )
60
         )
103
 
61
 
104
-    def all_off(self):
105
-        pass
106
-
107
 
62
 
108
 class first_floor_west_living(room):
63
 class first_floor_west_living(room):
109
     def __init__(self, mqtt_client):
64
     def __init__(self, mqtt_client):
115
         self.main_light_tradfri = devices.tradfri_light(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_ZIGBEE)
70
         self.main_light_tradfri = devices.tradfri_light(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_ZIGBEE)
116
         super().__init__(mqtt_client)
71
         super().__init__(mqtt_client)
117
 
72
 
118
-        ##### TEMPORARY ###################################################################################################################
119
-        self.gui_main_light = devices.nodered_gui_light(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_GUI)
120
-        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.main_light_shelly.set_output_0_mcb)
121
-        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_state_mcb)
122
-
123
-        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_enable_mcb)
124
-        self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_main_light.set_brightness_mcb)
125
-        self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_main_light.set_color_temp_mcb)
126
-        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_BRIGHTNESS, None, self.main_light_tradfri.set_brightness_mcb)
127
-        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_COLOR_TEMP, None, self.main_light_tradfri.set_color_temp_mcb)
128
-        ##### TEMPORARY ###################################################################################################################
129
-
130
         #
73
         #
131
         # Virtual Device Interface
74
         # Virtual Device Interface
132
         #
75
         #
148
         self.main_light_tradfri = devices.tradfri_light(mqtt_client, config.TOPIC_FFW_SLEEP_MAIN_LIGHT_ZIGBEE)
91
         self.main_light_tradfri = devices.tradfri_light(mqtt_client, config.TOPIC_FFW_SLEEP_MAIN_LIGHT_ZIGBEE)
149
         super().__init__(mqtt_client)
92
         super().__init__(mqtt_client)
150
 
93
 
151
-        ##### TEMPORARY ###################################################################################################################
152
-        self.gui_main_light = devices.nodered_gui_light(mqtt_client, config.TOPIC_FFW_SLEEP_MAIN_LIGHT_GUI)
153
-        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.main_light_shelly.set_output_0_mcb)
154
-        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_state_mcb)
155
-
156
-        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_enable_mcb)
157
-        self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_main_light.set_brightness_mcb)
158
-        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_BRIGHTNESS, None, self.main_light_tradfri.set_brightness_mcb)
159
-        ##### TEMPORARY ###################################################################################################################
160
-
161
         #
94
         #
162
         # Virtual Device Interface
95
         # Virtual Device Interface
163
         #
96
         #

+ 3
- 122
function/ground_floor_west.py View File

4
 
4
 
5
 import config
5
 import config
6
 import devices
6
 import devices
7
-from function.modules import brightness_choose_n_action, heating_function
8
-import logging
7
+from function.modules import brightness_choose_n_action, heating_function, switched_light
9
 from function.rooms import room
8
 from function.rooms import room
10
 from function.videv import videv_switching, videv_switch_brightness_color_temp, videv_heating, videv_multistate, videv_audio_player
9
 from function.videv import videv_switching, videv_switch_brightness_color_temp, videv_heating, videv_multistate, videv_audio_player
10
+import logging
11
 import task
11
 import task
12
 
12
 
13
 try:
13
 try:
34
         # Functionality initialisation
34
         # Functionality initialisation
35
         #
35
         #
36
         # Request silvercrest data of lead light after power on
36
         # Request silvercrest data of lead light after power on
37
-        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, True, self.main_light_tradfri[0].request_data, True)
38
-
39
-        ##### TEMPORARY ###################################################################################################################
40
-        self.gui_main_light = devices.nodered_gui_light(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_GUI)
41
-        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.main_light_shelly.set_output_0_mcb)
42
-        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_state_mcb)
43
-
44
-        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_enable_mcb)
45
-        self.main_light_tradfri[0].add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_main_light.set_brightness_mcb)
46
-        self.main_light_tradfri[0].add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_main_light.set_color_temp_mcb)
47
-        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_BRIGHTNESS, None, self.main_light_tradfri.set_brightness_mcb)
48
-        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_COLOR_TEMP, None, self.main_light_tradfri.set_color_temp_mcb)
49
-        ##### TEMPORARY ###################################################################################################################
37
+        switched_light(self.main_light_shelly, devices.shelly.KEY_OUTPUT_0, self.main_light_tradfri)
50
 
38
 
51
         #
39
         #
52
         # Virtual Device Interface
40
         # Virtual Device Interface
75
         # heating function
63
         # heating function
76
         self.heating_function = heating_function(self.heating_valve, config.DEFAULT_TEMPERATURE_GFW_MARION)
64
         self.heating_function = heating_function(self.heating_valve, config.DEFAULT_TEMPERATURE_GFW_MARION)
77
 
65
 
78
-        ##### TEMPORARY ###################################################################################################################
79
-        self.gui_main_light = devices.nodered_gui_light(mqtt_client, config.TOPIC_GFW_MARION_MAIN_LIGHT_GUI)
80
-        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.main_light_shelly.set_output_0_mcb)
81
-        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_state_mcb)
82
-
83
-        self.gui_heating = devices.nodered_gui_radiator(mqtt_client, config.TOPIC_GFW_MARION_HEATING_VALVE_GUI)
84
-        self.heating_function.add_callback(heating_function.KEY_TEMPERATURE_CURRENT, None, self.gui_heating.set_temperature_mcb, True)
85
-
86
-        def set_heating_setpoint(device, key, data):
87
-            self.heating_function.set(heating_function.KEY_USER_TEMPERATURE_SETPOINT, data)
88
-        self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_SETPOINT_TEMP, None, set_heating_setpoint)
89
-        self.heating_function.add_callback(heating_function.KEY_TEMPERATURE_SETPOINT, None, self.gui_heating.set_setpoint_temperature_mcb, True)
90
-
91
-        def boost(device, key, data):
92
-            self.heating_function.set(heating_function.KEY_START_BOOST, data)
93
-        self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_BOOST, None, boost)
94
-
95
-        def setpoint_to_default(device, key, data):
96
-            self.heating_function.set(heating_function.KEY_SET_DEFAULT_TEMPERATURE, data)
97
-        self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_SETPOINT_TO_DEFAULT, None, setpoint_to_default)
98
-
99
-        def away_mode(device, key, data):
100
-            self.heating_function.set(heating_function.KEY_AWAY_MODE, data)
101
-        self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_AWAY, None, away_mode)
102
-        self.heating_function.add_callback(heating_function.KEY_AWAY_MODE, None, self.gui_heating.set_away_mcb)
103
-
104
-        def summer_mode(device, key, data):
105
-            self.heating_function.set(heating_function.KEY_SUMMER_MODE, data)
106
-        self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_SUMMER, None, summer_mode)
107
-        self.heating_function.add_callback(heating_function.KEY_SUMMER_MODE, None, self.gui_heating.set_summer_mcb)
108
-
109
-        self.heating_function.add_callback(heating_function.KEY_BOOST_TIMER, None, self.gui_heating.set_timer_mcb)
110
-        ##### TEMPORARY ###################################################################################################################
111
-
112
         #
66
         #
113
         # Virtual Device Interface
67
         # Virtual Device Interface
114
         #
68
         #
128
     STATE_ACTIVE_DEVICE_AMPLIFIER = 2
82
     STATE_ACTIVE_DEVICE_AMPLIFIER = 2
129
     STATE_ACTIVE_DEVICE_MAX_VALUE = STATE_ACTIVE_DEVICE_AMPLIFIER
83
     STATE_ACTIVE_DEVICE_MAX_VALUE = STATE_ACTIVE_DEVICE_AMPLIFIER
130
     #
84
     #
131
-    LED_ACTIVE_DEVICE_MAIN_LIGHT = devices.nodered_gui_leds.KEY_LED_0
132
-    LED_ACTIVE_DEVICE_DESK_LIGHT = devices.nodered_gui_leds.KEY_LED_1
133
-    LED_ACTIVE_DEVICE_AMPLIFIER = devices.nodered_gui_leds.KEY_LED_2
134
-    #
135
     KEY_POWERPLUG_AMPLIFIER = devices.my_powerplug.KEY_OUTPUT_0
85
     KEY_POWERPLUG_AMPLIFIER = devices.my_powerplug.KEY_OUTPUT_0
136
     KEY_POWERPLUG_CD_PLAYER = devices.my_powerplug.KEY_OUTPUT_2
86
     KEY_POWERPLUG_CD_PLAYER = devices.my_powerplug.KEY_OUTPUT_2
137
     KEY_POWERPLUG_DESK_LIGHT = devices.my_powerplug.KEY_OUTPUT_1
87
     KEY_POWERPLUG_DESK_LIGHT = devices.my_powerplug.KEY_OUTPUT_1
194
         # heating function
144
         # heating function
195
         self.heating_function = heating_function(self.heating_valve, config.DEFAULT_TEMPERATURE_GFW_DIRK)
145
         self.heating_function = heating_function(self.heating_valve, config.DEFAULT_TEMPERATURE_GFW_DIRK)
196
 
146
 
197
-        ##### TEMPORARY ###################################################################################################################
198
-        self.gui_main_light = devices.nodered_gui_light(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_GUI)
199
-        self.gui_desk_light = devices.nodered_gui_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_GUI)
200
-        self.gui_amplifier = devices.nodered_gui_switch(mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_GUI)
201
-        self.gui_cd_player = devices.nodered_gui_switch(mqtt_client, config.TOPIC_GFW_DIRK_CD_PLAYER_GUI)
202
-        self.gui_pc_dock = devices.nodered_gui_switch(mqtt_client, config.TOPIC_GFW_DIRK_PC_DOCK_GUI)
203
-        # Callback initialisation
204
-        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.main_light_shelly.set_output_0_mcb)
205
-        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_state_mcb)
206
-        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_state_mcb)
207
-        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_enable_mcb)
208
-        self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_main_light.set_brightness_mcb)
209
-        self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_main_light.set_color_temp_mcb)
210
-        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_BRIGHTNESS, None, self.main_light_tradfri.set_brightness_mcb)
211
-        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_COLOR_TEMP, None, self.main_light_tradfri.set_color_temp_mcb)
212
-        self.gui_desk_light.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.powerplug_common.set_output_1_mcb)
213
-        self.powerplug_common.add_callback(self.KEY_POWERPLUG_DESK_LIGHT, None, self.gui_desk_light.set_state_mcb)
214
-        self.gui_desk_light.add_callback(devices.nodered_gui_light.KEY_BRIGHTNESS, None, self.desk_light_tradfri.set_brightness_mcb)
215
-        self.gui_desk_light.add_callback(devices.nodered_gui_light.KEY_COLOR_TEMP, None, self.desk_light_tradfri.set_color_temp_mcb)
216
-        self.powerplug_common.add_callback(self.KEY_POWERPLUG_DESK_LIGHT, None, self.gui_desk_light.set_enable_mcb)
217
-        self.desk_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_desk_light.set_brightness_mcb)
218
-        self.desk_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_desk_light.set_color_temp_mcb)
219
-        self.gui_amplifier.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_common.set_output_0_mcb)
220
-        self.powerplug_common.add_callback(self.KEY_POWERPLUG_AMPLIFIER, None, self.gui_amplifier.set_state_mcb)
221
-        self.gui_cd_player.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_common.set_output_2_mcb)
222
-        self.powerplug_common.add_callback(self.KEY_POWERPLUG_CD_PLAYER, None, self.gui_cd_player.set_state_mcb)
223
-        self.gui_pc_dock.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_common.set_output_3_mcb)
224
-        self.powerplug_common.add_callback(self.KEY_POWERPLUG_PC_DOCK, None, self.gui_pc_dock.set_state_mcb)
225
-
226
-        self.gui_heating = devices.nodered_gui_radiator(mqtt_client, config.TOPIC_GFW_DIRK_HEATING_VALVE_GUI)
227
-        self.heating_function.add_callback(heating_function.KEY_TEMPERATURE_CURRENT, None, self.gui_heating.set_temperature_mcb, True)
228
-
229
-        def set_heating_setpoint(device, key, data):
230
-            self.heating_function.set(heating_function.KEY_USER_TEMPERATURE_SETPOINT, data)
231
-        self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_SETPOINT_TEMP, None, set_heating_setpoint)
232
-        self.heating_function.add_callback(heating_function.KEY_TEMPERATURE_SETPOINT, None, self.gui_heating.set_setpoint_temperature_mcb, True)
233
-
234
-        def boost(device, key, data):
235
-            self.heating_function.set(heating_function.KEY_START_BOOST, data)
236
-        self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_BOOST, None, boost)
237
-
238
-        def setpoint_to_default(device, key, data):
239
-            self.heating_function.set(heating_function.KEY_SET_DEFAULT_TEMPERATURE, data)
240
-        self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_SETPOINT_TO_DEFAULT, None, setpoint_to_default)
241
-
242
-        def away_mode(device, key, data):
243
-            self.heating_function.set(heating_function.KEY_AWAY_MODE, data)
244
-        self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_AWAY, None, away_mode)
245
-        self.heating_function.add_callback(heating_function.KEY_AWAY_MODE, None, self.gui_heating.set_away_mcb)
246
-
247
-        def summer_mode(device, key, data):
248
-            self.heating_function.set(heating_function.KEY_SUMMER_MODE, data)
249
-        self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_SUMMER, None, summer_mode)
250
-        self.heating_function.add_callback(heating_function.KEY_SUMMER_MODE, None, self.gui_heating.set_summer_mcb)
251
-
252
-        self.heating_function.add_callback(heating_function.KEY_BOOST_TIMER, None, self.gui_heating.set_timer_mcb)
253
-
254
-        self.gui_led_active_device = devices.nodered_gui_leds(mqtt_client, config.TOPIC_GFW_DIRK_DEVICE_CHOOSER_LED)
255
-
256
-        def update_active_device_led(device, key, data):
257
-            for i in range(0, len(self.brightness_functions.brightness_device_list)):
258
-                self.gui_led_active_device.set_led(devices.nodered_gui_leds.KEY_LED_LIST[i], data == i)
259
-        self.brightness_functions.add_callback(brightness_choose_n_action.KEY_ACTIVE_DEVICE, None, update_active_device_led, True)
260
-        ##### TEMPORARY ###################################################################################################################
261
-
262
         #
147
         #
263
         # Virtual Device Interface
148
         # Virtual Device Interface
264
         #
149
         #
303
         #
188
         #
304
         self.delayed_task_remote = task.delayed(1.0, self.send_audio_source)
189
         self.delayed_task_remote = task.delayed(1.0, self.send_audio_source)
305
 
190
 
306
-    def all_off(self, device=None, key=None, data=None):
307
-        super().all_off(device, key, data)
308
-        self.powerplug_common.set_output_all(False)
309
-
310
     def audio_source_selector(self, device, key, data):
191
     def audio_source_selector(self, device, key, data):
311
         if device == self.powerplug_common and key == self.KEY_POWERPLUG_CD_PLAYER:
192
         if device == self.powerplug_common and key == self.KEY_POWERPLUG_CD_PLAYER:
312
             # switch on of cd player
193
             # switch on of cd player

+ 5
- 2
function/modules.py View File

25
 logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
25
 logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
26
 
26
 
27
 
27
 
28
+class switched_light(object):
29
+    def __init__(self, sw_device, sw_key, li_device):
30
+        sw_device.add_callback(devices.shelly.KEY_OUTPUT_0, True, li_device.request_data, True)
31
+
32
+
28
 class brightness_choose_n_action(common_base):
33
 class brightness_choose_n_action(common_base):
29
     KEY_ACTIVE_DEVICE = 'active_device'
34
     KEY_ACTIVE_DEVICE = 'active_device'
30
     #
35
     #
54
         callback_device: A device for installing callback which are executed, when the device is switched on or off. It needs the following method:
59
         callback_device: A device for installing callback which are executed, when the device is switched on or off. It needs the following method:
55
         * .add_callback(key, data or None, callback, on_changes_only)
60
         * .add_callback(key, data or None, callback, on_changes_only)
56
         """
61
         """
57
-        if len(self.brightness_device_list) >= len(devices.nodered_gui_leds.KEY_LED_LIST):
58
-            raise ValueError("Number of devices is limited by number of leds in devices.nodered_gui_leds.")
59
         self.brightness_device_list.append(brightness_device)
62
         self.brightness_device_list.append(brightness_device)
60
         self.callback_device_list.append((callback_device, callback_key))
63
         self.callback_device_list.append((callback_device, callback_key))
61
         self.device_states.append(False)
64
         self.device_states.append(False)

+ 0
- 15
function/stairway.py View File

36
             timer_value=config.USER_ON_TIME_STAIRWAYS
36
             timer_value=config.USER_ON_TIME_STAIRWAYS
37
         )
37
         )
38
 
38
 
39
-        ##### TEMPORARY ###################################################################################################################
40
-        self.gui_main_light = devices.nodered_gui_light(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_GUI)
41
-        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.main_light_shelly.set_output_0_mcb)
42
-        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_state_mcb)
43
-        self.motion_sensor_light.add_callback(motion_sensor_light.KEY_TIMER, None, self.gui_main_light.set_timer_mcb)
44
-
45
-        def set_led(device, key, data):
46
-            if key == motion_sensor_light.KEY_MOTION_SENSOR_0:
47
-                self.gui_main_light.set_led(devices.nodered_gui_light.KEY_LED_0, data)
48
-            if key == motion_sensor_light.KEY_MOTION_SENSOR_1:
49
-                self.gui_main_light.set_led(devices.nodered_gui_light.KEY_LED_1, data)
50
-        self.motion_sensor_light.add_callback(motion_sensor_light.KEY_MOTION_SENSOR_0, None, set_led)
51
-        self.motion_sensor_light.add_callback(motion_sensor_light.KEY_MOTION_SENSOR_1, None, set_led)
52
-        ##### TEMPORARY ###################################################################################################################
53
-
54
         #
39
         #
55
         # Virtual Device Interface
40
         # Virtual Device Interface
56
         #
41
         #

+ 3
- 1
function/videv.py View File

48
         # send default data to videv interface
48
         # send default data to videv interface
49
 
49
 
50
     def __rx_ext_device_data__(self, ext_device, ext_key, data):
50
     def __rx_ext_device_data__(self, ext_device, ext_key, data):
51
-        self.__tx__(self.__display_dict__[(id(ext_device), ext_key)], data)
51
+        my_key = self.__display_dict__[(id(ext_device), ext_key)]
52
+        self[my_key] = data
53
+        self.__tx__(my_key, data)
52
 
54
 
53
     def __tx__(self, key, data):
55
     def __tx__(self, key, data):
54
         if key in self.__control_dict__:
56
         if key in self.__control_dict__:

Loading…
Cancel
Save