Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Commit

Permalink
Fix refreshing of data
Browse files Browse the repository at this point in the history
  • Loading branch information
peternijssen committed Oct 30, 2021
1 parent 879187c commit fd9621c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "spiderpy"
version = "1.7.0"
version = "1.7.1"
description = "Python wrapper for the Spider API, a way to manage your Spider installation"
authors = ["Peter Nijssen <peter@peternijssen.nl>"]
license = "MIT"
Expand Down
11 changes: 5 additions & 6 deletions spiderpy/spiderapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,18 @@ def __init__(
self._password = password
self._thermostats: Dict[Any, Any] = {}
self._power_plugs: Dict[Any, Any] = {}
self._last_refresh = 0
self._access_token = ""
self._refresh_token = ""
self._last_refresh: int = 0
self._access_token: str = ""
self._refresh_token: str = ""
self._token_expires_at = datetime.now() - timedelta(days=1)
self._token_expires_in = None
self._refresh_rate = refresh_rate
self._refresh_rate: int = refresh_rate

def update(self) -> None:
""" Update the cache """
current_time = int(time.time())
last_refresh = 0 if self._last_refresh is None else self._last_refresh

if current_time >= (last_refresh + self._refresh_rate):
if current_time >= (self._last_refresh + self._refresh_rate):
self.update_thermostats()
self.update_power_plugs()

Expand Down

0 comments on commit fd9621c

Please sign in to comment.