Bladeren bron

warning mechanisms removed

tags/v1.3.0
Dirk Alders 1 jaar geleden
bovenliggende
commit
d93c9548c8
5 gewijzigde bestanden met toevoegingen van 2 en 84 verwijderingen
  1. 2
    27
      devices/base.py
  2. 0
    18
      devices/brennenstuhl.py
  3. 0
    11
      devices/shelly.py
  4. 0
    11
      devices/silvercrest.py
  5. 0
    17
      devices/tradfri.py

+ 2
- 27
devices/base.py Bestand weergeven

@@ -6,8 +6,6 @@ from base import videv_base
6 6
 import json
7 7
 import time
8 8
 
9
-BATTERY_WARN_LEVEL = 10
10
-
11 9
 
12 10
 def is_json(data):
13 11
     try:
@@ -29,11 +27,9 @@ class base(mqtt_base):
29 27
     RX_IGNORE_TOPICS = []
30 28
     RX_IGNORE_KEYS = []
31 29
     RX_FILTER_DATA_KEYS = []
32
-    #
33
-    KEY_WARNING = '__WARNING__'
34 30
 
35 31
     def __init__(self, mqtt_client, topic):
36
-        super().__init__(mqtt_client, topic, default_values=dict.fromkeys(self.RX_KEYS + [self.KEY_WARNING]))
32
+        super().__init__(mqtt_client, topic, default_values=dict.fromkeys(self.RX_KEYS))
37 33
         # data storage
38 34
         # initialisations
39 35
         mqtt_client.add_callback(topic=self.topic, callback=self.receive_callback)
@@ -44,7 +40,7 @@ class base(mqtt_base):
44 40
     def set(self, key, data, block_callback=[]):
45 41
         if key in self.RX_IGNORE_KEYS:
46 42
             pass    # ignore these keys
47
-        elif key in self.RX_KEYS or key == self.KEY_WARNING:
43
+        elif key in self.RX_KEYS:
48 44
             return super().set(key, data, block_callback)
49 45
         else:
50 46
             self.logger.warning("Unexpected key %s", key)
@@ -105,24 +101,3 @@ class base(mqtt_base):
105 101
                     self.mqtt_client.send('/'.join([self.topic, key, self.TX_TOPIC] if len(self.TX_TOPIC) > 0 else [self.topic, key]), data)
106 102
         else:
107 103
             self.logger.error("Unknown tx toptic. Set TX_TOPIC of class to a known value")
108
-
109
-
110
-class warning(dict):
111
-    TYPE_BATTERY_LOW = 1
112
-    TYPE_OVERTEMPERATURE = 2
113
-    #
114
-    KEY_ID = 'id'
115
-    KEY_TYPE = 'type'
116
-    KEY_TEXT = 'text'
117
-    KEY_TM = 'tm'
118
-
119
-    def __init__(self, identification, type, text, args):
120
-        super().__init__({
121
-            self.KEY_ID: identification,
122
-            self.KEY_TYPE: type,
123
-            self.KEY_TEXT: text % args,
124
-            self.KEY_TM: time.localtime(),
125
-        })
126
-
127
-    def __str__(self):
128
-        return time.asctime(self.get(self.KEY_TM)) + ": " + self[self.KEY_TEXT] + " - " + self[self.KEY_ID]

+ 0
- 18
devices/brennenstuhl.py Bestand weergeven

@@ -2,8 +2,6 @@
2 2
 # -*- coding: utf-8 -*-
3 3
 #
4 4
 from devices.base import base
5
-from devices.base import BATTERY_WARN_LEVEL
6
-from devices.base import warning
7 5
 import json
8 6
 
9 7
 
@@ -53,27 +51,11 @@ class brennenstuhl_heatingvalve(base):
53 51
         super().__init__(mqtt_client, topic)
54 52
         self.mqtt_client.send(self.topic + '/' + self.TX_TOPIC, json.dumps({self.KEY_WINDOW_DETECTION: "ON",
55 53
                               self.KEY_CHILD_LOCK: "UNLOCK", self.KEY_VALVE_DETECTION: "ON", self.KEY_SYSTEM_MODE: "heat", self.KEY_PRESET: "manual"}))
56
-        #
57
-        self.add_callback(self.KEY_BATTERY, None, self.__warning__, True)
58
-        self.__battery_warning__ = False
59 54
 
60 55
     def __state_logging__(self, inst, key, data):
61 56
         if key in [self.KEY_HEATING_SETPOINT, self.KEY_CHILD_LOCK, self.KEY_WINDOW_DETECTION, self.KEY_VALVE_DETECTION]:
62 57
             self.logger.info("State change of '%s' to '%s'", key, repr(data))
63 58
 
64
-    #
65
-    # WARNING CALL
66
-    #
67
-    def __warning__(self, client, key, data):
68
-        if data <= BATTERY_WARN_LEVEL:
69
-            if not self.__battery_warning__:
70
-                self.__battery_warning__ = True
71
-                w = warning(self.topic, warning.TYPE_BATTERY_LOW, "Battery low (%.1f%%)", data)
72
-                self.logger.warning(w)
73
-                self.set(self.KEY_WARNING, w)
74
-        else:
75
-            self.__battery_warning__ = False
76
-
77 59
     #
78 60
     # RX
79 61
     #

+ 0
- 11
devices/shelly.py Bestand weergeven

@@ -2,7 +2,6 @@
2 2
 # -*- coding: utf-8 -*-
3 3
 #
4 4
 from devices.base import base
5
-from devices.base import warning
6 5
 import logging
7 6
 import task
8 7
 
@@ -69,8 +68,6 @@ class shelly(base):
69 68
         self.delayed_flash_task = task.delayed(0.3, self.flash_task)
70 69
         self.delayed_off_task = task.delayed(0.3, self.off_task)
71 70
         #
72
-        self.add_callback(self.KEY_OVERTEMPERATURE, True, self.__warning__, True)
73
-        #
74 71
         self.all_off_requested = False
75 72
 
76 73
     def __state_logging__(self, inst, key, data):
@@ -93,14 +90,6 @@ class shelly(base):
93 90
     def flash_active(self):
94 91
         return self.output_key_delayed is not None
95 92
 
96
-    #
97
-    # WARNING CALL
98
-    #
99
-    def __warning__(self, client, key, data):
100
-        w = warning(self.topic, warning.TYPE_OVERTEMPERATURE, "Temperature to high (%.1f°C)", self.get(self.KEY_TEMPERATURE) or math.nan)
101
-        self.logger.warning(w)
102
-        self.set(self.KEY_WARNING, w)
103
-
104 93
     #
105 94
     # RX
106 95
     #

+ 0
- 11
devices/silvercrest.py Bestand weergeven

@@ -2,7 +2,6 @@
2 2
 # -*- coding: utf-8 -*-
3 3
 #
4 4
 from devices.base import base
5
-from devices.base import warning
6 5
 import logging
7 6
 
8 7
 
@@ -89,21 +88,11 @@ class silvercrest_motion_sensor(base):
89 88
 
90 89
     def __init__(self, mqtt_client, topic):
91 90
         super().__init__(mqtt_client, topic)
92
-        #
93
-        self.add_callback(self.KEY_BATTERY_LOW, True, self.__warning__, True)
94 91
 
95 92
     def __state_logging__(self, inst, key, data):
96 93
         if key in [self.KEY_OCCUPANCY, self.KEY_UNMOUNTED]:
97 94
             self.logger.info("State change of '%s' to '%s'", key, repr(data))
98 95
 
99
-    #
100
-    # WARNING CALL
101
-    #
102
-    def __warning__(self, client, key, data):
103
-        w = warning(self.topic, warning.TYPE_BATTERY_LOW, "Battery low (%.1f%%)", self.get(self.KEY_BATTERY) or math.nan)
104
-        self.logger.warning(w)
105
-        self.set(self.KEY_WARNING, w)
106
-
107 96
     #
108 97
     # RX
109 98
     #

+ 0
- 17
devices/tradfri.py Bestand weergeven

@@ -2,8 +2,6 @@
2 2
 # -*- coding: utf-8 -*-
3 3
 #
4 4
 from devices.base import base
5
-from devices.base import BATTERY_WARN_LEVEL
6
-from devices.base import warning
7 5
 import logging
8 6
 
9 7
 
@@ -180,26 +178,11 @@ class tradfri_button(base):
180 178
 
181 179
     def __init__(self, mqtt_client, topic):
182 180
         super().__init__(mqtt_client, topic)
183
-        #
184
-        self.add_callback(self.KEY_BATTERY, None, self.__warning__, True)
185
-        self.__battery_warning__ = False
186 181
 
187 182
     def __state_logging__(self, inst, key, data):
188 183
         if key in [self.KEY_ACTION]:
189 184
             self.logger.info("Input '%s' with '%s'", key, repr(data))
190 185
 
191
-    #
192
-    # WARNING CALL
193
-    #
194
-    def __warning__(self, client, key, data):
195
-        if data <= BATTERY_WARN_LEVEL:
196
-            if not self.__battery_warning__:
197
-                w = warning(self.topic, warning.TYPE_BATTERY_LOW, "Battery low (%.1f%%)", data)
198
-                self.logger.warning(w)
199
-                self.set(self.KEY_WARNING, w)
200
-        else:
201
-            self.__battery_warning__ = False
202
-
203 186
     #
204 187
     # RX
205 188
     #

Laden…
Annuleren
Opslaan