Explicitly pass in the config_entry in iometer coordinator (#138142)

explicitly pass in the config_entry in coordinator
This commit is contained in:
Michael 2025-02-09 21:13:54 +01:00 committed by GitHub
parent 8c3dab199e
commit 15af006fbe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View File

@ -26,7 +26,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: IOmeterConfigEntry) -> b
except IOmeterConnectionError as err: except IOmeterConnectionError as err:
raise ConfigEntryNotReady from err raise ConfigEntryNotReady from err
coordinator = IOMeterCoordinator(hass, client) coordinator = IOMeterCoordinator(hass, entry, client)
await coordinator.async_config_entry_first_refresh() await coordinator.async_config_entry_first_refresh()
entry.runtime_data = coordinator entry.runtime_data = coordinator
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

View File

@ -32,17 +32,23 @@ class IOMeterCoordinator(DataUpdateCoordinator[IOmeterData]):
config_entry: IOmeterConfigEntry config_entry: IOmeterConfigEntry
client: IOmeterClient client: IOmeterClient
def __init__(self, hass: HomeAssistant, client: IOmeterClient) -> None: def __init__(
self,
hass: HomeAssistant,
config_entry: IOmeterConfigEntry,
client: IOmeterClient,
) -> None:
"""Initialize coordinator.""" """Initialize coordinator."""
super().__init__( super().__init__(
hass, hass,
_LOGGER, _LOGGER,
config_entry=config_entry,
name=DOMAIN, name=DOMAIN,
update_interval=DEFAULT_SCAN_INTERVAL, update_interval=DEFAULT_SCAN_INTERVAL,
) )
self.client = client self.client = client
self.identifier = self.config_entry.entry_id self.identifier = config_entry.entry_id
async def _async_update_data(self) -> IOmeterData: async def _async_update_data(self) -> IOmeterData:
"""Update data async.""" """Update data async."""