Explicitly pass in the config_entry in upnp coordinator (#137885)
explicitly pass in the config_entry in coordinatorpull/137992/head
parent
999badf675
commit
f643f76f1f
|
@ -8,7 +8,6 @@ from datetime import timedelta
|
|||
from async_upnp_client.exceptions import UpnpConnectionError
|
||||
|
||||
from homeassistant.components import ssdp
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
|
@ -28,7 +27,7 @@ from .const import (
|
|||
IDENTIFIER_SERIAL_NUMBER,
|
||||
LOGGER,
|
||||
)
|
||||
from .coordinator import UpnpDataUpdateCoordinator
|
||||
from .coordinator import UpnpConfigEntry, UpnpDataUpdateCoordinator
|
||||
from .device import async_create_device, get_preferred_location
|
||||
|
||||
NOTIFICATION_ID = "upnp_notification"
|
||||
|
@ -37,9 +36,6 @@ NOTIFICATION_TITLE = "UPnP/IGD Setup"
|
|||
PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR]
|
||||
|
||||
|
||||
type UpnpConfigEntry = ConfigEntry[UpnpDataUpdateCoordinator]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: UpnpConfigEntry) -> bool:
|
||||
"""Set up UPnP/IGD device from a config entry."""
|
||||
LOGGER.debug("Setting up config entry: %s", entry.entry_id)
|
||||
|
@ -176,6 +172,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: UpnpConfigEntry) -> bool
|
|||
update_interval = timedelta(seconds=DEFAULT_SCAN_INTERVAL)
|
||||
coordinator = UpnpDataUpdateCoordinator(
|
||||
hass,
|
||||
config_entry=entry,
|
||||
device=device,
|
||||
device_entry=device_entry,
|
||||
update_interval=update_interval,
|
||||
|
@ -193,7 +190,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: UpnpConfigEntry) -> bool
|
|||
return True
|
||||
|
||||
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: UpnpConfigEntry) -> bool:
|
||||
"""Unload a UPnP/IGD device from a config entry."""
|
||||
LOGGER.debug("Unloading config entry: %s", entry.entry_id)
|
||||
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
|
|
|
@ -13,8 +13,8 @@ from homeassistant.const import EntityCategory
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import UpnpConfigEntry, UpnpDataUpdateCoordinator
|
||||
from .const import LOGGER, WAN_STATUS
|
||||
from .coordinator import UpnpConfigEntry, UpnpDataUpdateCoordinator
|
||||
from .entity import UpnpEntity, UpnpEntityDescription
|
||||
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ from datetime import datetime, timedelta
|
|||
|
||||
from async_upnp_client.exceptions import UpnpCommunicationError
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.device_registry import DeviceEntry
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
@ -13,15 +14,20 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, Upda
|
|||
from .const import LOGGER
|
||||
from .device import Device
|
||||
|
||||
type UpnpConfigEntry = ConfigEntry[UpnpDataUpdateCoordinator]
|
||||
|
||||
|
||||
class UpnpDataUpdateCoordinator(
|
||||
DataUpdateCoordinator[dict[str, str | datetime | int | float | None]]
|
||||
):
|
||||
"""Define an object to update data from UPNP device."""
|
||||
|
||||
config_entry: UpnpConfigEntry
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
config_entry: UpnpConfigEntry,
|
||||
device: Device,
|
||||
device_entry: DeviceEntry,
|
||||
update_interval: timedelta,
|
||||
|
@ -34,6 +40,7 @@ class UpnpDataUpdateCoordinator(
|
|||
super().__init__(
|
||||
hass,
|
||||
LOGGER,
|
||||
config_entry=config_entry,
|
||||
name=device.name,
|
||||
update_interval=update_interval,
|
||||
)
|
||||
|
|
|
@ -20,7 +20,6 @@ from homeassistant.const import (
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import UpnpConfigEntry
|
||||
from .const import (
|
||||
BYTES_RECEIVED,
|
||||
BYTES_SENT,
|
||||
|
@ -38,6 +37,7 @@ from .const import (
|
|||
ROUTER_UPTIME,
|
||||
WAN_STATUS,
|
||||
)
|
||||
from .coordinator import UpnpConfigEntry
|
||||
from .entity import UpnpEntity, UpnpEntityDescription
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue