Browse Source

send setting always for heating valve device

videv_dev
Dirk Alders 1 year ago
parent
commit
54d72802c2
1 changed files with 7 additions and 4 deletions
  1. 7
    4
      devices/__init__.py

+ 7
- 4
devices/__init__.py View File

@@ -26,13 +26,11 @@ devices (DEVICES)
26 26
 
27 27
 """
28 28
 
29
-# TODO: Usage of mqtt_base for all devices
30
-#
31
-# TODO: brennenstuhl_heatingvalve: always send "{"preset": "manual", "system_mode": "heat"}" with any information
32 29
 # TODO: usage of base.mqtt as parent for class base
33 30
 
34 31
 __DEPENDENCIES__ = []
35 32
 
33
+import copy
36 34
 import json
37 35
 import logging
38 36
 
@@ -110,6 +108,8 @@ class base(dict):
110 108
     RX_IGNORE_TOPICS = []
111 109
     RX_IGNORE_KEYS = []
112 110
     RX_FILTER_DATA_KEYS = []
111
+    #
112
+    TX_BASE_DATA = None
113 113
 
114 114
     def __init__(self, mqtt_client, topic):
115 115
         # data storage
@@ -194,7 +194,9 @@ class base(dict):
194 194
             else:
195 195
                 self.logger.debug("Sending data for %s - %s", key, str(data))
196 196
                 if self.TX_TYPE == self.TX_DICT:
197
-                    self.mqtt_client.send('/'.join([self.topic, self.TX_TOPIC]), json.dumps({key: data}))
197
+                    tx_data = copy.copy(self.TX_BASE_DATA or {})
198
+                    tx_data[key] = data
199
+                    self.mqtt_client.send('/'.join([self.topic, self.TX_TOPIC]), json.dumps(tx_data))
198 200
                 else:
199 201
                     if type(data) not in [str, bytes]:
200 202
                         data = json.dumps(data)
@@ -856,6 +858,7 @@ class brennenstuhl_heatingvalve(base):
856 858
     KEY_WINDOW_DETECTION = "window_detection"
857 859
     #
858 860
     TX_TYPE = base.TX_DICT
861
+    TX_BASE_DATA = {KEY_PRESET: "manual", KEY_SYSTEM_MODE: "heat"}
859 862
     #
860 863
     RX_KEYS = [KEY_LINKQUALITY, KEY_BATTERY, KEY_HEATING_SETPOINT, KEY_TEMPERATURE]
861 864
     RX_IGNORE_KEYS = [KEY_AWAY_MODE, KEY_CHILD_LOCK, KEY_PRESET, KEY_SYSTEM_MODE, KEY_VALVE_DETECTION, KEY_WINDOW_DETECTION]

Loading…
Cancel
Save