Skip to content

Commit

Permalink
Fix AccessDeniedException handling in Renault (home-assistant#104574)
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet authored Nov 27, 2023
1 parent 95c771e commit 5ba70ef
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions homeassistant/components/renault/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,24 @@ def __init__(
)
self.access_denied = False
self.not_supported = False
self._has_already_worked = False

async def _async_update_data(self) -> T:
"""Fetch the latest data from the source."""
if self.update_method is None:
raise NotImplementedError("Update method not implemented")
try:
async with _PARALLEL_SEMAPHORE:
return await self.update_method()
data = await self.update_method()
self._has_already_worked = True
return data

except AccessDeniedException as err:
# Disable because the account is not allowed to access this Renault endpoint.
self.update_interval = None
self.access_denied = True
# This can mean both a temporary error or a permanent error. If it has
# worked before, make it temporary, if not disable the update interval.
if not self._has_already_worked:
self.update_interval = None
self.access_denied = True
raise UpdateFailed(f"This endpoint is denied: {err}") from err

except NotSupportedException as err:
Expand Down

0 comments on commit 5ba70ef

Please sign in to comment.