From 8bb1cf0f11fb94c36e3340ea8bde53d0cb4dfcee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Leborne?= Date: Wed, 20 Nov 2024 15:21:58 +0100 Subject: [PATCH] Improve _last_update property --- pyluos/device.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pyluos/device.py b/pyluos/device.py index 1dc6c0c..5ca4467 100644 --- a/pyluos/device.py +++ b/pyluos/device.py @@ -111,7 +111,7 @@ def __init__(self, host, self._setup() self.logger.info('Device setup.') - self._last_update = time.time() + self._last_update = 0.0 self._running = True self._pause = False @@ -220,6 +220,10 @@ def services(self): def nodes(self): return nodeList(self._nodes) + @property + def last_update(self) -> float: + """The last_update property.""" + return self._last_update # Poll state from hardware. def _poll_once(self): @@ -299,7 +303,7 @@ def _update(self, new_state): if (self._freedomLink != None): self._freedomLink._update(alias, mod) - self._last_update = time.time() + self._last_update = float(new_state["timestamp"]) def update_cmd(self, alias, key, val): with self._cmd_lock: