Manage TimedOut device (>3h)

This commit is contained in:
2024-12-10 12:47:00 +01:00
parent 07240a1693
commit 95debb7ea3

View File

@@ -168,6 +168,7 @@ class BasePlugin:
self.pooling_current_step = 1 self.pooling_current_step = 1
else: else:
# Devices["9420ae048da545c88fc6274d204dd25f"].Refresh()
self.pooling_current_step = self.pooling_current_step + 1 self.pooling_current_step = self.pooling_current_step + 1
def get_token(self, user, password): def get_token(self, user, password):
@@ -256,7 +257,7 @@ class BasePlugin:
product_key = device['product_key'] product_key = device['product_key']
alias = device['dev_alias'] alias = device['dev_alias']
did = device['did'] 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}") Domoticz.Status(f"Devide Id from Heatzy API: {alias} - {did}")
unit = unit + 1 unit = unit + 1
@@ -303,13 +304,14 @@ class BasePlugin:
#Last Update #Last Update
if 'updated_at' in response: if 'updated_at' in response:
if device["last_update"] != response['updated_at']: obsolete_min = int((time.time() - response["updated_at"])//60)
device["last_update"] = response['updated_at'] if obsolete_min >= 180 and Devices[deviceid].TimedOut == 0:
else: Domoticz.Status(f"Last update from '{alias}' was {obsolete_min} min earlier: {response}")
obsolete_min = int((time.time() - device["last_update"])//60) Devices[deviceid].TimedOut = 1
if obsolete_min >= 30 and obsolete_min%60 == 0: #more than 30 min and every hour return
Domoticz.Error(f"Heatzy Mode obsolete! {obsolete_min} min") elif Devices[deviceid].TimedOut == 1:
return "" Domoticz.Status(f"'{alias}' is now back.")
Devices[deviceid].TimedOut = 0
if 'attr' in response and 'mode' in response['attr']: if 'attr' in response and 'mode' in response['attr']:
mode = HEATZY_MODE[response['attr']['mode']] mode = HEATZY_MODE[response['attr']['mode']]
@@ -354,7 +356,7 @@ class BasePlugin:
#attr is empty... #attr is empty...
Domoticz.Status("We force a setMode to try to get the correct mode at the next try...") 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']) self.set_mode(deviceid, HEATZY_MODE_VALUE['FROSTFREE'])
return "" return
# If mode = OFF and bug, then mode = FROSTFREE # If mode = OFF and bug, then mode = FROSTFREE
if self.bug and mode == 'OFF': if self.bug and mode == 'OFF':