Cleanup entity and device registry on MQTT discovery removal (#32693)

* Cleanup entity and device registry on MQTT discovery removal.

* Review comments
This commit is contained in:
Erik Montnemery 2020-03-12 02:00:47 +01:00 committed by GitHub
parent 5f5cb8bea8
commit 8bc542776b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 466 additions and 17 deletions

View file

@ -25,6 +25,7 @@ from . import (
CONF_PAYLOAD,
CONF_QOS,
DOMAIN,
cleanup_device_registry,
)
from .discovery import MQTT_DISCOVERY_UPDATED, clear_discovery_hash
@ -187,6 +188,7 @@ async def async_setup_trigger(hass, config, config_entry, discovery_data):
device_trigger.detach_trigger()
clear_discovery_hash(hass, discovery_hash)
remove_signal()
await cleanup_device_registry(hass, device.id)
else:
# Non-empty payload: Update trigger
_LOGGER.info("Updating trigger: %s", discovery_hash)