diff --git a/homeassistant/components/glances/__init__.py b/homeassistant/components/glances/__init__.py index 9d09e63606e..d7b645d9e11 100644 --- a/homeassistant/components/glances/__init__.py +++ b/homeassistant/components/glances/__init__.py @@ -10,7 +10,6 @@ from glances_api.exceptions import ( GlancesApiNoDataAvailable, ) -from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONF_HOST, CONF_PASSWORD, @@ -29,15 +28,13 @@ from homeassistant.exceptions import ( ) from homeassistant.helpers.httpx_client import get_async_client -from .coordinator import GlancesDataUpdateCoordinator +from .coordinator import GlancesConfigEntry, GlancesDataUpdateCoordinator PLATFORMS = [Platform.SENSOR] _LOGGER = logging.getLogger(__name__) -type GlancesConfigEntry = ConfigEntry[GlancesDataUpdateCoordinator] - async def async_setup_entry( hass: HomeAssistant, config_entry: GlancesConfigEntry diff --git a/homeassistant/components/glances/coordinator.py b/homeassistant/components/glances/coordinator.py index 8882b097ba9..28cf40aae6e 100644 --- a/homeassistant/components/glances/coordinator.py +++ b/homeassistant/components/glances/coordinator.py @@ -17,21 +17,25 @@ from .const import DEFAULT_SCAN_INTERVAL, DOMAIN _LOGGER = logging.getLogger(__name__) +type GlancesConfigEntry = ConfigEntry[GlancesDataUpdateCoordinator] + class GlancesDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]): """Get the latest data from Glances api.""" - config_entry: ConfigEntry + config_entry: GlancesConfigEntry - def __init__(self, hass: HomeAssistant, entry: ConfigEntry, api: Glances) -> None: + def __init__( + self, hass: HomeAssistant, entry: GlancesConfigEntry, api: Glances + ) -> None: """Initialize the Glances data.""" self.hass = hass - self.config_entry = entry self.host: str = entry.data[CONF_HOST] self.api = api super().__init__( hass, _LOGGER, + config_entry=entry, name=f"{DOMAIN} - {self.host}", update_interval=DEFAULT_SCAN_INTERVAL, ) diff --git a/homeassistant/components/glances/sensor.py b/homeassistant/components/glances/sensor.py index 0741926296e..61d88b744bf 100644 --- a/homeassistant/components/glances/sensor.py +++ b/homeassistant/components/glances/sensor.py @@ -22,8 +22,8 @@ from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.update_coordinator import CoordinatorEntity -from . import GlancesConfigEntry, GlancesDataUpdateCoordinator from .const import CPU_ICON, DOMAIN +from .coordinator import GlancesConfigEntry, GlancesDataUpdateCoordinator @dataclass(frozen=True, kw_only=True)