From 9f1023b1953a5c5495fddf56a991c71635e684d6 Mon Sep 17 00:00:00 2001
From: G Johansson <goran.johansson@shiftit.se>
Date: Mon, 30 Dec 2024 23:16:41 +0100
Subject: [PATCH] Explicitly set config entry in Trafikverket Weatherstation
 coordinator (#134310)

---
 .../components/trafikverket_weatherstation/__init__.py     | 2 +-
 .../components/trafikverket_weatherstation/coordinator.py  | 7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/homeassistant/components/trafikverket_weatherstation/__init__.py b/homeassistant/components/trafikverket_weatherstation/__init__.py
index e17dacfdace..8fe67b5c66a 100644
--- a/homeassistant/components/trafikverket_weatherstation/__init__.py
+++ b/homeassistant/components/trafikverket_weatherstation/__init__.py
@@ -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)
diff --git a/homeassistant/components/trafikverket_weatherstation/coordinator.py b/homeassistant/components/trafikverket_weatherstation/coordinator.py
index 22ecf6fc1b5..33f09c0ffe2 100644
--- a/homeassistant/components/trafikverket_weatherstation/coordinator.py
+++ b/homeassistant/components/trafikverket_weatherstation/coordinator.py
@@ -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."""
-- 
GitLab