Skip to content

Commit c1af4c0

Browse files
S3 Box: New initialisation, new events, new illustrations (#110)
Co-authored-by: Jesse Hills <[email protected]>
1 parent cd67e9c commit c1af4c0

File tree

3 files changed

+307
-262
lines changed

3 files changed

+307
-262
lines changed

voice-assistant/esp32-s3-box-3.yaml

+102-87
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,19 @@ esphome:
88
project:
99
name: esphome.voice-assistant
1010
version: "1.0"
11-
min_version: 2023.11.4
11+
min_version: 2023.11.5
12+
on_boot:
13+
priority: 600
14+
then:
15+
- display.page.show: initializing_page
16+
- component.update: s3_box_lcd
17+
- delay: 30s
18+
- if:
19+
condition:
20+
lambda: return id(init_in_progress);
21+
then:
22+
- lambda: id(init_in_progress) = false;
23+
- script.execute: reset_display
1224

1325
esp32:
1426
board: esp32s3box
@@ -37,11 +49,9 @@ external_components:
3749

3850
api:
3951
on_client_connected:
40-
then:
41-
- script.execute: reset_display
52+
- script.execute: reset_display
4253
on_client_disconnected:
43-
then:
44-
- script.execute: reset_display
54+
- script.execute: reset_display
4555

4656
ota:
4757
logger:
@@ -53,14 +63,12 @@ dashboard_import:
5363
wifi:
5464
ap:
5565
on_connect:
56-
then:
57-
- script.execute: reset_display
58-
- delay: 5s # Gives time for improv results to be transmitted
59-
- ble.disable:
66+
- delay: 5s # Gives time for improv results to be transmitted
67+
- ble.disable:
68+
- script.execute: reset_display
6069
on_disconnect:
61-
then:
62-
- script.execute: reset_display
63-
- ble.enable:
70+
- ble.enable:
71+
- script.execute: reset_display
6472

6573
improv_serial:
6674

@@ -103,7 +111,7 @@ binary_sensor:
103111
else:
104112
- voice_assistant.start:
105113
else:
106-
- voice_assistant.stop
114+
- voice_assistant.stop:
107115
- delay: 1s
108116
- script.execute: reset_display
109117
- script.wait: reset_display
@@ -149,65 +157,73 @@ voice_assistant:
149157
on_listening:
150158
- display.page.show: listening_page
151159
- component.update: s3_box_lcd
152-
on_tts_start:
153-
- display.page.show: talking_page
154-
- component.update: s3_box_lcd
155-
on_end:
156-
- delay: 100ms
157-
- wait_until:
158-
not:
159-
speaker.is_playing:
160-
- script.execute: reset_display
161160
on_stt_vad_end:
162161
- display.page.show: thinking_page
163162
- component.update: s3_box_lcd
164-
on_error:
165-
- display.page.show: error_page
163+
on_tts_stream_start:
164+
- display.page.show: replying_page
166165
- component.update: s3_box_lcd
167-
- delay: 1s
166+
on_tts_stream_end:
168167
- script.execute: reset_display
169-
on_client_connected:
168+
on_error:
170169
- if:
171170
condition:
172-
switch.is_on: use_wake_word
173-
then:
174-
- voice_assistant.start_continuous:
171+
lambda: return !id(init_in_progress);
172+
then:
173+
- display.page.show: error_page
174+
- component.update: s3_box_lcd
175+
- delay: 1s
175176
- script.execute: reset_display
176-
on_client_disconnected:
177+
on_client_connected:
177178
- if:
178179
condition:
179180
switch.is_on: use_wake_word
180181
then:
181-
- voice_assistant.stop:
182-
- display.page.show: sleeping_page
183-
- component.update: s3_box_lcd
182+
- wait_until:
183+
not: ble.enabled
184+
- voice_assistant.start_continuous:
185+
- lambda: id(init_in_progress) = false;
186+
- script.execute: reset_display
187+
on_client_disconnected:
188+
- script.execute: reset_display
184189

185190
script:
186191
- id: reset_display
187192
then:
188193
- if:
189194
condition:
190-
wifi.connected:
195+
lambda: return !id(init_in_progress);
191196
then:
192197
- if:
193198
condition:
194-
api.connected:
199+
wifi.connected:
195200
then:
196201
- if:
197202
condition:
198-
switch.is_on: use_wake_word
203+
api.connected:
199204
then:
200-
- display.page.show: idle_page
201-
- component.update: s3_box_lcd
205+
- if:
206+
condition:
207+
voice_assistant.connected:
208+
then:
209+
- if:
210+
condition:
211+
switch.is_on: use_wake_word
212+
then:
213+
- display.page.show: idle_page
214+
- component.update: s3_box_lcd
215+
else:
216+
- display.page.show: muted_page
217+
- component.update: s3_box_lcd
218+
else:
219+
- display.page.show: no_pipeline_page
220+
- component.update: s3_box_lcd
202221
else:
203-
- display.page.show: vad_off_page
222+
- display.page.show: no_api_page
204223
- component.update: s3_box_lcd
205224
else:
206-
- display.page.show: no_api_page
225+
- display.page.show: no_wifi_page
207226
- component.update: s3_box_lcd
208-
else:
209-
- display.page.show: no_wifi_page
210-
- component.update: s3_box_lcd
211227

212228
switch:
213229
- platform: template
@@ -230,49 +246,45 @@ switch:
230246
- lambda: id(va).set_use_wake_word(false);
231247
- script.execute: reset_display
232248

249+
globals:
250+
- id: init_in_progress
251+
type: bool
252+
restore_value: no
253+
initial_value: 'true'
254+
233255
image:
234-
- file: https://github.com/esphome/firmware/raw/main/voice-assistant/casita/[email protected]
235-
id: casita_error
236-
resize: 200x200
237-
type: RGB24
238-
use_transparency: true
239-
- file: https://github.com/esphome/firmware/raw/main/voice-assistant/casita/[email protected]
256+
# Standard path IDLE > LISTENING > THINKING > REPLYING
257+
- file: https://github.com/esphome/firmware/raw/main/voice-assistant/casita/[email protected]
240258
id: casita_idle
241259
resize: 200x200
242260
type: RGB24
243261
use_transparency: true
244-
- file: https://github.com/esphome/firmware/raw/main/voice-assistant/casita/Happy@2x.png
262+
- file: https://github.com/esphome/firmware/raw/main/voice-assistant/casita/Normal@2x.png
245263
id: casita_listening
246264
resize: 200x200
247265
type: RGB24
248266
use_transparency: true
249-
- file: https://github.com/esphome/firmware/raw/main/voice-assistant/casita/[email protected]
250-
id: casita_no_api
251-
resize: 200x200
252-
type: RGB24
253-
use_transparency: true
254-
- file: https://github.com/esphome/firmware/raw/main/voice-assistant/casita/[email protected]
255-
id: casita_no_wifi
256-
resize: 200x200
257-
type: RGB24
258-
use_transparency: true
259-
- file: https://github.com/esphome/firmware/raw/main/voice-assistant/casita/[email protected]
260-
id: casita_sleeping
267+
- file: https://github.com/esphome/firmware/raw/main/voice-assistant/casita/[email protected]
268+
id: casita_thinking
261269
resize: 200x200
262270
type: RGB24
263271
use_transparency: true
264-
- file: https://github.com/esphome/firmware/raw/main/voice-assistant/casita/Grinning@2x.png
265-
id: casita_talking
272+
- file: https://github.com/esphome/firmware/raw/main/voice-assistant/casita/Happy@2x.png
273+
id: casita_replying
266274
resize: 200x200
267275
type: RGB24
268276
use_transparency: true
269-
- file: https://github.com/esphome/firmware/raw/main/voice-assistant/casita/[email protected]
270-
id: casita_thinking
277+
278+
# Error cases (More specific flies to come soon)
279+
- file: https://github.com/esphome/firmware/raw/main/voice-assistant/casita/[email protected]
280+
id: casita_error
271281
resize: 200x200
272282
type: RGB24
273283
use_transparency: true
274-
- file: https://github.com/esphome/firmware/raw/main/voice-assistant/casita/[email protected]
275-
id: casita_vad_off
284+
285+
# Initialization illustration
286+
- file: https://github.com/esphome/firmware/raw/main/voice-assistant/casita/[email protected]
287+
id: casita_initializing
276288
resize: 200x200
277289
type: RGB24
278290
use_transparency: true
@@ -293,39 +305,42 @@ display:
293305
inverted: true
294306
update_interval: never
295307
pages:
296-
- id: error_page
297-
lambda: |-
298-
it.fill(Color::WHITE);
299-
it.image((it.get_width() / 2) - 100, (it.get_height() / 2) - 100, id(casita_error));
300308
- id: idle_page
301309
lambda: |-
302-
it.fill(Color::WHITE);
310+
it.fill(Color::BLACK);
303311
it.image((it.get_width() / 2) - 100, (it.get_height() / 2) - 100, id(casita_idle));
304312
- id: listening_page
305313
lambda: |-
306314
it.fill(Color::WHITE);
307315
it.image((it.get_width() / 2) - 100, (it.get_height() / 2) - 100, id(casita_listening));
316+
- id: thinking_page
317+
lambda: |-
318+
it.fill(Color::WHITE);
319+
it.image((it.get_width() / 2) - 100, (it.get_height() / 2) - 105, id(casita_thinking));
320+
- id: replying_page
321+
lambda: |-
322+
it.fill(Color::WHITE);
323+
it.image((it.get_width() / 2) - 100, (it.get_height() / 2) - 100, id(casita_replying));
324+
- id: error_page
325+
lambda: |-
326+
it.fill(Color::BLACK);
327+
it.image((it.get_width() / 2) - 100, (it.get_height() / 2) - 100, id(casita_error));
308328
- id: no_api_page
309329
lambda: |-
310330
it.fill(Color::BLACK);
311-
it.image((it.get_width() / 2) - 100, (it.get_height() / 2) - 100, id(casita_no_api));
331+
it.image((it.get_width() / 2) - 100, (it.get_height() / 2) - 100, id(casita_error));
312332
- id: no_wifi_page
313333
lambda: |-
314334
it.fill(Color::BLACK);
315-
it.image((it.get_width() / 2) - 100, (it.get_height() / 2) - 100, id(casita_no_wifi));
316-
- id: sleeping_page
317-
lambda: |-
318-
it.fill(Color::WHITE);
319-
it.image((it.get_width() / 2) - 100, (it.get_height() / 2) - 100, id(casita_sleeping));
320-
- id: talking_page
335+
it.image((it.get_width() / 2) - 100, (it.get_height() / 2) - 100, id(casita_error));
336+
- id: no_pipeline_page
321337
lambda: |-
322-
it.fill(Color::WHITE);
323-
it.image((it.get_width() / 2) - 100, (it.get_height() / 2) - 100, id(casita_talking));
324-
- id: thinking_page
338+
it.fill(Color::BLACK);
339+
it.image((it.get_width() / 2) - 100, (it.get_height() / 2) - 100, id(casita_error));
340+
- id: initializing_page
325341
lambda: |-
326-
it.fill(Color::WHITE);
327-
it.image((it.get_width() / 2) - 100, (it.get_height() / 2) - 105, id(casita_thinking));
328-
- id: vad_off_page
342+
it.fill(Color::BLACK);
343+
it.image((it.get_width() / 2) - 100, (it.get_height() / 2) - 100, id(casita_initializing));
344+
- id: muted_page
329345
lambda: |-
330346
it.fill(Color::BLACK);
331-
it.image((it.get_width() / 2) - 100, (it.get_height() / 2) - 100, id(casita_vad_off));

0 commit comments

Comments
 (0)