Преглед изворни кода

HeatValve: Automatic configuration implemented

master
Dirk Alders пре 7 месеци
родитељ
комит
8573dcf43f
2 измењених фајлова са 17 додато и 2 уклоњено
  1. 10
    0
      devices/base.py
  2. 7
    2
      devices/brennenstuhl.py

+ 10
- 0
devices/base.py Прегледај датотеку

@@ -27,6 +27,8 @@ class base(mqtt_base):
27 27
     RX_IGNORE_TOPICS = []
28 28
     RX_IGNORE_KEYS = []
29 29
     RX_FILTER_DATA_KEYS = []
30
+    #
31
+    CFG_DATA = {}
30 32
 
31 33
     def __init__(self, mqtt_client, topic):
32 34
         super().__init__(mqtt_client, topic, default_values=dict.fromkeys(self.RX_KEYS))
@@ -37,7 +39,15 @@ class base(mqtt_base):
37 39
         #
38 40
         self.add_callback(None, None, self.__state_logging__, on_change_only=True)
39 41
 
42
+    def __cfg_callback__(self, key, value):
43
+        if self.CFG_DATA.get(key) != value:
44
+            self.logger.warning("Differing configuration identified: %s=%s --> %s=%s",
45
+                                repr(key), repr(value), repr(key), repr(self.CFG_DATA.get(key)))
46
+            self.send_command(key, self.CFG_DATA.get(key))
47
+
40 48
     def set(self, key, data, block_callback=[]):
49
+        if key in self.CFG_DATA:
50
+            self.__cfg_callback__(key, data)
41 51
         if key in self.RX_IGNORE_KEYS:
42 52
             pass    # ignore these keys
43 53
         elif key in self.RX_KEYS:

+ 7
- 2
devices/brennenstuhl.py Прегледај датотеку

@@ -52,11 +52,16 @@ class brennenstuhl_heatingvalve(base):
52 52
     #
53 53
     RX_KEYS = [KEY_LINKQUALITY, KEY_BATTERY, KEY_HEATING_SETPOINT, KEY_TEMPERATURE]
54 54
     RX_IGNORE_KEYS = [KEY_AWAY_MODE, KEY_CHILD_LOCK, KEY_PRESET, KEY_SYSTEM_MODE, KEY_VALVE_DETECTION, KEY_WINDOW_DETECTION]
55
+    #
56
+    CFG_DATA = {
57
+        KEY_WINDOW_DETECTION: "ON",
58
+        KEY_VALVE_DETECTION: "ON",
59
+        KEY_SYSTEM_MODE: "heat",
60
+        KEY_PRESET: "manual"
61
+    }
55 62
 
56 63
     def __init__(self, mqtt_client, topic):
57 64
         super().__init__(mqtt_client, topic)
58
-        self.mqtt_client.send(self.topic + '/' + self.TX_TOPIC, json.dumps({self.KEY_WINDOW_DETECTION: "ON",
59
-                              self.KEY_CHILD_LOCK: "UNLOCK", self.KEY_VALVE_DETECTION: "ON", self.KEY_SYSTEM_MODE: "heat", self.KEY_PRESET: "manual"}))
60 65
         self.add_callback(self.KEY_HEATING_SETPOINT, None, self.__valave_temp_rx__)
61 66
         self.__tx_temperature__ = None
62 67
         self.__rx_temperature__ = None

Loading…
Откажи
Сачувај