From edd0a84c00487609903f13a32271d0414ab7875d Mon Sep 17 00:00:00 2001 From: Wolfgang Malgadey Date: Sun, 1 Jan 2017 01:56:34 +0100 Subject: [PATCH] wrong unit of token expires_in value --- PyTado/interface.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PyTado/interface.py b/PyTado/interface.py index 1b305a4..a93fe1f 100644 --- a/PyTado/interface.py +++ b/PyTado/interface.py @@ -4,6 +4,7 @@ import json, datetime + class Tado: """Interacts with a Tado thermostat via public API. Example usage: t = Tado('me@somewhere.com', 'mypasswd') @@ -16,6 +17,7 @@ class Tado: refresh_token = '' refresh_at = datetime.datetime.now() + datetime.timedelta(minutes=5) + # 'Private' methods for use in class, Tado mobile API V1.9. def _mobile_apiCall(self, cmd): self._refreshToken() @@ -45,7 +47,7 @@ def _setOAuthHeader(self, data): self.refresh_token = refresh_token self.refresh_at = datetime.datetime.now() - self.refresh_at = self.refresh_at + datetime.timedelta(minutes = expires_in) + self.refresh_at = self.refresh_at + datetime.timedelta(seconds = expires_in) self.headers['Authorization'] = 'Bearer ' + access_token @@ -66,8 +68,6 @@ def _refreshToken(self): response = self.opener.open(req) str_response = response.read().decode('utf-8') - print(str_response) - self._setOAuthHeader(json.loads(str_response)) return response