Skip to content

Commit

Permalink
Improve error handling in coordinator (during BadCredentials error) (#…
Browse files Browse the repository at this point in the history
…524)

* Improve error handling in coordinator (during BadCredentials)

* Catch TooManyRequestsException
  • Loading branch information
iMicknl authored Aug 12, 2021
1 parent f832afe commit 42ae0d8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions custom_components/tahoma/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,16 @@ async def _async_update_data(self) -> Dict[str, Device]:
raise UpdateFailed("Failed to connect.") from exception
except (ServerDisconnectedError, NotAuthenticatedException):
self.executions = {}
await self.client.login()
self.devices = await self._get_devices()

# During the relogin, similar exceptions can be thrown.
try:
await self.client.login()
self.devices = await self._get_devices()
except BadCredentialsException as exception:
raise ConfigEntryAuthFailed() from exception
except TooManyRequestsException as exception:
raise UpdateFailed("Too many requests, try again later.") from exception

return self.devices
except Exception as exception:
_LOGGER.debug(exception)
Expand Down

0 comments on commit 42ae0d8

Please sign in to comment.