Explicitly pass in the config_entry in openexchangerates coordinator (#138053)

explicitly pass in the config_entry in coordinator
This commit is contained in:
Michael 2025-02-09 13:55:55 +01:00 committed by GitHub
parent 62f9d9e6d3
commit 28f83cefda
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -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,

View File

@ -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)