Skip to content

Commit

Permalink
feat: use async_forward_entry_setups for loading platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
mukaschultze committed Nov 2, 2024
1 parent 7fa4be3 commit 361bb3d
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions custom_components/must_inverter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):

hass.data[DOMAIN][entry.entry_id] = inverter

for component in PLATFORMS:
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component)
)
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

return True
except ConfigEntryNotReady as ex:
Expand All @@ -51,15 +48,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
raise ConfigEntryNotReady(f"Unknown error connecting to modbus device") from ex

async def async_unload_entry(hass, entry):
"""Unload a config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, component)
for component in PLATFORMS
]
)
)
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)

if not unload_ok:
return False
Expand Down

0 comments on commit 361bb3d

Please sign in to comment.