mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +00:00
Explicitly pass in the config_entry in openexchangerates coordinator (#138053)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
62f9d9e6d3
commit
28f83cefda
@ -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)
|
update_interval = BASE_UPDATE_INTERVAL * (len(existing_coordinator_for_api_key) + 1)
|
||||||
coordinator = OpenexchangeratesCoordinator(
|
coordinator = OpenexchangeratesCoordinator(
|
||||||
hass,
|
hass,
|
||||||
|
entry,
|
||||||
async_get_clientsession(hass),
|
async_get_clientsession(hass),
|
||||||
api_key,
|
api_key,
|
||||||
base,
|
base,
|
||||||
|
@ -13,6 +13,7 @@ from aioopenexchangerates import (
|
|||||||
OpenExchangeRatesClientError,
|
OpenExchangeRatesClientError,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||||
@ -23,9 +24,12 @@ from .const import CLIENT_TIMEOUT, DOMAIN, LOGGER
|
|||||||
class OpenexchangeratesCoordinator(DataUpdateCoordinator[Latest]):
|
class OpenexchangeratesCoordinator(DataUpdateCoordinator[Latest]):
|
||||||
"""Represent a coordinator for Open Exchange Rates API."""
|
"""Represent a coordinator for Open Exchange Rates API."""
|
||||||
|
|
||||||
|
config_entry: ConfigEntry
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
session: ClientSession,
|
session: ClientSession,
|
||||||
api_key: str,
|
api_key: str,
|
||||||
base: str,
|
base: str,
|
||||||
@ -33,7 +37,11 @@ class OpenexchangeratesCoordinator(DataUpdateCoordinator[Latest]):
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the coordinator."""
|
"""Initialize the coordinator."""
|
||||||
super().__init__(
|
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.base = base
|
||||||
self.client = Client(api_key, session)
|
self.client = Client(api_key, session)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user