From 68aa3b87aa51fecf7a5ca2e1e82617ba4f51a435 Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Mon, 10 Aug 2026 07:46:31 -0400 Subject: [PATCH] [voice_assistant] Read the enabled preference without allocating a backend make_preference allocates a backend that ESPPreferenceObject never frees, and restore_runtime_models_ runs for every advertised model on every configuration request Home Assistant sends. Use load_from_key for the read instead. --- esphome/components/voice_assistant/voice_assistant.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/esphome/components/voice_assistant/voice_assistant.cpp b/esphome/components/voice_assistant/voice_assistant.cpp index 7fa8574b9e..00986eca07 100644 --- a/esphome/components/voice_assistant/voice_assistant.cpp +++ b/esphome/components/voice_assistant/voice_assistant.cpp @@ -1290,10 +1290,12 @@ void VoiceAssistant::restore_runtime_models_() { continue; } - // Only re-download models the user had enabled before the reboot. - auto pref = global_preferences->make_preference(fnv1_hash(cached_ww.id)); + // Only re-download models the user had enabled before the reboot. Read the key directly: make_preference + // allocates a backend that is never freed, and this runs for every advertised model on every request. bool enabled = false; - if (pref.load(&enabled) && enabled) { + if (global_preferences->load_from_key(fnv1_hash(cached_ww.id), reinterpret_cast(&enabled), + sizeof(enabled)) && + enabled) { ESP_LOGD(TAG, "Restoring runtime model %s", cached_ww.id.c_str()); this->model_download_queue_.push_back(cached_ww); this->pending_active_wake_words_.push_back(cached_ww.id);