Pass config entry to Unifi coordinator (#149952)

This commit is contained in:
Joost Lekkerkerker 2025-08-04 12:29:27 +02:00 committed by GitHub
parent cbf4130bff
commit 106c086e8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View File

@ -25,6 +25,7 @@ from ..const import LOGGER, UNIFI_WIRELESS_CLIENTS
from ..entity import UnifiEntity, UnifiEntityDescription
if TYPE_CHECKING:
from .. import UnifiConfigEntry
from .hub import UnifiHub
CHECK_HEARTBEAT_INTERVAL = timedelta(seconds=1)
@ -34,7 +35,7 @@ POLL_INTERVAL = timedelta(seconds=10)
class UnifiEntityLoader:
"""UniFi Network integration handling platforms for entity registration."""
def __init__(self, hub: UnifiHub) -> None:
def __init__(self, hub: UnifiHub, config_entry: UnifiConfigEntry) -> None:
"""Initialize the UniFi entity loader."""
self.hub = hub
self.api_updaters = (
@ -57,15 +58,16 @@ class UnifiEntityLoader:
)
self.wireless_clients = hub.hass.data[UNIFI_WIRELESS_CLIENTS]
self._dataUpdateCoordinator = DataUpdateCoordinator(
self._data_update_coordinator = DataUpdateCoordinator(
hub.hass,
LOGGER,
name="Unifi entity poller",
config_entry=config_entry,
update_method=self._update_pollable_api_data,
update_interval=POLL_INTERVAL,
)
self._update_listener = self._dataUpdateCoordinator.async_add_listener(
self._update_listener = self._data_update_coordinator.async_add_listener(
update_callback=lambda: None
)

View File

@ -39,7 +39,7 @@ class UnifiHub:
self.hass = hass
self.api = api
self.config = UnifiConfig.from_config_entry(config_entry)
self.entity_loader = UnifiEntityLoader(self)
self.entity_loader = UnifiEntityLoader(self, config_entry)
self._entity_helper = UnifiEntityHelper(hass, api)
self.websocket = UnifiWebsocket(hass, api, self.signal_reachable)