1 """The Google Photos integration."""
3 from __future__
import annotations
5 from aiohttp
import ClientError, ClientResponseError
6 from google_photos_library_api.api
import GooglePhotosLibraryApi
14 from .const
import DOMAIN
15 from .coordinator
import GooglePhotosUpdateCoordinator
16 from .services
import async_register_services
17 from .types
import GooglePhotosConfigEntry
25 hass: HomeAssistant, entry: GooglePhotosConfigEntry
27 """Set up Google Photos from a config entry."""
29 await config_entry_oauth2_flow.async_get_config_entry_implementation(
34 oauth_session = config_entry_oauth2_flow.OAuth2Session(hass, entry, implementation)
37 await auth.async_get_access_token()
38 except ClientResponseError
as err:
39 if 400 <= err.status < 500:
41 "OAuth session is not valid, reauth required"
43 raise ConfigEntryNotReady
from err
44 except ClientError
as err:
45 raise ConfigEntryNotReady
from err
47 await coordinator.async_config_entry_first_refresh()
48 entry.runtime_data = coordinator
56 hass: HomeAssistant, entry: GooglePhotosConfigEntry
58 """Unload a config entry."""
None async_register_services(HomeAssistant hass)
bool async_unload_entry(HomeAssistant hass, GooglePhotosConfigEntry entry)
bool async_setup_entry(HomeAssistant hass, GooglePhotosConfigEntry entry)
aiohttp.ClientSession async_get_clientsession(HomeAssistant hass, bool verify_ssl=True, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT)