mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
Explicitly pass in the config_entry in opower coordinator (#138048)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
8241429c5e
commit
020e8fe939
@ -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
|
||||
|
||||
|
@ -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()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user