mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Explicitly pass in the config_entry in switchbee coordinator (#137923)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
a7dbcf72c2
commit
43569df537
@ -63,10 +63,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
websession = async_get_clientsession(hass, verify_ssl=False)
|
||||
api = await get_api_object(central_unit, user, password, websession)
|
||||
|
||||
coordinator = SwitchBeeCoordinator(
|
||||
hass,
|
||||
api,
|
||||
)
|
||||
coordinator = SwitchBeeCoordinator(hass, entry, api)
|
||||
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
entry.async_on_unload(entry.add_update_listener(update_listener))
|
||||
|
@ -10,6 +10,7 @@ from switchbee.api import CentralUnitPolling, CentralUnitWsRPC
|
||||
from switchbee.api.central_unit import SwitchBeeError
|
||||
from switchbee.device import DeviceType, SwitchBeeBaseDevice
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.device_registry import format_mac
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
@ -22,9 +23,12 @@ _LOGGER = logging.getLogger(__name__)
|
||||
class SwitchBeeCoordinator(DataUpdateCoordinator[Mapping[int, SwitchBeeBaseDevice]]):
|
||||
"""Class to manage fetching SwitchBee data API."""
|
||||
|
||||
config_entry: ConfigEntry
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
swb_api: CentralUnitPolling | CentralUnitWsRPC,
|
||||
) -> None:
|
||||
"""Initialize."""
|
||||
@ -39,6 +43,7 @@ class SwitchBeeCoordinator(DataUpdateCoordinator[Mapping[int, SwitchBeeBaseDevic
|
||||
super().__init__(
|
||||
hass,
|
||||
_LOGGER,
|
||||
config_entry=config_entry,
|
||||
name=DOMAIN,
|
||||
update_interval=timedelta(seconds=SCAN_INTERVAL_SEC[type(self.api)]),
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user