diff --git a/homeassistant/components/geocaching/coordinator.py b/homeassistant/components/geocaching/coordinator.py index fdf8f1340da..bfe82069650 100644 --- a/homeassistant/components/geocaching/coordinator.py +++ b/homeassistant/components/geocaching/coordinator.py @@ -2,7 +2,7 @@ from __future__ import annotations -from geocachingapi.exceptions import GeocachingApiError +from geocachingapi.exceptions import GeocachingApiError, GeocachingInvalidSettingsError from geocachingapi.geocachingapi import GeocachingApi from geocachingapi.models import GeocachingStatus @@ -39,6 +39,7 @@ class GeocachingDataUpdateCoordinator(DataUpdateCoordinator[GeocachingStatus]): return str(token) client_session = async_get_clientsession(hass) + self.geocaching = GeocachingApi( environment=ENVIRONMENT, token=session.token["access_token"], @@ -55,7 +56,10 @@ class GeocachingDataUpdateCoordinator(DataUpdateCoordinator[GeocachingStatus]): ) async def _async_update_data(self) -> GeocachingStatus: + """Fetch the latest Geocaching status.""" try: return await self.geocaching.update() + except GeocachingInvalidSettingsError as error: + raise UpdateFailed(f"Invalid integration configuration: {error}") from error except GeocachingApiError as error: raise UpdateFailed(f"Invalid response from API: {error}") from error diff --git a/homeassistant/components/geocaching/sensor.py b/homeassistant/components/geocaching/sensor.py index a8008229c91..5ceef21dfbf 100644 --- a/homeassistant/components/geocaching/sensor.py +++ b/homeassistant/components/geocaching/sensor.py @@ -93,6 +93,7 @@ class GeocachingSensor( self._attr_unique_id = ( f"{coordinator.data.user.reference_code}_{description.key}" ) + self._attr_device_info = DeviceInfo( name=f"Geocaching {coordinator.data.user.username}", identifiers={(DOMAIN, cast(str, coordinator.data.user.reference_code))},