Persist an empty LLM API selection in Google Generative AI

Clearing every LLM API removed the key from the subentry data instead of
storing an empty list. Only remove the key when it is absent from the
submitted input.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016D21QGmGduj7t1aQLX26pS
This commit is contained in:
Claude
2026-08-23 08:39:07 +00:00
parent 99262963c9
commit fdf1d21620
2 changed files with 19 additions and 1 deletions
@@ -258,7 +258,7 @@ class LLMSubentryFlowHandler(ConfigSubentryFlow):
else:
if user_input[CONF_RECOMMENDED] == self.last_rendered_recommended:
if not user_input.get(CONF_LLM_HASS_API):
if user_input.get(CONF_LLM_HASS_API) is None:
user_input.pop(CONF_LLM_HASS_API, None)
# Don't allow to save options that enable the
# Google Search tool with an Assist API
@@ -583,6 +583,24 @@ def will_options_be_rendered_again(current_options, new_options) -> bool:
},
None,
),
(
{
CONF_RECOMMENDED: True,
CONF_PROMPT: "",
CONF_LLM_HASS_API: ["assist"],
},
{
CONF_RECOMMENDED: True,
CONF_PROMPT: "",
CONF_LLM_HASS_API: [],
},
{
CONF_RECOMMENDED: True,
CONF_PROMPT: "",
CONF_LLM_HASS_API: [],
},
None,
),
],
)
@pytest.mark.usefixtures("mock_init_component")