Add token in header of 'getmode' API
This commit is contained in:
14
plugin.py
14
plugin.py
@@ -3,7 +3,7 @@
|
||||
# Author: fjumelle
|
||||
#
|
||||
"""
|
||||
<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>
|
||||
<h2>Heatzy Pilote</h2><br/>
|
||||
Implementation of Heatzy Pilote as a Domoticz Plugin.<br/>
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user