|
@@ -2,7 +2,9 @@
|
2
|
2
|
# -*- coding: utf-8 -*-
|
3
|
3
|
#
|
4
|
4
|
|
|
5
|
+import config
|
5
|
6
|
import devices
|
|
7
|
+from function.rooms import room_shelly
|
6
|
8
|
import logging
|
7
|
9
|
import task
|
8
|
10
|
|
|
@@ -100,73 +102,94 @@ class brightness_choose_n_action(object):
|
100
|
102
|
target.default_stop()
|
101
|
103
|
|
102
|
104
|
|
103
|
|
-class heating_function_brennenstuhl(object):
|
104
|
|
- RETURN_TO_DEFAULT_TIME = 45 * 60
|
105
|
|
- BOOST_TEMP_OFFSET = 5
|
106
|
|
-
|
107
|
|
- def __init__(self, mqtt_client, topic_valve, default_temperature, topic_boost, topic_setpoint, topic_led):
|
108
|
|
- self.ct = task.periodic(1, self.cyclic_task)
|
|
105
|
+class circulation_pump(room_shelly):
|
|
106
|
+ def __init__(self, mqtt_client):
|
|
107
|
+ super().__init__(mqtt_client, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_SHELLY, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_GUI)
|
109
|
108
|
#
|
110
|
|
- self.topic = topic_valve
|
111
|
|
- self.default_temperature = default_temperature
|
|
109
|
+ self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.circ_pump_actions, True)
|
112
|
110
|
#
|
113
|
|
- self.heating_valve = devices.brennenstuhl_heatingvalve(mqtt_client, topic_valve)
|
114
|
|
- self.heating_valve.set_heating_setpoint(self.default_temperature)
|
115
|
|
- self.heating_valve.add_callback(
|
116
|
|
- devices.brennenstuhl_heatingvalve.KEY_HEATING_SETPOINT, None, self.heating_setpoint_actions)
|
|
111
|
+ self.gui_main_light.set_timer('-')
|
|
112
|
+ #
|
|
113
|
+ self.ct = task.periodic(6, self.cyclic_task)
|
|
114
|
+ self.pump_timer = None
|
|
115
|
+ #
|
|
116
|
+ self.ct.run()
|
117
|
117
|
|
118
|
|
- self.gui_value_temp_setp = devices.nodered_gui_heatvalve(mqtt_client, topic_setpoint)
|
119
|
|
- self.gui_value_temp_setp.add_callback(
|
120
|
|
- devices.nodered_gui_heatvalve.KEY_HEATING_SETPOINT, None, self.heating_setpoint_actions)
|
|
118
|
+ def circ_pump_actions(self, device, key, data):
|
|
119
|
+ if data is True:
|
|
120
|
+ self.pump_timer = 10
|
|
121
|
+ self.gui_main_light.set_timer(self.pump_timer)
|
|
122
|
+ else:
|
|
123
|
+ self.pump_timer = None
|
|
124
|
+ self.gui_main_light.set_timer('-')
|
121
|
125
|
|
122
|
|
- self.gui_button_boost = devices.nodered_gui_heatvalve(mqtt_client, topic_boost)
|
123
|
|
- self.gui_button_boost.add_callback(None, None, self.boost_actions)
|
|
126
|
+ def cyclic_task(self, rt):
|
|
127
|
+ if self.pump_timer is not None:
|
|
128
|
+ if self.pump_timer <= 0:
|
|
129
|
+ self.pump_timer = None
|
|
130
|
+ self.gui_main_light.set_timer('-')
|
|
131
|
+ else:
|
|
132
|
+ self.gui_main_light.set_timer(self.pump_timer)
|
|
133
|
+ self.pump_timer -= self.ct.cycle_time / 60
|
124
|
134
|
|
125
|
|
- self.gui_led_boost = devices.nodered_gui_heatvalve(mqtt_client, topic_led)
|
126
|
135
|
|
|
136
|
+# TODO:
|
|
137
|
+# - improve devices.brennenstuhl_heatingvalve (at least switch on for boost) and use boost in heating_function.boost_mcb
|
|
138
|
+# - implement modules.heating_function
|
|
139
|
+# * Central switch incl. central parameter storage for state (summer mode, away_mode - each switch activation disables the other switch)
|
|
140
|
+class radiator_function(object):
|
|
141
|
+ def __init__(self, mqtt_client, topic_valve, topic_gui, default_temperature):
|
|
142
|
+ self.default_temperature = default_temperature
|
|
143
|
+ self.regular_temp_setpoint = self.default_temperature
|
127
|
144
|
#
|
128
|
|
- self.return_to_default_timer = None
|
129
|
|
- self.return_to_default_setpoint = None
|
130
|
|
- self.gui_led_boost.set_feedback(False)
|
|
145
|
+ self.ct = task.periodic(1, self.cyclic_task)
|
|
146
|
+ #
|
|
147
|
+ self.heating_valve = devices.brennenstuhl_heatingvalve(mqtt_client, topic_valve)
|
|
148
|
+ self.gui_heating = devices.nodered_gui_radiator(mqtt_client, topic_gui)
|
|
149
|
+ #
|
|
150
|
+ self.heating_valve.set_heating_setpoint(self.default_temperature)
|
|
151
|
+ self.heating_valve.add_callback(devices.brennenstuhl_heatingvalve.KEY_TEMPERATURE, None, self.gui_heating.set_temperature_mcb)
|
|
152
|
+ self.heating_valve.add_callback(devices.brennenstuhl_heatingvalve.KEY_HEATING_SETPOINT, None, self.gui_heating.set_setpoint_temperature_mcb)
|
|
153
|
+ self.heating_valve.add_callback(devices.brennenstuhl_heatingvalve.KEY_HEATING_SETPOINT, None, self.store_regular_setpoint)
|
|
154
|
+ #
|
|
155
|
+ self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_SETPOINT_TEMP, None, self.heating_valve.set_heating_setpoint_mcb)
|
|
156
|
+ self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_BOOST, None, self.boost_mcb)
|
|
157
|
+ self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_SETPOINT_TO_DEFAULT, None, self.setpoint_to_default_mcb)
|
|
158
|
+ self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_SETPOINT_TEMP, None, self.cancel_boost)
|
|
159
|
+ self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_SETPOINT_TO_DEFAULT, None, self.cancel_boost)
|
|
160
|
+ #
|
|
161
|
+ self.boost_timer = None
|
131
|
162
|
#
|
132
|
163
|
self.ct.run()
|
133
|
164
|
|
134
|
|
- def heating_setpoint_actions(self, device, key, data):
|
135
|
|
- if device.topic == self.heating_valve.topic:
|
136
|
|
- # valve setpoint action
|
137
|
|
- self.gui_value_temp_setp.set_feedback(data)
|
138
|
|
- if data > self.default_temperature:
|
139
|
|
- if data != self.return_to_default_setpoint:
|
140
|
|
- logger.info('Got heating setpoint (%.1f°C) \"%s\" with deviation to the default value (%.1f°C). Starting timer for returning to default.',
|
141
|
|
- data, self.topic, self.default_temperature)
|
142
|
|
- self.return_to_default_timer = self.RETURN_TO_DEFAULT_TIME
|
143
|
|
- self.return_to_default_setpoint = data
|
144
|
|
- self.gui_led_boost.set_feedback(True)
|
145
|
|
- else:
|
146
|
|
- if self.return_to_default_timer is not None:
|
147
|
|
- logger.info('Deleting timer \"%s\" for returning to default.', self.topic)
|
148
|
|
- self.return_to_default_timer = None
|
149
|
|
- self.return_to_default_setpoint = None
|
150
|
|
- self.gui_led_boost.set_feedback(False)
|
151
|
|
- elif device.topic == self.gui_value_temp_setp.topic:
|
152
|
|
- # user setpoint action
|
153
|
|
- logger.info('Setpoint change \"%s\" to %.1f°C', self.topic, data)
|
154
|
|
- self.default_temperature = data
|
155
|
|
- self.heating_valve.set_heating_setpoint(self.default_temperature)
|
156
|
|
- self.return_to_default_timer = None
|
157
|
|
- self.return_to_default_setpoint = None
|
158
|
|
- self.gui_led_boost.set_feedback(False)
|
159
|
|
-
|
160
|
|
- def boost_actions(self, davice, key, data):
|
161
|
|
- logger.info('Starting boost mode \"%s\" with setpoint %.1f°C.', self.topic, self.default_temperature + self.BOOST_TEMP_OFFSET)
|
162
|
|
- self.heating_valve.set_heating_setpoint(self.default_temperature + self.BOOST_TEMP_OFFSET)
|
163
|
|
-
|
164
|
165
|
def cyclic_task(self, rt):
|
165
|
|
- if self.return_to_default_timer is not None:
|
166
|
|
- self.return_to_default_timer -= self.ct.cycle_time
|
167
|
|
- if self.return_to_default_timer <= 0:
|
168
|
|
- logger.info('Return to default timer expired \"%s\".', self.topic)
|
169
|
|
- self.heating_valve.set_heating_setpoint(self.default_temperature)
|
170
|
|
- self.return_to_default_timer = None
|
171
|
|
- self.return_to_default_setpoint = None
|
172
|
|
- self.gui_led_boost.set_feedback(False)
|
|
166
|
+ if self.boost_timer is not None:
|
|
167
|
+ self.gui_heating.set_timer(round(self.boost_timer / 60, 1))
|
|
168
|
+ #
|
|
169
|
+ self.boost_timer -= self.ct.cycle_time
|
|
170
|
+ if self.boost_timer <= 0:
|
|
171
|
+ self.cancel_boost()
|
|
172
|
+ self.heating_valve.set_heating_setpoint(self.regular_temp_setpoint)
|
|
173
|
+
|
|
174
|
+ def cancel_boost(self, device=None, key=None, data=None):
|
|
175
|
+ if self.boost_timer is not None:
|
|
176
|
+ self.heating_valve.logger.info('Timer expired. returning to regular temperature setpoint %.1f°C.', self.regular_temp_setpoint)
|
|
177
|
+ self.boost_timer = None
|
|
178
|
+ self.gui_heating.set_timer('-')
|
|
179
|
+
|
|
180
|
+ def store_regular_setpoint(self, device, key, data):
|
|
181
|
+ if self.boost_timer is None:
|
|
182
|
+ self.regular_temp_setpoint = data
|
|
183
|
+
|
|
184
|
+ def boost_mcb(self, device, key, data):
|
|
185
|
+ if self.boost_timer is None:
|
|
186
|
+ self.heating_valve.logger.info('Starting boost mode with setpoint %.1f°C.', self.regular_temp_setpoint + 5)
|
|
187
|
+ self.boost_timer = 15*60
|
|
188
|
+ self.heating_valve.set_heating_setpoint(self.regular_temp_setpoint + 5) # TODO: Change setpoint to "on" if possible
|
|
189
|
+ else:
|
|
190
|
+ self.boost_timer += 15 * 60
|
|
191
|
+ if self.boost_timer > 60 * 60:
|
|
192
|
+ self.boost_timer = 60 * 60
|
|
193
|
+
|
|
194
|
+ def setpoint_to_default_mcb(self, device, key, data):
|
|
195
|
+ self.heating_valve.set_heating_setpoint(self.default_temperature)
|