diff --git a/homeassistant/components/anthropic/__init__.py b/homeassistant/components/anthropic/__init__.py index c537a000c14..68a46f19031 100644 --- a/homeassistant/components/anthropic/__init__.py +++ b/homeassistant/components/anthropic/__init__.py @@ -123,6 +123,12 @@ async def async_migrate_integration(hass: HomeAssistant) -> None: device.id, remove_config_entry_id=entry.entry_id, ) + else: + device_registry.async_update_device( + device.id, + remove_config_entry_id=entry.entry_id, + remove_config_subentry_id=None, + ) if not use_existing: await hass.config_entries.async_remove(entry.entry_id) diff --git a/tests/components/anthropic/test_init.py b/tests/components/anthropic/test_init.py index 6295bac67cb..16240ef8120 100644 --- a/tests/components/anthropic/test_init.py +++ b/tests/components/anthropic/test_init.py @@ -141,6 +141,10 @@ async def test_migration_from_v1_to_v2( ) assert migrated_device.identifiers == {(DOMAIN, subentry.subentry_id)} assert migrated_device.id == device.id + assert migrated_device.config_entries == {mock_config_entry.entry_id} + assert migrated_device.config_entries_subentries == { + mock_config_entry.entry_id: {subentry.subentry_id} + } async def test_migration_from_v1_to_v2_with_multiple_keys( @@ -231,6 +235,8 @@ async def test_migration_from_v1_to_v2_with_multiple_keys( identifiers={(DOMAIN, list(entry.subentries.values())[0].subentry_id)} ) assert dev is not None + assert dev.config_entries == {entry.entry_id} + assert dev.config_entries_subentries == {entry.entry_id: {subentry.subentry_id}} async def test_migration_from_v1_to_v2_with_same_keys( @@ -329,3 +335,7 @@ async def test_migration_from_v1_to_v2_with_same_keys( identifiers={(DOMAIN, subentry.subentry_id)} ) assert dev is not None + assert dev.config_entries == {mock_config_entry.entry_id} + assert dev.config_entries_subentries == { + mock_config_entry.entry_id: {subentry.subentry_id} + }