-
Notifications
You must be signed in to change notification settings - Fork 20
/
s3b_no_sensors.yaml
3597 lines (3355 loc) · 115 KB
/
s3b_no_sensors.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
## You can change the friendly name if you wish on line 7 below. The friendly name is how the device will show in HA
## However the <name:> is how HA connects to the device eg. esp32-s3-box-3.local is the mDNS hostname for the device.
## Once added to HA changing the device name can lead to connection issues, between HA and the device.
substitutions:
name: esp32-s3box-3
friendly_name: ESP32-S3-Box-3
external_media_player: your_media_player ##change this to your external media player enity_id: do not include media_player.
home_assistant_host: http://homeassistant.local:8123 ##change to the full url or IP of your HA server including port
tts_voice_speed: "24000" #options #nabu casa "24000" #piper "16000" elevenlabs "44100" must include quotes
#################### ON DEVICE WAKE WORDS #######################################
#### all of the below wakewords are installed on the device #####
#### you can use any of these without re-compiling - just say them! #####
#################################################################################
# TO REMOVE A WAKE WORD - COMMENT OUT THE CORESPONDING LINE FROM THE CONFIG BELOW - CTRL + F to search for "models"
micro_wake_word_model_1: alexa
micro_wake_word_model_2: hey_jarvis
micro_wake_word_model_3: okay_nabu # latest test can also be used >> replace okay_nabu with this url https://github.com/kahrendt/microWakeWord/releases/download/okay_nabu/okay_nabu.json
micro_wake_word_model_4: hey_mycroft
####################################################################
##### Days and months #####
## Change the values on the right to match your locale ##
monday: Monday
tuesday: Tuesday
wednesday: Wednesday
thursday: Thursday
friday: Friday
saturday: Saturday
sunday: Sunday
jan: January
feb: February
mar: March
apr: April
may: May
jun: June
jul: July
aug: August
sept: September
oct: October
nov: November
dec: December
#####################################################################
##### DO NOT CHANGE SUBSTITUTIONS BELOW THIS LINE ######
##### UNLESS YOU KNOW WHAT YOU ARE DOING ######
font_glyphs: '&@!"''%()+=,-_.:°/$€£¥?0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyzÀàÁáÂâÃãÄäĀāĂăÅåǺǻẠạĄąÆæǼǽĆćĈĉČčĊċÇçĎďĐđÐðÈèÉéÊêẼẽĚěËëĒēĔĕĖėẸẹĘęĜĝǦǧĞğĠġĢģĤĥĦħıÌìÍíÎîĨĩÏïĪīĬĭİỊịĮįȷĴĵĶķĸĹ弾ĻļŁłĿŀŃńÑñŇňŅņƝɲŊŋʼnÒòÓóÔôÕõÖöŌōŎŏŐőỌọǪǫØøǾǿŒœŔŕŘřŖŗŚśŜŝŠšŞşȘșẞߍťŢţȚțŦŧÞþÙùÚúÛûŨũÜüŪūŬŭŮůŰűỤụŲųẀẁẂẃŴŵẄẅỲỳÝýŶŷỸỹŸÿȲȳŹźŽžŻżIJijƏə'
############# END OF SUBSTITUTIONS #################
####################################################
esphome:
name: ${name}
friendly_name: ${friendly_name}
min_version: 2024.9.0
platformio_options:
board_build.flash_mode: dio
on_boot:
priority: 600
then:
- lambda: id(led).turn_on().set_brightness(id(s_default_brightness).state /100).perform();
- display.page.show: loading_page
- component.update: s3_box_lcd
- script.execute: saver_enabled
- lambda: id(time_remaining_0).publish_state ("0:00:00");
- if:
condition:
switch.is_on: output_audio
then:
media_player.volume_set:
id: adf_media_player
volume: 0
project:
name: "BigBobbas.s3box"
version: "2024.09.01"
esp32:
board: esp32s3box
flash_size: 16MB
framework:
type: esp-idf
sdkconfig_options:
CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: "y"
CONFIG_ESP32S3_DATA_CACHE_64KB: "y"
CONFIG_ESP32S3_DATA_CACHE_LINE_64B: "y"
CONFIG_AUDIO_BOARD_CUSTOM: "y"
CONFIG_ESP32_S3_BOX_3_BOARD: "y"
components:
- name: esp32_s3_box_3_board
source: github://jesserockz/esp32-s3-box-3-board@main
refresh: 0s
psram:
mode: octal
speed: 80MHz
external_components:
- source:
type: git
url: https://github.com/gnumpi/esphome_audio
ref: dev-next
components: [ adf_pipeline, i2s_audio ]
refresh: 0s
api:
on_client_connected:
- lambda: |-
id(api_connection) = true;
- lambda: id(led).turn_on().set_brightness(id(s_default_brightness).state /100).perform();
- component.update: s3_box_lcd
- script.execute: saver_enabled
on_client_disconnected:
- lambda: |-
id(api_connection) = false;
ota:
- platform: esphome
on_begin:
- lambda: id(led).turn_on().set_brightness(1.0).set_transition_length(0).perform();
id(led).loop();
- display.page.show: ota_page
- component.update: s3_box_lcd
logger:
hardware_uart: USB_SERIAL_JTAG
logs:
text_sensor: WARN
component: ERROR
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: ${name}
password: s3box123
on_connect:
- lambda: |-
id(wifi_connection) = true;
- display.page.show: idle_page
- component.update: s3_box_lcd
on_disconnect:
- lambda: |-
id(wifi_connection) = false;
captive_portal:
time:
- platform: homeassistant
id: ha_time
interval:
- interval: 30s
then:
- component.update: s3_box_lcd
- interval: 10s
then:
- if:
condition:
- lambda: 'return { (id(api_connection) != true) };'
then:
- if:
condition:
api.connected:
then:
- lambda: "id(api_connection) = true;"
else:
- if:
condition:
not:
api.connected:
then:
- lambda: "id(api_connection) = false;"
- interval: 10s
then:
- if:
condition:
- lambda: 'return { (id(wifi_connection) != true) };'
then:
- if:
condition:
wifi.connected:
then:
- lambda: "id(wifi_connection) = true;"
else:
- if:
condition:
not:
wifi.connected:
then:
- lambda: "id(wifi_connection) = false;"
select:
- platform: template
entity_category: config
name: Wake word engine location
id: wake_word_engine_location
optimistic: true
restore_value: true
options:
- In Home Assistant
- On device
initial_option: In Home Assistant
on_value:
- if:
condition:
lambda: return x == "In Home Assistant";
then:
- micro_wake_word.stop
- delay: 500ms
- lambda: id(va).set_use_wake_word(true);
- voice_assistant.start_continuous:
- text_sensor.template.publish:
id: wakeword_location
state: !lambda 'return "Home Assistant";'
- component.update: s3_box_lcd
- if:
condition:
lambda: return x == "On device";
then:
- text_sensor.template.publish:
id: wakeword_location
state: !lambda 'return "On Device";'
- lambda: id(va).set_use_wake_word(false);
- voice_assistant.stop
- delay: 500ms
- micro_wake_word.start
- component.update: s3_box_lcd
- platform: template
entity_category: config
name: Time Format
id: time_format
optimistic: true
restore_value: true
options:
- 12 Hr
- 24 Hr
initial_option: 24 Hr
on_value:
then:
- if:
condition:
lambda: return x == "24 Hr";
then:
- text_sensor.template.publish:
id: time_display_format
state: !lambda 'return "24 Hr";'
else:
- text_sensor.template.publish:
id: time_display_format
state: !lambda 'return "12 Hr";'
- component.update: s3_box_lcd
script:
- id: set_volume
then:
- media_player.volume_set:
volume: !lambda return 0.5 + id(speaker_volume) * 0.05 ;
- id: saver_enabled
then:
- if:
condition:
switch.is_on: s_saver
then:
- lambda: id(led).turn_on().set_brightness(id(s_default_brightness).state /100).perform();
- delay: !lambda return id(s_saver_delay).state * 1000;
- lambda: id(led).turn_on().set_brightness(id(s_saver_brightness).state /100).perform();
- display.page.show: saver_page
- component.update: s3_box_lcd
- if:
condition:
- switch.is_on: s_saver_mode
then:
- delay: !lambda return id(s_saver_blank_delay).state * 1000;
- light.turn_off: led
mode: restart
- id: saver_enabled_manual
then:
- if:
condition:
- switch.is_on: s_saver
then:
- lambda: id(led).turn_on().set_brightness(id(s_saver_brightness).state /100).perform();
- display.page.show: saver_page
- component.update: s3_box_lcd
- if:
condition:
- switch.is_on: s_saver_mode
then:
- delay: !lambda return id(s_saver_blank_delay).state * 1000;
- light.turn_off: led
- component.update: s3_box_lcd
mode: restart
- id: timer_started
then:
while:
condition:
switch.is_on: timer_ringing
then:
- media_player.play_media:
media_url: '${home_assistant_host}/local/sounds/timer_finished.mp3'
- delay: 1s
- id: timer_started_external
then:
while:
condition:
switch.is_on: timer_ringing
then:
- homeassistant.service:
service: media_player.play_media
data:
entity_id: media_player.${external_media_player}
media_content_id: '${home_assistant_host}/local/sounds/timer_finished.mp3'
media_content_type: music
- delay: 1700ms
- id: timer_ending
then:
- wait_until:
- lambda: return (id(time_remaining_0).state == "0:00:10");
- script.execute: saver_enabled
- display.page.show: time_remaining_page
- component.update: s3_box_lcd
- id: increment_digit_1
then:
- lambda: |-
id(current_pin) += "1";
ESP_LOGD("increment_digit_1", "Current PIN: %s", id(current_pin).c_str());
- id: increment_digit_2
then:
- lambda: |-
id(current_pin) += "2";
ESP_LOGD("increment_digit_2", "Current PIN: %s", id(current_pin).c_str());
- id: increment_digit_3
then:
- lambda: |-
id(current_pin) += "3";
ESP_LOGD("increment_digit_3", "Current PIN: %s", id(current_pin).c_str());
- id: increment_digit_4
then:
- lambda: |-
id(current_pin) += "4";
ESP_LOGD("increment_digit_4", "Current PIN: %s", id(current_pin).c_str());
- id: increment_digit_5
then:
- lambda: |-
id(current_pin) += "5";
ESP_LOGD("increment_digit_5", "Current PIN: %s", id(current_pin).c_str());
- id: increment_digit_6
then:
- lambda: |-
id(current_pin) += "6";
ESP_LOGD("increment_digit_6", "Current PIN: %s", id(current_pin).c_str());
- id: increment_digit_7
then:
- lambda: |-
id(current_pin) += "7";
ESP_LOGD("increment_digit_7", "Current PIN: %s", id(current_pin).c_str());
- id: increment_digit_8
then:
- lambda: |-
id(current_pin) += "8";
ESP_LOGD("increment_digit_8", "Current PIN: %s", id(current_pin).c_str());
- id: increment_digit_9
then:
- lambda: |-
id(current_pin) += "9";
ESP_LOGD("increment_digit_9", "Current PIN: %s", id(current_pin).c_str());
- id: increment_digit_0
then:
- lambda: |-
id(current_pin) += "0";
ESP_LOGD("increment_digit_0", "Current PIN: %s", id(current_pin).c_str());
globals:
- id: wifi_connection
type: bool
restore_value: no
initial_value: "false"
- id: api_connection
type: bool
restore_value: no
initial_value: "false"
- id: mute_value
type: bool
restore_value: no
initial_value: "false"
- id: speaker_volume
type: int
restore_value: no
initial_value: '5'
- id: media_state
type: bool
restore_value: no
initial_value: "false"
- id: global_first_active_timer
type: voice_assistant::Timer
restore_value: false
- id: global_is_timer_active
type: bool
restore_value: false
- id: global_first_timer
type: voice_assistant::Timer
restore_value: false
- id: global_is_timer
type: bool
restore_value: false
- id: current_pin
type: std::string
initial_value: ""
number:
- id: s_saver_delay
platform: template
name: "Scr/save delay"
icon: 'mdi:sleep'
entity_category: config
unit_of_measurement: 'secs'
optimistic: true
restore_value: true
initial_value: 30
step: 5
min_value: 10
max_value: 999999
on_value:
- component.update: s3_box_lcd
- component.update: s_saver_delay
- script.execute: saver_enabled
- id: s_saver_blank_delay
platform: template
name: "Scr/off delay"
icon: 'mdi:monitor-off'
entity_category: config
unit_of_measurement: 'secs'
optimistic: true
restore_value: true
initial_value: 30
step: 5
min_value: 10
max_value: 999999
on_value:
- component.update: s_saver_blank_delay
- script.execute: saver_enabled
- component.update: s3_box_lcd
- id: s_saver_brightness
platform: template
name: "Scr/save Brightness"
icon: 'mdi:sleep'
entity_category: config
unit_of_measurement: '%'
optimistic: true
restore_value: true
initial_value: 30
step: 5
min_value: 20
max_value: 100
on_value:
- component.update: s_saver_brightness
- script.execute: saver_enabled
- component.update: s3_box_lcd
- id: s_default_brightness
platform: template
name: "Default Brightness"
icon: 'mdi:monitor'
entity_category: config
unit_of_measurement: '%'
optimistic: true
restore_value: true
initial_value: 100
step: 5
min_value: 20
max_value: 100
on_value:
- component.update: s_default_brightness
- script.execute: saver_enabled
- component.update: s3_box_lcd
button:
- platform: restart
id: reboot
name: "Reboot"
entity_category: diagnostic
switch:
- platform: template
name: Display conversation
id: display_conversation
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
entity_category: config
icon: 'mdi:chat'
- platform: template
name: Output audio externally
id: output_audio
icon: 'mdi:volume-off'
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
entity_category: config
on_turn_on:
media_player.volume_set:
id: adf_media_player
volume: 0
on_turn_off:
media_player.volume_set:
id: adf_media_player
volume: 1.0
- platform: template
name: Mute
id: mute_switch
icon: "mdi:microphone-off"
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
entity_category: config
on_turn_on:
then:
- voice_assistant.stop
- micro_wake_word.stop
on_turn_off:
- if:
condition:
not:
- voice_assistant.is_running
then:
- if:
condition:
lambda: return id(wake_word_engine_location).state == "In Home Assistant";
then:
- lambda: id(va).set_use_wake_word(true);
- delay: 50ms
- voice_assistant.start_continuous
- if:
condition:
lambda: return id(wake_word_engine_location).state == "On device";
then:
- lambda: id(va).set_use_wake_word(false);
- micro_wake_word.start
- component.update: s3_box_lcd
- platform: template
id: media_mute
optimistic: true
on_turn_on:
media_player.volume_set:
id: adf_media_player
volume: 0
on_turn_off:
media_player.volume_set:
id: adf_media_player
volume: 1.0
- platform: template
id: s_saver
name: Scr/save enable
icon: mdi:sleep
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
entity_category: config
- platform: template
id: s_saver_mode
name: Scr/off enable
icon: 'mdi:monitor-off'
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
entity_category: config
- platform: template
id: timer_ringing
optimistic: true
internal: true
restore_mode: ALWAYS_OFF
on_turn_on:
- lambda: id(led).turn_on().set_brightness(1.0).perform();
- delay: 15min
- switch.turn_off: timer_ringing
on_turn_off:
- media_player.stop
- platform: template
id: wake_sound
name: Play wake sound
icon: mdi:music
entity_category: config
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
- platform: template
id: mute_response_switch
name: Mute Responses
icon: mdi:chat-sleep
entity_category: config
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
- platform: template
id: ext_media_mute
icon: 'mdi:volume-off'
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
entity_category: config
on_turn_on:
then:
- homeassistant.service:
service: media_player.volume_mute
data:
entity_id: media_player.${external_media_player}
on_turn_off:
- homeassistant.service:
service: media_player.volume_mute
data:
entity_id: media_player.${external_media_player}
output:
- platform: ledc
pin: GPIO47
id: backlight_output
light:
- platform: monochromatic
id: led
name: LCD Backlight
entity_category: config
output: backlight_output
restore_mode: ALWAYS_ON
default_transition_length: 50ms
sensor:
- platform: uptime
id: up_sens
on_value:
- lambda: |-
int seconds = id(up_sens).state;
int days = seconds / 86400;
int hours = seconds / 3600;
int minutes = (seconds % 3600) / 60;
seconds %= 60;
id(up_sens_text).publish_state(str_sprintf("%03d:%02d:%02d:%02d", days, hours, minutes, seconds));
update_interval: 30s
- platform: wifi_signal
name: "WiFi db"
id: wifi_signal_db
update_interval: 30s
- platform: copy
source_id: wifi_signal_db
name: "WiFi Signal"
id: wifi_percent
filters:
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
unit_of_measurement: "%"
entity_category: "diagnostic"
device_class: ""
text_sensor:
- id: text_request
platform: template
on_value:
lambda: |-
if(id(text_request).state.length()>32) {
std::string name = id(text_request).state.c_str();
std::string truncated = esphome::str_truncate(name.c_str(),31);
id(text_request).state = (truncated+"...").c_str();
}
- id: text_response
platform: template
on_value:
lambda: |-
if(id(text_response).state.length()>32) {
std::string name = id(text_response).state.c_str();
std::string truncated = esphome::str_truncate(name.c_str(),31);
id(text_response).state = (truncated+"...").c_str();
}
- platform: wifi_info
ip_address:
name: IP Address
id: ip_addr
entity_category: "diagnostic"
ssid:
id: connected_ssid
name: SSID
entity_category: "diagnostic"
bssid:
id: connected_bssid
name: BSSID
entity_category: "diagnostic"
mac_address:
id: device_mac
- platform: template
id: up_sens_text
name: Device uptime
entity_category: "diagnostic"
icon: mdi:clock
- platform: template
id: wakeword_location
- platform: template
id: time_remaining_0
name: Timer
icon: mdi:clock
- platform: template
id: time_remaining_1
- platform: template
id: time_display_format
update_interval: never
- platform: homeassistant
entity_id: media_player.${external_media_player}
id: ha_media_status
on_value:
component.update: s3_box_lcd
- platform: homeassistant
entity_id: media_player.${external_media_player}
id: ha_media_title
attribute: media_content_id
on_value:
component.update: s3_box_lcd
- platform: homeassistant
name: "Alarm Status"
entity_id: alarm_control_panel.alarmo
id: alarm_status
on_value:
- component.update: s3_box_lcd
i2s_audio:
- id: i2s_shared
i2s_lrclk_pin:
number: GPIO45
ignore_strapping_warning: true
i2s_bclk_pin: GPIO17
i2s_mclk_pin: GPIO2
access_mode: duplex
adf_pipeline:
- platform: i2s_audio
type: audio_out
id: adf_i2s_out
i2s_audio_id: i2s_shared
i2s_dout_pin: GPIO15
adf_alc: false
dac:
i2c_id: bus_a
model: es8311
address: 0x18
enable_pin:
number: GPIO46
ignore_strapping_warning: true
sample_rate: 16000
bits_per_sample: 16bit
fixed_settings: true
- platform: i2s_audio
type: audio_in
id: adf_i2s_in
i2s_audio_id: i2s_shared
i2s_din_pin: GPIO16
pdm: false
adc:
i2c_id: bus_a
model: es7210
address: 0x40
sample_rate: 16000
bits_per_sample: 16bit
fixed_settings: true
media_player:
- platform: adf_pipeline
id: adf_media_player
name: s3-box_media_player
internal: false
keep_pipeline_alive: true
announcement_audio:
sample_rate: ${tts_voice_speed}
bits_per_sample: 16
num_channels: 1
pipeline:
- self
- resampler
- adf_i2s_out
on_play:
- lambda: |-
id(media_state) = true;
- component.update: s3_box_lcd
on_idle:
- lambda: |-
id(media_state) = false;
- component.update: s3_box_lcd
microphone:
- platform: adf_pipeline
id: box_mic
keep_pipeline_alive: true
pipeline:
- adf_i2s_in
- resampler
- self
micro_wake_word:
vad:
models:
- model: ${micro_wake_word_model_1}
- model: ${micro_wake_word_model_2}
- model: ${micro_wake_word_model_3}
- model: ${micro_wake_word_model_4}
on_wake_word_detected:
- if:
condition:
and:
- switch.is_off: output_audio
- switch.is_on: wake_sound
then:
- media_player.play_media:
id: adf_media_player
media_url: '${home_assistant_host}/local/sounds/awake.mp3'
- delay: 500ms
- media_player.stop
- voice_assistant.start
else:
if:
condition:
and:
- switch.is_on: output_audio
- switch.is_on: wake_sound
then:
- homeassistant.service:
service: media_player.play_media
data:
entity_id: media_player.${external_media_player}
media_content_id: '${home_assistant_host}/local/sounds/awake.mp3'
media_content_type: music
- media_player.stop
- voice_assistant.start
else:
if:
condition:
- switch.is_off: wake_sound
then:
- media_player.stop
- voice_assistant.start
voice_assistant:
id: va
microphone: box_mic
media_player: adf_media_player
use_wake_word: true
noise_suppression_level: 2
auto_gain: 31dBFS
volume_multiplier: 4.0
on_wake_word_detected:
- if:
condition:
and:
- switch.is_off: output_audio
- switch.is_on: wake_sound
then:
- media_player.play_media:
media_url: '${home_assistant_host}/local/sounds/awake.mp3'
- delay: 500ms
- media_player.stop
- display.page.show: listening_page
- component.update: s3_box_lcd
else:
if:
condition:
and:
- switch.is_on: wake_sound
- switch.is_on: output_audio
then:
- homeassistant.service:
service: media_player.play_media
data:
entity_id: media_player.${external_media_player}
media_content_id: '${home_assistant_host}/local/sounds/awake.mp3'
media_content_type: music
- media_player.stop
on_start:
if:
condition:
- display.is_displaying_page: listening_page
- display.is_displaying_page: thinking_page
then:
- display.page.show: idle_page
- component.update: s3_box_lcd
on_listening:
- text_sensor.template.publish:
id: text_request
state: "..."
- text_sensor.template.publish:
id: text_response
state: "..."
- script.execute: saver_enabled
- display.page.show: listening_page
- component.update: s3_box_lcd
on_stt_end:
- text_sensor.template.publish:
id: text_request
state: !lambda return x;
on_stt_vad_end:
- display.page.show: thinking_page
- component.update: s3_box_lcd
on_tts_start:
- text_sensor.template.publish:
id: text_response
state: !lambda return x;
on_tts_end:
- if:
condition:
and:
- switch.is_on: mute_response_switch
- switch.is_off: media_mute
- switch.is_off: ext_media_mute
then:
- switch.turn_on: media_mute
- switch.turn_on: ext_media_mute
- display.page.show: replying_page
- component.update: s3_box_lcd
- if:
condition:
- switch.is_on: output_audio
then:
- homeassistant.service:
service: media_player.play_media
data:
entity_id: media_player.${external_media_player}
media_content_id: !lambda 'return x;'
media_content_type: music
announce: "false"
- delay: 5s
- display.page.show: idle_page
- component.update: s3_box_lcd
on_error:
- if:
condition:
not:
- voice_assistant.is_running
then:
- display.page.show: error_page
- component.update: s3_box_lcd
- delay: 4s
- if:
condition:
- display.is_displaying_page: error_page
then:
- display.page.show: idle_page
- component.update: s3_box_lcd
on_idle:
- display.page.show: idle_page
- component.update: s3_box_lcd
on_end:
- if:
condition:
and:
- switch.is_off: mute_switch
- lambda: return id(wake_word_engine_location).state == "On device";
then:
- voice_assistant.stop
- wait_until:
not:
voice_assistant.is_running:
- delay: 100ms
- micro_wake_word.start
else:
if:
condition: