Explicitly pass in the config_entry in hko coordinator (#138154)

explicitly pass in the config_entry in coordinator
This commit is contained in:
Michael 2025-02-09 21:17:11 +01:00 committed by GitHub
parent d9a17506f5
commit 39bcef63bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View File

@ -25,7 +25,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
)[KEY_DISTRICT]
websession = async_get_clientsession(hass)
coordinator = HKOUpdateCoordinator(hass, websession, district, location)
coordinator = HKOUpdateCoordinator(hass, entry, websession, district, location)
await coordinator.async_config_entry_first_refresh()
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator

View File

@ -26,6 +26,7 @@ from homeassistant.components.weather import (
ATTR_FORECAST_TEMP_LOW,
ATTR_FORECAST_TIME,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
@ -69,8 +70,15 @@ _LOGGER = logging.getLogger(__name__)
class HKOUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
"""HKO Update Coordinator."""
config_entry: ConfigEntry
def __init__(
self, hass: HomeAssistant, session: ClientSession, district: str, location: str
self,
hass: HomeAssistant,
config_entry: ConfigEntry,
session: ClientSession,
district: str,
location: str,
) -> None:
"""Update data via library."""
self.location = location
@ -80,6 +88,7 @@ class HKOUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
super().__init__(
hass,
_LOGGER,
config_entry=config_entry,
name=DOMAIN,
update_interval=timedelta(minutes=15),
)