|
@@ -7,11 +7,16 @@ from function.first_floor_west import first_floor_west_julian, first_floor_west_
|
7
|
7
|
from function.first_floor_east import first_floor_east_floor, first_floor_east_kitchen, first_floor_east_dining, first_floor_east_sleep_madi, first_floor_east_living
|
8
|
8
|
from function.common import common_heating, common_circulation_pump
|
9
|
9
|
import inspect
|
10
|
|
-from function import modules
|
|
10
|
+import logging
|
|
11
|
+
|
|
12
|
+try:
|
|
13
|
+ from config import APP_NAME as ROOT_LOGGER_NAME
|
|
14
|
+except ImportError:
|
|
15
|
+ ROOT_LOGGER_NAME = 'root'
|
|
16
|
+logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
|
11
|
17
|
|
12
|
|
-# TODO: implement switch off functionality (except of switch off button transportation)
|
13
|
|
-# TODO: implement garland (incl. day events like sunset, sunrise, ...)
|
14
|
18
|
# TODO: implement existing nodered functionality "dirk" (ground floor west)
|
|
19
|
+# TODO: implement garland (incl. day events like sunset, sunrise, ...)
|
15
|
20
|
# TODO: implement warning message
|
16
|
21
|
|
17
|
22
|
|
|
@@ -20,6 +25,9 @@ class all_functions(object):
|
20
|
25
|
self.mqtt_client = mqtt_client
|
21
|
26
|
#
|
22
|
27
|
self.__devices__ = None
|
|
28
|
+ # heating and warm water
|
|
29
|
+ self.common_heat_sleep_madi = common_heating(self.mqtt_client)
|
|
30
|
+ self.common_circulation_pump = common_circulation_pump(self.mqtt_client)
|
23
|
31
|
# ground floor west
|
24
|
32
|
self.gfw_floor = ground_floor_west_floor(self.mqtt_client)
|
25
|
33
|
self.gfw_marion = ground_floor_west_marion(self.mqtt_client)
|
|
@@ -33,35 +41,75 @@ class all_functions(object):
|
33
|
41
|
self.ffe_dining = first_floor_east_dining(self.mqtt_client)
|
34
|
42
|
self.ffe_sleep_madi = first_floor_east_sleep_madi(self.mqtt_client)
|
35
|
43
|
self.ffe_living = first_floor_east_living(self.mqtt_client)
|
36
|
|
- # heating and warm water
|
37
|
|
- self.common_heat_sleep_madi = common_heating(self.mqtt_client)
|
38
|
|
- self.common_circulation_pump = common_circulation_pump(self.mqtt_client)
|
39
|
44
|
#
|
40
|
45
|
# Interactions
|
41
|
46
|
#
|
42
|
|
- # shelly dirk input 1
|
43
|
|
- self.last_gfw_dirk_input_1 = None
|
44
|
|
- self.gfw_dirk.main_light_shelly.add_callback(devices.shelly.KEY_INPUT_1, None, self.gfw_dirk_input_1)
|
45
|
|
- # input device
|
46
|
|
- self.init_input_device_sleep_madi_functionality()
|
|
47
|
+ # cross_room_interactions
|
|
48
|
+ self.init_cross_room_interactions()
|
47
|
49
|
# Circulation pump
|
48
|
50
|
self.init_circulation_pump()
|
|
51
|
+ # Off Buttons
|
|
52
|
+ self.init_off_functionality()
|
49
|
53
|
|
50
|
|
- def init_input_device_sleep_madi_functionality(self):
|
|
54
|
+ def init_off_functionality(self):
|
|
55
|
+ # Off Buttons
|
|
56
|
+ self.gui_button_all_off = devices.nodered_gui(self.mqtt_client, topic="gui/button_all_off")
|
|
57
|
+ self.gui_button_gfw_off = devices.nodered_gui(self.mqtt_client, topic="gui/button_gfw_off")
|
|
58
|
+ self.gui_button_ffw_off = devices.nodered_gui(self.mqtt_client, topic="gui/button_ffw_off")
|
|
59
|
+ self.gui_button_ffe_off = devices.nodered_gui(self.mqtt_client, topic="gui/button_ffe_off")
|
51
|
60
|
#
|
52
|
|
- self.ffe_button_tradfri_sleep = devices.tradfri_button(
|
53
|
|
- self.mqtt_client, topic="zigbee_og_e/input_device/og_east")
|
54
|
|
- #
|
55
|
|
- self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, "toggle",
|
56
|
|
- self.ffe_sleep_madi.toggle_main_light)
|
57
|
|
- self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, "brightness_up_click",
|
58
|
|
- self.ffe_sleep_madi.toggle_bed_light_di)
|
59
|
|
- self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, "brightness_down_click",
|
60
|
|
- self.ffe_sleep_madi.toggle_bed_light_di)
|
61
|
|
- self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, "arrow_right_click",
|
62
|
|
- self.ffe_floor.toggle_main_light)
|
63
|
|
- self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, None,
|
64
|
|
- self.ffe_sleep_madi.fade_light)
|
|
61
|
+ self.gui_button_all_off.add_callback(devices.nodered_gui.KEY_OFF_BUTTON, True, self.all_off)
|
|
62
|
+ self.gui_button_gfw_off.add_callback(devices.nodered_gui.KEY_OFF_BUTTON, True, self.gfw_off)
|
|
63
|
+ self.gui_button_ffw_off.add_callback(devices.nodered_gui.KEY_OFF_BUTTON, True, self.ffw_off)
|
|
64
|
+ self.gui_button_ffe_off.add_callback(devices.nodered_gui.KEY_OFF_BUTTON, True, self.ffe_off)
|
|
65
|
+ # Long push ffe_floor
|
|
66
|
+ self.ffe_floor.main_light_shelly.add_callback(
|
|
67
|
+ devices.shelly.KEY_LONGPUSH_0, True, self.ffe_floor.all_off_feedback)
|
|
68
|
+ self.ffe_floor.main_light_shelly.add_callback(devices.shelly.KEY_LONGPUSH_0, True, self.ffe_off)
|
|
69
|
+ # Long push input device
|
|
70
|
+ self.ffe_sleep_madi.button_tradfri.add_callback(
|
|
71
|
+ devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_RIGHT_LONG, self.ffe_off)
|
|
72
|
+
|
|
73
|
+ def getmembers(self, prefix):
|
|
74
|
+ rv = []
|
|
75
|
+ for name, obj in inspect.getmembers(self):
|
|
76
|
+ if name.startswith(prefix) and obj.__module__.split('.')[0] == 'function' and len(obj.__module__.split('.')) == 2:
|
|
77
|
+ rv.append(obj)
|
|
78
|
+ return rv
|
|
79
|
+
|
|
80
|
+ def common_off(self, device=None, key=None, data=None):
|
|
81
|
+ logger.info("Switching \"common\" off.")
|
|
82
|
+ for common in self.getmembers('common'):
|
|
83
|
+ common.all_off()
|
|
84
|
+
|
|
85
|
+ def gfw_off(self, device=None, key=None, data=None):
|
|
86
|
+ logger.info("Switching \"ground floor west\" off.")
|
|
87
|
+ for gfw in self.getmembers('gfw'):
|
|
88
|
+ gfw.all_off()
|
|
89
|
+
|
|
90
|
+ def ffw_off(self, device=None, key=None, data=None):
|
|
91
|
+ logger.info("Switching \"first floor west\" off.")
|
|
92
|
+ for ffw in self.getmembers('ffw'):
|
|
93
|
+ ffw.all_off()
|
|
94
|
+
|
|
95
|
+ def ffe_off(self, device=None, key=None, data=None):
|
|
96
|
+ logger.info("Switching \"first floor east\" off.")
|
|
97
|
+ for ffe in self.getmembers('ffe'):
|
|
98
|
+ ffe.all_off()
|
|
99
|
+
|
|
100
|
+ def all_off(self, device=None, key=None, data=None):
|
|
101
|
+ self.common_off(device, key, data)
|
|
102
|
+ self.gfw_off(device, key, data)
|
|
103
|
+ self.ffw_off(device, key, data)
|
|
104
|
+ self.ffe_off(device, key, data)
|
|
105
|
+
|
|
106
|
+ def init_cross_room_interactions(self):
|
|
107
|
+ # shelly dirk input 1
|
|
108
|
+ self.last_gfw_dirk_input_1 = None
|
|
109
|
+ self.gfw_dirk.main_light_shelly.add_callback(devices.shelly.KEY_INPUT_1, None, self.gfw_dirk_input_1)
|
|
110
|
+ # tradfri button sleep madi right click
|
|
111
|
+ self.ffe_sleep_madi.button_tradfri.add_callback(
|
|
112
|
+ devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_RIGHT, self.ffe_floor.toggle_main_light)
|
65
|
113
|
|
66
|
114
|
def init_circulation_pump(self):
|
67
|
115
|
self.common_circulation_pump.main_light_shelly.add_callback(
|