From 26b3d9544114c00b580e4dd1c86751b0007ff723 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sun, 23 Aug 2026 12:53:22 +0200 Subject: [PATCH] Persist an empty LLM API selection in Anthropic (#179892) Co-authored-by: Claude --- homeassistant/components/anthropic/config_flow.py | 2 +- tests/components/anthropic/test_config_flow.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/anthropic/config_flow.py b/homeassistant/components/anthropic/config_flow.py index ee49b60c7874..9cc8ccd7fe37 100644 --- a/homeassistant/components/anthropic/config_flow.py +++ b/homeassistant/components/anthropic/config_flow.py @@ -271,7 +271,7 @@ class ConversationSubentryFlowHandler(ConfigSubentryFlow): ] = bool if user_input is not None: - 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) if user_input[CONF_RECOMMENDED]: diff --git a/tests/components/anthropic/test_config_flow.py b/tests/components/anthropic/test_config_flow.py index b8140115f8d4..606a42c734e4 100644 --- a/tests/components/anthropic/test_config_flow.py +++ b/tests/components/anthropic/test_config_flow.py @@ -592,6 +592,7 @@ async def test_invalid_model( { CONF_RECOMMENDED: False, CONF_PROMPT: "Speak like a pirate", + CONF_LLM_HASS_API: [], CONF_PROMPT_CACHING: "off", CONF_CHAT_MODEL: "claude-haiku-4-5", CONF_MAX_TOKENS: DEFAULT[CONF_MAX_TOKENS], @@ -695,6 +696,7 @@ async def test_invalid_model( { CONF_RECOMMENDED: False, CONF_PROMPT: "Speak like a pirate", + CONF_LLM_HASS_API: [], CONF_PROMPT_CACHING: "prompt", CONF_CHAT_MODEL: "claude-opus-4-7", CONF_MAX_TOKENS: DEFAULT[CONF_MAX_TOKENS], @@ -728,6 +730,7 @@ async def test_invalid_model( { CONF_RECOMMENDED: False, CONF_PROMPT: "Speak like a pirate", + CONF_LLM_HASS_API: [], CONF_PROMPT_CACHING: "automatic", CONF_CHAT_MODEL: "claude-haiku-4-5", CONF_MAX_TOKENS: DEFAULT[CONF_MAX_TOKENS],