mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Explicitly pass in the config_entry in rympro coordinator init (#137464)
explicitly pass in the config_entry in coordinator init
This commit is contained in:
parent
db6bd6aad1
commit
2aea078d9a
@ -38,7 +38,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
data={**data, CONF_TOKEN: token},
|
||||
)
|
||||
|
||||
coordinator = RymProDataUpdateCoordinator(hass, rympro)
|
||||
coordinator = RymProDataUpdateCoordinator(hass, entry, rympro)
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
|
||||
hass.data.setdefault(DOMAIN, {})
|
||||
|
@ -7,6 +7,7 @@ import logging
|
||||
|
||||
from pyrympro import CannotConnectError, OperationError, RymPro, UnauthorizedError
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
||||
@ -20,13 +21,18 @@ _LOGGER = logging.getLogger(__name__)
|
||||
class RymProDataUpdateCoordinator(DataUpdateCoordinator[dict[int, dict]]):
|
||||
"""Class to manage fetching RYM Pro data."""
|
||||
|
||||
def __init__(self, hass: HomeAssistant, rympro: RymPro) -> None:
|
||||
config_entry: ConfigEntry
|
||||
|
||||
def __init__(
|
||||
self, hass: HomeAssistant, config_entry: ConfigEntry, rympro: RymPro
|
||||
) -> None:
|
||||
"""Initialize global RymPro data updater."""
|
||||
self.rympro = rympro
|
||||
interval = timedelta(seconds=SCAN_INTERVAL)
|
||||
super().__init__(
|
||||
hass,
|
||||
_LOGGER,
|
||||
config_entry=config_entry,
|
||||
name=DOMAIN,
|
||||
update_interval=interval,
|
||||
)
|
||||
@ -40,7 +46,6 @@ class RymProDataUpdateCoordinator(DataUpdateCoordinator[dict[int, dict]]):
|
||||
meter_id
|
||||
)
|
||||
except UnauthorizedError as error:
|
||||
assert self.config_entry
|
||||
await self.hass.config_entries.async_reload(self.config_entry.entry_id)
|
||||
raise UpdateFailed(error) from error
|
||||
except (CannotConnectError, OperationError) as error:
|
||||
|
Loading…
x
Reference in New Issue
Block a user