Explicitly pass in the config_entry in srp_energy coordinator (#137933)
explicitly pass in the config_entry in coordinatorpull/138061/head
parent
9c5928c2d0
commit
51d3e449ab
|
@ -6,7 +6,7 @@ from homeassistant.config_entries import ConfigEntry
|
|||
from homeassistant.const import CONF_ID, CONF_PASSWORD, CONF_USERNAME, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .const import CONF_IS_TOU, DOMAIN, LOGGER
|
||||
from .const import DOMAIN, LOGGER
|
||||
from .coordinator import SRPEnergyDataUpdateCoordinator
|
||||
|
||||
PLATFORMS = [Platform.SENSOR]
|
||||
|
@ -26,9 +26,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
api_password,
|
||||
)
|
||||
|
||||
coordinator = SRPEnergyDataUpdateCoordinator(
|
||||
hass, api_instance, entry.data[CONF_IS_TOU]
|
||||
)
|
||||
coordinator = SRPEnergyDataUpdateCoordinator(hass, entry, api_instance)
|
||||
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
|
||||
|
|
|
@ -12,7 +12,13 @@ from homeassistant.core import HomeAssistant
|
|||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from .const import DOMAIN, LOGGER, MIN_TIME_BETWEEN_UPDATES, PHOENIX_TIME_ZONE
|
||||
from .const import (
|
||||
CONF_IS_TOU,
|
||||
DOMAIN,
|
||||
LOGGER,
|
||||
MIN_TIME_BETWEEN_UPDATES,
|
||||
PHOENIX_TIME_ZONE,
|
||||
)
|
||||
|
||||
TIMEOUT = 10
|
||||
PHOENIX_ZONE_INFO = dt_util.get_time_zone(PHOENIX_TIME_ZONE)
|
||||
|
@ -24,14 +30,15 @@ class SRPEnergyDataUpdateCoordinator(DataUpdateCoordinator[float]):
|
|||
config_entry: ConfigEntry
|
||||
|
||||
def __init__(
|
||||
self, hass: HomeAssistant, client: SrpEnergyClient, is_time_of_use: bool
|
||||
self, hass: HomeAssistant, config_entry: ConfigEntry, client: SrpEnergyClient
|
||||
) -> None:
|
||||
"""Initialize the srp_energy data coordinator."""
|
||||
self._client = client
|
||||
self._is_time_of_use = is_time_of_use
|
||||
self._is_time_of_use = config_entry.data[CONF_IS_TOU]
|
||||
super().__init__(
|
||||
hass,
|
||||
LOGGER,
|
||||
config_entry=config_entry,
|
||||
name=DOMAIN,
|
||||
update_interval=MIN_TIME_BETWEEN_UPDATES,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue