Eagerly remove MQTT entities on reload (#118213)

pull/118224/head
J. Nick Koston 2024-05-26 21:55:42 -10:00 committed by GitHub
parent e6142985a5
commit cfc2cadb77
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 2 deletions

View File

@ -38,6 +38,7 @@ from homeassistant.helpers.service import async_register_admin_service
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import async_get_integration, async_get_loaded_integration
from homeassistant.setup import SetupPhases, async_pause_setup
from homeassistant.util.async_ import create_eager_task
# Loading the config flow file will register the flow
from . import debug_info, discovery
@ -393,9 +394,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
# Reload the modern yaml platforms
mqtt_platforms = async_get_platforms(hass, DOMAIN)
tasks = [
entity.async_remove()
create_eager_task(entity.async_remove())
for mqtt_platform in mqtt_platforms
for entity in mqtt_platform.entities.values()
for entity in list(mqtt_platform.entities.values())
if getattr(entity, "_discovery_data", None) is None
and mqtt_platform.config_entry
and mqtt_platform.domain in RELOADABLE_PLATFORMS