Skip to content
Snippets Groups Projects
Unverified Commit 9f1023b1 authored by G Johansson's avatar G Johansson Committed by GitHub
Browse files

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

parent 256fc54a
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,7 @@ TVWeatherConfigEntry = ConfigEntry[TVDataUpdateCoordinator] ...@@ -14,7 +14,7 @@ TVWeatherConfigEntry = ConfigEntry[TVDataUpdateCoordinator]
async def async_setup_entry(hass: HomeAssistant, entry: TVWeatherConfigEntry) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: TVWeatherConfigEntry) -> bool:
"""Set up Trafikverket Weatherstation from a config entry.""" """Set up Trafikverket Weatherstation from a config entry."""
coordinator = TVDataUpdateCoordinator(hass) coordinator = TVDataUpdateCoordinator(hass, entry)
await coordinator.async_config_entry_first_refresh() await coordinator.async_config_entry_first_refresh()
entry.runtime_data = coordinator entry.runtime_data = coordinator
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
......
...@@ -34,18 +34,19 @@ class TVDataUpdateCoordinator(DataUpdateCoordinator[WeatherStationInfoModel]): ...@@ -34,18 +34,19 @@ class TVDataUpdateCoordinator(DataUpdateCoordinator[WeatherStationInfoModel]):
config_entry: TVWeatherConfigEntry config_entry: TVWeatherConfigEntry
def __init__(self, hass: HomeAssistant) -> None: def __init__(self, hass: HomeAssistant, config_entry: TVWeatherConfigEntry) -> None:
"""Initialize the Sensibo coordinator.""" """Initialize the Sensibo coordinator."""
super().__init__( super().__init__(
hass, hass,
_LOGGER, _LOGGER,
config_entry=config_entry,
name=DOMAIN, name=DOMAIN,
update_interval=TIME_BETWEEN_UPDATES, update_interval=TIME_BETWEEN_UPDATES,
) )
self._weather_api = TrafikverketWeather( 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: async def _async_update_data(self) -> WeatherStationInfoModel:
"""Fetch data from Trafikverket.""" """Fetch data from Trafikverket."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment