Explicitly pass in the config_entry in tomorrowio coordinator (#137900)

explicitly pass in the config_entry in coordinator
pull/130406/merge
Michael 2025-02-09 14:33:25 +01:00 committed by GitHub
parent 028c74e488
commit 14733de68c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 3 deletions

View File

@ -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
# lats and longs
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
await coordinator.async_setup_entry(entry)

View File

@ -116,14 +116,23 @@ def async_set_update_interval(
class TomorrowioDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
"""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."""
self._api = api
self.data = {CURRENT: {}, FORECASTS: {}}
self.entry_id_to_location_dict: dict[str, str] = {}
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:
"""Add an entry to the location dict."""