1 """Data update coordinator for the Sonarr integration."""
3 from __future__
import annotations
5 from datetime
import timedelta
6 from typing
import TypeVar, cast
18 from aiopyarr.models.host_configuration
import PyArrHostConfiguration
19 from aiopyarr.sonarr_client
import SonarrClient
27 from .const
import CONF_UPCOMING_DAYS, CONF_WANTED_MAX_ITEMS, DOMAIN, LOGGER
29 SonarrDataT = TypeVar(
44 """Data update coordinator for the Sonarr integration."""
46 config_entry: ConfigEntry
51 host_configuration: PyArrHostConfiguration,
52 api_client: SonarrClient,
54 """Initialize the coordinator."""
63 self.system_version: str |
None =
None
66 """Get the latest data from Sonarr."""
70 except exceptions.ArrConnectionException
as ex:
72 except exceptions.ArrAuthenticationException
as ex:
74 "API Key is no longer valid. Please reauthenticate"
78 """Fetch the actual data."""
79 raise NotImplementedError
83 """Calendar update coordinator."""
86 """Fetch the movies data."""
87 local = dt_util.start_of_local_day().replace(microsecond=0)
88 start = dt_util.as_utc(local)
92 await self.
api_clientapi_client.async_get_calendar(
93 start_date=start, end_date=end, include_series=
True
99 """Commands update coordinator for Sonarr."""
102 """Fetch the data."""
103 return cast(list[Command], await self.
api_clientapi_client.async_get_commands())
107 """Disk space update coordinator for Sonarr."""
110 """Fetch the data."""
111 return await self.
api_clientapi_client.async_get_diskspace()
115 """Queue update coordinator."""
118 """Fetch the data."""
119 return await self.
api_clientapi_client.async_get_queue(
120 include_series=
True, include_episode=
True
125 """Series update coordinator."""
128 """Fetch the data."""
129 return cast(list[SonarrSeries], await self.
api_clientapi_client.async_get_series())
133 """Status update coordinator for Sonarr."""
136 """Fetch the data."""
137 return await self.
api_clientapi_client.async_get_system_status()
141 """Wanted update coordinator."""
144 """Fetch the data."""
145 return await self.
api_clientapi_client.async_get_wanted(
146 page_size=self.
config_entryconfig_entry.options[CONF_WANTED_MAX_ITEMS],
list[SonarrCalendar] _fetch_data(self)
list[Command] _fetch_data(self)
list[Diskspace] _fetch_data(self)
SonarrQueue _fetch_data(self)
list[SonarrSeries] _fetch_data(self)
SonarrDataT _async_update_data(self)
SonarrDataT _fetch_data(self)
None __init__(self, HomeAssistant hass, PyArrHostConfiguration host_configuration, SonarrClient api_client)
SystemStatus _fetch_data(self)
SonarrWantedMissing _fetch_data(self)