diff --git a/homeassistant/components/google_photos/__init__.py b/homeassistant/components/google_photos/__init__.py index 2a7109d8189..40de02554ae 100644 --- a/homeassistant/components/google_photos/__init__.py +++ b/homeassistant/components/google_photos/__init__.py @@ -12,9 +12,8 @@ from homeassistant.helpers.aiohttp_client import async_get_clientsession from . import api from .const import DOMAIN -from .coordinator import GooglePhotosUpdateCoordinator +from .coordinator import GooglePhotosConfigEntry, GooglePhotosUpdateCoordinator from .services import async_register_services -from .types import GooglePhotosConfigEntry __all__ = [ "DOMAIN", @@ -43,7 +42,9 @@ async def async_setup_entry( raise ConfigEntryNotReady from err except ClientError as err: raise ConfigEntryNotReady from err - coordinator = GooglePhotosUpdateCoordinator(hass, GooglePhotosLibraryApi(auth)) + coordinator = GooglePhotosUpdateCoordinator( + hass, entry, GooglePhotosLibraryApi(auth) + ) await coordinator.async_config_entry_first_refresh() entry.runtime_data = coordinator diff --git a/homeassistant/components/google_photos/coordinator.py b/homeassistant/components/google_photos/coordinator.py index 3ba5a8124d6..215d40d7864 100644 --- a/homeassistant/components/google_photos/coordinator.py +++ b/homeassistant/components/google_photos/coordinator.py @@ -15,6 +15,7 @@ from google_photos_library_api.api import GooglePhotosLibraryApi from google_photos_library_api.exceptions import GooglePhotosApiError from google_photos_library_api.model import Album, NewAlbum +from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed @@ -23,6 +24,8 @@ _LOGGER = logging.getLogger(__name__) UPDATE_INTERVAL: Final = datetime.timedelta(hours=24) ALBUM_PAGE_SIZE = 50 +type GooglePhotosConfigEntry = ConfigEntry[GooglePhotosUpdateCoordinator] + class GooglePhotosUpdateCoordinator(DataUpdateCoordinator[dict[str, str]]): """Coordinator for fetching Google Photos albums. @@ -30,11 +33,19 @@ class GooglePhotosUpdateCoordinator(DataUpdateCoordinator[dict[str, str]]): The `data` object is a dict from Album ID to Album title. """ - def __init__(self, hass: HomeAssistant, client: GooglePhotosLibraryApi) -> None: + config_entry: GooglePhotosConfigEntry + + def __init__( + self, + hass: HomeAssistant, + config_entry: GooglePhotosConfigEntry, + client: GooglePhotosLibraryApi, + ) -> None: """Initialize TaskUpdateCoordinator.""" super().__init__( hass, _LOGGER, + config_entry=config_entry, name="Google Photos", update_interval=UPDATE_INTERVAL, ) diff --git a/homeassistant/components/google_photos/media_source.py b/homeassistant/components/google_photos/media_source.py index 7ee81b51bc0..c0a87e46fbc 100644 --- a/homeassistant/components/google_photos/media_source.py +++ b/homeassistant/components/google_photos/media_source.py @@ -20,8 +20,8 @@ from homeassistant.components.media_source import ( ) from homeassistant.core import HomeAssistant -from . import GooglePhotosConfigEntry from .const import DOMAIN, READ_SCOPE +from .coordinator import GooglePhotosConfigEntry _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/google_photos/services.py b/homeassistant/components/google_photos/services.py index 22d3cc7deb0..8042df8f811 100644 --- a/homeassistant/components/google_photos/services.py +++ b/homeassistant/components/google_photos/services.py @@ -21,7 +21,7 @@ from homeassistant.exceptions import HomeAssistantError, ServiceValidationError from homeassistant.helpers import config_validation as cv from .const import DOMAIN, UPLOAD_SCOPE -from .types import GooglePhotosConfigEntry +from .coordinator import GooglePhotosConfigEntry CONF_CONFIG_ENTRY_ID = "config_entry_id" CONF_ALBUM = "album" diff --git a/homeassistant/components/google_photos/types.py b/homeassistant/components/google_photos/types.py deleted file mode 100644 index 4f4cc1845e4..00000000000 --- a/homeassistant/components/google_photos/types.py +++ /dev/null @@ -1,7 +0,0 @@ -"""Google Photos types.""" - -from homeassistant.config_entries import ConfigEntry - -from .coordinator import GooglePhotosUpdateCoordinator - -type GooglePhotosConfigEntry = ConfigEntry[GooglePhotosUpdateCoordinator]