mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Explicitly pass in the config_entry in incomfort coordinator (#138131)
This commit is contained in:
parent
56eecf05e7
commit
2dbf475d6f
@ -5,14 +5,18 @@ from __future__ import annotations
|
|||||||
from aiohttp import ClientResponseError
|
from aiohttp import ClientResponseError
|
||||||
from incomfortclient import InvalidGateway, InvalidHeaterList
|
from incomfortclient import InvalidGateway, InvalidHeaterList
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||||
from homeassistant.helpers import device_registry as dr
|
from homeassistant.helpers import device_registry as dr
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .coordinator import InComfortData, InComfortDataCoordinator, async_connect_gateway
|
from .coordinator import (
|
||||||
|
InComfortConfigEntry,
|
||||||
|
InComfortData,
|
||||||
|
InComfortDataCoordinator,
|
||||||
|
async_connect_gateway,
|
||||||
|
)
|
||||||
from .errors import InComfortTimeout, InComfortUnknownError, NoHeaters, NotFound
|
from .errors import InComfortTimeout, InComfortUnknownError, NoHeaters, NotFound
|
||||||
|
|
||||||
PLATFORMS = (
|
PLATFORMS = (
|
||||||
@ -24,8 +28,6 @@ PLATFORMS = (
|
|||||||
|
|
||||||
INTEGRATION_TITLE = "Intergas InComfort/Intouch Lan2RF gateway"
|
INTEGRATION_TITLE = "Intergas InComfort/Intouch Lan2RF gateway"
|
||||||
|
|
||||||
type InComfortConfigEntry = ConfigEntry[InComfortDataCoordinator]
|
|
||||||
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_cleanup_stale_devices(
|
def async_cleanup_stale_devices(
|
||||||
@ -93,7 +95,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: InComfortConfigEntry) ->
|
|||||||
name="RFGateway",
|
name="RFGateway",
|
||||||
)
|
)
|
||||||
async_cleanup_stale_devices(hass, entry, data, gateway_device)
|
async_cleanup_stale_devices(hass, entry, data, gateway_device)
|
||||||
coordinator = InComfortDataCoordinator(hass, data, entry.entry_id)
|
coordinator = InComfortDataCoordinator(hass, entry, data)
|
||||||
entry.runtime_data = coordinator
|
entry.runtime_data = coordinator
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
|
|
||||||
|
@ -17,8 +17,7 @@ from homeassistant.const import EntityCategory
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import InComfortConfigEntry
|
from .coordinator import InComfortConfigEntry, InComfortDataCoordinator
|
||||||
from .coordinator import InComfortDataCoordinator
|
|
||||||
from .entity import IncomfortBoilerEntity
|
from .entity import IncomfortBoilerEntity
|
||||||
|
|
||||||
PARALLEL_UPDATES = 0
|
PARALLEL_UPDATES = 0
|
||||||
|
@ -17,9 +17,8 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.helpers.device_registry import DeviceInfo
|
from homeassistant.helpers.device_registry import DeviceInfo
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import InComfortConfigEntry
|
|
||||||
from .const import CONF_LEGACY_SETPOINT_STATUS, DOMAIN
|
from .const import CONF_LEGACY_SETPOINT_STATUS, DOMAIN
|
||||||
from .coordinator import InComfortDataCoordinator
|
from .coordinator import InComfortConfigEntry, InComfortDataCoordinator
|
||||||
from .entity import IncomfortEntity
|
from .entity import IncomfortEntity
|
||||||
|
|
||||||
PARALLEL_UPDATES = 1
|
PARALLEL_UPDATES = 1
|
||||||
@ -74,7 +73,10 @@ class InComfortClimate(IncomfortEntity, ClimateEntity):
|
|||||||
name=f"Thermostat {room.room_no}",
|
name=f"Thermostat {room.room_no}",
|
||||||
)
|
)
|
||||||
if coordinator.unique_id:
|
if coordinator.unique_id:
|
||||||
self._attr_device_info["via_device"] = (DOMAIN, coordinator.unique_id)
|
self._attr_device_info["via_device"] = (
|
||||||
|
DOMAIN,
|
||||||
|
coordinator.config_entry.entry_id,
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self) -> dict[str, Any]:
|
def extra_state_attributes(self) -> dict[str, Any]:
|
||||||
|
@ -28,9 +28,8 @@ from homeassistant.helpers.selector import (
|
|||||||
)
|
)
|
||||||
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||||
|
|
||||||
from . import InComfortConfigEntry
|
|
||||||
from .const import CONF_LEGACY_SETPOINT_STATUS, DOMAIN
|
from .const import CONF_LEGACY_SETPOINT_STATUS, DOMAIN
|
||||||
from .coordinator import async_connect_gateway
|
from .coordinator import InComfortConfigEntry, async_connect_gateway
|
||||||
|
|
||||||
TITLE = "Intergas InComfort/Intouch Lan2RF gateway"
|
TITLE = "Intergas InComfort/Intouch Lan2RF gateway"
|
||||||
|
|
||||||
|
@ -12,12 +12,15 @@ from incomfortclient import (
|
|||||||
InvalidHeaterList,
|
InvalidHeaterList,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_HOST
|
from homeassistant.const import CONF_HOST
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryError
|
from homeassistant.exceptions import ConfigEntryError
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||||
|
|
||||||
|
type InComfortConfigEntry = ConfigEntry[InComfortDataCoordinator]
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
UPDATE_INTERVAL = 30
|
UPDATE_INTERVAL = 30
|
||||||
@ -50,14 +53,20 @@ async def async_connect_gateway(
|
|||||||
class InComfortDataCoordinator(DataUpdateCoordinator[InComfortData]):
|
class InComfortDataCoordinator(DataUpdateCoordinator[InComfortData]):
|
||||||
"""Data coordinator for InComfort entities."""
|
"""Data coordinator for InComfort entities."""
|
||||||
|
|
||||||
|
config_entry: InComfortConfigEntry
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, hass: HomeAssistant, incomfort_data: InComfortData, unique_id: str | None
|
self,
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config_entry: InComfortConfigEntry,
|
||||||
|
incomfort_data: InComfortData,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize coordinator."""
|
"""Initialize coordinator."""
|
||||||
self.unique_id = unique_id
|
self.unique_id = config_entry.unique_id
|
||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
_LOGGER,
|
||||||
|
config_entry=config_entry,
|
||||||
name="InComfort datacoordinator",
|
name="InComfort datacoordinator",
|
||||||
update_interval=timedelta(seconds=UPDATE_INTERVAL),
|
update_interval=timedelta(seconds=UPDATE_INTERVAL),
|
||||||
)
|
)
|
||||||
|
@ -8,7 +8,7 @@ from homeassistant.components.diagnostics import async_redact_data
|
|||||||
from homeassistant.const import CONF_PASSWORD
|
from homeassistant.const import CONF_PASSWORD
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
|
||||||
from . import InComfortConfigEntry
|
from .coordinator import InComfortConfigEntry
|
||||||
|
|
||||||
REDACT_CONFIG = {CONF_PASSWORD}
|
REDACT_CONFIG = {CONF_PASSWORD}
|
||||||
|
|
||||||
|
@ -29,4 +29,7 @@ class IncomfortBoilerEntity(IncomfortEntity):
|
|||||||
serial_number=heater.serial_no,
|
serial_number=heater.serial_no,
|
||||||
)
|
)
|
||||||
if coordinator.unique_id:
|
if coordinator.unique_id:
|
||||||
self._attr_device_info["via_device"] = (DOMAIN, coordinator.unique_id)
|
self._attr_device_info["via_device"] = (
|
||||||
|
DOMAIN,
|
||||||
|
coordinator.config_entry.entry_id,
|
||||||
|
)
|
||||||
|
@ -18,8 +18,7 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
|
|
||||||
from . import InComfortConfigEntry
|
from .coordinator import InComfortConfigEntry, InComfortDataCoordinator
|
||||||
from .coordinator import InComfortDataCoordinator
|
|
||||||
from .entity import IncomfortBoilerEntity
|
from .entity import IncomfortBoilerEntity
|
||||||
|
|
||||||
PARALLEL_UPDATES = 0
|
PARALLEL_UPDATES = 0
|
||||||
|
@ -12,8 +12,7 @@ from homeassistant.const import EntityCategory, UnitOfTemperature
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import InComfortConfigEntry
|
from .coordinator import InComfortConfigEntry, InComfortDataCoordinator
|
||||||
from .coordinator import InComfortDataCoordinator
|
|
||||||
from .entity import IncomfortBoilerEntity
|
from .entity import IncomfortBoilerEntity
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user