Skip to content

Commit

Permalink
corrected timestamp comparison for sessionid
Browse files Browse the repository at this point in the history
  • Loading branch information
IngoS11 committed Jul 3, 2022
1 parent 04825fa commit 3918248
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion custom_components/schluter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,18 @@ async def _async_update_data(self) -> dict[str, Any]:
self._sessionid = await self._api.async_get_sessionid(
self._username, self._password
)
# add 1 day to the session timestamp to be able to check agains
# the current time. if the time is expired renew the sessionid.
# This workaround mediates the missing long lived tokens on
# ths Schluter API side.
expiration_timestamp = self._api.sessionid_timestamp + timedelta(
days=+1
)
_LOGGER.debug(
"Sessionid expiration timestamp is: %s",
expiration_timestamp.strftime("%Y-%m-%d %H:%M:%S"),
)
if expiration_timestamp >= datetime.now():
if expiration_timestamp <= datetime.now():
_LOGGER.info("Schluter Sessionid is expired, authenticating again")
self._sessionid = await self._api.async_get_sessionid(
self._username, self._password
Expand Down

0 comments on commit 3918248

Please sign in to comment.