Fix restarting and starting voice_assistant

This commit is contained in:
Joshua Boniface 2023-12-16 03:56:44 -05:00
parent 5663409138
commit 09e76eb8d0

View File

@ -195,20 +195,22 @@ script:
} }
interval: interval:
- interval: 1s - interval: 5s
then: then:
- logger.log: "Checking Voice Assistant is running"
- if: - if:
condition: condition:
api.connected: and:
- api.connected:
- switch.is_on: use_wake_word
- not:
- voice_assistant.is_running
then: then:
- if: - logger.log: "Voice Assistant not running; restarting it"
condition: - switch.turn_off: use_wake_word
and: - delay: 1s
- switch.is_on: use_wake_word - switch.turn_on: use_wake_word
- not: - delay: 1s
- voice_assistant.is_running
then:
- voice_assistant.start_continuous:
logger: logger:
level: DEBUG level: DEBUG
@ -645,12 +647,7 @@ switch:
entity_category: config entity_category: config
on_turn_on: on_turn_on:
- lambda: id(assist).set_use_wake_word(true); - lambda: id(assist).set_use_wake_word(true);
- if: - voice_assistant.start_continuous
condition:
not:
- voice_assistant.is_running
then:
- voice_assistant.start_continuous
on_turn_off: on_turn_off:
- voice_assistant.stop - voice_assistant.stop
- lambda: id(assist).set_use_wake_word(false); - lambda: id(assist).set_use_wake_word(false);