Browse Source

warning improvements for nodered dashboard

tags/v1.1.1
Dirk Alders 1 year ago
parent
commit
5212cba366
3 changed files with 7 additions and 6 deletions
  1. 3
    3
      devices/__init__.py
  2. 3
    2
      function/videv.py
  3. 1
    1
      smart_brain.py

+ 3
- 3
devices/__init__.py View File

39
 except ImportError:
39
 except ImportError:
40
     ROOT_LOGGER_NAME = 'root'
40
     ROOT_LOGGER_NAME = 'root'
41
 
41
 
42
-BATTERY_WARN_LEVEL = 5
42
+BATTERY_WARN_LEVEL = 10
43
 
43
 
44
 
44
 
45
 class warning(dict):
45
 class warning(dict):
253
     # WARNING CALL
253
     # WARNING CALL
254
     #
254
     #
255
     def __warning__(self, client, key, data):
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
         self.logger.warning(w)
257
         self.logger.warning(w)
258
         self.set(self.KEY_WARNING, w)
258
         self.set(self.KEY_WARNING, w)
259
 
259
 
407
     # WARNING CALL
407
     # WARNING CALL
408
     #
408
     #
409
     def __warning__(self, client, key, data):
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
         self.logger.warning(w)
411
         self.logger.warning(w)
412
         self.set(self.KEY_WARNING, w)
412
         self.set(self.KEY_WARNING, w)
413
 
413
 

+ 3
- 2
function/videv.py View File

262
 
262
 
263
 class videv_warnings(base):
263
 class videv_warnings(base):
264
     MAX_WARNINGS = 10
264
     MAX_WARNINGS = 10
265
-    KEY_WARNING = 'text'
265
+    KEY_WARNING = 'html_short'
266
 
266
 
267
     def __init__(self, mqtt_client, topic, default_values=None):
267
     def __init__(self, mqtt_client, topic, default_values=None):
268
         super().__init__(mqtt_client, topic, default_values)
268
         super().__init__(mqtt_client, topic, default_values)
271
     def warningcollector(self, client, key, data):
271
     def warningcollector(self, client, key, data):
272
         self.__warnings__.append(data)
272
         self.__warnings__.append(data)
273
         self.__warnings__ = self.__warnings__[-self.MAX_WARNINGS:]
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
 class all_off(base):
278
 class all_off(base):

+ 1
- 1
smart_brain.py View File

43
     if config.DEBUG:
43
     if config.DEBUG:
44
         report.appLoggingConfigure(None, None, ((config.APP_NAME, logging.DEBUG), ), fmt=report.SHORT_FMT, host='localhost', port=19996)
44
         report.appLoggingConfigure(None, None, ((config.APP_NAME, logging.DEBUG), ), fmt=report.SHORT_FMT, host='localhost', port=19996)
45
     else:
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
     mc = mqtt.mqtt_client(host=config.MQTT_SERVER, port=config.MQTT_PORT, username=config.MQTT_USER,
48
     mc = mqtt.mqtt_client(host=config.MQTT_SERVER, port=config.MQTT_PORT, username=config.MQTT_USER,
49
                           password=config.MQTT_PASSWORD, name=config.APP_NAME)
49
                           password=config.MQTT_PASSWORD, name=config.APP_NAME)

Loading…
Cancel
Save