Explicitly set config entry in Trafikverket Weatherstation coordinator (#134310)

This commit is contained in:
G Johansson 2024-12-30 23:16:41 +01:00 committed by GitHub
parent 256fc54aa1
commit 9f1023b195
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View File

@ -14,7 +14,7 @@ TVWeatherConfigEntry = ConfigEntry[TVDataUpdateCoordinator]
async def async_setup_entry(hass: HomeAssistant, entry: TVWeatherConfigEntry) -> bool:
"""Set up Trafikverket Weatherstation from a config entry."""
coordinator = TVDataUpdateCoordinator(hass)
coordinator = TVDataUpdateCoordinator(hass, entry)
await coordinator.async_config_entry_first_refresh()
entry.runtime_data = coordinator
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

View File

@ -34,18 +34,19 @@ class TVDataUpdateCoordinator(DataUpdateCoordinator[WeatherStationInfoModel]):
config_entry: TVWeatherConfigEntry
def __init__(self, hass: HomeAssistant) -> None:
def __init__(self, hass: HomeAssistant, config_entry: TVWeatherConfigEntry) -> None:
"""Initialize the Sensibo coordinator."""
super().__init__(
hass,
_LOGGER,
config_entry=config_entry,
name=DOMAIN,
update_interval=TIME_BETWEEN_UPDATES,
)
self._weather_api = TrafikverketWeather(
async_get_clientsession(hass), self.config_entry.data[CONF_API_KEY]
async_get_clientsession(hass), config_entry.data[CONF_API_KEY]
)
self._station = self.config_entry.data[CONF_STATION]
self._station = config_entry.data[CONF_STATION]
async def _async_update_data(self) -> WeatherStationInfoModel:
"""Fetch data from Trafikverket."""