From 95debb7ea39aafe01b7cfae4275a0c42a73c3e58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20JUMELLE?= Date: Tue, 10 Dec 2024 12:47:00 +0100 Subject: [PATCH] Manage TimedOut device (>3h) --- plugin.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/plugin.py b/plugin.py index edf6e6b..7f219d5 100755 --- a/plugin.py +++ b/plugin.py @@ -168,6 +168,7 @@ class BasePlugin: self.pooling_current_step = 1 else: + # Devices["9420ae048da545c88fc6274d204dd25f"].Refresh() self.pooling_current_step = self.pooling_current_step + 1 def get_token(self, user, password): @@ -256,7 +257,7 @@ class BasePlugin: product_key = device['product_key'] alias = device['dev_alias'] did = device['did'] - self.did[product_key] = {"did":did, "alias":alias, "last_update":0} + self.did[product_key] = {"did":did, "alias":alias} Domoticz.Status(f"Devide Id from Heatzy API: {alias} - {did}") unit = unit + 1 @@ -303,13 +304,14 @@ class BasePlugin: #Last Update if 'updated_at' in response: - if device["last_update"] != response['updated_at']: - device["last_update"] = response['updated_at'] - else: - obsolete_min = int((time.time() - device["last_update"])//60) - if obsolete_min >= 30 and obsolete_min%60 == 0: #more than 30 min and every hour - Domoticz.Error(f"Heatzy Mode obsolete! {obsolete_min} min") - return "" + obsolete_min = int((time.time() - response["updated_at"])//60) + if obsolete_min >= 180 and Devices[deviceid].TimedOut == 0: + Domoticz.Status(f"Last update from '{alias}' was {obsolete_min} min earlier: {response}") + Devices[deviceid].TimedOut = 1 + return + elif Devices[deviceid].TimedOut == 1: + Domoticz.Status(f"'{alias}' is now back.") + Devices[deviceid].TimedOut = 0 if 'attr' in response and 'mode' in response['attr']: mode = HEATZY_MODE[response['attr']['mode']] @@ -354,7 +356,7 @@ class BasePlugin: #attr is empty... Domoticz.Status("We force a setMode to try to get the correct mode at the next try...") self.set_mode(deviceid, HEATZY_MODE_VALUE['FROSTFREE']) - return "" + return # If mode = OFF and bug, then mode = FROSTFREE if self.bug and mode == 'OFF':