Switch mqtt to use async_unload_platforms (#118097)

This commit is contained in:
J. Nick Koston 2024-05-24 23:55:36 -10:00 committed by GitHub
parent b58e0331cf
commit 3f76b865fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -522,24 +522,13 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
mqtt_client = mqtt_data.client
# Unload publish and dump services.
hass.services.async_remove(
DOMAIN,
SERVICE_PUBLISH,
)
hass.services.async_remove(
DOMAIN,
SERVICE_DUMP,
)
hass.services.async_remove(DOMAIN, SERVICE_PUBLISH)
hass.services.async_remove(DOMAIN, SERVICE_DUMP)
# Stop the discovery
await discovery.async_stop(hass)
# Unload the platforms
await asyncio.gather(
*(
hass.config_entries.async_forward_entry_unload(entry, component)
for component in mqtt_data.platforms_loaded
)
)
await hass.config_entries.async_unload_platforms(entry, mqtt_data.platforms_loaded)
mqtt_data.platforms_loaded = set()
await asyncio.sleep(0)
# Unsubscribe reload dispatchers