Explicitly pass in the config_entry in aquacell coordinator init (#137713)

explicitly pass in the config_entry in aquacell coordinator init
This commit is contained in:
Michael 2025-02-07 20:42:05 +01:00 committed by GitHub
parent c595b12e98
commit 7007bd121f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 10 deletions

View File

@ -5,18 +5,15 @@ from __future__ import annotations
from aioaquacell import AquacellApi
from aioaquacell.const import Brand
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import CONF_BRAND
from .coordinator import AquacellCoordinator
from .coordinator import AquacellConfigEntry, AquacellCoordinator
PLATFORMS = [Platform.SENSOR]
type AquacellConfigEntry = ConfigEntry[AquacellCoordinator]
async def async_setup_entry(hass: HomeAssistant, entry: AquacellConfigEntry) -> bool:
"""Set up Aquacell from a config entry."""
@ -26,7 +23,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: AquacellConfigEntry) ->
aquacell_api = AquacellApi(session, brand)
coordinator = AquacellCoordinator(hass, aquacell_api)
coordinator = AquacellCoordinator(hass, entry, aquacell_api)
await coordinator.async_config_entry_first_refresh()
entry.runtime_data = coordinator
@ -36,6 +33,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: AquacellConfigEntry) ->
return True
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def async_unload_entry(hass: HomeAssistant, entry: AquacellConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)

View File

@ -26,17 +26,25 @@ from .const import (
_LOGGER = logging.getLogger(__name__)
type AquacellConfigEntry = ConfigEntry[AquacellCoordinator]
class AquacellCoordinator(DataUpdateCoordinator[dict[str, Softener]]):
"""My aquacell coordinator."""
config_entry: ConfigEntry
config_entry: AquacellConfigEntry
def __init__(self, hass: HomeAssistant, aquacell_api: AquacellApi) -> None:
def __init__(
self,
hass: HomeAssistant,
config_entry: AquacellConfigEntry,
aquacell_api: AquacellApi,
) -> None:
"""Initialize coordinator."""
super().__init__(
hass,
_LOGGER,
config_entry=config_entry,
name="Aquacell Coordinator",
update_interval=UPDATE_INTERVAL,
)

View File

@ -18,8 +18,7 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType
from . import AquacellConfigEntry
from .coordinator import AquacellCoordinator
from .coordinator import AquacellConfigEntry, AquacellCoordinator
from .entity import AquacellEntity
PARALLEL_UPDATES = 1