Explicitly pass in the config_entry in aurora_abb_powerone coordinator init (#137715)

This commit is contained in:
Michael 2025-02-07 22:16:09 +01:00 committed by GitHub
parent b9a3cab4b4
commit 292409f1d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 3 deletions

View File

@ -23,7 +23,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: AuroraAbbConfigEntry) ->
comport = entry.data[CONF_PORT]
address = entry.data[CONF_ADDRESS]
coordinator = AuroraAbbDataUpdateCoordinator(hass, comport, address)
coordinator = AuroraAbbDataUpdateCoordinator(hass, entry, comport, address)
await coordinator.async_config_entry_first_refresh()
entry.runtime_data = coordinator

View File

@ -21,12 +21,26 @@ type AuroraAbbConfigEntry = ConfigEntry[AuroraAbbDataUpdateCoordinator]
class AuroraAbbDataUpdateCoordinator(DataUpdateCoordinator[dict[str, float]]):
"""Class to manage fetching AuroraAbbPowerone data."""
def __init__(self, hass: HomeAssistant, comport: str, address: int) -> None:
config_entry: AuroraAbbConfigEntry
def __init__(
self,
hass: HomeAssistant,
config_entry: AuroraAbbConfigEntry,
comport: str,
address: int,
) -> None:
"""Initialize the data update coordinator."""
self.available_prev = False
self.available = False
self.client = AuroraSerialClient(address, comport, parity="N", timeout=1)
super().__init__(hass, _LOGGER, name=DOMAIN, update_interval=SCAN_INTERVAL)
super().__init__(
hass,
_LOGGER,
config_entry=config_entry,
name=DOMAIN,
update_interval=SCAN_INTERVAL,
)
def _update_data(self) -> dict[str, float]:
"""Fetch new state data for the sensors.