From 76caa0fb401733b5ce492b0d5193b4c17e89d828 Mon Sep 17 00:00:00 2001 From: radu Date: Wed, 2 Dec 2026 15:13:55 +0700 Subject: [PATCH] 3 mb ch --- services/voices3mb4.yaml | 43 +++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/services/voices3mb4.yaml b/services/voices3mb4.yaml index f76fc08..a693098 100644 --- a/services/voices3mb4.yaml +++ b/services/voices3mb4.yaml @@ -58,10 +58,11 @@ voice_assistant: on_stt_vad_start: # Turn off the script if speech is detected - lambda: id(stt_vad_started) = true; - - + + on_stt_vad_end: + - lambda: id(voice_assistant_phase) = 3; # recording finished, HA is processing #- logger.log: "===============================VAD is the END ==================================" - script.stop: listening_timeout - light.turn_on: @@ -72,6 +73,8 @@ voice_assistant: effect: none on_stt_end: + - lambda: id(voice_assistant_phase) = 3; + - script.stop: listening_timeout - logger.log: format: "STT text: %s" args: ["x.c_str()"] @@ -96,6 +99,17 @@ voice_assistant: announce: "false" on_end: + # No local speaker/media_player, so ESPHome never reports playback as finished + # and HA keeps the satellite in "responding". Report it ourselves. + - lambda: |- + auto *conn = id(va).get_api_connection(); + if (conn != nullptr) { + api::VoiceAssistantAnnounceFinished msg; + msg.success = true; + if (!conn->send_message(msg)) { + ESP_LOGW("va", "Could not send announce-finished to HA"); + } + } - lambda: id(voice_assistant_phase) = 1; - lambda: id(stt_vad_started) = false; - script.execute: start_wake_word @@ -164,14 +178,25 @@ script: - if: condition: lambda: |- - return id(voice_assistant_phase) == 2 && !id(stt_vad_started); + return id(voice_assistant_phase) == 2; then: - - logger.log: "+++++++++++++++++++++++++ reset ==========================================" - - light.turn_off: - id: led - - voice_assistant.stop: - - delay: 1s - - script.execute: start_wake_word + - if: + condition: + lambda: 'return id(stt_vad_started);' + then: + # Speech is still going after the max time: stop the mic. + # HA processes the audio received so far; on_end restarts the wake word. + - logger.log: "Max listen time reached, stopping audio stream" + - lambda: id(voice_assistant_phase) = 3; + - voice_assistant.stop: + else: + # No speech at all: abort and return to wake word listening + - logger.log: "No speech detected, back to wake word" + - light.turn_off: + id: led + - voice_assistant.stop: + - delay: 1s + - script.execute: start_wake_word - id: start_wake_word then: