scr2
This commit is contained in:
+56
-5
@@ -2,7 +2,9 @@
|
|||||||
# Use together with board/ws146.yaml and services/voice.yaml.
|
# Use together with board/ws146.yaml and services/voice.yaml.
|
||||||
#
|
#
|
||||||
# Shows the voice assistant state (coloured ring + status text) and the last
|
# Shows the voice assistant state (coloured ring + status text) and the last
|
||||||
# command / reply. Adds a "Screen" switch that turns the backlight on and off.
|
# command / reply. The screen stays dark until the wake word is heard, stays on
|
||||||
|
# while HA thinks and replies, and turns off 5 s after the conversation ends.
|
||||||
|
# The "Screen" switch enables or disables this; when off the screen never lights.
|
||||||
#
|
#
|
||||||
# The voice_assistant triggers below are APPENDED to the ones in
|
# The voice_assistant triggers below are APPENDED to the ones in
|
||||||
# services/voice.yaml (ESPHome concatenates lists when merging packages).
|
# services/voice.yaml (ESPHome concatenates lists when merging packages).
|
||||||
@@ -51,7 +53,7 @@ light:
|
|||||||
name: Screen Backlight
|
name: Screen Backlight
|
||||||
internal: true
|
internal: true
|
||||||
output: backlight_pwm
|
output: backlight_pwm
|
||||||
restore_mode: ALWAYS_OFF # the Screen switch sets it at boot
|
restore_mode: ALWAYS_OFF # lit only by screen_wake during a conversation
|
||||||
default_transition_length: 300ms
|
default_transition_length: 300ms
|
||||||
|
|
||||||
switch:
|
switch:
|
||||||
@@ -62,9 +64,18 @@ switch:
|
|||||||
optimistic: true
|
optimistic: true
|
||||||
restore_mode: RESTORE_DEFAULT_ON
|
restore_mode: RESTORE_DEFAULT_ON
|
||||||
on_turn_on:
|
on_turn_on:
|
||||||
- lvgl.resume:
|
# Enabled: light up now if a conversation is in progress, else stay dark.
|
||||||
- light.turn_on: backlight
|
- if:
|
||||||
|
condition:
|
||||||
|
lambda: 'return id(screen_state) >= 1 && id(screen_state) <= 3;'
|
||||||
|
then:
|
||||||
|
- script.execute: screen_wake
|
||||||
|
else:
|
||||||
|
- script.execute:
|
||||||
|
id: screen_sleep
|
||||||
|
delay_ms: 0
|
||||||
on_turn_off:
|
on_turn_off:
|
||||||
|
- script.stop: screen_sleep
|
||||||
- light.turn_off: backlight
|
- light.turn_off: backlight
|
||||||
- lvgl.pause:
|
- lvgl.pause:
|
||||||
|
|
||||||
@@ -170,6 +181,33 @@ script:
|
|||||||
id: transcript_label
|
id: transcript_label
|
||||||
text: ""
|
text: ""
|
||||||
|
|
||||||
|
# Light the screen for a conversation (only if the Screen switch is on).
|
||||||
|
# Also arms a 60 s fallback so it can never stay lit if on_end is missed.
|
||||||
|
- id: screen_wake
|
||||||
|
mode: restart
|
||||||
|
then:
|
||||||
|
- if:
|
||||||
|
condition:
|
||||||
|
switch.is_on: screen_switch
|
||||||
|
then:
|
||||||
|
- lvgl.resume:
|
||||||
|
- light.turn_on: backlight
|
||||||
|
- script.execute:
|
||||||
|
id: screen_sleep
|
||||||
|
delay_ms: 60000
|
||||||
|
|
||||||
|
# Turn the screen off after delay_ms; a new call restarts the countdown.
|
||||||
|
- id: screen_sleep
|
||||||
|
mode: restart
|
||||||
|
parameters:
|
||||||
|
|
||||||
|
delay_ms: int
|
||||||
|
then:
|
||||||
|
- delay: !lambda return delay_ms;
|
||||||
|
- light.turn_off: backlight
|
||||||
|
- delay: 300ms # let the fade finish before freezing the UI
|
||||||
|
- lvgl.pause:
|
||||||
|
|
||||||
# ------------------------------------------- hooks into services/voice.yaml --
|
# ------------------------------------------- hooks into services/voice.yaml --
|
||||||
voice_assistant:
|
voice_assistant:
|
||||||
on_listening:
|
on_listening:
|
||||||
@@ -178,6 +216,7 @@ voice_assistant:
|
|||||||
- script.execute:
|
- script.execute:
|
||||||
id: screen_set_transcript
|
id: screen_set_transcript
|
||||||
text: ""
|
text: ""
|
||||||
|
- script.execute: screen_wake
|
||||||
on_stt_vad_end:
|
on_stt_vad_end:
|
||||||
- lambda: id(screen_state) = 2;
|
- lambda: id(screen_state) = 2;
|
||||||
- script.execute: screen_refresh
|
- script.execute: screen_refresh
|
||||||
@@ -192,19 +231,31 @@ voice_assistant:
|
|||||||
- lambda: id(screen_state) = 3;
|
- lambda: id(screen_state) = 3;
|
||||||
- script.execute: screen_refresh
|
- script.execute: screen_refresh
|
||||||
- script.execute:
|
- script.execute:
|
||||||
id: screen_set_transcript
|
id: screen_set_transc
|
||||||
|
|
||||||
|
|
||||||
|
ript
|
||||||
text: !lambda return x;
|
text: !lambda return x;
|
||||||
on_end:
|
on_end:
|
||||||
- lambda: id(screen_state) = 0;
|
- lambda: id(screen_state) = 0;
|
||||||
- script.execute: screen_refresh
|
- script.execute: screen_refresh
|
||||||
|
- script.execute:
|
||||||
|
id: screen_sleep
|
||||||
|
delay_ms: 5000
|
||||||
on_error:
|
on_error:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
if (message.find("duplicate_wake_up_detected") == std::string::npos)
|
if (message.find("duplicate_wake_up_detected") == std::string::npos)
|
||||||
id(screen_state) = 4;
|
id(screen_state) = 4;
|
||||||
- script.execute: screen_refresh
|
- script.execute: screen_refresh
|
||||||
|
- script.execute:
|
||||||
|
id: screen_sleep
|
||||||
|
delay_ms: 5000
|
||||||
on_client_connected:
|
on_client_connected:
|
||||||
- lambda: id(screen_state) = 0;
|
- lambda: id(screen_state) = 0;
|
||||||
- script.execute: screen_refresh
|
- script.execute: screen_refresh
|
||||||
on_client_disconnected:
|
on_client_disconnected:
|
||||||
- lambda: id(screen_state) = 5;
|
- lambda: id(screen_state) = 5;
|
||||||
- script.execute: screen_refresh
|
- script.execute: screen_refresh
|
||||||
|
- script.execute:
|
||||||
|
id: screen_sleep
|
||||||
|
delay_ms: 0
|
||||||
Reference in New Issue
Block a user