Skip to content

Commit

Permalink
Different fix for #65, really just a workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
jimboca committed Dec 31, 2020
1 parent 1fac124 commit 74e296e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ __IMPORTANT__ Starting with version 2.2.0 users should to re-authorize
- Polyglot Cloud: Restart
- After restarting you may get a message in the Polyglot UI saying that the token is invalid, but has not some number of seconds remaining, so you will need to let it expire then you will be asked to re-authorize

- 2.2.2: JimBo 12/31/2020
- Different workaround for [Crash getting date/time](https://github.com/Einstein42/udi-ecobee-poly/issues/65)
- This is only an issue on Polyglot Cloud
- 2.2.1: JimBo 12/27/2020
- Another fix for [Add support for dryContact sensors](https://github.com/Einstein42/udi-ecobee-poly/issues/24)
- 2.2.0: JimBo 12/22/2020
Expand Down
27 changes: 15 additions & 12 deletions nodes/Controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def _getOAuth(self):
else:
#LOGGER.error(self.poly.init)
url = 'https://{}/authorize?response_type=code&client_id={}&redirect_uri={}&state={}'.format(ECOBEE_API_URL,self.api_key,self.redirect_url,self.poly.init['worker'])
msg = 'No existing Authorization found, Please <a target="_blank" href="{}">Authorize acess to your Ecobee Account</a>'.format(url)
msg = 'No existing Authorization found, Please <a target="_blank" href="{}">Authorize access to your Ecobee Account</a>'.format(url)
self.addNotice({'oauth': msg})
LOGGER.warning(msg)
self.waiting_on_tokens = "OAuth"
Expand Down Expand Up @@ -337,17 +337,20 @@ def _startRefresh(self,test=False):
LOGGER.error("Someone changed the db?")
LOGGER.error("{}= {}".format(self._data_tag,self.polyConfig['customData'][self._data_tag]))
LOGGER.error("_last_dtns={}".format(self._last_dtns))
l_dt = datetime.fromtimestamp(int(self._last_dtns)).strftime(self._lock_fmt)
c_dt = datetime.fromtimestamp(int(self.polyConfig['customData'][self._data_tag])).strftime(self._lock_fmt)
if c_dt < l_dt:
LOGGER.error("But it is older than what we wrote, so will ignore it...")
else:
LOGGER.error("And it's newer than what we wrote so will use it?")
LOGGER.error(" Mine: {}".format(self.tokenData))
LOGGER.error(" Current: {}".format(self.polyConfig['customData']['tokenData']))
LOGGER.error("We will use the new tokens...")
self.tokenData = deepcopy(self.polyConfig['customData']['tokenData'])
return False
try:
l_dt = datetime.fromtimestamp(self._last_dtns).strftime(self._lock_fmt)
c_dt = datetime.fromtimestamp(self.polyConfig['customData'][self._data_tag]).strftime(self._lock_fmt)
if c_dt < l_dt:
LOGGER.error("But it is older than what we wrote, so will ignore it...")
else:
LOGGER.error("And it's newer than what we wrote so will use it?")
LOGGER.error(" Mine: {}".format(self.tokenData))
LOGGER.error(" Current: {}".format(self.polyConfig['customData']['tokenData']))
LOGGER.error("We will use the new tokens...")
self.tokenData = deepcopy(self.polyConfig['customData']['tokenData'])
return False
except:
LOGGER.error("Failed determing age of last db write by someone else, will ignore it.",exc_info=True)
rval = self.lockCustomData()
if (rval):
self.refreshingTokens = True
Expand Down
2 changes: 1 addition & 1 deletion server.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{
"title": "ecobee: Polyglot NodeServer for Ecobee",
"author": "James Milne (Einstein.42)",
"version": "2.2.1",
"version": "2.2.2",
"date": "July 25, 2018",
"source": "https://github.com/Einstein42/udi-ecobee-poly",
"license": "https://github.com/Einstein42/udi-ecobee-poly/master/LICENSE"
Expand Down

0 comments on commit 74e296e

Please sign in to comment.