1 """Proxy to handle account communication with Renault servers."""
3 from __future__
import annotations
6 from collections.abc
import Awaitable, Callable
7 from datetime
import timedelta
9 from typing
import TypeVar
11 from renault_api.kamereon.exceptions
import (
12 AccessDeniedException,
13 KamereonResponseException,
14 NotSupportedException,
16 from renault_api.kamereon.models
import KamereonVehicleDataAttributes
21 T = TypeVar(
"T", bound=KamereonVehicleDataAttributes |
None)
24 _PARALLEL_SEMAPHORE = asyncio.Semaphore(1)
28 """Handle vehicle communication with Renault servers."""
33 logger: logging.Logger,
36 update_interval: timedelta,
37 update_method: Callable[[], Awaitable[T]],
39 """Initialise coordinator."""
44 update_interval=update_interval,
45 update_method=update_method,
52 """Fetch the latest data from the source."""
54 raise NotImplementedError(
"Update method not implemented")
56 async
with _PARALLEL_SEMAPHORE:
59 except AccessDeniedException
as err:
65 raise UpdateFailed(f
"This endpoint is denied: {err}")
from err
67 except NotSupportedException
as err:
71 raise UpdateFailed(f
"This endpoint is not supported: {err}")
from err
73 except KamereonResponseException
as err:
75 raise UpdateFailed(f
"Error communicating with API: {err}")
from err
81 """Refresh data for the first time when a config entry is setup.
83 Contrary to base implementation, we are not raising ConfigEntryNotReady
84 but only updating the `access_denied` and `not_supported` flags.
86 await self.
_async_refresh_async_refresh(log_failures=
False, raise_on_auth_failed=
True)
None async_config_entry_first_refresh(self)
T _async_update_data(self)
None __init__(self, HomeAssistant hass, logging.Logger logger, *str name, timedelta update_interval, Callable[[], Awaitable[T]] update_method)
None update_interval(self, timedelta|None value)
timedelta|None update_interval(self)
None _async_refresh(self, bool log_failures=True, bool raise_on_auth_failed=False, bool scheduled=False, bool raise_on_entry_error=False)