From 412d9b25c24d348d553aef7ced2ca567f53c303a Mon Sep 17 00:00:00 2001 From: slyoldfox Date: Thu, 8 Aug 2024 17:05:36 +0200 Subject: [PATCH] Replace deprecated async_forward_entry_setup call (#171) Fixes #165 --- custom_components/dyson_local/__init__.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/custom_components/dyson_local/__init__.py b/custom_components/dyson_local/__init__.py index 1ec086d..21db41b 100644 --- a/custom_components/dyson_local/__init__.py +++ b/custom_components/dyson_local/__init__.py @@ -95,11 +95,8 @@ async def async_setup_account(hass: HomeAssistant, entry: ConfigEntry) -> bool: DATA_ACCOUNT: account, DATA_DEVICES: devices, } - for component in PLATFORMS: - hass.async_create_task( - hass.config_entries.async_forward_entry_setup(entry, component) - ) + await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) return True @@ -135,12 +132,6 @@ async def async_update_data(): else: coordinator = None - async def _async_forward_entry_setup(): - for component in _async_get_platforms(device): - hass.async_create_task( - hass.config_entries.async_forward_entry_setup(entry, component) - ) - def setup_entry(host: str, is_discovery: bool = True) -> bool: try: device.connect(host) @@ -156,7 +147,7 @@ def setup_entry(host: str, is_discovery: bool = True) -> bool: hass.data[DOMAIN][DATA_DEVICES][entry.entry_id] = device hass.data[DOMAIN][DATA_COORDINATORS][entry.entry_id] = coordinator asyncio.run_coroutine_threadsafe( - _async_forward_entry_setup(), hass.loop + hass.config_entries.async_forward_entry_setups(entry, _async_get_platforms(device)), hass.loop ).result() host = entry.data.get(CONF_HOST)