mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Explicitly pass in the config_entry in duke_energy coordinator (#137741)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
9e8f2e81bd
commit
ad9d43bc50
@ -10,7 +10,7 @@ from .coordinator import DukeEnergyConfigEntry, DukeEnergyCoordinator
|
|||||||
async def async_setup_entry(hass: HomeAssistant, entry: DukeEnergyConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: DukeEnergyConfigEntry) -> bool:
|
||||||
"""Set up Duke Energy from a config entry."""
|
"""Set up Duke Energy from a config entry."""
|
||||||
|
|
||||||
coordinator = DukeEnergyCoordinator(hass, entry.data)
|
coordinator = DukeEnergyCoordinator(hass, entry)
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
entry.runtime_data = coordinator
|
entry.runtime_data = coordinator
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import logging
|
import logging
|
||||||
from types import MappingProxyType
|
|
||||||
from typing import Any, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
from aiodukeenergy import DukeEnergy
|
from aiodukeenergy import DukeEnergy
|
||||||
@ -37,22 +36,21 @@ class DukeEnergyCoordinator(DataUpdateCoordinator[None]):
|
|||||||
config_entry: DukeEnergyConfigEntry
|
config_entry: DukeEnergyConfigEntry
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self, hass: HomeAssistant, config_entry: DukeEnergyConfigEntry
|
||||||
hass: HomeAssistant,
|
|
||||||
entry_data: MappingProxyType[str, Any],
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the data handler."""
|
"""Initialize the data handler."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
_LOGGER,
|
||||||
|
config_entry=config_entry,
|
||||||
name="Duke Energy",
|
name="Duke Energy",
|
||||||
# Data is updated daily on Duke Energy.
|
# Data is updated daily on Duke Energy.
|
||||||
# Refresh every 12h to be at most 12h behind.
|
# Refresh every 12h to be at most 12h behind.
|
||||||
update_interval=timedelta(hours=12),
|
update_interval=timedelta(hours=12),
|
||||||
)
|
)
|
||||||
self.api = DukeEnergy(
|
self.api = DukeEnergy(
|
||||||
entry_data[CONF_USERNAME],
|
config_entry.data[CONF_USERNAME],
|
||||||
entry_data[CONF_PASSWORD],
|
config_entry.data[CONF_PASSWORD],
|
||||||
async_get_clientsession(hass),
|
async_get_clientsession(hass),
|
||||||
)
|
)
|
||||||
self._statistic_ids: set = set()
|
self._statistic_ids: set = set()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user