mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
Migrate zwave_js to use async_unload_platforms (#118101)
This commit is contained in:
parent
2954cba65d
commit
b58e0331cf
@ -4,7 +4,6 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from collections.abc import Coroutine
|
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
@ -958,14 +957,12 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
client: ZwaveClient = entry.runtime_data[DATA_CLIENT]
|
client: ZwaveClient = entry.runtime_data[DATA_CLIENT]
|
||||||
driver_events: DriverEvents = entry.runtime_data[DATA_DRIVER_EVENTS]
|
driver_events: DriverEvents = entry.runtime_data[DATA_DRIVER_EVENTS]
|
||||||
|
platforms = [
|
||||||
tasks: list[Coroutine] = [
|
platform
|
||||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
|
||||||
for platform, task in driver_events.platform_setup_tasks.items()
|
for platform, task in driver_events.platform_setup_tasks.items()
|
||||||
if not task.cancel()
|
if not task.cancel()
|
||||||
]
|
]
|
||||||
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, platforms)
|
||||||
unload_ok = all(await asyncio.gather(*tasks)) if tasks else True
|
|
||||||
|
|
||||||
if client.connected and client.driver:
|
if client.connected and client.driver:
|
||||||
await async_disable_server_logging_if_needed(hass, entry, client.driver)
|
await async_disable_server_logging_if_needed(hass, entry, client.driver)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user