Browse Source

bug-fix: radiator function

tags/v1.0.0
Dirk Alders 1 year ago
parent
commit
7b0ada6f41
2 changed files with 26 additions and 24 deletions
  1. 8
    9
      devices/__init__.py
  2. 18
    15
      function/modules.py

+ 8
- 9
devices/__init__.py View File

@@ -744,15 +744,6 @@ class nodered_gui_radiator(nodered_gui_timer):
744 744
     #
745 745
     RX_KEYS = [KEY_TEMPERATURE, KEY_SETPOINT_TEMP, KEY_SETPOINT_TO_DEFAULT, KEY_BOOST, KEY_AWAY, KEY_SUMMER]
746 746
 
747
-    def __init__(self, mqtt_client, topic):
748
-        super().__init__(mqtt_client, topic)
749
-        self[self.KEY_ENABLE] = True
750
-        self.add_callback(self.KEY_AWAY, None, self.enable_gui)
751
-        self.add_callback(self.KEY_SUMMER, None, self.enable_gui)
752
-
753
-    def enable_gui(self, device, key, data):
754
-        self.pack(self.KEY_ENABLE, not self.get(self.KEY_AWAY) and not self.get(self.KEY_SUMMER))
755
-
756 747
     #
757 748
     # TX
758 749
     #
@@ -788,6 +779,14 @@ class nodered_gui_radiator(nodered_gui_timer):
788 779
         self.logger.debug("Sending %s with content %s", key, str(data))
789 780
         self.set_summer(data)
790 781
 
782
+    def set_enable(self, data):
783
+        """data: [True, False]"""
784
+        self.pack(self.KEY_ENABLE, data)
785
+
786
+    def set_enable_mcb(self, device, key, data):
787
+        self.logger.debug("Sending %s with content %s", key, str(data))
788
+        self.set_enable(data)
789
+
791 790
 
792 791
 class brennenstuhl_heatingvalve(base):
793 792
     KEY_LINKQUALITY = "linkquality"

+ 18
- 15
function/modules.py View File

@@ -178,30 +178,34 @@ class radiator_function(object):
178 178
             self.boost_timer = None
179 179
             self.gui_heating.set_timer('-')
180 180
 
181
+    def update_states(self, away_mode=None, summer_mode=None):
182
+        if away_mode is not None:
183
+            self.__away_mode__ = away_mode
184
+        if summer_mode is not None:
185
+            self.__summer_mode__ = summer_mode
186
+        self.gui_heating.set_away(self.__away_mode__)
187
+        self.gui_heating.set_summer(self.__summer_mode__)
188
+        self.gui_heating.set_enable(not self.__away_mode__ and not self.__summer_mode__)
189
+
181 190
     def away_mode(self, device, key, value):
182
-        self.__away_mode__ = value
183
-        self.gui_heating.set_away(value)
184 191
         if value is True:
185
-            self.__summer_mode__ = False
186
-            self.gui_heating.set_summer(False)
187 192
             self.cancel_boost()
193
+            self.update_states(away_mode=value, summer_mode=False)
188 194
             self.heating_valve.set_heating_setpoint(self.default_temperature - self.AWAY_REDUCTION)
189 195
         else:
196
+            self.update_states(away_mode=value)
190 197
             self.heating_valve.set_heating_setpoint(self.default_temperature)
191 198
 
192 199
     def summer_mode(self, device, key, value):
193
-        self.__summer_mode__ = value
194
-        self.gui_heating.set_summer(value)
195 200
         if value is True:
196
-            self.__away_mode__ = False
197
-            self.gui_heating.set_away(False)
198 201
             self.cancel_boost()
202
+            self.update_states(away_mode=False, summer_mode=value)
199 203
             self.heating_valve.set_heating_setpoint(self.SUMMER_TEMPERATURE)
200 204
         else:
205
+            self.update_states(summer_mode=value)
201 206
             self.heating_valve.set_heating_setpoint(self.default_temperature)
202 207
 
203 208
     def boost(self, device, key, data):
204
-        self.cancel_boost()
205 209
         if self.boost_timer is None:
206 210
             self.heating_valve.logger.info('Starting boost mode with setpoint %.1f°C.', self.BOOST_TEMPERATURE)
207 211
             self.boost_timer = 15*60
@@ -210,19 +214,18 @@ class radiator_function(object):
210 214
             self.boost_timer += 15 * 60
211 215
         if self.boost_timer > 60 * 60:
212 216
             self.boost_timer = 60 * 60
217
+        self.update_states(away_mode=False, summer_mode=False)
213 218
 
214 219
     def setpoint_to_default(self, device, key, data):
215
-        self.heating_valve.set_heating_setpoint(self.default_temperature)
220
+        self.set_heating_setpoint(device, key, self.default_temperature)
216 221
 
217 222
     def set_heating_setpoint(self, device, key, data):
218
-        self.cancel_boost()
219 223
         self.heating_valve.set_heating_setpoint(data)
224
+        self.cancel_boost()
225
+        self.update_states(away_mode=False, summer_mode=False)
220 226
 
221 227
     def get_radiator_setpoint(self, device, key, data):
222 228
         self.gui_heating.set_setpoint_temperature(data)
223
-        if self.__away_mode__:
224
-            self.away_mode(device, self.gui_heating.KEY_AWAY, True)
225
-        if self.__summer_mode__:
226
-            self.summer_mode(device, self.gui_heating.KEY_SUMMER, True)
229
+        self.update_states()
227 230
         if self.boost_timer is None and not self.__away_mode__ and not self.__summer_mode__:
228 231
             self.regular_temp_setpoint = data

Loading…
Cancel
Save