From 88f0e4000b86819937750d41f36701ddcaf63cd2 Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Mon, 24 Apr 2023 16:09:36 +0200 Subject: [PATCH] Cleanup unreachable code where device_entry will never be None on an update event (#91855) --- homeassistant/components/mqtt/mixins.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/mqtt/mixins.py b/homeassistant/components/mqtt/mixins.py index 69001b837a2..38826438091 100644 --- a/homeassistant/components/mqtt/mixins.py +++ b/homeassistant/components/mqtt/mixins.py @@ -1193,10 +1193,9 @@ def async_removed_from_device( if "config_entries" not in event.data["changes"]: return False device_registry = dr.async_get(hass) - if not (device_entry := device_registry.async_get(device_id)): - # The device is already removed, do cleanup when we get "remove" event - return False - if config_entry_id in device_entry.config_entries: + if ( + device_entry := device_registry.async_get(device_id) + ) and config_entry_id in device_entry.config_entries: # Not removed from device return False