diff --git a/homeassistant/components/mqtt/__init__.py b/homeassistant/components/mqtt/__init__.py index 6be2cc525d8..a6c76aa5fb0 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -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