mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Explicitly pass in the config_entry in refoss coordinator (#137978)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
4706beb6ef
commit
2418ef8e8e
@ -24,7 +24,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Set up Refoss from a config entry."""
|
||||
hass.data.setdefault(DOMAIN, {})
|
||||
discover = await refoss_discovery_server(hass)
|
||||
refoss_discovery = DiscoveryService(hass, discover)
|
||||
refoss_discovery = DiscoveryService(hass, entry, discover)
|
||||
hass.data[DOMAIN][DATA_DISCOVERY_SERVICE] = refoss_discovery
|
||||
|
||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||
|
@ -6,6 +6,7 @@ from refoss_ha.device import DeviceInfo
|
||||
from refoss_ha.device_manager import async_build_base_device
|
||||
from refoss_ha.discovery import Discovery, Listener
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
|
||||
@ -16,9 +17,12 @@ from .coordinator import RefossDataUpdateCoordinator
|
||||
class DiscoveryService(Listener):
|
||||
"""Discovery event handler for refoss devices."""
|
||||
|
||||
def __init__(self, hass: HomeAssistant, discovery: Discovery) -> None:
|
||||
def __init__(
|
||||
self, hass: HomeAssistant, config_entry: ConfigEntry, discovery: Discovery
|
||||
) -> None:
|
||||
"""Init discovery service."""
|
||||
self.hass = hass
|
||||
self.config_entry = config_entry
|
||||
|
||||
self.discovery = discovery
|
||||
self.discovery.add_listener(self)
|
||||
@ -32,7 +36,7 @@ class DiscoveryService(Listener):
|
||||
if device is None:
|
||||
return
|
||||
|
||||
coordo = RefossDataUpdateCoordinator(self.hass, device)
|
||||
coordo = RefossDataUpdateCoordinator(self.hass, self.config_entry, device)
|
||||
self.hass.data[DOMAIN][COORDINATORS].append(coordo)
|
||||
await coordo.async_refresh()
|
||||
|
||||
|
@ -7,6 +7,7 @@ from datetime import timedelta
|
||||
from refoss_ha.controller.device import BaseDevice
|
||||
from refoss_ha.exceptions import DeviceTimeoutError
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||
|
||||
@ -16,11 +17,16 @@ from .const import _LOGGER, DOMAIN, MAX_ERRORS
|
||||
class RefossDataUpdateCoordinator(DataUpdateCoordinator[None]):
|
||||
"""Manages polling for state changes from the device."""
|
||||
|
||||
def __init__(self, hass: HomeAssistant, device: BaseDevice) -> None:
|
||||
config_entry: ConfigEntry
|
||||
|
||||
def __init__(
|
||||
self, hass: HomeAssistant, config_entry: ConfigEntry, device: BaseDevice
|
||||
) -> None:
|
||||
"""Initialize the data update coordinator."""
|
||||
super().__init__(
|
||||
hass,
|
||||
_LOGGER,
|
||||
config_entry=config_entry,
|
||||
name=f"{DOMAIN}-{device.device_info.dev_name}",
|
||||
update_interval=timedelta(seconds=15),
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user