mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Explicitly pass in the config_entry in weheat coordinator (#137868)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
a59d829e6a
commit
07e9d80607
@ -8,7 +8,6 @@ import aiohttp
|
||||
from weheat.abstractions.discovery import HeatPumpDiscovery
|
||||
from weheat.exceptions import UnauthorizedException
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||
@ -19,12 +18,10 @@ from homeassistant.helpers.config_entry_oauth2_flow import (
|
||||
)
|
||||
|
||||
from .const import API_URL, LOGGER
|
||||
from .coordinator import WeheatDataUpdateCoordinator
|
||||
from .coordinator import WeheatConfigEntry, WeheatDataUpdateCoordinator
|
||||
|
||||
PLATFORMS: list[Platform] = [Platform.BINARY_SENSOR, Platform.SENSOR]
|
||||
|
||||
type WeheatConfigEntry = ConfigEntry[list[WeheatDataUpdateCoordinator]]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: WeheatConfigEntry) -> bool:
|
||||
"""Set up Weheat from a config entry."""
|
||||
@ -58,7 +55,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: WeheatConfigEntry) -> bo
|
||||
for pump_info in discovered_heat_pumps:
|
||||
LOGGER.debug("Adding %s", pump_info)
|
||||
# for each pump, add a coordinator
|
||||
new_coordinator = WeheatDataUpdateCoordinator(hass, session, pump_info)
|
||||
new_coordinator = WeheatDataUpdateCoordinator(hass, entry, session, pump_info)
|
||||
|
||||
await new_coordinator.async_config_entry_first_refresh()
|
||||
|
||||
|
@ -14,8 +14,7 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import StateType
|
||||
|
||||
from . import WeheatConfigEntry
|
||||
from .coordinator import WeheatDataUpdateCoordinator
|
||||
from .coordinator import WeheatConfigEntry, WeheatDataUpdateCoordinator
|
||||
from .entity import WeheatEntity
|
||||
|
||||
# Coordinator is used to centralize the data updates
|
||||
|
@ -13,6 +13,7 @@ from weheat.exceptions import (
|
||||
UnauthorizedException,
|
||||
)
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||
@ -30,13 +31,18 @@ EXCEPTIONS = (
|
||||
ApiException,
|
||||
)
|
||||
|
||||
type WeheatConfigEntry = ConfigEntry[list[WeheatDataUpdateCoordinator]]
|
||||
|
||||
|
||||
class WeheatDataUpdateCoordinator(DataUpdateCoordinator[HeatPump]):
|
||||
"""A custom coordinator for the Weheat heatpump integration."""
|
||||
|
||||
config_entry: WeheatConfigEntry
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
config_entry: WeheatConfigEntry,
|
||||
session: OAuth2Session,
|
||||
heat_pump: HeatPumpDiscovery.HeatPumpInfo,
|
||||
) -> None:
|
||||
@ -44,6 +50,7 @@ class WeheatDataUpdateCoordinator(DataUpdateCoordinator[HeatPump]):
|
||||
super().__init__(
|
||||
hass,
|
||||
logger=LOGGER,
|
||||
config_entry=config_entry,
|
||||
name=DOMAIN,
|
||||
update_interval=timedelta(seconds=UPDATE_INTERVAL),
|
||||
)
|
||||
|
@ -22,13 +22,12 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import StateType
|
||||
|
||||
from . import WeheatConfigEntry
|
||||
from .const import (
|
||||
DISPLAY_PRECISION_COP,
|
||||
DISPLAY_PRECISION_WATER_TEMP,
|
||||
DISPLAY_PRECISION_WATTS,
|
||||
)
|
||||
from .coordinator import WeheatDataUpdateCoordinator
|
||||
from .coordinator import WeheatConfigEntry, WeheatDataUpdateCoordinator
|
||||
from .entity import WeheatEntity
|
||||
|
||||
# Coordinator is used to centralize the data updates
|
||||
|
Loading…
x
Reference in New Issue
Block a user