Add re-auth flow to glances integration (#100929)

* Add reauth flow to glances integration.

* add reauth string

* add reauth strings
This commit is contained in:
Rami Mosleh 2023-09-26 18:46:12 +03:00 committed by GitHub
parent c823e407fd
commit 785b46af22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 155 additions and 7 deletions

View file

@ -7,6 +7,7 @@ from glances_api import Glances, exceptions
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOST
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from .const import DEFAULT_SCAN_INTERVAL, DOMAIN
@ -36,6 +37,8 @@ class GlancesDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
"""Get the latest data from the Glances REST API."""
try:
data = await self.api.get_ha_sensor_data()
except exceptions.GlancesApiAuthorizationError as err:
raise ConfigEntryAuthFailed from err
except exceptions.GlancesApiError as err:
raise UpdateFailed from err
return data or {}