1 """Data update coordinator for the Lidarr integration."""
3 from __future__
import annotations
5 from abc
import ABC, abstractmethod
6 from datetime
import timedelta
7 from typing
import Generic, TypeVar, cast
9 from aiopyarr
import LidarrAlbum, LidarrQueue, LidarrRootFolder, exceptions
10 from aiopyarr.lidarr_client
import LidarrClient
11 from aiopyarr.models.host_configuration
import PyArrHostConfiguration
18 from .const
import DEFAULT_MAX_RECORDS, DOMAIN, LOGGER
20 T = TypeVar(
"T", bound=list[LidarrRootFolder] | LidarrQueue | str | LidarrAlbum | int)
24 """Data update coordinator for the Lidarr integration."""
26 config_entry: ConfigEntry
31 host_configuration: PyArrHostConfiguration,
32 api_client: LidarrClient,
34 """Initialize the coordinator."""
45 """Get the latest data from Lidarr."""
49 except exceptions.ArrConnectionException
as ex:
51 except exceptions.ArrAuthenticationException
as ex:
53 "API Key is no longer valid. Please reauthenticate"
58 """Fetch the actual data."""
59 raise NotImplementedError
63 LidarrDataUpdateCoordinator[list[LidarrRootFolder]]
65 """Disk space update coordinator for Lidarr."""
70 list[LidarrRootFolder], await self.
api_clientapi_client.async_get_root_folders()
75 """Queue update coordinator."""
78 """Fetch the album count in queue."""
79 return await self.
api_clientapi_client.async_get_queue(page_size=DEFAULT_MAX_RECORDS)
83 """Status update coordinator for Lidarr."""
87 return (await self.
api_clientapi_client.async_get_system_status()).version
91 """Wanted update coordinator."""
94 """Fetch the wanted data."""
97 await self.
api_clientapi_client.async_get_wanted(page_size=DEFAULT_MAX_RECORDS),
102 """Albums update coordinator."""
105 """Fetch the album data."""
106 return len(cast(list[LidarrAlbum], await self.
api_clientapi_client.async_get_albums()))
list[LidarrRootFolder] _fetch_data(self)
None __init__(self, HomeAssistant hass, PyArrHostConfiguration host_configuration, LidarrClient api_client)
T _async_update_data(self)
LidarrQueue _fetch_data(self)
LidarrAlbum _fetch_data(self)