Explicitly pass in the config_entry in tomorrowio coordinator (#137900)
explicitly pass in the config_entry in coordinatorpull/138061/head
parent
028c74e488
commit
14733de68c
|
@ -29,7 +29,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
# we will not use the class's lat and long so we can pass in garbage
|
# we will not use the class's lat and long so we can pass in garbage
|
||||||
# lats and longs
|
# lats and longs
|
||||||
api = TomorrowioV4(api_key, 361.0, 361.0, unit_system="metric", session=session)
|
api = TomorrowioV4(api_key, 361.0, 361.0, unit_system="metric", session=session)
|
||||||
coordinator = TomorrowioDataUpdateCoordinator(hass, api)
|
coordinator = TomorrowioDataUpdateCoordinator(hass, entry, api)
|
||||||
hass.data[DOMAIN][api_key] = coordinator
|
hass.data[DOMAIN][api_key] = coordinator
|
||||||
|
|
||||||
await coordinator.async_setup_entry(entry)
|
await coordinator.async_setup_entry(entry)
|
||||||
|
|
|
@ -116,14 +116,23 @@ def async_set_update_interval(
|
||||||
class TomorrowioDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
class TomorrowioDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
||||||
"""Define an object to hold Tomorrow.io data."""
|
"""Define an object to hold Tomorrow.io data."""
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistant, api: TomorrowioV4) -> None:
|
config_entry: ConfigEntry
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self, hass: HomeAssistant, config_entry: ConfigEntry, api: TomorrowioV4
|
||||||
|
) -> None:
|
||||||
"""Initialize."""
|
"""Initialize."""
|
||||||
self._api = api
|
self._api = api
|
||||||
self.data = {CURRENT: {}, FORECASTS: {}}
|
self.data = {CURRENT: {}, FORECASTS: {}}
|
||||||
self.entry_id_to_location_dict: dict[str, str] = {}
|
self.entry_id_to_location_dict: dict[str, str] = {}
|
||||||
self._coordinator_ready: asyncio.Event | None = None
|
self._coordinator_ready: asyncio.Event | None = None
|
||||||
|
|
||||||
super().__init__(hass, LOGGER, name=f"{DOMAIN}_{self._api.api_key_masked}")
|
super().__init__(
|
||||||
|
hass,
|
||||||
|
LOGGER,
|
||||||
|
config_entry=config_entry,
|
||||||
|
name=f"{DOMAIN}_{self._api.api_key_masked}",
|
||||||
|
)
|
||||||
|
|
||||||
def add_entry_to_location_dict(self, entry: ConfigEntry) -> None:
|
def add_entry_to_location_dict(self, entry: ConfigEntry) -> None:
|
||||||
"""Add an entry to the location dict."""
|
"""Add an entry to the location dict."""
|
||||||
|
|
Loading…
Reference in New Issue