Explorar el Código

HeatValve: Automatic configuration implemented

master
Dirk Alders hace 7 meses
padre
commit
8573dcf43f
Se han modificado 2 ficheros con 17 adiciones y 2 borrados
  1. 10
    0
      devices/base.py
  2. 7
    2
      devices/brennenstuhl.py

+ 10
- 0
devices/base.py Ver fichero

27
     RX_IGNORE_TOPICS = []
27
     RX_IGNORE_TOPICS = []
28
     RX_IGNORE_KEYS = []
28
     RX_IGNORE_KEYS = []
29
     RX_FILTER_DATA_KEYS = []
29
     RX_FILTER_DATA_KEYS = []
30
+    #
31
+    CFG_DATA = {}
30
 
32
 
31
     def __init__(self, mqtt_client, topic):
33
     def __init__(self, mqtt_client, topic):
32
         super().__init__(mqtt_client, topic, default_values=dict.fromkeys(self.RX_KEYS))
34
         super().__init__(mqtt_client, topic, default_values=dict.fromkeys(self.RX_KEYS))
37
         #
39
         #
38
         self.add_callback(None, None, self.__state_logging__, on_change_only=True)
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
     def set(self, key, data, block_callback=[]):
48
     def set(self, key, data, block_callback=[]):
49
+        if key in self.CFG_DATA:
50
+            self.__cfg_callback__(key, data)
41
         if key in self.RX_IGNORE_KEYS:
51
         if key in self.RX_IGNORE_KEYS:
42
             pass    # ignore these keys
52
             pass    # ignore these keys
43
         elif key in self.RX_KEYS:
53
         elif key in self.RX_KEYS:

+ 7
- 2
devices/brennenstuhl.py Ver fichero

52
     #
52
     #
53
     RX_KEYS = [KEY_LINKQUALITY, KEY_BATTERY, KEY_HEATING_SETPOINT, KEY_TEMPERATURE]
53
     RX_KEYS = [KEY_LINKQUALITY, KEY_BATTERY, KEY_HEATING_SETPOINT, KEY_TEMPERATURE]
54
     RX_IGNORE_KEYS = [KEY_AWAY_MODE, KEY_CHILD_LOCK, KEY_PRESET, KEY_SYSTEM_MODE, KEY_VALVE_DETECTION, KEY_WINDOW_DETECTION]
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
     def __init__(self, mqtt_client, topic):
63
     def __init__(self, mqtt_client, topic):
57
         super().__init__(mqtt_client, topic)
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
         self.add_callback(self.KEY_HEATING_SETPOINT, None, self.__valave_temp_rx__)
65
         self.add_callback(self.KEY_HEATING_SETPOINT, None, self.__valave_temp_rx__)
61
         self.__tx_temperature__ = None
66
         self.__tx_temperature__ = None
62
         self.__rx_temperature__ = None
67
         self.__rx_temperature__ = None

Loading…
Cancelar
Guardar