From edfc4537fd0dac735a5b4ec418efaa8b613ddb65 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Fri, 17 Jul 2026 11:20:06 +0200 Subject: [PATCH] Use modern device registry API for device move in ollama (#176661) --- homeassistant/components/ollama/__init__.py | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/homeassistant/components/ollama/__init__.py b/homeassistant/components/ollama/__init__.py index 16717b66d4d2..7ee31e4e8662 100644 --- a/homeassistant/components/ollama/__init__.py +++ b/homeassistant/components/ollama/__init__.py @@ -26,7 +26,7 @@ from homeassistant.helpers import ( device_registry as dr, entity_registry as er, ) -from homeassistant.helpers.typing import ConfigType +from homeassistant.helpers.typing import UNDEFINED, ConfigType, UndefinedType from homeassistant.util.ssl import get_default_context from .const import ( @@ -192,7 +192,7 @@ async def async_migrate_integration(hass: HomeAssistant) -> None: # Device and entity registries will set the disabled_by flag to None # when moving a device or entity disabled by CONFIG_ENTRY to an enabled # config entry, but we want to set it to USER instead, - device_disabled_by = device.disabled_by + device_disabled_by: dr.DeviceEntryDisabler | UndefinedType = UNDEFINED if ( device.disabled_by is dr.DeviceEntryDisabler.CONFIG_ENTRY and not all_disabled @@ -202,20 +202,9 @@ async def async_migrate_integration(hass: HomeAssistant) -> None: device.id, disabled_by=device_disabled_by, new_identifiers={(DOMAIN, subentry.subentry_id)}, - add_config_subentry_id=subentry.subentry_id, - add_config_entry_id=parent_entry.entry_id, + new_config_entry_id=parent_entry.entry_id, + new_config_subentry_id=subentry.subentry_id, ) - if parent_entry.entry_id != entry.entry_id: - device_registry.async_update_device( - 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)