mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Explicitly pass in the config_entry in purpleair coordinator (#138034)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
91c95efb96
commit
64cbf44da7
@ -49,16 +49,21 @@ UPDATE_INTERVAL = timedelta(minutes=2)
|
|||||||
class PurpleAirDataUpdateCoordinator(DataUpdateCoordinator[GetSensorsResponse]):
|
class PurpleAirDataUpdateCoordinator(DataUpdateCoordinator[GetSensorsResponse]):
|
||||||
"""Define a PurpleAir-specific coordinator."""
|
"""Define a PurpleAir-specific coordinator."""
|
||||||
|
|
||||||
|
config_entry: ConfigEntry
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None:
|
def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||||
"""Initialize."""
|
"""Initialize."""
|
||||||
self._entry = entry
|
|
||||||
self._api = API(
|
self._api = API(
|
||||||
entry.data[CONF_API_KEY],
|
entry.data[CONF_API_KEY],
|
||||||
session=aiohttp_client.async_get_clientsession(hass),
|
session=aiohttp_client.async_get_clientsession(hass),
|
||||||
)
|
)
|
||||||
|
|
||||||
super().__init__(
|
super().__init__(
|
||||||
hass, LOGGER, name=entry.title, update_interval=UPDATE_INTERVAL
|
hass,
|
||||||
|
LOGGER,
|
||||||
|
config_entry=entry,
|
||||||
|
name=entry.title,
|
||||||
|
update_interval=UPDATE_INTERVAL,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def _async_update_data(self) -> GetSensorsResponse:
|
async def _async_update_data(self) -> GetSensorsResponse:
|
||||||
@ -66,7 +71,7 @@ class PurpleAirDataUpdateCoordinator(DataUpdateCoordinator[GetSensorsResponse]):
|
|||||||
try:
|
try:
|
||||||
return await self._api.sensors.async_get_sensors(
|
return await self._api.sensors.async_get_sensors(
|
||||||
SENSOR_FIELDS_TO_RETRIEVE,
|
SENSOR_FIELDS_TO_RETRIEVE,
|
||||||
sensor_indices=self._entry.options[CONF_SENSOR_INDICES],
|
sensor_indices=self.config_entry.options[CONF_SENSOR_INDICES],
|
||||||
)
|
)
|
||||||
except InvalidApiKeyError as err:
|
except InvalidApiKeyError as err:
|
||||||
raise ConfigEntryAuthFailed("Invalid API key") from err
|
raise ConfigEntryAuthFailed("Invalid API key") from err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user