mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 10:17:51 +00:00
Explicitly pass in the config_entry in glances coordinator (#137835)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
9bdd8d04c5
commit
0efdceef27
@ -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
|
||||
|
@ -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,
|
||||
)
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user