Explicitly pass in the config_entry in opensky coordinator (#138051)

explicitly pass in the config_entry in coordinator
This commit is contained in:
Michael 2025-02-09 14:54:04 +01:00 committed by GitHub
parent 64cbf44da7
commit 9c5928c2d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 6 deletions

View File

@ -32,7 +32,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
except OpenSkyError as exc:
raise ConfigEntryNotReady from exc
coordinator = OpenSkyDataUpdateCoordinator(hass, client)
coordinator = OpenSkyDataUpdateCoordinator(hass, entry, client)
await coordinator.async_config_entry_first_refresh()
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator

View File

@ -36,11 +36,14 @@ class OpenSkyDataUpdateCoordinator(DataUpdateCoordinator[int]):
config_entry: ConfigEntry
def __init__(self, hass: HomeAssistant, opensky: OpenSky) -> None:
def __init__(
self, hass: HomeAssistant, config_entry: ConfigEntry, opensky: OpenSky
) -> None:
"""Initialize the OpenSky data coordinator."""
super().__init__(
hass,
LOGGER,
config_entry=config_entry,
name=DOMAIN,
update_interval={
True: timedelta(seconds=90),
@ -50,11 +53,11 @@ class OpenSkyDataUpdateCoordinator(DataUpdateCoordinator[int]):
self._opensky = opensky
self._previously_tracked: set[str] | None = None
self._bounding_box = OpenSky.get_bounding_box(
self.config_entry.data[CONF_LATITUDE],
self.config_entry.data[CONF_LONGITUDE],
self.config_entry.options[CONF_RADIUS],
config_entry.data[CONF_LATITUDE],
config_entry.data[CONF_LONGITUDE],
config_entry.options[CONF_RADIUS],
)
self._altitude = self.config_entry.options.get(CONF_ALTITUDE, DEFAULT_ALTITUDE)
self._altitude = config_entry.options.get(CONF_ALTITUDE, DEFAULT_ALTITUDE)
async def _async_update_data(self) -> int:
try: