mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 05:37:44 +00:00
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:
parent
c595b12e98
commit
7007bd121f
@ -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)
|
||||
|
@ -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,
|
||||
)
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user