From 0f95fe566cbbbff6b7dd60c5c145059a43ae9cc9 Mon Sep 17 00:00:00 2001 From: tronikos Date: Wed, 25 Jun 2025 19:30:41 -0700 Subject: [PATCH] Use default title for migrated Google Generative AI entries (#147551) --- .../components/google_generative_ai_conversation/__init__.py | 2 ++ .../google_generative_ai_conversation/config_flow.py | 3 ++- .../components/google_generative_ai_conversation/const.py | 1 + .../components/google_generative_ai_conversation/test_init.py | 4 ++++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/google_generative_ai_conversation/__init__.py b/homeassistant/components/google_generative_ai_conversation/__init__.py index 1802073f760..7890af59f88 100644 --- a/homeassistant/components/google_generative_ai_conversation/__init__.py +++ b/homeassistant/components/google_generative_ai_conversation/__init__.py @@ -37,6 +37,7 @@ from homeassistant.helpers.typing import ConfigType from .const import ( CONF_PROMPT, + DEFAULT_TITLE, DEFAULT_TTS_NAME, DOMAIN, FILE_POLLING_INTERVAL_SECONDS, @@ -289,6 +290,7 @@ async def async_migrate_integration(hass: HomeAssistant) -> None: else: hass.config_entries.async_update_entry( entry, + title=DEFAULT_TITLE, options={}, version=2, ) diff --git a/homeassistant/components/google_generative_ai_conversation/config_flow.py b/homeassistant/components/google_generative_ai_conversation/config_flow.py index bb526f95a21..ad90cbcf553 100644 --- a/homeassistant/components/google_generative_ai_conversation/config_flow.py +++ b/homeassistant/components/google_generative_ai_conversation/config_flow.py @@ -47,6 +47,7 @@ from .const import ( CONF_TOP_P, CONF_USE_GOOGLE_SEARCH_TOOL, DEFAULT_CONVERSATION_NAME, + DEFAULT_TITLE, DEFAULT_TTS_NAME, DOMAIN, RECOMMENDED_CHAT_MODEL, @@ -116,7 +117,7 @@ class GoogleGenerativeAIConfigFlow(ConfigFlow, domain=DOMAIN): data=user_input, ) return self.async_create_entry( - title="Google Generative AI", + title=DEFAULT_TITLE, data=user_input, subentries=[ { diff --git a/homeassistant/components/google_generative_ai_conversation/const.py b/homeassistant/components/google_generative_ai_conversation/const.py index 9f4132a1e3e..72665cd3437 100644 --- a/homeassistant/components/google_generative_ai_conversation/const.py +++ b/homeassistant/components/google_generative_ai_conversation/const.py @@ -6,6 +6,7 @@ from homeassistant.const import CONF_LLM_HASS_API from homeassistant.helpers import llm DOMAIN = "google_generative_ai_conversation" +DEFAULT_TITLE = "Google Generative AI" LOGGER = logging.getLogger(__package__) CONF_PROMPT = "prompt" diff --git a/tests/components/google_generative_ai_conversation/test_init.py b/tests/components/google_generative_ai_conversation/test_init.py index a8a1e2840e3..46a2d634b81 100644 --- a/tests/components/google_generative_ai_conversation/test_init.py +++ b/tests/components/google_generative_ai_conversation/test_init.py @@ -8,6 +8,7 @@ from requests.exceptions import Timeout from syrupy.assertion import SnapshotAssertion from homeassistant.components.google_generative_ai_conversation.const import ( + DEFAULT_TITLE, DEFAULT_TTS_NAME, DOMAIN, RECOMMENDED_TTS_OPTIONS, @@ -473,6 +474,7 @@ async def test_migration_from_v1_to_v2( entry = entries[0] assert entry.version == 2 assert not entry.options + assert entry.title == DEFAULT_TITLE assert len(entry.subentries) == 3 conversation_subentries = [ subentry @@ -609,6 +611,7 @@ async def test_migration_from_v1_to_v2_with_multiple_keys( for entry in entries: assert entry.version == 2 assert not entry.options + assert entry.title == DEFAULT_TITLE assert len(entry.subentries) == 2 subentry = list(entry.subentries.values())[0] assert subentry.subentry_type == "conversation" @@ -702,6 +705,7 @@ async def test_migration_from_v1_to_v2_with_same_keys( entry = entries[0] assert entry.version == 2 assert not entry.options + assert entry.title == DEFAULT_TITLE assert len(entry.subentries) == 3 conversation_subentries = [ subentry