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
     #
744
     #
745
     RX_KEYS = [KEY_TEMPERATURE, KEY_SETPOINT_TEMP, KEY_SETPOINT_TO_DEFAULT, KEY_BOOST, KEY_AWAY, KEY_SUMMER]
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
     # TX
748
     # TX
758
     #
749
     #
788
         self.logger.debug("Sending %s with content %s", key, str(data))
779
         self.logger.debug("Sending %s with content %s", key, str(data))
789
         self.set_summer(data)
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
 class brennenstuhl_heatingvalve(base):
791
 class brennenstuhl_heatingvalve(base):
793
     KEY_LINKQUALITY = "linkquality"
792
     KEY_LINKQUALITY = "linkquality"

+ 18
- 15
function/modules.py View File

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

Loading…
Cancel
Save