Explicitly pass in the config_entry in powerfox coordinator (#138037)
explicitly pass in the config_entry in coordinatorpull/137224/head
parent
cb3a7dc503
commit
f8169f1110
|
@ -6,18 +6,15 @@ import asyncio
|
|||
|
||||
from powerfox import Powerfox, PowerfoxConnectionError
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
from .coordinator import PowerfoxDataUpdateCoordinator
|
||||
from .coordinator import PowerfoxConfigEntry, PowerfoxDataUpdateCoordinator
|
||||
|
||||
PLATFORMS: list[Platform] = [Platform.SENSOR]
|
||||
|
||||
type PowerfoxConfigEntry = ConfigEntry[list[PowerfoxDataUpdateCoordinator]]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: PowerfoxConfigEntry) -> bool:
|
||||
"""Set up Powerfox from a config entry."""
|
||||
|
@ -34,7 +31,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: PowerfoxConfigEntry) ->
|
|||
raise ConfigEntryNotReady from err
|
||||
|
||||
coordinators: list[PowerfoxDataUpdateCoordinator] = [
|
||||
PowerfoxDataUpdateCoordinator(hass, client, device) for device in devices
|
||||
PowerfoxDataUpdateCoordinator(hass, entry, client, device) for device in devices
|
||||
]
|
||||
|
||||
await asyncio.gather(
|
||||
|
|
|
@ -18,15 +18,18 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, Upda
|
|||
|
||||
from .const import DOMAIN, LOGGER, SCAN_INTERVAL
|
||||
|
||||
type PowerfoxConfigEntry = ConfigEntry[list[PowerfoxDataUpdateCoordinator]]
|
||||
|
||||
|
||||
class PowerfoxDataUpdateCoordinator(DataUpdateCoordinator[Poweropti]):
|
||||
"""Class to manage fetching Powerfox data from the API."""
|
||||
|
||||
config_entry: ConfigEntry
|
||||
config_entry: PowerfoxConfigEntry
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
config_entry: PowerfoxConfigEntry,
|
||||
client: Powerfox,
|
||||
device: Device,
|
||||
) -> None:
|
||||
|
@ -34,6 +37,7 @@ class PowerfoxDataUpdateCoordinator(DataUpdateCoordinator[Poweropti]):
|
|||
super().__init__(
|
||||
hass,
|
||||
LOGGER,
|
||||
config_entry=config_entry,
|
||||
name=DOMAIN,
|
||||
update_interval=SCAN_INTERVAL,
|
||||
)
|
||||
|
|
|
@ -9,7 +9,7 @@ from powerfox import HeatMeter, PowerMeter, WaterMeter
|
|||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import PowerfoxConfigEntry, PowerfoxDataUpdateCoordinator
|
||||
from .coordinator import PowerfoxConfigEntry, PowerfoxDataUpdateCoordinator
|
||||
|
||||
|
||||
async def async_get_config_entry_diagnostics(
|
||||
|
|
|
@ -17,8 +17,7 @@ from homeassistant.const import UnitOfEnergy, UnitOfPower, UnitOfVolume
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import PowerfoxConfigEntry
|
||||
from .coordinator import PowerfoxDataUpdateCoordinator
|
||||
from .coordinator import PowerfoxConfigEntry, PowerfoxDataUpdateCoordinator
|
||||
from .entity import PowerfoxEntity
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue