Skip to content

Commit

Permalink
Update __init__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDescender authored and rospogrigio committed Nov 16, 2023
1 parent 914381b commit 7e3284d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions custom_components/airbnk_mqtt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,16 @@ async def async_options_updated(hass, entry):
async def async_unload_entry(hass, config_entry):
"""Unload a config entry."""
_LOGGER.debug("Unloading %s %s", config_entry.entry_id, config_entry.data)
await asyncio.wait(asyncio.create_task(
[
hass.config_entries.async_forward_entry_unload(config_entry, component)
for component in COMPONENT_TYPES
]
))

# Create a list of coroutines to be awaited
tasks = [
hass.config_entries.async_forward_entry_unload(config_entry, component)
for component in COMPONENT_TYPES
]

# Await each coroutine individually
await asyncio.gather(*tasks)

for dev_id, device in hass.data[DOMAIN][AIRBNK_DEVICES].items():
_LOGGER.debug("Unsubscribing %s", dev_id)
await device.mqtt_unsubscribe()
Expand Down

0 comments on commit 7e3284d

Please sign in to comment.