From cb9e85aa74e98b2e166d7c5367eb429002a57f32 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Sun, 2 Aug 2026 16:21:19 +0200 Subject: [PATCH] Simplify subentry migrators in LLM integrations (#177960) --- homeassistant/components/anthropic/__init__.py | 14 +++----------- .../google_generative_ai_conversation/__init__.py | 14 +++----------- homeassistant/components/ollama/__init__.py | 14 +++----------- .../components/openai_conversation/__init__.py | 14 +++----------- 4 files changed, 12 insertions(+), 44 deletions(-) diff --git a/homeassistant/components/anthropic/__init__.py b/homeassistant/components/anthropic/__init__.py index e70e5719894d..67537146fc3d 100644 --- a/homeassistant/components/anthropic/__init__.py +++ b/homeassistant/components/anthropic/__init__.py @@ -168,17 +168,9 @@ async def async_migrate_entry(hass: HomeAssistant, entry: AnthropicConfigEntry) LOGGER.debug("Migrating from version %s:%s", entry.version, entry.minor_version) if entry.version == 2 and entry.minor_version == 1: - # Correct broken device migration in Home Assistant Core 2025.7.0b0-2025.7.0b1 - device_registry = dr.async_get(hass) - for device in dr.async_entries_for_config_entry( - device_registry, entry.entry_id - ): - device_registry.async_update_device( - device.id, - remove_config_entry_id=entry.entry_id, - remove_config_subentry_id=None, - ) - + # Devices left in both the config entry and its subentry by Home Assistant Core + # 2025.7.0b0-2025.7.0b1 are collapsed onto the subentry by the device registry + # migration, so there's nothing to correct here. hass.config_entries.async_update_entry(entry, minor_version=2) if entry.version == 2 and entry.minor_version == 2: diff --git a/homeassistant/components/google_generative_ai_conversation/__init__.py b/homeassistant/components/google_generative_ai_conversation/__init__.py index 3186d9c50bad..3df476d36281 100644 --- a/homeassistant/components/google_generative_ai_conversation/__init__.py +++ b/homeassistant/components/google_generative_ai_conversation/__init__.py @@ -230,17 +230,9 @@ async def async_migrate_entry( ), ) - # Correct broken device migration in Home Assistant Core 2025.7.0b0-2025.7.0b1 - device_registry = dr.async_get(hass) - for device in dr.async_entries_for_config_entry( - device_registry, entry.entry_id - ): - device_registry.async_update_device( - device.id, - remove_config_entry_id=entry.entry_id, - remove_config_subentry_id=None, - ) - + # Devices left in both the config entry and its subentry by Home Assistant Core + # 2025.7.0b0-2025.7.0b1 are collapsed onto the subentry by the device registry + # migration, so there's nothing to correct here. hass.config_entries.async_update_entry(entry, minor_version=2) if entry.version == 2 and entry.minor_version == 2: diff --git a/homeassistant/components/ollama/__init__.py b/homeassistant/components/ollama/__init__.py index f97d67a9503c..77b8f18e2385 100644 --- a/homeassistant/components/ollama/__init__.py +++ b/homeassistant/components/ollama/__init__.py @@ -226,17 +226,9 @@ async def async_migrate_entry(hass: HomeAssistant, entry: OllamaConfigEntry) -> _LOGGER.debug("Migrating from version %s:%s", entry.version, entry.minor_version) if entry.version == 2 and entry.minor_version == 1: - # Correct broken device migration in Home Assistant Core 2025.7.0b0-2025.7.0b1 - device_registry = dr.async_get(hass) - for device in dr.async_entries_for_config_entry( - device_registry, entry.entry_id - ): - device_registry.async_update_device( - device.id, - remove_config_entry_id=entry.entry_id, - remove_config_subentry_id=None, - ) - + # Devices left in both the config entry and its subentry by Home Assistant Core + # 2025.7.0b0-2025.7.0b1 are collapsed onto the subentry by the device registry + # migration, so there's nothing to correct here. hass.config_entries.async_update_entry(entry, minor_version=2) if entry.version == 2 and entry.minor_version == 2: diff --git a/homeassistant/components/openai_conversation/__init__.py b/homeassistant/components/openai_conversation/__init__.py index 5327599c9abe..2ff1088ce1c9 100644 --- a/homeassistant/components/openai_conversation/__init__.py +++ b/homeassistant/components/openai_conversation/__init__.py @@ -418,17 +418,9 @@ async def async_migrate_entry(hass: HomeAssistant, entry: OpenAIConfigEntry) -> LOGGER.debug("Migrating from version %s:%s", entry.version, entry.minor_version) if entry.version == 2 and entry.minor_version == 1: - # Correct broken device migration in Home Assistant Core 2025.7.0b0-2025.7.0b1 - device_registry = dr.async_get(hass) - for device in dr.async_entries_for_config_entry( - device_registry, entry.entry_id - ): - device_registry.async_update_device( - device.id, - remove_config_entry_id=entry.entry_id, - remove_config_subentry_id=None, - ) - + # Devices left in both the config entry and its subentry by Home Assistant Core + # 2025.7.0b0-2025.7.0b1 are collapsed onto the subentry by the device registry + # migration, so there's nothing to correct here. hass.config_entries.async_update_entry(entry, minor_version=2) if entry.version == 2 and entry.minor_version == 2: