瀏覽代碼

warning improvements for nodered dashboard

tags/v1.1.1
Dirk Alders 1 年之前
父節點
當前提交
5212cba366
共有 3 個文件被更改,包括 7 次插入6 次删除
  1. 3
    3
      devices/__init__.py
  2. 3
    2
      function/videv.py
  3. 1
    1
      smart_brain.py

+ 3
- 3
devices/__init__.py 查看文件

@@ -39,7 +39,7 @@ try:
39 39
 except ImportError:
40 40
     ROOT_LOGGER_NAME = 'root'
41 41
 
42
-BATTERY_WARN_LEVEL = 5
42
+BATTERY_WARN_LEVEL = 10
43 43
 
44 44
 
45 45
 class warning(dict):
@@ -253,7 +253,7 @@ class shelly(base):
253 253
     # WARNING CALL
254 254
     #
255 255
     def __warning__(self, client, key, data):
256
-        w = warning(self.topic, warning.TYPE_OVERTEMPERATURE, "Temperature to high (%.1f°C)", self.get(self.KEY_TEMPERATURE, math.nan))
256
+        w = warning(self.topic, warning.TYPE_OVERTEMPERATURE, "Temperature to high (%.1f°C)", self.get(self.KEY_TEMPERATURE) or math.nan)
257 257
         self.logger.warning(w)
258 258
         self.set(self.KEY_WARNING, w)
259 259
 
@@ -407,7 +407,7 @@ class silvercrest_motion_sensor(base):
407 407
     # WARNING CALL
408 408
     #
409 409
     def __warning__(self, client, key, data):
410
-        w = warning(self.topic, warning.TYPE_BATTERY_LOW, "Battery low (%.1f%%)", self.get(self.KEY_BATTERY, math.nan))
410
+        w = warning(self.topic, warning.TYPE_BATTERY_LOW, "Battery low (%.1f%%)", self.get(self.KEY_BATTERY) or math.nan)
411 411
         self.logger.warning(w)
412 412
         self.set(self.KEY_WARNING, w)
413 413
 

+ 3
- 2
function/videv.py 查看文件

@@ -262,7 +262,7 @@ class videv_audio_player(base):
262 262
 
263 263
 class videv_warnings(base):
264 264
     MAX_WARNINGS = 10
265
-    KEY_WARNING = 'text'
265
+    KEY_WARNING = 'html_short'
266 266
 
267 267
     def __init__(self, mqtt_client, topic, default_values=None):
268 268
         super().__init__(mqtt_client, topic, default_values)
@@ -271,7 +271,8 @@ class videv_warnings(base):
271 271
     def warningcollector(self, client, key, data):
272 272
         self.__warnings__.append(data)
273 273
         self.__warnings__ = self.__warnings__[-self.MAX_WARNINGS:]
274
-        self.__tx__(self.KEY_WARNING, '\n'.join([str(w) for w in self.__warnings__]))
274
+        txt = "<br><br>".join([time.asctime(w[w.KEY_TM]) + "<br>" + w[w.KEY_TEXT] + "<br>" + w[w.KEY_ID] for w in self.__warnings__])
275
+        self.__tx__(self.KEY_WARNING, txt)
275 276
 
276 277
 
277 278
 class all_off(base):

+ 1
- 1
smart_brain.py 查看文件

@@ -43,7 +43,7 @@ if __name__ == "__main__":
43 43
     if config.DEBUG:
44 44
         report.appLoggingConfigure(None, None, ((config.APP_NAME, logging.DEBUG), ), fmt=report.SHORT_FMT, host='localhost', port=19996)
45 45
     else:
46
-        report.stdoutLoggingConfigure(((config.APP_NAME, logging.INFO), ), report.SHORT_FMT)
46
+        report.stdoutLoggingConfigure(((config.APP_NAME, logging.WARNING), ), report.SHORT_FMT)
47 47
     #
48 48
     mc = mqtt.mqtt_client(host=config.MQTT_SERVER, port=config.MQTT_PORT, username=config.MQTT_USER,
49 49
                           password=config.MQTT_PASSWORD, name=config.APP_NAME)

Loading…
取消
儲存