diff --git a/homeassistant/components/mqtt/mixins.py b/homeassistant/components/mqtt/mixins.py index 6f881a70690..ba67339a5d4 100644 --- a/homeassistant/components/mqtt/mixins.py +++ b/homeassistant/components/mqtt/mixins.py @@ -839,12 +839,11 @@ def async_removed_from_device( if "config_entries" not in event.data["changes"]: return False device_registry = dr.async_get(hass) - device_entry = device_registry.async_get(mqtt_device_id) + device_entry = device_registry.async_get(device_id) if not device_entry: # The device is already removed, do cleanup when we get "remove" event return False - entry_id = config_entry_id - if entry_id in device_entry.config_entries: + if config_entry_id in device_entry.config_entries: # Not removed from device return False