From bec8cf3ea87df885cbd824a102386d204571df49 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Thu, 28 Aug 2025 20:10:10 +0200 Subject: [PATCH] Fix restoring disabled_by flag of deleted devices (#151313) --- homeassistant/helpers/device_registry.py | 2 ++ tests/helpers/test_device_registry.py | 1 + 2 files changed, 3 insertions(+) diff --git a/homeassistant/helpers/device_registry.py b/homeassistant/helpers/device_registry.py index d07dfb2da64..222e1396380 100644 --- a/homeassistant/helpers/device_registry.py +++ b/homeassistant/helpers/device_registry.py @@ -944,6 +944,8 @@ class DeviceRegistry(BaseRegistry[dict[str, list[dict[str, Any]]]]): identifiers, disabled_by, ) + disabled_by = UNDEFINED + self.devices[device.id] = device # If creating a new device, default to the config entry name if device_info_type == "primary" and (not name or name is UNDEFINED): diff --git a/tests/helpers/test_device_registry.py b/tests/helpers/test_device_registry.py index dfa96fa6051..8cfd3c66ad9 100644 --- a/tests/helpers/test_device_registry.py +++ b/tests/helpers/test_device_registry.py @@ -4066,6 +4066,7 @@ async def test_restore_disabled_by( config_subentry_id=None, configuration_url="http://config_url_new.bla", connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")}, + disabled_by=None, entry_type=None, hw_version="hw_version_new", identifiers={("bridgeid", "0123")},