Explicitly pass in the config_entry in opower coordinator (#138048)

explicitly pass in the config_entry in coordinator
This commit is contained in:
Michael 2025-02-09 16:33:51 +01:00 committed by GitHub
parent 8241429c5e
commit 020e8fe939
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 8 deletions

View File

@ -13,7 +13,7 @@ PLATFORMS: list[Platform] = [Platform.SENSOR]
async def async_setup_entry(hass: HomeAssistant, entry: OpowerConfigEntry) -> bool:
"""Set up Opower from a config entry."""
coordinator = OpowerCoordinator(hass, entry.data)
coordinator = OpowerCoordinator(hass, entry)
await coordinator.async_config_entry_first_refresh()
entry.runtime_data = coordinator

View File

@ -2,8 +2,7 @@
from datetime import datetime, timedelta
import logging
from types import MappingProxyType
from typing import Any, cast
from typing import cast
from opower import (
Account,
@ -46,12 +45,13 @@ class OpowerCoordinator(DataUpdateCoordinator[dict[str, Forecast]]):
def __init__(
self,
hass: HomeAssistant,
entry_data: MappingProxyType[str, Any],
config_entry: OpowerConfigEntry,
) -> None:
"""Initialize the data handler."""
super().__init__(
hass,
_LOGGER,
config_entry=config_entry,
name="Opower",
# Data is updated daily on Opower.
# Refresh every 12h to be at most 12h behind.
@ -59,10 +59,10 @@ class OpowerCoordinator(DataUpdateCoordinator[dict[str, Forecast]]):
)
self.api = Opower(
aiohttp_client.async_get_clientsession(hass),
entry_data[CONF_UTILITY],
entry_data[CONF_USERNAME],
entry_data[CONF_PASSWORD],
entry_data.get(CONF_TOTP_SECRET),
config_entry.data[CONF_UTILITY],
config_entry.data[CONF_USERNAME],
config_entry.data[CONF_PASSWORD],
config_entry.data.get(CONF_TOTP_SECRET),
)
self._statistic_ids: set[str] = set()