mirror of
https://github.com/home-assistant/core.git
synced 2025-08-05 19:48:23 +00:00
Pass config entry to Unifi coordinator (#149952)
This commit is contained in:
parent
cbf4130bff
commit
106c086e8b
@ -25,6 +25,7 @@ from ..const import LOGGER, UNIFI_WIRELESS_CLIENTS
|
|||||||
from ..entity import UnifiEntity, UnifiEntityDescription
|
from ..entity import UnifiEntity, UnifiEntityDescription
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
from .. import UnifiConfigEntry
|
||||||
from .hub import UnifiHub
|
from .hub import UnifiHub
|
||||||
|
|
||||||
CHECK_HEARTBEAT_INTERVAL = timedelta(seconds=1)
|
CHECK_HEARTBEAT_INTERVAL = timedelta(seconds=1)
|
||||||
@ -34,7 +35,7 @@ POLL_INTERVAL = timedelta(seconds=10)
|
|||||||
class UnifiEntityLoader:
|
class UnifiEntityLoader:
|
||||||
"""UniFi Network integration handling platforms for entity registration."""
|
"""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."""
|
"""Initialize the UniFi entity loader."""
|
||||||
self.hub = hub
|
self.hub = hub
|
||||||
self.api_updaters = (
|
self.api_updaters = (
|
||||||
@ -57,15 +58,16 @@ class UnifiEntityLoader:
|
|||||||
)
|
)
|
||||||
self.wireless_clients = hub.hass.data[UNIFI_WIRELESS_CLIENTS]
|
self.wireless_clients = hub.hass.data[UNIFI_WIRELESS_CLIENTS]
|
||||||
|
|
||||||
self._dataUpdateCoordinator = DataUpdateCoordinator(
|
self._data_update_coordinator = DataUpdateCoordinator(
|
||||||
hub.hass,
|
hub.hass,
|
||||||
LOGGER,
|
LOGGER,
|
||||||
name="Unifi entity poller",
|
name="Unifi entity poller",
|
||||||
|
config_entry=config_entry,
|
||||||
update_method=self._update_pollable_api_data,
|
update_method=self._update_pollable_api_data,
|
||||||
update_interval=POLL_INTERVAL,
|
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
|
update_callback=lambda: None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class UnifiHub:
|
|||||||
self.hass = hass
|
self.hass = hass
|
||||||
self.api = api
|
self.api = api
|
||||||
self.config = UnifiConfig.from_config_entry(config_entry)
|
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._entity_helper = UnifiEntityHelper(hass, api)
|
||||||
self.websocket = UnifiWebsocket(hass, api, self.signal_reachable)
|
self.websocket = UnifiWebsocket(hass, api, self.signal_reachable)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user