Browse Source

Zigbee heating valve check improved

master
Dirk Alders 1 year ago
parent
commit
c913350d5f
1 changed files with 5 additions and 3 deletions
  1. 5
    3
      z_server/devices/__init__.py

+ 5
- 3
z_server/devices/__init__.py View File

@@ -34,15 +34,17 @@ class base(object):
34 34
         logger.debug("Target value for device identified: %s: %s", key, repr(value))
35 35
 
36 36
     def state(self, key, value):
37
-        self.__state_storage__[key] = value
37
+        self.__state_storage__[key] = time.time(), value
38 38
         logger.debug("Device state identified: %s: %s", key, repr(value))
39 39
 
40 40
     def status(self, key):
41
+        tm_s, value_s = self.__state_storage__.get(key, (0, None))
41 42
         try:
42 43
             tm_t, value_t = self.__target_storage__[key]
43
-            value_s = self.__state_storage__.get(key)
44 44
         except KeyError:
45
-            return {"status": nagios.Nagios.UNKNOWN, "msg": "Device exists, but no setpoint change or unknown monitoring"}
45
+            if value_s is not None:
46
+                return {"status": nagios.Nagios.WARNING, "msg": "Current temperature setpoint %.1f°C (age=%.1fs), but never received a setpoint" % (value_s, time.time()-tm_s)}
47
+            return {"status": nagios.Nagios.UNKNOWN, "msg": "Device exists, but no data received or unknown monitoring"}
46 48
         else:
47 49
             tm = time.time()
48 50
             dt = tm - tm_t

Loading…
Cancel
Save