This commit is contained in:
2024-11-17 17:26:39 +01:00

View File

@@ -4,7 +4,7 @@
# #
#pylint: disable=line-too-long,broad-exception-caught,possibly-used-before-assignment #pylint: disable=line-too-long,broad-exception-caught,possibly-used-before-assignment
""" """
<plugin key="Heatzy_FJU" name="Heatzy Pilote" author="fjumelle" version="1.0.2" wikilink="" externallink=""> <plugin key="Heatzy_FJU" name="Heatzy Pilote" author="fjumelle" version="1.0.4" wikilink="" externallink="">
<description> <description>
<h2>Heatzy Pilote</h2><br/> <h2>Heatzy Pilote</h2><br/>
Implementation of Heatzy Pilote as a Domoticz Plugin.<br/> Implementation of Heatzy Pilote as a Domoticz Plugin.<br/>
@@ -41,6 +41,9 @@ if None is not None: #Fake statement to remove warning on global Domoticz variab
Images = Images # type: ignore #NOSONAR #pylint: disable=undefined-variable,self-assigning-variable Images = Images # type: ignore #NOSONAR #pylint: disable=undefined-variable,self-assigning-variable
Devices = Devices # type: ignore #NOSONAR #pylint: disable=undefined-variable,self-assigning-variable Devices = Devices # type: ignore #NOSONAR #pylint: disable=undefined-variable,self-assigning-variable
global Parameters
global Devices
HEATZY_MODE = { HEATZY_MODE = {
'停止': 'OFF', '停止': 'OFF',
'解冻': 'FROSTFREE', '解冻': 'FROSTFREE',
@@ -146,6 +149,10 @@ class BasePlugin:
Domoticz.Status("No connection to Heatzy API ==> Device disabled for 15 minutes") Domoticz.Status("No connection to Heatzy API ==> Device disabled for 15 minutes")
self.pooling_current_step = - 15 * 60 // self.pooling + self.pooling_steps self.pooling_current_step = - 15 * 60 // self.pooling + self.pooling_steps
self.retry = self.max_retry self.retry = self.max_retry
#Force refresh token/did
Domoticz.Status("Force refresh token and device id.")
self.token = ""
self.did = ""
return return
self.mode = self.get_mode() self.mode = self.get_mode()
@@ -273,6 +280,7 @@ class BasePlugin:
headers = { headers = {
'Accept': 'application/json', 'Accept': 'application/json',
'X-Gizwits-User-token': self.token,
'X-Gizwits-Application-Id': 'c70a66ff039d41b4a220e198b0fcc8b3', 'X-Gizwits-Application-Id': 'c70a66ff039d41b4a220e198b0fcc8b3',
} }
url = f"https://euapi.gizwits.com/app/devdata/{self.did}/latest" url = f"https://euapi.gizwits.com/app/devdata/{self.did}/latest"
@@ -324,6 +332,10 @@ class BasePlugin:
#Invalid token #Invalid token
self.token = "" self.token = ""
self.did = "" self.did = ""
elif 'attr' in response and len(response["attr"]) == 0:
#attr is empty...
Domoticz.Status("We force a setMode to try to get the correct mode at the next try...")
self.setMode(HEATZY_MODE_VALUE['FROSTFREE'])
return "" return ""
return mode return mode