properly clear llm API when updating settings

This commit is contained in:
Alex O'Connell
2025-10-23 21:22:33 -04:00
parent 455ad3f3d2
commit f50997d1a3

View File

@@ -1166,9 +1166,6 @@ class LocalLLMSubentryFlowHandler(ConfigSubentryFlow):
errors["base"] = "missing_icl_file"
description_placeholders["filename"] = filename
if user_input[CONF_LLM_HASS_API] == "none":
user_input.pop(CONF_LLM_HASS_API)
# --- Normalize numeric fields to ints to avoid slice/type errors later ---
for key in (
CONF_REMEMBER_NUM_INTERACTIONS,
@@ -1185,6 +1182,11 @@ class LocalLLMSubentryFlowHandler(ConfigSubentryFlow):
# validate input
schema(user_input)
self.model_config.update(user_input)
# clear LLM API if 'none' selected
if self.model_config.get(CONF_LLM_HASS_API) == "none":
self.model_config.pop(CONF_LLM_HASS_API, None)
return await self.async_step_finish()
except Exception:
_LOGGER.exception("An unknown error has occurred!")