From 28f83cefda3d3e7d293ef066a05445618b24d85b Mon Sep 17 00:00:00 2001 From: Michael <35783820+mib1185@users.noreply.github.com> Date: Sun, 9 Feb 2025 13:55:55 +0100 Subject: [PATCH] Explicitly pass in the config_entry in openexchangerates coordinator (#138053) explicitly pass in the config_entry in coordinator --- homeassistant/components/openexchangerates/__init__.py | 1 + .../components/openexchangerates/coordinator.py | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/openexchangerates/__init__.py b/homeassistant/components/openexchangerates/__init__.py index 65005235c6b..ed704a61fed 100644 --- a/homeassistant/components/openexchangerates/__init__.py +++ b/homeassistant/components/openexchangerates/__init__.py @@ -33,6 +33,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: update_interval = BASE_UPDATE_INTERVAL * (len(existing_coordinator_for_api_key) + 1) coordinator = OpenexchangeratesCoordinator( hass, + entry, async_get_clientsession(hass), api_key, base, diff --git a/homeassistant/components/openexchangerates/coordinator.py b/homeassistant/components/openexchangerates/coordinator.py index 627e0d92e32..6245877ddbd 100644 --- a/homeassistant/components/openexchangerates/coordinator.py +++ b/homeassistant/components/openexchangerates/coordinator.py @@ -13,6 +13,7 @@ from aioopenexchangerates import ( OpenExchangeRatesClientError, ) +from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed @@ -23,9 +24,12 @@ from .const import CLIENT_TIMEOUT, DOMAIN, LOGGER class OpenexchangeratesCoordinator(DataUpdateCoordinator[Latest]): """Represent a coordinator for Open Exchange Rates API.""" + config_entry: ConfigEntry + def __init__( self, hass: HomeAssistant, + config_entry: ConfigEntry, session: ClientSession, api_key: str, base: str, @@ -33,7 +37,11 @@ class OpenexchangeratesCoordinator(DataUpdateCoordinator[Latest]): ) -> None: """Initialize the coordinator.""" super().__init__( - hass, LOGGER, name=f"{DOMAIN} base {base}", update_interval=update_interval + hass, + LOGGER, + config_entry=config_entry, + name=f"{DOMAIN} base {base}", + update_interval=update_interval, ) self.base = base self.client = Client(api_key, session)