|
@@ -6,6 +6,15 @@ import devices
|
6
|
6
|
import inspect
|
7
|
7
|
import logging
|
8
|
8
|
|
|
9
|
+# TODO: implement first floor west and dirk (ground floor west)
|
|
10
|
+# TODO: implement bed light dirk fading by input device
|
|
11
|
+# TODO: implement heating function sleep_madi
|
|
12
|
+# TODO: implement garland
|
|
13
|
+# TODO: implement circulation pump
|
|
14
|
+# TODO: implement switch off functionality (except of switch off button transportation)
|
|
15
|
+# TODO: WARNING - Got a message from "shellies/floor_eg_w"with unparsed content "event" and "event_cnt"
|
|
16
|
+# TODO: implement warning message (incl. fixing all_functions.devicelist
|
|
17
|
+
|
9
|
18
|
try:
|
10
|
19
|
from config import APP_NAME as ROOT_LOGGER_NAME
|
11
|
20
|
except ImportError:
|
|
@@ -13,6 +22,52 @@ except ImportError:
|
13
|
22
|
logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
|
14
|
23
|
|
15
|
24
|
|
|
25
|
+class all_functions(object):
|
|
26
|
+ def __init__(self, mqtt_client):
|
|
27
|
+ self.rooms = {}
|
|
28
|
+ self.__devices__ = None
|
|
29
|
+ #
|
|
30
|
+ # first floor east
|
|
31
|
+ #
|
|
32
|
+ self.ffe_floor = first_floor_east_floor(mqtt_client)
|
|
33
|
+ self.ffe_kitchen = first_floor_east_kitchen(mqtt_client)
|
|
34
|
+ self.ffe_dining = first_floor_east_dining(mqtt_client)
|
|
35
|
+ self.ffe_sleep_madi = first_floor_east_sleep_madi(mqtt_client)
|
|
36
|
+ self.ffe_living = first_floor_east_living(mqtt_client)
|
|
37
|
+ #
|
|
38
|
+ # ground floor west
|
|
39
|
+ #
|
|
40
|
+ self.gfw_floor = ground_floor_west_floor(mqtt_client)
|
|
41
|
+ self.gfw_marion = ground_floor_west_marion(mqtt_client)
|
|
42
|
+ self.gfw_dirk = ground_floor_west_dirk(mqtt_client)
|
|
43
|
+ #
|
|
44
|
+ # Input devices and Off Buttons
|
|
45
|
+ #
|
|
46
|
+ self.ffe_button_tradfri_sleep = devices.tradfri_button(mqtt_client, topic="zigbee_og_e/input_device/og_east")
|
|
47
|
+ #
|
|
48
|
+ # Callback initialisation
|
|
49
|
+ #
|
|
50
|
+ self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, "toggle",
|
|
51
|
+ self.ffe_sleep_madi.toggle_main_light)
|
|
52
|
+ self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, "brightness_up_click",
|
|
53
|
+ self.ffe_sleep_madi.toggle_bed_light_di)
|
|
54
|
+ self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, "brightness_down_click",
|
|
55
|
+ self.ffe_sleep_madi.toggle_bed_light_di)
|
|
56
|
+ self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, "arrow_right_click",
|
|
57
|
+ self.ffe_floor.toggle_main_light)
|
|
58
|
+
|
|
59
|
+ def devicelist(self):
|
|
60
|
+ raise Exception
|
|
61
|
+ # TODO: generate list by using getattr
|
|
62
|
+ if self.__devices__ is None:
|
|
63
|
+ self.__devices__ = []
|
|
64
|
+ for room in self.rooms:
|
|
65
|
+ for name, obj in inspect.getmembers(room):
|
|
66
|
+ if type(obj) in devices.DEVICE_TYPE_LIST():
|
|
67
|
+ self.__devices__.append(obj)
|
|
68
|
+ return self.__devices__
|
|
69
|
+
|
|
70
|
+
|
16
|
71
|
class room(object):
|
17
|
72
|
def gui_switch_feedback(self, device, key, data):
|
18
|
73
|
self.gui_switch_main_light.set_feedback(data)
|
|
@@ -87,6 +142,25 @@ class room_shelly_tradfri_light(room_shelly):
|
87
|
142
|
self.main_light_tradfri.set_color_temp(data * 10)
|
88
|
143
|
|
89
|
144
|
|
|
145
|
+class room_shelly_silvercrest_light(room_shelly_tradfri_light):
|
|
146
|
+ def __init__(self, mqtt_client, topic_shelly, topic_gui_switch, topic_tradfri_light, topic_gui_brightness, topic_gui_color_temp):
|
|
147
|
+ super().__init__(mqtt_client, topic_shelly, topic_gui_switch, topic_tradfri_light, topic_gui_brightness, topic_gui_color_temp)
|
|
148
|
+ #
|
|
149
|
+ # Callback initialisation
|
|
150
|
+ #
|
|
151
|
+ self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.get_initial_main_light_data)
|
|
152
|
+ #
|
|
153
|
+ self.main_light_shelly_last = None
|
|
154
|
+
|
|
155
|
+ def get_initial_main_light_data(self, device, key, data):
|
|
156
|
+ if data is True and self.main_light_shelly_last is not True:
|
|
157
|
+ self.send_init_message_main_light()
|
|
158
|
+ self.main_light_shelly_last = data
|
|
159
|
+
|
|
160
|
+ def send_init_message_main_light(self):
|
|
161
|
+ self.main_light_tradfri.mqtt_client.send(self.main_light_tradfri.topic + "/get", '{"state": ""}')
|
|
162
|
+
|
|
163
|
+
|
90
|
164
|
class first_floor_east_floor(room_shelly):
|
91
|
165
|
def __init__(self, mqtt_client):
|
92
|
166
|
# http://shelly1l-3C6105E4E629
|
|
@@ -269,41 +343,39 @@ class first_floor_east_living(room_shelly_tradfri_light):
|
269
|
343
|
device.set_color_temp(data * 10)
|
270
|
344
|
|
271
|
345
|
|
272
|
|
-class all_functions(object):
|
|
346
|
+class ground_floor_west_floor(room_shelly_silvercrest_light):
|
|
347
|
+ # https://shelly1l-84CCA8AD1148
|
273
|
348
|
def __init__(self, mqtt_client):
|
274
|
|
- self.rooms = {}
|
275
|
|
- self.__devices__ = None
|
276
|
|
- #
|
277
|
|
- # first floor east
|
278
|
|
- #
|
279
|
|
- self.ffe_floor = first_floor_east_floor(mqtt_client)
|
280
|
|
- self.ffe_kitchen = first_floor_east_kitchen(mqtt_client)
|
281
|
|
- self.ffe_dining = first_floor_east_dining(mqtt_client)
|
282
|
|
- self.ffe_sleep_madi = first_floor_east_sleep_madi(mqtt_client)
|
283
|
|
- self.ffe_living = first_floor_east_living(mqtt_client)
|
284
|
|
- #
|
285
|
|
- # Input devices and Off Buttons
|
286
|
|
- #
|
287
|
|
- self.ffe_button_tradfri_sleep = devices.tradfri_button(mqtt_client, topic="zigbee_og_e/input_device/og_east")
|
|
349
|
+ super().__init__(mqtt_client, "shellies/floor_eg_w", "gui/gfw_sw_floor",
|
|
350
|
+ "zigbee_eg_w/light/floor_eg_w/a", "gui/gfw_br_floor", "gui/gfw_ct_floor")
|
288
|
351
|
#
|
289
|
352
|
# Callback initialisation
|
290
|
353
|
#
|
291
|
|
- self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, "toggle",
|
292
|
|
- self.ffe_sleep_madi.toggle_main_light)
|
293
|
|
- self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, "brightness_up_click",
|
294
|
|
- self.ffe_sleep_madi.toggle_bed_light_di)
|
295
|
|
- self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, "brightness_down_click",
|
296
|
|
- self.ffe_sleep_madi.toggle_bed_light_di)
|
297
|
|
- self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, "arrow_right_click",
|
298
|
|
- self.ffe_floor.toggle_main_light)
|
|
354
|
+ self.main_light_tradfri_2 = devices.tradfri_light(mqtt_client, "zigbee_eg_w/light/floor_eg_w/b")
|
|
355
|
+ self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS,
|
|
356
|
+ None, self.sync_brightness_main_light)
|
|
357
|
+ self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP,
|
|
358
|
+ None, self.sync_color_temp_main_light)
|
299
|
359
|
|
300
|
|
- def devicelist(self):
|
301
|
|
- raise Exception
|
302
|
|
- # TODO: generate list by using getattr
|
303
|
|
- if self.__devices__ is None:
|
304
|
|
- self.__devices__ = []
|
305
|
|
- for room in self.rooms:
|
306
|
|
- for name, obj in inspect.getmembers(room):
|
307
|
|
- if type(obj) in devices.DEVICE_TYPE_LIST():
|
308
|
|
- self.__devices__.append(obj)
|
309
|
|
- return self.__devices__
|
|
360
|
+ def send_init_message_main_light(self):
|
|
361
|
+ return super().send_init_message_main_light()
|
|
362
|
+ self.main_light_tradfri_2.mqtt_client.send(self.main_light_tradfri_2.topic + "/get", '{"state": ""}')
|
|
363
|
+
|
|
364
|
+ def sync_brightness_main_light(self, device, key, data):
|
|
365
|
+ self.main_light_tradfri_2.set_brightness(data)
|
|
366
|
+
|
|
367
|
+ def sync_color_temp_main_light(self, device, key, data):
|
|
368
|
+ self.main_light_tradfri_2.set_color_temp(data)
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+class ground_floor_west_marion(room_shelly):
|
|
372
|
+ # https://shelly1l-E8DB84A1E067
|
|
373
|
+ def __init__(self, mqtt_client):
|
|
374
|
+ super().__init__(mqtt_client, "shellies/marion", "gui/gfw_sw_marion")
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+class ground_floor_west_dirk(room_shelly_tradfri_light):
|
|
378
|
+ # https://shelly1l-3C6105E44F27
|
|
379
|
+ def __init__(self, mqtt_client):
|
|
380
|
+ super().__init__(mqtt_client, "shellies/dirk", "gui/gfw_sw_dirk",
|
|
381
|
+ "zigbee_eg_w/light/dirk", "gui/gfw_br_dirk", "gui/gfw_ct_dirk")
|