diff --git a/plugin.py b/plugin.py index 1318fe3..2649c1b 100755 --- a/plugin.py +++ b/plugin.py @@ -3,7 +3,7 @@ # Author: fjumelle # """ - +

Heatzy Pilote


Implementation of Heatzy Pilote as a Domoticz Plugin.
@@ -35,6 +35,9 @@ import urllib.parse as parse import urllib.request as request from datetime import datetime, timedelta +global Parameters +global Devices + HEATZY_MODE = { '停止': 'OFF', '解冻': 'FROSTFREE', @@ -148,6 +151,10 @@ class BasePlugin: Domoticz.Status("No connection to Heatzy API ==> Device disabled for 15 minutes") self.pooling_current_step = - 15 * 60 // self.pooling + self.pooling_steps self.retry = self.max_retry + #Force refresh token/did + Domoticz.Status("Force refresh token and device id.") + self.token = "" + self.did = "" return self.mode = self.getMode() @@ -268,6 +275,7 @@ class BasePlugin: headers = { 'Accept': 'application/json', + 'X-Gizwits-User-token': self.token, 'X-Gizwits-Application-Id': 'c70a66ff039d41b4a220e198b0fcc8b3', } url = 'https://euapi.gizwits.com/app/devdata/{}/latest'.format(self.did) @@ -319,6 +327,10 @@ class BasePlugin: #Invalid token self.token = "" 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 mode