Migrate vera to use async_unload_platforms (#118099)

This commit is contained in:
J. Nick Koston 2024-05-24 23:48:55 -10:00 committed by GitHub
parent 204cd376cb
commit 131c1807c4
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 import asyncio
from collections import defaultdict from collections import defaultdict
from collections.abc import Awaitable
import logging import logging
from typing import Any from typing import Any
@ -157,16 +156,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
"""Unload Withings config entry.""" """Unload vera config entry."""
controller_data: ControllerData = get_controller_data(hass, config_entry) controller_data: ControllerData = get_controller_data(hass, config_entry)
await asyncio.gather(
tasks: list[Awaitable] = [ *(
hass.config_entries.async_forward_entry_unload(config_entry, platform) hass.config_entries.async_unload_platforms(
for platform in get_configured_platforms(controller_data) config_entry, get_configured_platforms(controller_data)
] ),
tasks.append(hass.async_add_executor_job(controller_data.controller.stop)) hass.async_add_executor_job(controller_data.controller.stop),
await asyncio.gather(*tasks) )
)
return True return True