Migrate zwave_js to use async_unload_platforms (#118101)

This commit is contained in:
J. Nick Koston 2024-05-24 23:54:25 -10:00 committed by GitHub
parent 2954cba65d
commit b58e0331cf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,7 +4,6 @@ from __future__ import annotations
import asyncio
from collections import defaultdict
from collections.abc import Coroutine
from contextlib import suppress
import logging
from typing import Any
@ -958,14 +957,12 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
client: ZwaveClient = entry.runtime_data[DATA_CLIENT]
driver_events: DriverEvents = entry.runtime_data[DATA_DRIVER_EVENTS]
tasks: list[Coroutine] = [
hass.config_entries.async_forward_entry_unload(entry, platform)
platforms = [
platform
for platform, task in driver_events.platform_setup_tasks.items()
if not task.cancel()
]
unload_ok = all(await asyncio.gather(*tasks)) if tasks else True
unload_ok = await hass.config_entries.async_unload_platforms(entry, platforms)
if client.connected and client.driver:
await async_disable_server_logging_if_needed(hass, entry, client.driver)