Reduce config entry setup/unload boilerplate T-U (#49786)
This commit is contained in:
parent
87420627a8
commit
4b74c57285
19 changed files with 64 additions and 198 deletions
|
@ -1,5 +1,4 @@
|
|||
"""Support for the (unofficial) Tado API."""
|
||||
import asyncio
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
|
@ -85,10 +84,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||
UPDATE_LISTENER: update_listener,
|
||||
}
|
||||
|
||||
for platform in PLATFORMS:
|
||||
hass.async_create_task(
|
||||
hass.config_entries.async_forward_entry_setup(entry, platform)
|
||||
)
|
||||
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||
|
||||
return True
|
||||
|
||||
|
@ -108,14 +104,7 @@ async def _async_update_listener(hass: HomeAssistant, entry: ConfigEntry):
|
|||
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||
"""Unload a config entry."""
|
||||
unload_ok = all(
|
||||
await asyncio.gather(
|
||||
*[
|
||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
||||
for platform in PLATFORMS
|
||||
]
|
||||
)
|
||||
)
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
|
||||
hass.data[DOMAIN][entry.entry_id][UPDATE_TRACK]()
|
||||
hass.data[DOMAIN][entry.entry_id][UPDATE_LISTENER]()
|
||||
|
|
|
@ -104,14 +104,7 @@ async def async_unload_entry(hass, entry):
|
|||
"""Unload a config entry."""
|
||||
|
||||
# cleanup platforms
|
||||
unload_ok = all(
|
||||
await asyncio.gather(
|
||||
*[
|
||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
||||
for platform in PLATFORMS
|
||||
]
|
||||
)
|
||||
)
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
if not unload_ok:
|
||||
return False
|
||||
|
||||
|
|
|
@ -119,15 +119,13 @@ async def async_unload_entry(hass, config_entry):
|
|||
hass.data[NEW_CLIENT_TASK].cancel()
|
||||
interval_tracker = hass.data.pop(INTERVAL_TRACKER)
|
||||
interval_tracker()
|
||||
await asyncio.wait(
|
||||
[
|
||||
hass.config_entries.async_forward_entry_unload(config_entry, platform)
|
||||
for platform in hass.data.pop(CONFIG_ENTRY_IS_SETUP)
|
||||
]
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||
config_entry, CONFIG_ENTRY_IS_SETUP
|
||||
)
|
||||
del hass.data[DOMAIN]
|
||||
del hass.data[DATA_CONFIG_ENTRY_LOCK]
|
||||
return True
|
||||
del hass.data[CONFIG_ENTRY_IS_SETUP]
|
||||
return unload_ok
|
||||
|
||||
|
||||
class TelldusLiveClient:
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
"""Support for Tesla cars."""
|
||||
import asyncio
|
||||
from collections import defaultdict
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
@ -188,23 +187,15 @@ async def async_setup_entry(hass, config_entry):
|
|||
for device in all_devices:
|
||||
entry_data["devices"][device.hass_type].append(device)
|
||||
|
||||
for platform in PLATFORMS:
|
||||
_LOGGER.debug("Loading %s", platform)
|
||||
hass.async_create_task(
|
||||
hass.config_entries.async_forward_entry_setup(config_entry, platform)
|
||||
)
|
||||
hass.config_entries.async_setup_platforms(config_entry, PLATFORMS)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
async def async_unload_entry(hass, config_entry) -> bool:
|
||||
"""Unload a config entry."""
|
||||
unload_ok = all(
|
||||
await asyncio.gather(
|
||||
*[
|
||||
hass.config_entries.async_forward_entry_unload(config_entry, platform)
|
||||
for platform in PLATFORMS
|
||||
]
|
||||
)
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||
config_entry, PLATFORMS
|
||||
)
|
||||
for listener in hass.data[DOMAIN][config_entry.entry_id][DATA_LISTENER]:
|
||||
listener()
|
||||
|
|
|
@ -73,10 +73,7 @@ async def async_setup_entry(hass, entry):
|
|||
_LOGGER.error("Failed to login. %s", exp)
|
||||
return False
|
||||
|
||||
for platform in PLATFORMS:
|
||||
hass.async_create_task(
|
||||
hass.config_entries.async_forward_entry_setup(entry, platform)
|
||||
)
|
||||
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||
|
||||
# set up notify platform, no entry support for notify component yet,
|
||||
# have to use discovery to load platform.
|
||||
|
@ -90,17 +87,10 @@ async def async_setup_entry(hass, entry):
|
|||
|
||||
async def async_unload_entry(hass, config_entry):
|
||||
"""Unload a config entry."""
|
||||
unload_ok = all(
|
||||
await asyncio.gather(
|
||||
*[
|
||||
hass.config_entries.async_forward_entry_unload(config_entry, platform)
|
||||
for platform in PLATFORMS
|
||||
]
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||
config_entry, PLATFORMS
|
||||
)
|
||||
)
|
||||
|
||||
if unload_ok:
|
||||
tibber_connection = hass.data.get(DOMAIN)
|
||||
await tibber_connection.rt_disconnect()
|
||||
|
||||
return unload_ok
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
"""The Tile component."""
|
||||
import asyncio
|
||||
from datetime import timedelta
|
||||
from functools import partial
|
||||
|
||||
|
@ -74,25 +73,14 @@ async def async_setup_entry(hass, entry):
|
|||
|
||||
await gather_with_concurrency(DEFAULT_INIT_TASK_LIMIT, *coordinator_init_tasks)
|
||||
|
||||
for platform in PLATFORMS:
|
||||
hass.async_create_task(
|
||||
hass.config_entries.async_forward_entry_setup(entry, platform)
|
||||
)
|
||||
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
async def async_unload_entry(hass, entry):
|
||||
"""Unload a Tile config entry."""
|
||||
unload_ok = all(
|
||||
await asyncio.gather(
|
||||
*[
|
||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
||||
for platform in PLATFORMS
|
||||
]
|
||||
)
|
||||
)
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
if unload_ok:
|
||||
hass.data[DOMAIN][DATA_COORDINATOR].pop(entry.entry_id)
|
||||
|
||||
return unload_ok
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
"""Support for Toon van Eneco devices."""
|
||||
import asyncio
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
|
@ -115,10 +114,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
)
|
||||
|
||||
# Spin up the platforms
|
||||
for platform in PLATFORMS:
|
||||
hass.async_create_task(
|
||||
hass.config_entries.async_forward_entry_setup(entry, platform)
|
||||
)
|
||||
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||
|
||||
# If Home Assistant is already in a running state, register the webhook
|
||||
# immediately, else trigger it after Home Assistant has finished starting.
|
||||
|
@ -139,14 +135,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
await hass.data[DOMAIN][entry.entry_id].unregister_webhook()
|
||||
|
||||
# Unload entities for this entry/device.
|
||||
unload_ok = all(
|
||||
await asyncio.gather(
|
||||
*(
|
||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
||||
for platform in PLATFORMS
|
||||
)
|
||||
)
|
||||
)
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
|
||||
# Cleanup
|
||||
if unload_ok:
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
"""The totalconnect component."""
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
from total_connect_client import TotalConnectClient
|
||||
|
@ -58,24 +57,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||
hass.data.setdefault(DOMAIN, {})
|
||||
hass.data[DOMAIN][entry.entry_id] = client
|
||||
|
||||
for platform in PLATFORMS:
|
||||
hass.async_create_task(
|
||||
hass.config_entries.async_forward_entry_setup(entry, platform)
|
||||
)
|
||||
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
async def async_unload_entry(hass, entry: ConfigEntry):
|
||||
"""Unload a config entry."""
|
||||
unload_ok = all(
|
||||
await asyncio.gather(
|
||||
*[
|
||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
||||
for platform in PLATFORMS
|
||||
]
|
||||
)
|
||||
)
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
if unload_ok:
|
||||
hass.data[DOMAIN].pop(entry.entry_id)
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@ _LOGGER = logging.getLogger(__name__)
|
|||
|
||||
DOMAIN = "tplink"
|
||||
|
||||
PLATFORMS = [CONF_LIGHT, CONF_SWITCH]
|
||||
|
||||
TPLINK_HOST_SCHEMA = vol.Schema({vol.Required(CONF_HOST): cv.string})
|
||||
|
||||
|
||||
|
@ -109,17 +111,9 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigType):
|
|||
|
||||
async def async_unload_entry(hass, entry):
|
||||
"""Unload a config entry."""
|
||||
forward_unload = hass.config_entries.async_forward_entry_unload
|
||||
remove_lights = remove_switches = False
|
||||
if hass.data[DOMAIN][CONF_LIGHT]:
|
||||
remove_lights = await forward_unload(entry, "light")
|
||||
if hass.data[DOMAIN][CONF_SWITCH]:
|
||||
remove_switches = await forward_unload(entry, "switch")
|
||||
|
||||
if remove_lights or remove_switches:
|
||||
platforms = [platform for platform in PLATFORMS if platform in hass.data[DOMAIN]]
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(entry, platforms)
|
||||
if unload_ok:
|
||||
hass.data[DOMAIN].clear()
|
||||
return True
|
||||
|
||||
# We were not able to unload the platforms, either because there
|
||||
# were none or one of the forward_unloads failed.
|
||||
return False
|
||||
return unload_ok
|
||||
|
|
|
@ -25,6 +25,9 @@ from .const import (
|
|||
DOMAIN,
|
||||
)
|
||||
|
||||
PLATFORMS = [DEVICE_TRACKER]
|
||||
|
||||
|
||||
TRACKER_UPDATE = f"{DOMAIN}_tracker_update"
|
||||
|
||||
|
||||
|
@ -93,9 +96,7 @@ async def async_setup_entry(hass, entry):
|
|||
DOMAIN, "Traccar", entry.data[CONF_WEBHOOK_ID], handle_webhook
|
||||
)
|
||||
|
||||
hass.async_create_task(
|
||||
hass.config_entries.async_forward_entry_setup(entry, DEVICE_TRACKER)
|
||||
)
|
||||
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||
return True
|
||||
|
||||
|
||||
|
@ -103,8 +104,7 @@ async def async_unload_entry(hass, entry):
|
|||
"""Unload a config entry."""
|
||||
hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID])
|
||||
hass.data[DOMAIN]["unsub_device_tracker"].pop(entry.entry_id)()
|
||||
await hass.config_entries.async_forward_entry_unload(entry, DEVICE_TRACKER)
|
||||
return True
|
||||
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
|
||||
|
||||
async_remove_entry = config_entry_flow.webhook_async_remove_entry
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
"""Support for IKEA Tradfri."""
|
||||
import asyncio
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
|
@ -149,10 +148,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||
sw_version=gateway_info.firmware_version,
|
||||
)
|
||||
|
||||
for platform in PLATFORMS:
|
||||
hass.async_create_task(
|
||||
hass.config_entries.async_forward_entry_setup(entry, platform)
|
||||
)
|
||||
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||
|
||||
async def async_keep_alive(now):
|
||||
if hass.is_stopping:
|
||||
|
@ -172,14 +168,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||
"""Unload a config entry."""
|
||||
unload_ok = all(
|
||||
await asyncio.gather(
|
||||
*[
|
||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
||||
for platform in PLATFORMS
|
||||
]
|
||||
)
|
||||
)
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
if unload_ok:
|
||||
tradfri_data = hass.data[DOMAIN].pop(entry.entry_id)
|
||||
factory = tradfri_data[FACTORY]
|
||||
|
|
|
@ -127,8 +127,9 @@ async def async_unload_entry(hass, config_entry):
|
|||
if client.unsub_timer:
|
||||
client.unsub_timer()
|
||||
|
||||
for platform in PLATFORMS:
|
||||
await hass.config_entries.async_forward_entry_unload(config_entry, platform)
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||
config_entry, PLATFORMS
|
||||
)
|
||||
|
||||
if not hass.data[DOMAIN]:
|
||||
hass.services.async_remove(DOMAIN, SERVICE_ADD_TORRENT)
|
||||
|
@ -136,7 +137,7 @@ async def async_unload_entry(hass, config_entry):
|
|||
hass.services.async_remove(DOMAIN, SERVICE_START_TORRENT)
|
||||
hass.services.async_remove(DOMAIN, SERVICE_STOP_TORRENT)
|
||||
|
||||
return True
|
||||
return unload_ok
|
||||
|
||||
|
||||
async def get_api(hass, entry):
|
||||
|
@ -198,12 +199,7 @@ class TransmissionClient:
|
|||
self.add_options()
|
||||
self.set_scan_interval(self.config_entry.options[CONF_SCAN_INTERVAL])
|
||||
|
||||
for platform in PLATFORMS:
|
||||
self.hass.async_create_task(
|
||||
self.hass.config_entries.async_forward_entry_setup(
|
||||
self.config_entry, platform
|
||||
)
|
||||
)
|
||||
self.hass.config_entries.async_setup_platforms(self.config_entry, PLATFORMS)
|
||||
|
||||
def add_torrent(service):
|
||||
"""Add new torrent to download."""
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
"""Support for Tuya Smart devices."""
|
||||
import asyncio
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
|
@ -250,17 +249,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||
"""Unloading the Tuya platforms."""
|
||||
domain_data = hass.data[DOMAIN]
|
||||
|
||||
unload_ok = all(
|
||||
await asyncio.gather(
|
||||
*[
|
||||
hass.config_entries.async_forward_entry_unload(
|
||||
entry, platform.split(".", 1)[0]
|
||||
)
|
||||
for platform in domain_data[ENTRY_IS_SETUP]
|
||||
]
|
||||
)
|
||||
)
|
||||
platforms = [platform.split(".", 1)[0] for platform in domain_data[ENTRY_IS_SETUP]]
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(entry, platforms)
|
||||
if unload_ok:
|
||||
domain_data["listener"]()
|
||||
domain_data[STOP_CANCEL]()
|
||||
|
|
|
@ -28,6 +28,8 @@ SCAN_INTERVAL = timedelta(seconds=3600)
|
|||
SERVICE_UPDATE = "update"
|
||||
SERVICE_SCHEMA = vol.Schema({vol.Optional(CONF_ID): cv.string})
|
||||
|
||||
PLATFORMS = ["sensor"]
|
||||
|
||||
|
||||
async def _update_twentemilieu(hass: HomeAssistant, unique_id: str | None) -> None:
|
||||
"""Update Twente Milieu."""
|
||||
|
@ -71,9 +73,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
unique_id = entry.data[CONF_ID]
|
||||
hass.data.setdefault(DOMAIN, {})[unique_id] = twentemilieu
|
||||
|
||||
hass.async_create_task(
|
||||
hass.config_entries.async_forward_entry_setup(entry, "sensor")
|
||||
)
|
||||
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||
|
||||
async def _interval_update(now=None) -> None:
|
||||
"""Update Twente Milieu data."""
|
||||
|
@ -86,8 +86,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Unload Twente Milieu config entry."""
|
||||
await hass.config_entries.async_forward_entry_unload(entry, "sensor")
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
|
||||
del hass.data[DOMAIN][entry.data[CONF_ID]]
|
||||
|
||||
return True
|
||||
return unload_ok
|
||||
|
|
|
@ -8,11 +8,7 @@ from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
|||
|
||||
from .const import CONF_ENTRY_HOST, CONF_ENTRY_ID, DOMAIN
|
||||
|
||||
|
||||
async def async_setup(hass: HomeAssistant, config: dict):
|
||||
"""Set up the twinkly integration."""
|
||||
|
||||
return True
|
||||
PLATFORMS = ["light"]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
|
||||
|
@ -27,9 +23,8 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
|
|||
host, async_get_clientsession(hass)
|
||||
)
|
||||
|
||||
hass.async_create_task(
|
||||
hass.config_entries.async_forward_entry_setup(config_entry, "light")
|
||||
)
|
||||
hass.config_entries.async_setup_platforms(config_entry, PLATFORMS)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
|
|
@ -362,12 +362,7 @@ class UniFiController:
|
|||
self.wireless_clients = wireless_clients.get_data(self.config_entry)
|
||||
self.update_wireless_clients()
|
||||
|
||||
for platform in PLATFORMS:
|
||||
self.hass.async_create_task(
|
||||
self.hass.config_entries.async_forward_entry_setup(
|
||||
self.config_entry, platform
|
||||
)
|
||||
)
|
||||
self.hass.config_entries.async_setup_platforms(self.config_entry, PLATFORMS)
|
||||
|
||||
self.api.start_websocket()
|
||||
|
||||
|
@ -452,16 +447,10 @@ class UniFiController:
|
|||
"""
|
||||
self.api.stop_websocket()
|
||||
|
||||
unload_ok = all(
|
||||
await asyncio.gather(
|
||||
*[
|
||||
self.hass.config_entries.async_forward_entry_unload(
|
||||
self.config_entry, platform
|
||||
)
|
||||
for platform in PLATFORMS
|
||||
]
|
||||
)
|
||||
unload_ok = await self.hass.config_entries.async_unload_platforms(
|
||||
self.config_entry, PLATFORMS
|
||||
)
|
||||
|
||||
if not unload_ok:
|
||||
return False
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
"""Support the UPB PIM."""
|
||||
import asyncio
|
||||
|
||||
import upb_lib
|
||||
|
||||
|
@ -29,10 +28,7 @@ async def async_setup_entry(hass, config_entry):
|
|||
hass.data.setdefault(DOMAIN, {})
|
||||
hass.data[DOMAIN][config_entry.entry_id] = {"upb": upb}
|
||||
|
||||
for platform in PLATFORMS:
|
||||
hass.async_create_task(
|
||||
hass.config_entries.async_forward_entry_setup(config_entry, platform)
|
||||
)
|
||||
hass.config_entries.async_setup_platforms(config_entry, PLATFORMS)
|
||||
|
||||
def _element_changed(element, changeset):
|
||||
change = changeset.get("last_change")
|
||||
|
@ -60,21 +56,13 @@ async def async_setup_entry(hass, config_entry):
|
|||
|
||||
async def async_unload_entry(hass, config_entry):
|
||||
"""Unload the config_entry."""
|
||||
|
||||
unload_ok = all(
|
||||
await asyncio.gather(
|
||||
*[
|
||||
hass.config_entries.async_forward_entry_unload(config_entry, platform)
|
||||
for platform in PLATFORMS
|
||||
]
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||
config_entry, PLATFORMS
|
||||
)
|
||||
)
|
||||
|
||||
if unload_ok:
|
||||
upb = hass.data[DOMAIN][config_entry.entry_id]["upb"]
|
||||
upb.disconnect()
|
||||
hass.data[DOMAIN].pop(config_entry.entry_id)
|
||||
|
||||
return unload_ok
|
||||
|
||||
|
||||
|
|
|
@ -223,22 +223,20 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
|||
upcloud_data.coordinators[config_entry.data[CONF_USERNAME]] = coordinator
|
||||
|
||||
# Forward entry setup
|
||||
for domain in CONFIG_ENTRY_DOMAINS:
|
||||
hass.async_create_task(
|
||||
hass.config_entries.async_forward_entry_setup(config_entry, domain)
|
||||
)
|
||||
hass.config_entries.async_setup_platforms(config_entry, CONFIG_ENTRY_DOMAINS)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
async def async_unload_entry(hass, config_entry):
|
||||
"""Unload the config entry."""
|
||||
for domain in CONFIG_ENTRY_DOMAINS:
|
||||
await hass.config_entries.async_forward_entry_unload(config_entry, domain)
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||
config_entry, CONFIG_ENTRY_DOMAINS
|
||||
)
|
||||
|
||||
hass.data[DATA_UPCLOUD].coordinators.pop(config_entry.data[CONF_USERNAME])
|
||||
|
||||
return True
|
||||
return unload_ok
|
||||
|
||||
|
||||
class UpCloudServerEntity(CoordinatorEntity):
|
||||
|
|
|
@ -31,6 +31,8 @@ from .device import Device
|
|||
NOTIFICATION_ID = "upnp_notification"
|
||||
NOTIFICATION_TITLE = "UPnP/IGD Setup"
|
||||
|
||||
PLATFORMS = ["sensor"]
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
DOMAIN: vol.Schema(
|
||||
|
@ -144,9 +146,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
|||
|
||||
# Create sensors.
|
||||
_LOGGER.debug("Enabling sensors")
|
||||
hass.async_create_task(
|
||||
hass.config_entries.async_forward_entry_setup(config_entry, "sensor")
|
||||
)
|
||||
hass.config_entries.async_setup_platforms(config_entry, PLATFORMS)
|
||||
|
||||
# Start device updater.
|
||||
await device.async_start()
|
||||
|
@ -166,4 +166,4 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
|
|||
del hass.data[DOMAIN][DOMAIN_DEVICES][udn]
|
||||
|
||||
_LOGGER.debug("Deleting sensors")
|
||||
return await hass.config_entries.async_forward_entry_unload(config_entry, "sensor")
|
||||
return await hass.config_entries.async_unload_platforms(config_entry, PLATFORMS)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue