1 """Provides the Geocaching DataUpdateCoordinator."""
3 from __future__
import annotations
5 from geocachingapi.exceptions
import GeocachingApiError
6 from geocachingapi.geocachingapi
import GeocachingApi
7 from geocachingapi.models
import GeocachingStatus
15 from .const
import DOMAIN, ENVIRONMENT, LOGGER, UPDATE_INTERVAL
19 """Class to manage fetching Geocaching data from single endpoint."""
22 self, hass: HomeAssistant, *, entry: ConfigEntry, session: OAuth2Session
24 """Initialize global Geocaching data updater."""
28 async
def async_token_refresh() -> str:
29 await session.async_ensure_token_valid()
30 token = session.token[
"access_token"]
31 LOGGER.debug(
str(token))
36 environment=ENVIRONMENT,
37 token=session.token[
"access_token"],
38 session=client_session,
39 token_refresh_method=async_token_refresh,
42 super().
__init__(hass, LOGGER, name=DOMAIN, update_interval=UPDATE_INTERVAL)
47 except GeocachingApiError
as error:
48 raise UpdateFailed(f
"Invalid response from API: {error}")
from error
GeocachingStatus _async_update_data(self)
None __init__(self, HomeAssistant hass, *ConfigEntry entry, OAuth2Session session)
IssData update(pyiss.ISS iss)
aiohttp.ClientSession async_get_clientsession(HomeAssistant hass, bool verify_ssl=True, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT)