mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Fix AccessDeniedException handling in Renault (#104574)
This commit is contained in:
parent
95c771e330
commit
5ba70ef2cb
@ -45,6 +45,7 @@ class RenaultDataUpdateCoordinator(DataUpdateCoordinator[T]):
|
|||||||
)
|
)
|
||||||
self.access_denied = False
|
self.access_denied = False
|
||||||
self.not_supported = False
|
self.not_supported = False
|
||||||
|
self._has_already_worked = False
|
||||||
|
|
||||||
async def _async_update_data(self) -> T:
|
async def _async_update_data(self) -> T:
|
||||||
"""Fetch the latest data from the source."""
|
"""Fetch the latest data from the source."""
|
||||||
@ -52,9 +53,14 @@ class RenaultDataUpdateCoordinator(DataUpdateCoordinator[T]):
|
|||||||
raise NotImplementedError("Update method not implemented")
|
raise NotImplementedError("Update method not implemented")
|
||||||
try:
|
try:
|
||||||
async with _PARALLEL_SEMAPHORE:
|
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:
|
except AccessDeniedException as err:
|
||||||
# Disable because the account is not allowed to access this Renault endpoint.
|
# 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.update_interval = None
|
||||||
self.access_denied = True
|
self.access_denied = True
|
||||||
raise UpdateFailed(f"This endpoint is denied: {err}") from err
|
raise UpdateFailed(f"This endpoint is denied: {err}") from err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user