Refactor mqtt entity cleanup on reload (#102375)

This commit is contained in:
Jan Bouwhuis
2023-10-20 20:28:04 +02:00
committed by GitHub
parent 5ff6779f5c
commit 1bd0b2d05f

View File

@@ -426,9 +426,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
entity.async_remove() entity.async_remove()
for mqtt_platform in mqtt_platforms for mqtt_platform in mqtt_platforms
for entity in mqtt_platform.entities.values() for entity in mqtt_platform.entities.values()
# pylint: disable-next=protected-access if getattr(entity, "_discovery_data", None) is None
if not entity._discovery_data # type: ignore[attr-defined] and mqtt_platform.config_entry
if mqtt_platform.config_entry
and mqtt_platform.domain in RELOADABLE_PLATFORMS and mqtt_platform.domain in RELOADABLE_PLATFORMS
] ]
await asyncio.gather(*tasks) await asyncio.gather(*tasks)