diff --git a/homeassistant/components/rachio/__init__.py b/homeassistant/components/rachio/__init__.py index 0335bd9928c..3f75537cc8d 100644 --- a/homeassistant/components/rachio/__init__.py +++ b/homeassistant/components/rachio/__init__.py @@ -1,5 +1,4 @@ """Integration with the Rachio Iro sprinkler system controller.""" -import asyncio import logging import secrets @@ -28,18 +27,9 @@ CONFIG_SCHEMA = cv.deprecated(DOMAIN) 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: hass.data[DOMAIN].pop(entry.entry_id) - return unload_ok @@ -96,9 +86,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): hass.data[DOMAIN][entry.entry_id] = person async_register_webhook(hass, webhook_id, entry.entry_id) - 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 diff --git a/homeassistant/components/rainmachine/__init__.py b/homeassistant/components/rainmachine/__init__.py index e71e8a1f6d2..4e709e319f6 100644 --- a/homeassistant/components/rainmachine/__init__.py +++ b/homeassistant/components/rainmachine/__init__.py @@ -155,10 +155,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: await asyncio.gather(*controller_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) hass.data[DOMAIN][DATA_LISTENER] = entry.add_update_listener(async_reload_entry) @@ -167,14 +164,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload an RainMachine 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) cancel_listener = hass.data[DOMAIN][DATA_LISTENER].pop(entry.entry_id) diff --git a/homeassistant/components/recollect_waste/__init__.py b/homeassistant/components/recollect_waste/__init__.py index 2e6f780c749..f061532c3d1 100644 --- a/homeassistant/components/recollect_waste/__init__.py +++ b/homeassistant/components/recollect_waste/__init__.py @@ -1,7 +1,6 @@ """The ReCollect Waste integration.""" from __future__ import annotations -import asyncio from datetime import date, timedelta from aiorecollect.client import Client, PickupEvent @@ -58,10 +57,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: hass.data[DOMAIN][DATA_COORDINATOR][entry.entry_id] = coordinator - 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) hass.data[DOMAIN][DATA_LISTENER][entry.entry_id] = entry.add_update_listener( async_reload_entry @@ -77,14 +73,7 @@ async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry): async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload an RainMachine 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) cancel_listener = hass.data[DOMAIN][DATA_LISTENER].pop(entry.entry_id) diff --git a/homeassistant/components/rfxtrx/__init__.py b/homeassistant/components/rfxtrx/__init__.py index d23a3e4e6ff..a4be36df998 100644 --- a/homeassistant/components/rfxtrx/__init__.py +++ b/homeassistant/components/rfxtrx/__init__.py @@ -202,24 +202,14 @@ async def async_setup_entry(hass, entry: config_entries.ConfigEntry): ) 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) return True async def async_unload_entry(hass, entry: config_entries.ConfigEntry): """Unload RFXtrx component.""" - if not all( - await asyncio.gather( - *[ - hass.config_entries.async_forward_entry_unload(entry, platform) - for platform in PLATFORMS - ] - ) - ): + if not await hass.config_entries.async_unload_platforms(entry, PLATFORMS): return False hass.services.async_remove(DOMAIN, SERVICE_SEND) diff --git a/homeassistant/components/ring/__init__.py b/homeassistant/components/ring/__init__.py index f5211ac54c0..a0d07d0a878 100644 --- a/homeassistant/components/ring/__init__.py +++ b/homeassistant/components/ring/__init__.py @@ -100,10 +100,7 @@ async def async_setup_entry(hass, entry): ), } - 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 hass.services.has_service(DOMAIN, "update"): return True @@ -124,15 +121,7 @@ async def async_setup_entry(hass, entry): async def async_unload_entry(hass, entry): """Unload Ring entry.""" - unload_ok = all( - await asyncio.gather( - *[ - hass.config_entries.async_forward_entry_unload(entry, platform) - for platform in PLATFORMS - ] - ) - ) - if not unload_ok: + if not await hass.config_entries.async_unload_platforms(entry, PLATFORMS): return False hass.data[DOMAIN].pop(entry.entry_id) diff --git a/homeassistant/components/risco/__init__.py b/homeassistant/components/risco/__init__.py index 3a39bbb00f3..48c50f9cc46 100644 --- a/homeassistant/components/risco/__init__.py +++ b/homeassistant/components/risco/__init__.py @@ -71,15 +71,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: hass.data[DOMAIN][entry.entry_id][UNDO_UPDATE_LISTENER]() hass.data[DOMAIN].pop(entry.entry_id) diff --git a/homeassistant/components/rituals_perfume_genie/__init__.py b/homeassistant/components/rituals_perfume_genie/__init__.py index 3cc5c29d369..7b1a4ae7d1c 100644 --- a/homeassistant/components/rituals_perfume_genie/__init__.py +++ b/homeassistant/components/rituals_perfume_genie/__init__.py @@ -1,5 +1,4 @@ """The Rituals Perfume Genie integration.""" -import asyncio from datetime import timedelta import logging @@ -48,24 +47,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): hass.data[DOMAIN][entry.entry_id][DEVICES][hublot] = device hass.data[DOMAIN][entry.entry_id][COORDINATORS][hublot] = coordinator - 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: 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: hass.data[DOMAIN].pop(entry.entry_id) diff --git a/homeassistant/components/roku/__init__.py b/homeassistant/components/roku/__init__.py index d7bf3059374..72ecd0a8d05 100644 --- a/homeassistant/components/roku/__init__.py +++ b/homeassistant/components/roku/__init__.py @@ -1,7 +1,6 @@ """Support for Roku.""" from __future__ import annotations -import asyncio from datetime import timedelta import logging from typing import Any @@ -49,28 +48,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: await coordinator.async_config_entry_first_refresh() - 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: HomeAssistant, entry: ConfigEntry) -> bool: """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) - return unload_ok diff --git a/homeassistant/components/roomba/__init__.py b/homeassistant/components/roomba/__init__.py index aa7c06d23a0..3936d3f6d1d 100644 --- a/homeassistant/components/roomba/__init__.py +++ b/homeassistant/components/roomba/__init__.py @@ -68,10 +68,7 @@ async def async_setup_entry(hass, config_entry): CANCEL_STOP: cancel_stop, } - 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) if not config_entry.update_listeners: config_entry.add_update_listener(async_update_options) @@ -119,13 +116,8 @@ async def async_update_options(hass, config_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: domain_data = hass.data[DOMAIN][config_entry.entry_id] diff --git a/homeassistant/components/rpi_power/__init__.py b/homeassistant/components/rpi_power/__init__.py index 3f9a9d6e74c..305ad7d1f62 100644 --- a/homeassistant/components/rpi_power/__init__.py +++ b/homeassistant/components/rpi_power/__init__.py @@ -2,15 +2,15 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant +PLATFORMS = ["binary_sensor"] + async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up Raspberry Pi Power Supply Checker from a config entry.""" - hass.async_create_task( - hass.config_entries.async_forward_entry_setup(entry, "binary_sensor") - ) + hass.config_entries.async_setup_platforms(entry, PLATFORMS) return True async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): """Unload a config entry.""" - return await hass.config_entries.async_forward_entry_unload(entry, "binary_sensor") + return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) diff --git a/homeassistant/components/ruckus_unleashed/__init__.py b/homeassistant/components/ruckus_unleashed/__init__.py index 78d15f24a63..6ea3b736dcd 100644 --- a/homeassistant/components/ruckus_unleashed/__init__.py +++ b/homeassistant/components/ruckus_unleashed/__init__.py @@ -1,5 +1,4 @@ """The Ruckus Unleashed integration.""" -import asyncio from pyruckus import Ruckus @@ -64,24 +63,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: UNDO_UPDATE_LISTENERS: [], } - 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: HomeAssistant, entry: ConfigEntry) -> bool: """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: for listener in hass.data[DOMAIN][entry.entry_id][UNDO_UPDATE_LISTENERS]: listener() diff --git a/homeassistant/components/screenlogic/__init__.py b/homeassistant/components/screenlogic/__init__.py index 6fa19582a46..30f544303cd 100644 --- a/homeassistant/components/screenlogic/__init__.py +++ b/homeassistant/components/screenlogic/__init__.py @@ -77,24 +77,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): "listener": entry.add_update_listener(async_update_listener), } - for component in PLATFORMS: - hass.async_create_task( - hass.config_entries.async_forward_entry_setup(entry, component) - ) + hass.config_entries.async_setup_platforms(entry, PLATFORMS) return True 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, component) - for component in PLATFORMS - ] - ) - ) + unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) hass.data[DOMAIN][entry.entry_id]["listener"]() if unload_ok: hass.data[DOMAIN].pop(entry.entry_id) diff --git a/homeassistant/components/sense/__init__.py b/homeassistant/components/sense/__init__.py index ee466c813f5..162b7cd75cf 100644 --- a/homeassistant/components/sense/__init__.py +++ b/homeassistant/components/sense/__init__.py @@ -1,5 +1,4 @@ """Support for monitoring a Sense energy sensor.""" -import asyncio from datetime import timedelta import logging @@ -146,10 +145,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): SENSE_DISCOVERED_DEVICES_DATA: sense_discovered_devices, } - 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_sense_update(_): """Retrieve latest state.""" @@ -181,14 +177,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) data = hass.data[DOMAIN][entry.entry_id] data[EVENT_STOP_REMOVE]() data[TRACK_TIME_REMOVE]() diff --git a/homeassistant/components/sharkiq/__init__.py b/homeassistant/components/sharkiq/__init__.py index 02e1bba8511..ed5c7ae1b54 100644 --- a/homeassistant/components/sharkiq/__init__.py +++ b/homeassistant/components/sharkiq/__init__.py @@ -63,10 +63,7 @@ async def async_setup_entry(hass, config_entry): hass.data.setdefault(DOMAIN, {}) hass.data[DOMAIN][config_entry.entry_id] = coordinator - 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) return True @@ -87,13 +84,8 @@ async def async_update_options(hass, config_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: domain_data = hass.data[DOMAIN][config_entry.entry_id] diff --git a/homeassistant/components/shelly/__init__.py b/homeassistant/components/shelly/__init__.py index 1e68ca78409..29eb07b3a90 100644 --- a/homeassistant/components/shelly/__init__.py +++ b/homeassistant/components/shelly/__init__.py @@ -137,10 +137,7 @@ async def async_device_setup( ] = ShellyDeviceRestWrapper(hass, device) platforms = 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) class ShellyDeviceWrapper(update_coordinator.DataUpdateCoordinator): @@ -334,14 +331,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): hass.data[DOMAIN][DATA_CONFIG_ENTRY][entry.entry_id][REST] = None platforms = 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 unload_ok: hass.data[DOMAIN][DATA_CONFIG_ENTRY][entry.entry_id][COAP].shutdown() hass.data[DOMAIN][DATA_CONFIG_ENTRY].pop(entry.entry_id) diff --git a/homeassistant/components/simplisafe/__init__.py b/homeassistant/components/simplisafe/__init__.py index 12c27c3c63c..9997b86c288 100644 --- a/homeassistant/components/simplisafe/__init__.py +++ b/homeassistant/components/simplisafe/__init__.py @@ -224,10 +224,7 @@ async def async_setup_entry(hass, config_entry): # noqa: C901 ) await simplisafe.async_init() - 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) @callback def verify_system_exists(coro): @@ -329,14 +326,7 @@ async def async_setup_entry(hass, config_entry): # noqa: C901 async def async_unload_entry(hass, entry): """Unload a SimpliSafe 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_CLIENT].pop(entry.entry_id) for remove_listener in hass.data[DOMAIN][DATA_LISTENER].pop(entry.entry_id): diff --git a/homeassistant/components/sma/__init__.py b/homeassistant/components/sma/__init__.py index 6ca5fe712b7..ef948440a17 100644 --- a/homeassistant/components/sma/__init__.py +++ b/homeassistant/components/sma/__init__.py @@ -1,7 +1,6 @@ """The sma integration.""" from __future__ import annotations -import asyncio from datetime import timedelta import logging @@ -187,24 +186,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: PYSMA_REMOVE_LISTENER: remove_stop_listener, } - for component in PLATFORMS: - hass.async_create_task( - hass.config_entries.async_forward_entry_setup(entry, component) - ) + hass.config_entries.async_setup_platforms(entry, PLATFORMS) return True async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload a config entry.""" - unload_ok = all( - await asyncio.gather( - *[ - hass.config_entries.async_forward_entry_unload(entry, component) - for component in PLATFORMS - ] - ) - ) + unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) if unload_ok: data = hass.data[DOMAIN].pop(entry.entry_id) await data[PYSMA_OBJECT].close_session() diff --git a/homeassistant/components/smappee/__init__.py b/homeassistant/components/smappee/__init__.py index 9c867b7d17f..3386f7340eb 100644 --- a/homeassistant/components/smappee/__init__.py +++ b/homeassistant/components/smappee/__init__.py @@ -1,5 +1,4 @@ """The Smappee integration.""" -import asyncio from pysmappee import Smappee, helper, mqtt import voluptuous as vol @@ -105,28 +104,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): hass.data[DOMAIN][entry.entry_id] = SmappeeBase(hass, smappee) - 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: 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: hass.data[DOMAIN].pop(entry.entry_id, None) - return unload_ok diff --git a/homeassistant/components/smart_meter_texas/__init__.py b/homeassistant/components/smart_meter_texas/__init__.py index 71504fb52aa..1fc3eb218a7 100644 --- a/homeassistant/components/smart_meter_texas/__init__.py +++ b/homeassistant/components/smart_meter_texas/__init__.py @@ -78,10 +78,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): asyncio.create_task(coordinator.async_refresh()) - 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 @@ -114,14 +111,7 @@ class SmartMeterTexasData: 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: hass.data[DOMAIN].pop(entry.entry_id) diff --git a/homeassistant/components/smarthab/__init__.py b/homeassistant/components/smarthab/__init__.py index ba6e7a5e5e7..7759d038224 100644 --- a/homeassistant/components/smarthab/__init__.py +++ b/homeassistant/components/smarthab/__init__.py @@ -1,5 +1,4 @@ """Support for SmartHab device integration.""" -import asyncio import logging import pysmarthab @@ -69,27 +68,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): # Pass hub object to child platforms hass.data[DOMAIN][entry.entry_id] = {DATA_HUB: hub} - 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: HomeAssistant, entry: ConfigEntry): """Unload config entry from SmartHab integration.""" - - result = all( - await asyncio.gather( - *[ - hass.config_entries.async_forward_entry_unload(entry, platform) - for platform in PLATFORMS - ] - ) - ) - - if result: + unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) + if unload_ok: hass.data[DOMAIN].pop(entry.entry_id) - - return result + return unload_ok diff --git a/homeassistant/components/smartthings/__init__.py b/homeassistant/components/smartthings/__init__.py index d9a96301e66..00ea0eb681e 100644 --- a/homeassistant/components/smartthings/__init__.py +++ b/homeassistant/components/smartthings/__init__.py @@ -189,10 +189,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): ) 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) return True @@ -217,11 +214,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): if broker: broker.disconnect() - tasks = [ - hass.config_entries.async_forward_entry_unload(entry, platform) - for platform in PLATFORMS - ] - return all(await asyncio.gather(*tasks)) + return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) async def async_remove_entry(hass: HomeAssistant, entry: ConfigEntry) -> None: diff --git a/homeassistant/components/smarttub/__init__.py b/homeassistant/components/smarttub/__init__.py index c907bfdeae3..a396b50840d 100644 --- a/homeassistant/components/smarttub/__init__.py +++ b/homeassistant/components/smarttub/__init__.py @@ -1,5 +1,4 @@ """SmartTub integration.""" -import asyncio import logging from .const import DOMAIN, SMARTTUB_CONTROLLER @@ -22,26 +21,14 @@ async def async_setup_entry(hass, entry): if not await controller.async_setup_entry(entry): 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) return True async def async_unload_entry(hass, entry): """Remove a smarttub config entry.""" - if not all( - await asyncio.gather( - *[ - hass.config_entries.async_forward_entry_unload(entry, platform) - for platform in PLATFORMS - ] - ) - ): - return False - - hass.data[DOMAIN].pop(entry.entry_id) - - return True + unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) + if unload_ok: + hass.data[DOMAIN].pop(entry.entry_id) + return unload_ok diff --git a/homeassistant/components/smhi/__init__.py b/homeassistant/components/smhi/__init__.py index 84151bd35ee..70ee0aaa386 100644 --- a/homeassistant/components/smhi/__init__.py +++ b/homeassistant/components/smhi/__init__.py @@ -8,16 +8,15 @@ from .const import DOMAIN # noqa: F401 DEFAULT_NAME = "smhi" +PLATFORMS = ["weather"] -async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: + +async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up SMHI forecast as config entry.""" - hass.async_create_task( - hass.config_entries.async_forward_entry_setup(config_entry, "weather") - ) + hass.config_entries.async_setup_platforms(entry, PLATFORMS) return True -async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: +async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload a config entry.""" - await hass.config_entries.async_forward_entry_unload(config_entry, "weather") - return True + return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) diff --git a/homeassistant/components/sms/__init__.py b/homeassistant/components/sms/__init__.py index c4fdb38ebaa..55238c5cf39 100644 --- a/homeassistant/components/sms/__init__.py +++ b/homeassistant/components/sms/__init__.py @@ -1,5 +1,4 @@ """The sms component.""" -import asyncio import voluptuous as vol @@ -46,25 +45,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): if not gateway: return False hass.data[DOMAIN][SMS_GATEWAY] = gateway - 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: 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: gateway = hass.data[DOMAIN].pop(SMS_GATEWAY) await gateway.terminate_async() diff --git a/homeassistant/components/solarlog/__init__.py b/homeassistant/components/solarlog/__init__.py index 5db2e15f121..f48dcfc6267 100644 --- a/homeassistant/components/solarlog/__init__.py +++ b/homeassistant/components/solarlog/__init__.py @@ -2,15 +2,15 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant +PLATFORMS = ["sensor"] + async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up a config entry for solarlog.""" - hass.async_create_task( - hass.config_entries.async_forward_entry_setup(entry, "sensor") - ) + hass.config_entries.async_setup_platforms(entry, PLATFORMS) return True async def async_unload_entry(hass, entry): """Unload a config entry.""" - return await hass.config_entries.async_forward_entry_unload(entry, "sensor") + return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) diff --git a/homeassistant/components/soma/__init__.py b/homeassistant/components/soma/__init__.py index 7c4d252208a..62cdeb11f8b 100644 --- a/homeassistant/components/soma/__init__.py +++ b/homeassistant/components/soma/__init__.py @@ -1,5 +1,4 @@ """Support for Soma Smartshades.""" -import asyncio from api.soma_api import SomaApi import voluptuous as vol @@ -50,26 +49,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): devices = await hass.async_add_executor_job(hass.data[DOMAIN][API].list_devices) hass.data[DOMAIN][DEVICES] = devices["shades"] - 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: 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 - ] - ) - ) - - return unload_ok + return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) class SomaEntity(Entity): diff --git a/homeassistant/components/somfy/__init__.py b/homeassistant/components/somfy/__init__.py index 80cf20a95c4..e5c3015d2fa 100644 --- a/homeassistant/components/somfy/__init__.py +++ b/homeassistant/components/somfy/__init__.py @@ -1,6 +1,5 @@ """Support for Somfy hubs.""" from abc import abstractmethod -import asyncio from datetime import timedelta import logging @@ -135,10 +134,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): model=hub.type, ) - 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 @@ -146,13 +142,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): """Unload a config entry.""" hass.data[DOMAIN].pop(API, None) - await asyncio.gather( - *[ - hass.config_entries.async_forward_entry_unload(entry, platform) - for platform in PLATFORMS - ] - ) - return True + return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) class SomfyEntity(CoordinatorEntity, Entity): diff --git a/homeassistant/components/somfy_mylink/__init__.py b/homeassistant/components/somfy_mylink/__init__.py index 40240306dc4..dfb0220a531 100644 --- a/homeassistant/components/somfy_mylink/__init__.py +++ b/homeassistant/components/somfy_mylink/__init__.py @@ -121,10 +121,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): UNDO_UPDATE_LISTENER: undo_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 @@ -179,14 +176,7 @@ def _async_migrate_entity_config( 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][UNDO_UPDATE_LISTENER]() diff --git a/homeassistant/components/sonarr/__init__.py b/homeassistant/components/sonarr/__init__.py index 12fe47f80c7..3299842c48c 100644 --- a/homeassistant/components/sonarr/__init__.py +++ b/homeassistant/components/sonarr/__init__.py @@ -1,7 +1,6 @@ """The Sonarr component.""" from __future__ import annotations -import asyncio from datetime import timedelta import logging from typing import Any @@ -81,24 +80,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: DATA_UNDO_UPDATE_LISTENER: undo_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 async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """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][DATA_UNDO_UPDATE_LISTENER]() diff --git a/homeassistant/components/songpal/__init__.py b/homeassistant/components/songpal/__init__.py index b5d87e29c45..b542591b294 100644 --- a/homeassistant/components/songpal/__init__.py +++ b/homeassistant/components/songpal/__init__.py @@ -19,6 +19,8 @@ CONFIG_SCHEMA = vol.Schema( extra=vol.ALLOW_EXTRA, ) +PLATFORMS = ["media_player"] + async def async_setup(hass: HomeAssistant, config: OrderedDict) -> bool: """Set up songpal environment.""" @@ -38,12 +40,10 @@ async def async_setup(hass: HomeAssistant, config: OrderedDict) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up songpal media player.""" - hass.async_create_task( - hass.config_entries.async_forward_entry_setup(entry, "media_player") - ) + hass.config_entries.async_setup_platforms(entry, PLATFORMS) return True async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload songpal media player.""" - return await hass.config_entries.async_forward_entry_unload(entry, "media_player") + return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) diff --git a/homeassistant/components/speedtestdotnet/__init__.py b/homeassistant/components/speedtestdotnet/__init__.py index cb3144e266e..9c76b351f33 100644 --- a/homeassistant/components/speedtestdotnet/__init__.py +++ b/homeassistant/components/speedtestdotnet/__init__.py @@ -46,6 +46,8 @@ CONFIG_SCHEMA = vol.Schema( extra=vol.ALLOW_EXTRA, ) +PLATFORMS = ["sensor"] + def server_id_valid(server_id): """Check if server_id is valid.""" @@ -96,9 +98,7 @@ async def async_setup_entry(hass, config_entry): hass.data[DOMAIN] = coordinator - hass.async_create_task( - hass.config_entries.async_forward_entry_setup(config_entry, "sensor") - ) + hass.config_entries.async_setup_platforms(config_entry, PLATFORMS) return True @@ -109,11 +109,12 @@ async def async_unload_entry(hass, config_entry): hass.data[DOMAIN].async_unload() - await hass.config_entries.async_forward_entry_unload(config_entry, "sensor") - - hass.data.pop(DOMAIN) - - return True + unload_ok = await hass.config_entries.async_unload_platforms( + config_entry, PLATFORMS + ) + if unload_ok: + hass.data.pop(DOMAIN) + return unload_ok class SpeedTestDataCoordinator(DataUpdateCoordinator): diff --git a/homeassistant/components/spider/__init__.py b/homeassistant/components/spider/__init__.py index d9ccdfd248a..887f6471cca 100644 --- a/homeassistant/components/spider/__init__.py +++ b/homeassistant/components/spider/__init__.py @@ -1,5 +1,4 @@ """Support for Spider Smart devices.""" -import asyncio import logging from spiderpy.spiderapi import SpiderApi, SpiderApiException, UnauthorizedException @@ -66,25 +65,14 @@ async def async_setup_entry(hass, entry): hass.data[DOMAIN][entry.entry_id] = api - 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 Spider 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 not unload_ok: return False diff --git a/homeassistant/components/spotify/__init__.py b/homeassistant/components/spotify/__init__.py index c4b8e30a8ba..3aab37c9392 100644 --- a/homeassistant/components/spotify/__init__.py +++ b/homeassistant/components/spotify/__init__.py @@ -37,6 +37,8 @@ CONFIG_SCHEMA = vol.Schema( extra=vol.ALLOW_EXTRA, ) +PLATFORMS = [MEDIA_PLAYER_DOMAIN] + async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Spotify integration.""" @@ -86,20 +88,18 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: if not set(session.token["scope"].split(" ")).issuperset(SPOTIFY_SCOPES): raise ConfigEntryAuthFailed - hass.async_create_task( - hass.config_entries.async_forward_entry_setup(entry, MEDIA_PLAYER_DOMAIN) - ) + hass.config_entries.async_setup_platforms(entry, PLATFORMS) return True async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload Spotify config entry.""" # Unload entities for this entry/device. - await hass.config_entries.async_forward_entry_unload(entry, MEDIA_PLAYER_DOMAIN) + unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) # Cleanup del hass.data[DOMAIN][entry.entry_id] if not hass.data[DOMAIN]: del hass.data[DOMAIN] - return True + return unload_ok diff --git a/homeassistant/components/squeezebox/__init__.py b/homeassistant/components/squeezebox/__init__.py index f276daac56a..f680c4f5f2f 100644 --- a/homeassistant/components/squeezebox/__init__.py +++ b/homeassistant/components/squeezebox/__init__.py @@ -10,12 +10,12 @@ from .const import DISCOVERY_TASK, DOMAIN, PLAYER_DISCOVERY_UNSUB _LOGGER = logging.getLogger(__name__) +PLATFORMS = [MP_DOMAIN] + async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up Logitech Squeezebox from a config entry.""" - hass.async_create_task( - hass.config_entries.async_forward_entry_setup(entry, MP_DOMAIN) - ) + hass.config_entries.async_setup_platforms(entry, PLATFORMS) return True @@ -34,4 +34,4 @@ async def async_unload_entry(hass, entry): hass.data[DOMAIN][DISCOVERY_TASK].cancel() hass.data[DOMAIN].pop(DISCOVERY_TASK) - return await hass.config_entries.async_forward_entry_unload(entry, MP_DOMAIN) + return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) diff --git a/homeassistant/components/srp_energy/__init__.py b/homeassistant/components/srp_energy/__init__.py index b8a93ee44b0..785558ba34e 100644 --- a/homeassistant/components/srp_energy/__init__.py +++ b/homeassistant/components/srp_energy/__init__.py @@ -30,9 +30,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): _LOGGER.error("Unable to connect to Srp Energy: %s", str(ex)) raise ConfigEntryNotReady from ex - hass.async_create_task( - hass.config_entries.async_forward_entry_setup(entry, "sensor") - ) + hass.config_entries.async_setup_platforms(entry, PLATFORMS) return True @@ -42,6 +40,4 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry): # unload srp client hass.data[SRP_ENERGY_DOMAIN] = None # Remove config entry - await hass.config_entries.async_forward_entry_unload(config_entry, "sensor") - - return True + return await hass.config_entries.async_unload_platforms(config_entry, PLATFORMS) diff --git a/homeassistant/components/starline/__init__.py b/homeassistant/components/starline/__init__.py index 2eb729721d3..91edc7badeb 100644 --- a/homeassistant/components/starline/__init__.py +++ b/homeassistant/components/starline/__init__.py @@ -37,10 +37,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b config_entry_id=config_entry.entry_id, **account.device_info(device) ) - for domain in PLATFORMS: - hass.async_create_task( - hass.config_entries.async_forward_entry_setup(config_entry, domain) - ) + hass.config_entries.async_setup_platforms(config_entry, PLATFORMS) async def async_set_scan_interval(call): """Set scan interval.""" @@ -85,7 +82,9 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b ), ) - config_entry.add_update_listener(async_options_updated) + config_entry.async_on_unload( + config_entry.add_update_listener(async_options_updated) + ) await async_options_updated(hass, config_entry) return True @@ -93,12 +92,13 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Unload a config entry.""" - for domain in PLATFORMS: - await hass.config_entries.async_forward_entry_unload(config_entry, domain) + unload_ok = await hass.config_entries.async_unload_platforms( + config_entry, PLATFORMS + ) account: StarlineAccount = hass.data[DOMAIN][config_entry.entry_id] account.unload() - return True + return unload_ok async def async_options_updated(hass: HomeAssistant, config_entry: ConfigEntry) -> None: diff --git a/homeassistant/components/subaru/__init__.py b/homeassistant/components/subaru/__init__.py index 4807ca25910..94c1243b710 100644 --- a/homeassistant/components/subaru/__init__.py +++ b/homeassistant/components/subaru/__init__.py @@ -1,5 +1,4 @@ """The Subaru integration.""" -import asyncio from datetime import timedelta import logging import time @@ -89,24 +88,14 @@ async def async_setup_entry(hass, entry): ENTRY_VEHICLES: vehicle_info, } - 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: 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: hass.data[DOMAIN].pop(entry.entry_id) return unload_ok diff --git a/homeassistant/components/syncthru/__init__.py b/homeassistant/components/syncthru/__init__.py index b09f799df36..120796d935f 100644 --- a/homeassistant/components/syncthru/__init__.py +++ b/homeassistant/components/syncthru/__init__.py @@ -16,6 +16,8 @@ from .const import DOMAIN _LOGGER = logging.getLogger(__name__) +PLATFORMS = [SENSOR_DOMAIN] + async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up config entry.""" @@ -47,17 +49,15 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: name=printer.hostname(), ) - hass.async_create_task( - hass.config_entries.async_forward_entry_setup(entry, SENSOR_DOMAIN) - ) + hass.config_entries.async_setup_platforms(entry, PLATFORMS) return True async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload the config entry.""" - await hass.config_entries.async_forward_entry_unload(entry, SENSOR_DOMAIN) + unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) hass.data[DOMAIN].pop(entry.entry_id, None) - return True + return unload_ok def device_identifiers(printer: SyncThru) -> set[tuple[str, str]]: diff --git a/homeassistant/components/synology_dsm/__init__.py b/homeassistant/components/synology_dsm/__init__.py index cdfad25e972..058c810b157 100644 --- a/homeassistant/components/synology_dsm/__init__.py +++ b/homeassistant/components/synology_dsm/__init__.py @@ -1,7 +1,6 @@ """The Synology DSM component.""" from __future__ import annotations -import asyncio from datetime import timedelta import logging from typing import Any @@ -119,7 +118,7 @@ async def async_setup(hass, config): return True -async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): # noqa: C901 +async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up Synology DSM sensors.""" # Migrate old unique_id @@ -286,25 +285,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): # noqa: C update_interval=timedelta(seconds=30), ) - 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: HomeAssistant, entry: ConfigEntry): """Unload Synology DSM sensors.""" - 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: entry_data = hass.data[DOMAIN][entry.unique_id] entry_data[UNDO_UPDATE_LISTENER]() diff --git a/tests/components/smhi/test_init.py b/tests/components/smhi/test_init.py index 297a6f587d8..ac4177dca7d 100644 --- a/tests/components/smhi/test_init.py +++ b/tests/components/smhi/test_init.py @@ -19,11 +19,12 @@ async def test_forward_async_setup_entry() -> None: hass = Mock() assert await smhi.async_setup_entry(hass, {}) is True - assert len(hass.config_entries.async_forward_entry_setup.mock_calls) == 1 + assert len(hass.config_entries.async_setup_platforms.mock_calls) == 1 async def test_forward_async_unload_entry() -> None: """Test that it will forward unload entry.""" hass = AsyncMock() + hass.config_entries.async_unload_platforms = AsyncMock(return_value=True) assert await smhi.async_unload_entry(hass, {}) is True - assert len(hass.config_entries.async_forward_entry_unload.mock_calls) == 1 + assert len(hass.config_entries.async_unload_platforms.mock_calls) == 1