Obsolete device when > 30min
This commit is contained in:
15
plugin.py
15
plugin.py
@@ -84,6 +84,7 @@ class BasePlugin:
|
|||||||
pooling_current_step = 1
|
pooling_current_step = 1
|
||||||
max_retry = 6
|
max_retry = 6
|
||||||
retry = max_retry
|
retry = max_retry
|
||||||
|
last_update = 0
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
return
|
return
|
||||||
@@ -301,6 +302,20 @@ class BasePlugin:
|
|||||||
|
|
||||||
Domoticz.Debug("Get Mode Response:" + str(response))
|
Domoticz.Debug("Get Mode Response:" + str(response))
|
||||||
|
|
||||||
|
#Last Update
|
||||||
|
if 'updated_at' in response:
|
||||||
|
if self.last_update != response['updated_at']:
|
||||||
|
self.last_update = response['updated_at']
|
||||||
|
|
||||||
|
if time.time() > self.last_update + 60*30: #30 minutes
|
||||||
|
Domoticz.Status(f"Heatzy Mode obsolete! {(time.time() - self.last_update)//60} min")
|
||||||
|
Devices[1].Update(nValue=Devices[1].nValue, sValue=Devices[1].sValue, TimedOut = 1)
|
||||||
|
Devices[2].Update(nValue=Devices[2].nValue, sValue=Devices[2].sValue, TimedOut = 1)
|
||||||
|
else:
|
||||||
|
Domoticz.Status("Heatzy is back!")
|
||||||
|
Devices[1].Update(nValue=Devices[1].nValue, sValue=Devices[1].sValue, TimedOut = 0)
|
||||||
|
Devices[2].Update(nValue=Devices[2].nValue, sValue=Devices[2].sValue, 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']]
|
||||||
Domoticz.Debug(f"Current Heatzy Mode: {HEATZY_MODE_NAME[mode]}")
|
Domoticz.Debug(f"Current Heatzy Mode: {HEATZY_MODE_NAME[mode]}")
|
||||||
|
|||||||
Reference in New Issue
Block a user