This commit is contained in:
radu
2026-12-02 16:19:15 +07:00
parent f329c518ff
commit 515cdb83fb
2 changed files with 50 additions and 20 deletions
+24 -9
View File
@@ -150,6 +150,8 @@ voice_assistant:
- script.execute: rboot - script.execute: rboot
#- script.execute: reset_led #- script.execute: reset_led
on_client_connected: on_client_connected:
- lambda: id(voice_assistant_phase) = 1; # connected again: clear "disconnected" state
- script.stop: rboot # cancel the pending reboot
- delay: 1s # Give the api server time to settle - delay: 1s # Give the api server time to settle
- script.execute: start_wake_word - script.execute: start_wake_word
on_client_disconnected: on_client_disconnected:
@@ -166,6 +168,7 @@ interval:
- api.connected: - api.connected:
- not: - not:
- voice_assistant.is_running: - voice_assistant.is_running:
- switch.is_off: stop_listen
then: then:
- script.execute: start_wake_word - script.execute: start_wake_word
@@ -176,8 +179,10 @@ script:
- delay: 180s - delay: 180s
- if: - if:
condition: condition:
lambda: |- and:
return id(voice_assistant_phase) == 4; - lambda: 'return id(voice_assistant_phase) == 4;'
- not:
- api.connected: # only reboot if HA is still not connected
then: then:
- switch.turn_on: - switch.turn_on:
id: rbt id: rbt
@@ -227,17 +232,27 @@ script:
- lambda: id(va).set_use_wake_word(false); - lambda: id(va).set_use_wake_word(false);
- voice_assistant.stop: - voice_assistant.stop:
switch: switch:
# - platform: restart
# name: Restart
# id: rbt
- platform: template - platform: template
name: Stop Listen name: Stop Listen
id: stop_listen
optimistic: true optimistic: true
restore_mode: RESTORE_DEFAULT_OFF restore_mode: RESTORE_DEFAULT_OFF
#entity_category: config #entity_category: config
on_turn_on: on_turn_on:
- microphone.mute: mic_id # Stop streaming to HA completely instead of sending silence
#- script.execute: stop_wake_word - script.execute: stop_wake_word
- light.turn_off: led
on_turn_off: on_turn_off:
- microphone.unmute: mic_id - script.execute: start_wake_word
#- script.execute: listening_timeout
start_wake_word script: add the switch.is_off condition.
- id: start_wake_word
then:
- if:
condition:
- not:
- voice_assistant.is_running:
- switch.is_off: stop_listen
then:
- lambda: id(va).set_use_wake_word(true);
- voice_assistant.start_continuous:
+26 -11
View File
@@ -136,7 +136,9 @@ voice_assistant:
- delay: 2s - delay: 2s
- script.execute: rboot - script.execute: rboot
#- script.execute: reset_led #- script.execute: reset_led
on_client_connected: on_client_connected:
- lambda: id(voice_assistant_phase) = 1; # connected again: clear "disconnected" state
- script.stop: rboot # cancel the pending reboot
- delay: 1s # Give the api server time to settle - delay: 1s # Give the api server time to settle
- script.execute: start_wake_word - script.execute: start_wake_word
on_client_disconnected: on_client_disconnected:
@@ -153,6 +155,7 @@ interval:
- api.connected: - api.connected:
- not: - not:
- voice_assistant.is_running: - voice_assistant.is_running:
- switch.is_off: stop_listen
then: then:
- script.execute: start_wake_word - script.execute: start_wake_word
@@ -163,8 +166,10 @@ script:
- delay: 180s - delay: 180s
- if: - if:
condition: condition:
lambda: |- and:
return id(voice_assistant_phase) == 4; - lambda: 'return id(voice_assistant_phase) == 4;'
- not:
- api.connected: # only reboot if HA is still not connected
then: then:
- switch.turn_on: - switch.turn_on:
id: rbt id: rbt
@@ -214,17 +219,27 @@ script:
- lambda: id(va).set_use_wake_word(false); - lambda: id(va).set_use_wake_word(false);
- voice_assistant.stop: - voice_assistant.stop:
switch: switch:
# - platform: restart - platform: template
# #name: Restart
# id: rbt
- platform: template
name: Stop Listen name: Stop Listen
id: stop_listen
optimistic: true optimistic: true
restore_mode: RESTORE_DEFAULT_OFF restore_mode: RESTORE_DEFAULT_OFF
#entity_category: config #entity_category: config
on_turn_on: on_turn_on:
- microphone.mute: echo_microphone # Stop streaming to HA completely instead of sending silence
#- script.execute: stop_wake_word - script.execute: stop_wake_word
- light.turn_off: led
on_turn_off: on_turn_off:
- microphone.unmute: echo_microphone - script.execute: start_wake_word
#- script.execute: listening_timeout
start_wake_word script: add the switch.is_off condition.
- id: start_wake_word
then:
- if:
condition:
- not:
- voice_assistant.is_running:
- switch.is_off: stop_listen
then:
- lambda: id(va).set_use_wake_word(true);
- voice_assistant.start_continuous: