1 """DataUpdateCoordinator for WeatherKit integration."""
3 from __future__
import annotations
5 from datetime
import timedelta
7 from apple_weatherkit
import DataSetType
8 from apple_weatherkit.client
import WeatherKitApiClient, WeatherKitApiClientError
15 from .const
import DOMAIN, LOGGER
17 REQUESTED_DATA_SETS = [
18 DataSetType.CURRENT_WEATHER,
19 DataSetType.DAILY_FORECAST,
20 DataSetType.HOURLY_FORECAST,
25 """Class to manage fetching data from the API."""
27 config_entry: ConfigEntry
28 supported_data_sets: list[DataSetType] |
None =
None
33 client: WeatherKitApiClient,
45 """Obtain the supported data sets for this location and store them."""
46 supported_data_sets = await self.
clientclient.get_availability(
53 for data_set
in REQUESTED_DATA_SETS
54 if data_set
in supported_data_sets
60 """Update the current weather and forecasts."""
65 return await self.
clientclient.get_weather_data(
70 except WeatherKitApiClientError
as exception:
def update_supported_data_sets(self)
None __init__(self, HomeAssistant hass, WeatherKitApiClient client)
def _async_update_data(self)