diff --git a/homeassistant/components/overkiz/__init__.py b/homeassistant/components/overkiz/__init__.py index 51efb52e55d..8aa1ed0e4fe 100644 --- a/homeassistant/components/overkiz/__init__.py +++ b/homeassistant/components/overkiz/__init__.py @@ -39,7 +39,6 @@ from .const import ( LOGGER, OVERKIZ_DEVICE_TO_PLATFORM, PLATFORMS, - UPDATE_INTERVAL, UPDATE_INTERVAL_ALL_ASSUMED_STATE, UPDATE_INTERVAL_LOCAL, ) @@ -104,13 +103,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: OverkizDataConfigEntry) coordinator = OverkizDataUpdateCoordinator( hass, + entry, LOGGER, - name="device events", client=client, devices=setup.devices, places=setup.root_place, - update_interval=UPDATE_INTERVAL, - config_entry_id=entry.entry_id, ) await coordinator.async_config_entry_first_refresh() diff --git a/homeassistant/components/overkiz/coordinator.py b/homeassistant/components/overkiz/coordinator.py index 484ef138cf7..4b79cfc9c06 100644 --- a/homeassistant/components/overkiz/coordinator.py +++ b/homeassistant/components/overkiz/coordinator.py @@ -5,7 +5,7 @@ from __future__ import annotations from collections.abc import Callable, Coroutine from datetime import timedelta import logging -from typing import Any +from typing import TYPE_CHECKING, Any from aiohttp import ClientConnectorError, ServerDisconnectedError from pyoverkiz.client import OverkizClient @@ -26,7 +26,10 @@ from homeassistant.helpers import device_registry as dr from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from homeassistant.util.decorator import Registry -from .const import DOMAIN, IGNORED_OVERKIZ_DEVICES, LOGGER +if TYPE_CHECKING: + from . import OverkizDataConfigEntry + +from .const import DOMAIN, IGNORED_OVERKIZ_DEVICES, LOGGER, UPDATE_INTERVAL EVENT_HANDLERS: Registry[ str, Callable[[OverkizDataUpdateCoordinator, Event], Coroutine[Any, Any, None]] @@ -36,26 +39,26 @@ EVENT_HANDLERS: Registry[ class OverkizDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Device]]): """Class to manage fetching data from Overkiz platform.""" + config_entry: OverkizDataConfigEntry _default_update_interval: timedelta def __init__( self, hass: HomeAssistant, + config_entry: OverkizDataConfigEntry, logger: logging.Logger, *, - name: str, client: OverkizClient, devices: list[Device], places: Place | None, - update_interval: timedelta, - config_entry_id: str, ) -> None: """Initialize global data updater.""" super().__init__( hass, logger, - name=name, - update_interval=update_interval, + config_entry=config_entry, + name="device events", + update_interval=UPDATE_INTERVAL, ) self.data = {} @@ -63,8 +66,7 @@ class OverkizDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Device]]): self.devices: dict[str, Device] = {d.device_url: d for d in devices} self.executions: dict[str, dict[str, str]] = {} self.areas = self._places_to_area(places) if places else None - self.config_entry_id = config_entry_id - self._default_update_interval = update_interval + self._default_update_interval = UPDATE_INTERVAL self.is_stateless = all( device.protocol in (Protocol.RTS, Protocol.INTERNAL) @@ -164,7 +166,7 @@ async def on_device_created_updated( ) -> None: """Handle device unavailable / disabled event.""" coordinator.hass.async_create_task( - coordinator.hass.config_entries.async_reload(coordinator.config_entry_id) + coordinator.hass.config_entries.async_reload(coordinator.config_entry.entry_id) )