1 """The AccuWeather coordinator."""
3 from __future__
import annotations
5 from asyncio
import timeout
6 from dataclasses
import dataclass
7 from datetime
import timedelta
9 from typing
import TYPE_CHECKING, Any
11 from accuweather
import AccuWeather, ApiError, InvalidApiKeyError, RequestsExceededError
12 from aiohttp.client_exceptions
import ClientConnectorError
18 DataUpdateCoordinator,
19 TimestampDataUpdateCoordinator,
23 from .const
import DOMAIN, MANUFACTURER
25 EXCEPTIONS = (ApiError, ClientConnectorError, InvalidApiKeyError, RequestsExceededError)
27 _LOGGER = logging.getLogger(__name__)
32 """Data for AccuWeather integration."""
34 coordinator_observation: AccuWeatherObservationDataUpdateCoordinator
35 coordinator_daily_forecast: AccuWeatherDailyForecastDataUpdateCoordinator
38 type AccuWeatherConfigEntry = ConfigEntry[AccuWeatherData]
42 DataUpdateCoordinator[dict[str, Any]]
44 """Class to manage fetching AccuWeather data API."""
49 config_entry: AccuWeatherConfigEntry,
50 accuweather: AccuWeather,
52 coordinator_type: str,
53 update_interval: timedelta,
67 config_entry=config_entry,
68 name=f
"{name} ({coordinator_type})",
69 update_interval=update_interval,
73 """Update data via library."""
75 async
with timeout(10):
76 result = await self.
accuweatheraccuweather.async_get_current_conditions()
77 except EXCEPTIONS
as error:
80 _LOGGER.debug(
"Requests remaining: %d", self.
accuweatheraccuweather.requests_remaining)
86 TimestampDataUpdateCoordinator[list[dict[str, Any]]]
88 """Class to manage fetching AccuWeather data API."""
93 config_entry: AccuWeatherConfigEntry,
94 accuweather: AccuWeather,
96 coordinator_type: str,
97 update_interval: timedelta,
111 config_entry=config_entry,
112 name=f
"{name} ({coordinator_type})",
113 update_interval=update_interval,
117 """Update data via library."""
119 async
with timeout(10):
120 result = await self.
accuweatheraccuweather.async_get_daily_forecast()
121 except EXCEPTIONS
as error:
124 _LOGGER.debug(
"Requests remaining: %d", self.
accuweatheraccuweather.requests_remaining)
130 """Get device info."""
132 entry_type=DeviceEntryType.SERVICE,
133 identifiers={(DOMAIN, location_key)},
134 manufacturer=MANUFACTURER,
140 "http://accuweather.com/en/"
141 f
"_/_/{location_key}/weather-forecast/{location_key}/"
list[dict[str, Any]] _async_update_data(self)
None __init__(self, HomeAssistant hass, AccuWeatherConfigEntry config_entry, AccuWeather accuweather, str name, str coordinator_type, timedelta update_interval)
dict[str, Any] _async_update_data(self)
None __init__(self, HomeAssistant hass, AccuWeatherConfigEntry config_entry, AccuWeather accuweather, str name, str coordinator_type, timedelta update_interval)
DeviceInfo _get_device_info(str location_key, str name)