mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Migrate firmata to use async_unload_platforms (#118098)
This commit is contained in:
parent
4da125e27b
commit
204cd376cb
@ -1,6 +1,5 @@
|
||||
"""Support for Arduino-compatible Microcontrollers through Firmata."""
|
||||
|
||||
import asyncio
|
||||
from copy import copy
|
||||
import logging
|
||||
|
||||
@ -212,16 +211,15 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
||||
async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
|
||||
"""Shutdown and close a Firmata board for a config entry."""
|
||||
_LOGGER.debug("Closing Firmata board %s", config_entry.data[CONF_NAME])
|
||||
|
||||
unload_entries = []
|
||||
for conf, platform in CONF_PLATFORM_MAP.items():
|
||||
if conf in config_entry.data:
|
||||
unload_entries.append(
|
||||
hass.config_entries.async_forward_entry_unload(config_entry, platform)
|
||||
)
|
||||
results = []
|
||||
if unload_entries:
|
||||
results = await asyncio.gather(*unload_entries)
|
||||
results: list[bool] = []
|
||||
if platforms := [
|
||||
platform
|
||||
for conf, platform in CONF_PLATFORM_MAP.items()
|
||||
if conf in config_entry.data
|
||||
]:
|
||||
results.append(
|
||||
await hass.config_entries.async_unload_platforms(config_entry, platforms)
|
||||
)
|
||||
results.append(await hass.data[DOMAIN].pop(config_entry.entry_id).async_reset())
|
||||
|
||||
return False not in results
|
||||
|
Loading…
x
Reference in New Issue
Block a user