mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +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."""
|
"""Support for Arduino-compatible Microcontrollers through Firmata."""
|
||||||
|
|
||||||
import asyncio
|
|
||||||
from copy import copy
|
from copy import copy
|
||||||
import logging
|
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:
|
async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
|
||||||
"""Shutdown and close a Firmata board for a config entry."""
|
"""Shutdown and close a Firmata board for a config entry."""
|
||||||
_LOGGER.debug("Closing Firmata board %s", config_entry.data[CONF_NAME])
|
_LOGGER.debug("Closing Firmata board %s", config_entry.data[CONF_NAME])
|
||||||
|
results: list[bool] = []
|
||||||
unload_entries = []
|
if platforms := [
|
||||||
for conf, platform in CONF_PLATFORM_MAP.items():
|
platform
|
||||||
if conf in config_entry.data:
|
for conf, platform in CONF_PLATFORM_MAP.items()
|
||||||
unload_entries.append(
|
if conf in config_entry.data
|
||||||
hass.config_entries.async_forward_entry_unload(config_entry, platform)
|
]:
|
||||||
)
|
results.append(
|
||||||
results = []
|
await hass.config_entries.async_unload_platforms(config_entry, platforms)
|
||||||
if unload_entries:
|
)
|
||||||
results = await asyncio.gather(*unload_entries)
|
|
||||||
results.append(await hass.data[DOMAIN].pop(config_entry.entry_id).async_reset())
|
results.append(await hass.data[DOMAIN].pop(config_entry.entry_id).async_reset())
|
||||||
|
|
||||||
return False not in results
|
return False not in results
|
||||||
|
Loading…
x
Reference in New Issue
Block a user