-
Notifications
You must be signed in to change notification settings - Fork 0
/
ultimatesensor_mini_v1_basic.yaml
1153 lines (1098 loc) · 34 KB
/
ultimatesensor_mini_v1_basic.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
## Optimized config for the Ultimatesensor Mini hardware by smarthomeshop.io
## Config made by https://espthings.io
## Read the full blog article at: https://www.espthings.io/ultimatesensor_mini
## This config utilizes the esp-idf framework and the adf pipeline for support of
## micro wake word locally on the esp32-s3 SOC.
substitutions:
device_name: "ultimatesensor-mini-01"
friendly_name: "Office presence"
device_description: "Ultimatesensor Mini in the office"
## Hardware version - This config is optimized for the "Ultimatesensor Mini Complete"
ultimatesensor_mini_hardware_version: "V1-Complete"
## Preferred wake word, choose from: https://github.com/esphome/micro-wake-word-models/tree/main/models
wake_word: hey_jarvis
## Set the buildt in speaker volume percentage to prevent it from distorting
speaker_volume: 50%
## Phases of the Voice Assistant
## IDLE: The voice assistant is ready to be triggered by a wake-word
voice_assist_idle_phase_id: '1'
## LISTENING: The voice assistant is ready to listen to a voice command (after being triggered by the wake word)
voice_assist_listening_phase_id: '2'
## THINKING: The voice assistant is currently processing the command
voice_assist_thinking_phase_id: '3'
## REPLYING: The voice assistant is replying to the command
voice_assist_replying_phase_id: '4'
## NOT_READY: The voice assistant is not ready
voice_assist_not_ready_phase_id: '10'
## ERROR: The voice assistant encountered an error
voice_assist_error_phase_id: '11'
## MUTED: The voice assistant is muted and will not reply to a wake-word
voice_assist_muted_phase_id: '12'
external_components:
- source:
type: git
url: https://github.com/gnumpi/esphome_audio
ref: dev-next
components: [ adf_pipeline, i2s_audio ]
refresh: 0s
esphome:
name: ${device_name}
comment: ${device_description}
friendly_name: ${friendly_name}
project:
name: "Ultimatesensor.mini"
version: ${ultimatesensor_mini_hardware_version}
min_version: 2024.7.0
platformio_options:
build_flags: -DBOARD_HAS_PSRAM
board_build.flash_mode: dio
board_upload.maximum_size: 16777216
on_boot:
priority: 200.0
then:
## Set a volume limit to prevent the speaker from distorting
- media_player.volume_set:
id: adf_media_player
volume: ${speaker_volume}
## Run the script to refresh the LED status
## If after 30 seconds, the device is still initializing (It did not yet connect to Home Assistant),
## turn off the init_in_progress variable and run the script to refresh the LED status
- delay: 30s
- if:
condition:
lambda: return id(init_in_progress);
then:
- lambda: id(init_in_progress) = false;
esp32:
board: esp32-s3-devkitc-1
variant: ESP32S3
flash_size: 16MB
framework:
type: esp-idf
version: 4.4.6
sdkconfig_options:
CONFIG_ESP32_S3_BOX_BOARD: "y"
CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM: "16"
CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM: "512"
CONFIG_TCPIP_RECVMBOX_SIZE: "512"
CONFIG_TCP_SND_BUF_DEFAULT: "65535"
CONFIG_TCP_WND_DEFAULT: "512000"
CONFIG_TCP_RECVMBOX_SIZE: "512"
logger:
globals:
## Global initialisation variable.
## Initialized to "true" and set to "false" once everything is connected.
## Only used to have a smooth plugging experience
- id: init_in_progress
type: bool
restore_value: no
initial_value: 'true'
## Global variable tracking the phase of the voice assistant (defined above).
## Initialized to not_ready
- id: voice_assistant_phase
type: int
restore_value: no
initial_value: ${voice_assist_not_ready_phase_id}
## mmwave update time
- id: mmwave_update_time
type: unsigned long
restore_value: no
initial_value: '0'
psram:
mode: octal
speed: 80MHz
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
enable_rrm: true
ota:
- platform: esphome
password: !secret ota_password
api:
encryption:
key: !secret api_key
## esp restart button
button:
- platform: restart
id: restart_btn
name: "${friendly_name} REBOOT"
## Configure I2C for the SGP40, SCD41 and BH1750 sensor
i2c:
id: bus_a
sda: GPIO11
scl: GPIO10
scan: true
## esp status led
status_led:
pin: GPIO19
## LD2450 mmwave on uart bus
uart:
id: uart_bus
tx_pin:
number: GPIO13
mode:
input: true
pullup: true
rx_pin:
number: GPIO14
mode:
input: true
pullup: true
baud_rate: 256000
parity: NONE
stop_bits: 1
data_bits: 8
debug:
direction: BOTH
dummy_receiver: True
after:
delimiter: [0X55, 0XCC]
sequence:
## - lambda: UARTDebug::log_hex(direction, bytes, ' ');
- lambda: |-
if ((millis() - id(mmwave_update_time)) <= 1000) {
return;
};
id(mmwave_update_time) = millis();
int16_t p1_x = (uint16_t((bytes[5] << 8) | bytes[4] ));
if ((bytes[5] & 0x80) >> 7){
p1_x -= pow(2, 15);
}else{
p1_x = 0 - p1_x; // was 0 - p1_x;
}
p1_x = -p1_x;
int16_t p1_y = (uint16_t((bytes[7] << 8) | bytes[6] ));
if ((bytes[7] & 0x80) >> 7){
p1_y -= pow(2, 15);
}else{
p1_y = 0 - p1_y;
}
float p1_speed = (bytes[9] << 8 | bytes[8] );
if ((bytes[9] & 0x80) >> 7){
p1_speed -= pow(2, 15);
}else{
p1_speed = 0 - p1_speed;
}
int16_t p1_distance_resolution = (uint16_t((bytes[11] << 8) | bytes[10] ));
int16_t p2_x = (uint16_t((bytes[13] << 8) | bytes[12] ));
if ((bytes[13] & 0x80) >> 7){
p2_x -= pow(2, 15);
}else{
p2_x = 0 - p2_x;
}
int16_t p2_y = (uint16_t((bytes[15] << 8) | bytes[14] ));
if ((bytes[15] & 0x80) >> 7){
p2_y -= pow(2, 15);
}else{
p2_y = 0 - p2_y;
}
float p2_speed = (bytes[17] << 8 | bytes[16] );
if ((bytes[17] & 0x80) >> 7){
p2_speed -= pow(2, 15);
}else{
p2_speed = 0 - p2_speed;
}
int16_t p2_distance_resolution = (uint16_t((bytes[19] << 8) | bytes[18] ));
int16_t p3_x = (uint16_t((bytes[21] << 8) | bytes[20] ));
if ((bytes[21] & 0x80) >> 7){
p3_x -= pow(2, 15);
}else{
p3_x = 0 - p3_x;
}
int16_t p3_y = (uint16_t((bytes[23] << 8) | bytes[22] ));
if ((bytes[23] & 0x80) >> 7){
p3_y -= pow(2, 15);
}else{
p3_y = 0 - p3_y;
}
float p3_speed = (bytes[25] << 8 | bytes[24] );
if ((bytes[25] & 0x80) >> 7){
p3_speed -= pow(2, 15);
}else{
p3_speed = 0 - p3_speed;
}
int16_t p3_distance_resolution = (uint16_t((bytes[27] << 8) | bytes[26] ));
const float RADIANS_TO_DEGREES = 180.0 / 3.14159265358979323846;
float p1_angle = atan2(p1_y, p1_x) * RADIANS_TO_DEGREES;
float p2_angle = atan2(p2_y, p2_x) * RADIANS_TO_DEGREES;
float p3_angle = atan2(p3_y, p3_x) * RADIANS_TO_DEGREES;
float p1_distance = sqrt(p1_x * p1_x + p1_y * p1_y);
float p2_distance = sqrt(p2_x * p2_x + p2_y * p2_y);
float p3_distance = sqrt(p3_x * p3_x + p3_y * p3_y);
float max_distance = float(id(maxx_distance).state) * 10;
if (p1_distance < max_distance) {
id(target1_x).publish_state(p1_x * -1);
id(target1_y).publish_state(p1_y);
id(target1_speed).publish_state(p1_speed / 100);
id(target1_resolution).publish_state(p1_distance_resolution);
id(target1_distance).publish_state(p1_distance);
id(target1_angle).publish_state(p1_angle - 90);
} else {
id(target1_x).publish_state(0);
id(target1_y).publish_state(0);
id(target1_speed).publish_state(0);
id(target1_resolution).publish_state(0);
id(target1_distance).publish_state(0);
id(target1_angle).publish_state(0);
}
if (p2_distance < max_distance) {
id(target2_x).publish_state(p2_x);
id(target2_y).publish_state(p2_y);
id(target2_speed).publish_state(p2_speed / 100);
id(target2_resolution).publish_state(p2_distance_resolution);
id(target2_distance).publish_state(p2_distance);
id(target2_angle).publish_state(p2_angle);
} else {
id(target2_x).publish_state(0);
id(target2_y).publish_state(0);
id(target2_speed).publish_state(0);
id(target2_resolution).publish_state(0);
id(target2_distance).publish_state(0);
id(target2_angle).publish_state(0);
}
if (p3_distance < max_distance) {
id(target3_x).publish_state(p3_x);
id(target3_y).publish_state(p3_y);
id(target3_speed).publish_state(p3_speed / 100);
id(target3_resolution).publish_state(p3_distance_resolution);
id(target3_distance).publish_state(p3_distance);
id(target3_angle).publish_state(p3_angle);
} else {
id(target3_x).publish_state(0);
id(target3_y).publish_state(0);
id(target3_speed).publish_state(0);
id(target3_resolution).publish_state(0);
id(target3_distance).publish_state(0);
id(target3_angle).publish_state(0);
}
int zone1_count = 0;
if (id(target1_active).state == true ) {
if ((id(target1_x).state >= id(zone1_begin_x).state && id(target1_x).state <= id(zone1_end_x).state) &&
(id(target1_y).state >= id(zone1_begin_y).state && id(target1_y).state <= id(zone1_end_y).state)) {
zone1_count++;
}
}
if (id(target2_active).state == true ) {
if ((id(target2_x).state >= id(zone1_begin_x).state && id(target2_x).state <= id(zone1_end_x).state) &&
(id(target2_y).state >= id(zone1_begin_y).state && id(target2_y).state <= id(zone1_end_y).state)) {
zone1_count++;
}
}
if (id(target3_active).state == true ) {
if ((id(target3_x).state >= id(zone1_begin_x).state && id(target3_x).state <= id(zone1_end_x).state) &&
(id(target3_y).state >= id(zone1_begin_y).state && id(target3_y).state <= id(zone1_end_y).state)) {
zone1_count++;
}
}
if (zone1_count > 0) {
id(zone1_occupancy).publish_state(true);
id(zone1_target_count).publish_state(zone1_count);
} else {
id(zone1_occupancy).publish_state(false);
id(zone1_target_count).publish_state(0);
}
int zone2_count = 0;
if (id(target1_active).state == true ) {
if ((id(target1_x).state >= id(zone2_begin_x).state && id(target1_x).state <= id(zone2_end_x).state) &&
(id(target1_y).state >= id(zone2_begin_y).state && id(target1_y).state <= id(zone2_end_y).state)) {
zone2_count++;
}
}
if (id(target2_active).state == true ) {
if ((id(target2_x).state >= id(zone2_begin_x).state && id(target2_x).state <= id(zone2_end_x).state) &&
(id(target2_y).state >= id(zone2_begin_y).state && id(target2_y).state <= id(zone2_end_y).state)) {
zone2_count++;
}
}
if (id(target3_active).state == true ) {
if ((id(target3_x).state >= id(zone2_begin_x).state && id(target3_x).state <= id(zone2_end_x).state) &&
(id(target3_y).state >= id(zone2_begin_y).state && id(target3_y).state <= id(zone2_end_y).state)) {
zone2_count++;
}
}
if (zone2_count > 0) {
id(zone2_occupancy).publish_state(true);
id(zone2_target_count).publish_state(zone2_count);
} else {
id(zone2_occupancy).publish_state(false);
id(zone2_target_count).publish_state(0);
}
int zone3_count = 0;
if (id(target1_active).state == true ) {
if ((id(target1_x).state >= id(zone3_begin_x).state && id(target1_x).state <= id(zone3_end_x).state) &&
(id(target1_y).state >= id(zone3_begin_y).state && id(target1_y).state <= id(zone3_end_y).state)) {
zone3_count++;
}
}
if (id(target2_active).state == true ) {
if ((id(target2_x).state >= id(zone3_begin_x).state && id(target2_x).state <= id(zone3_end_x).state) &&
(id(target2_y).state >= id(zone3_begin_y).state && id(target2_y).state <= id(zone3_end_y).state)) {
zone3_count++;
}
}
if (id(target3_active).state == true ) {
if ((id(target3_x).state >= id(zone3_begin_x).state && id(target3_x).state <= id(zone3_end_x).state) &&
(id(target3_y).state >= id(zone3_begin_y).state && id(target3_y).state <= id(zone3_end_y).state)) {
zone3_count++;
}
}
if (zone3_count > 0) {
id(zone3_occupancy).publish_state(true);
id(zone3_target_count).publish_state(zone3_count);
} else {
id(zone3_occupancy).publish_state(false);
id(zone3_target_count).publish_state(0);
}
int zone4_count = 0;
if (id(target1_active).state == true ) {
if ((id(target1_x).state >= id(zone4_begin_x).state && id(target1_x).state <= id(zone4_end_x).state) &&
(id(target1_y).state >= id(zone4_begin_y).state && id(target1_y).state <= id(zone4_end_y).state)) {
zone4_count++;
}
}
if (id(target2_active).state == true ) {
if ((id(target2_x).state >= id(zone4_begin_x).state && id(target2_x).state <= id(zone4_end_x).state) &&
(id(target2_y).state >= id(zone4_begin_y).state && id(target2_y).state <= id(zone4_end_y).state)) {
zone4_count++;
}
}
if (id(target3_active).state == true ) {
if ((id(target3_x).state >= id(zone4_begin_x).state && id(target3_x).state <= id(zone4_end_x).state) &&
(id(target3_y).state >= id(zone4_begin_y).state && id(target3_y).state <= id(zone4_end_y).state)) {
zone4_count++;
}
}
if (zone4_count > 0) {
id(zone4_occupancy).publish_state(true);
id(zone4_target_count).publish_state(zone4_count);
} else {
id(zone4_occupancy).publish_state(false);
id(zone4_target_count).publish_state(0);
}
text_sensor:
## WiFi info
- platform: wifi_info
ip_address:
name: "${friendly_name} IP-address"
icon: "mdi:network-outline"
ssid:
name: "${friendly_name} SSID"
bssid:
name: "${friendly_name} BSSID"
## ESPHome Version Info
- platform: version
id: text_sensor_version
name: "${friendly_name} ESPHome Version"
## UltimateSensor Mini Info
- platform: template
id: text_sensor_ultimatesensor_mini_hardware_version
name: "${friendly_name} Hardware Version"
update_interval: 5h
lambda: |-
return {"${ultimatesensor_mini_hardware_version}"};
sensor:
## BH1750 Digital Ambient Light Sensor on I2C bus
- platform: bh1750
name: "${friendly_name} Illuminance"
id: illuminance
address: 0x23
update_interval: 90s
## Configure the SGP40 Indoor air quality sensor (VOC)
- platform: sgp4x
voc:
name: "${friendly_name} VOC Index"
nox:
name: "${friendly_name} NOx Index"
update_interval: 70s
## Configure the SCD41 Co2 sensor on I2C bus
- platform: scd4x
id: my_scd41
co2:
name: "${friendly_name} CO2"
id: scd41_co2
temperature:
name: "${friendly_name} Temperature"
id: scd41_temperature
temperature_offset: 2.3
humidity:
name: "${friendly_name} Humidity"
id: scd41_humidity
filters:
offset: 3
measurement_mode: low_power_periodic
update_interval: 60s
## SPS30 Particulate Matter (PM) Sensor
- platform: sps30
pm_1_0:
name: "${friendly_name} PM <1µm Weight concentration"
id: "PM_1_0"
pm_2_5:
name: "${friendly_name} PM <2.5µm Weight concentration"
id: "PM_2_5"
pm_4_0:
name: "${friendly_name} PM <4µm Weight concentration"
id: "PM_4_0"
pm_10_0:
name: "${friendly_name} PM <10µm Weight concentration"
id: "PM_10_0"
pmc_0_5:
name: "${friendly_name} PM <0.5µm Number concentration"
id: "PMC_0_5"
pmc_1_0:
name: "${friendly_name} PM <1µm Number concentration"
id: "PMC_1_0"
pmc_2_5:
name: "${friendly_name} PM <2.5µm Number concentration"
id: "PMC_2_5"
pmc_4_0:
name: "${friendly_name} PM <4µm Number concentration"
id: "PMC_4_0"
pmc_10_0:
name: "${friendly_name} PM <10µm Number concentration"
id: "PMC_10_0"
pm_size:
name: "${friendly_name} PM Typical Particle size"
id: "pm_size"
address: 0x69
update_interval: 115s
## LD2450 mmwave sensor template sensors
- platform: template
name: "${friendly_name} Target 1 X"
id: target1_x
accuracy_decimals: 0
unit_of_measurement: 'mm'
state_class: measurement
device_class: distance
- platform: template
name: "${friendly_name} Target 1 Y"
id: target1_y
accuracy_decimals: 0
unit_of_measurement: 'mm'
state_class: measurement
device_class: distance
- platform: template
name: "${friendly_name} Target 1 Speed"
id: target1_speed
accuracy_decimals: 2
unit_of_measurement: 'm/s'
state_class: measurement
device_class: speed
- platform: template
name: "${friendly_name} Target 1 Resolution"
id: target1_resolution
accuracy_decimals: 0
unit_of_measurement: 'mm'
state_class: measurement
device_class: distance
- platform: template
name: "${friendly_name} Target 2 X"
id: target2_x
accuracy_decimals: 0
unit_of_measurement: 'mm'
state_class: measurement
device_class: distance
- platform: template
name: "${friendly_name} Target 2 Y"
id: target2_y
accuracy_decimals: 0
unit_of_measurement: 'mm'
state_class: measurement
device_class: distance
- platform: template
name: "${friendly_name} Target 2 Speed"
id: target2_speed
accuracy_decimals: 2
unit_of_measurement: 'm/s'
state_class: measurement
device_class: speed
- platform: template
name: "${friendly_name} Target 2 Resolution"
id: target2_resolution
accuracy_decimals: 0
unit_of_measurement: 'mm'
state_class: measurement
device_class: distance
- platform: template
name: "${friendly_name} Target 3 X"
id: target3_x
accuracy_decimals: 0
unit_of_measurement: 'mm'
state_class: measurement
device_class: distance
- platform: template
name: "${friendly_name} Target 3 Y"
id: target3_y
accuracy_decimals: 0
unit_of_measurement: 'mm'
state_class: measurement
device_class: distance
- platform: template
name: "${friendly_name} Target 3 Speed"
id: target3_speed
accuracy_decimals: 2
unit_of_measurement: 'm/s'
state_class: measurement
device_class: speed
- platform: template
name: "${friendly_name} Target 3 Resolution"
id: target3_resolution
accuracy_decimals: 0
unit_of_measurement: 'mm'
state_class: measurement
device_class: distance
- platform: template
name: "${friendly_name} Target 1 Angle"
id: target1_angle
accuracy_decimals: 0
unit_of_measurement: '°'
state_class: measurement
- platform: template
name: "${friendly_name} Target 2 Angle"
id: target2_angle
accuracy_decimals: 0
unit_of_measurement: '°'
state_class: measurement
- platform: template
name: "${friendly_name} Target 3 Angle"
id: target3_angle
accuracy_decimals: 0
unit_of_measurement: '°'
state_class: measurement
- platform: template
name: "${friendly_name} Target 1 Distance"
id: target1_distance
accuracy_decimals: 0
unit_of_measurement: 'mm'
state_class: measurement
device_class: distance
- platform: template
name: "${friendly_name} Target 2 Distance"
id: target2_distance
accuracy_decimals: 0
unit_of_measurement: 'mm'
state_class: measurement
device_class: distance
- platform: template
name: "${friendly_name} Target 3 Distance"
id: target3_distance
accuracy_decimals: 0
unit_of_measurement: 'mm'
state_class: measurement
device_class: distance
- platform: template
name: "${friendly_name} Zone 1 Target Count"
id: zone1_target_count
accuracy_decimals: 0
- platform: template
name: "${friendly_name} Zone 2 Target Count"
id: zone2_target_count
accuracy_decimals: 0
- platform: template
name: "${friendly_name} Zone 3 Target Count"
id: zone3_target_count
accuracy_decimals: 0
- platform: template
name: "${friendly_name} Zone 4 Target Count"
id: zone4_target_count
accuracy_decimals: 0
disabled_by_default: true
binary_sensor:
## mmwave template sensors
- platform: template
name: "${friendly_name} Occupancy"
device_class: occupancy
filters:
- delayed_off: !lambda return (id(off_delay).state *1000);
lambda: |-
return (id(target1_distance).state != 0
|| id(target2_distance).state != 0
|| id(target3_distance).state != 0);
- platform: template
name: "${friendly_name} Zone 1 Occupancy"
id: zone1_occupancy
filters:
- delayed_off: !lambda return (id(zone_1_off_delay).state *1000);
- platform: template
name: "${friendly_name} Zone 2 Occupancy"
id: zone2_occupancy
filters:
- delayed_off: !lambda return (id(zone_2_off_delay).state *1000);
- platform: template
name: "${friendly_name} Zone 3 Occupancy"
id: zone3_occupancy
filters:
- delayed_off: !lambda return (id(zone_3_off_delay).state *1000);
- platform: template
name: "${friendly_name} Zone 4 Occupancy"
id: zone4_occupancy
filters:
- delayed_off: !lambda return (id(zone_4_off_delay).state *1000);
disabled_by_default: true
- platform: template
name: "${friendly_name} Target 1 Active"
id: target1_active
lambda: |-
return id(target1_distance).state != 0;
- platform: template
name: "${friendly_name} Target 2 Active"
id: target2_active
lambda: |-
return id(target2_distance).state != 0;
- platform: template
name: "${friendly_name} Target 3 Active"
id: target3_active
lambda: |-
return id(target3_distance).state != 0;
number:
## mmwave template sensors
- platform: template
name: "${friendly_name} Occupancy Off Delay"
id: off_delay
max_value: 600
min_value: 0
step: 1
optimistic: True
restore_value: True
unit_of_measurement: "s"
initial_value: 15
- platform: template
name: "${friendly_name} Max Distance"
id: maxx_distance
max_value: 600
min_value: 0
unit_of_measurement: "cm"
step: 1
optimistic: True
restore_value: True
initial_value: 600
- platform: template
name: "${friendly_name} Zone 1 Begin X"
id: zone1_begin_x
max_value: 4000
min_value: -4000
unit_of_measurement: "mm"
step: 10
optimistic: True
restore_value: True
initial_value: -4000
- platform: template
name: "${friendly_name} Zone 1 End X"
id: zone1_end_x
max_value: 4000
min_value: -4000
unit_of_measurement: "mm"
step: 10
optimistic: True
restore_value: True
initial_value: 4000
- platform: template
name: "${friendly_name} Zone 1 Begin Y"
id: zone1_begin_y
max_value: 6000
min_value: 0
unit_of_measurement: "mm"
step: 10
optimistic: True
restore_value: True
initial_value: 0
- platform: template
name: "${friendly_name} Zone 1 End Y"
id: zone1_end_y
max_value: 6000
min_value: 0
unit_of_measurement: "mm"
step: 10
optimistic: True
restore_value: True
initial_value: 6000
- platform: template
name: "${friendly_name} Zone 1 Occupancy Off Delay"
id: zone_1_off_delay
max_value: 600
min_value: 0
step: 1
optimistic: True
restore_value: True
unit_of_measurement: "s"
initial_value: 15
- platform: template
name: "${friendly_name} Zone 2 Begin X"
id: zone2_begin_x
max_value: 4000
min_value: -4000
unit_of_measurement: "mm"
step: 10
optimistic: True
restore_value: True
- platform: template
name: "${friendly_name} Zone 2 End X"
id: zone2_end_x
max_value: 4000
min_value: -4000
unit_of_measurement: "mm"
step: 10
optimistic: True
restore_value: True
- platform: template
name: "${friendly_name} Zone 2 Begin Y"
id: zone2_begin_y
max_value: 6000
min_value: 0
unit_of_measurement: "mm"
step: 10
optimistic: True
restore_value: True
- platform: template
name: "${friendly_name} Zone 2 End Y"
id: zone2_end_y
max_value: 6000
min_value: 0
unit_of_measurement: "mm"
step: 10
optimistic: True
restore_value: True
- platform: template
name: "${friendly_name} Zone 2 Occupancy Off Delay"
id: zone_2_off_delay
max_value: 600
min_value: 0
step: 1
optimistic: True
restore_value: True
unit_of_measurement: "s"
initial_value: 15
- platform: template
name: "${friendly_name} Zone 3 Begin X"
id: zone3_begin_x
max_value: 4000
min_value: -4000
unit_of_measurement: "mm"
step: 10
optimistic: True
restore_value: True
- platform: template
name: "${friendly_name} Zone 3 End X"
id: zone3_end_x
max_value: 4000
min_value: -4000
unit_of_measurement: "mm"
step: 10
optimistic: True
restore_value: True
- platform: template
name: "${friendly_name} Zone 3 Begin Y"
id: zone3_begin_y
max_value: 6000
min_value: 0
unit_of_measurement: "mm"
step: 10
optimistic: True
restore_value: True
- platform: template
name: "${friendly_name} Zone 3 End Y"
id: zone3_end_y
max_value: 6000
min_value: 0
unit_of_measurement: "mm"
step: 10
optimistic: True
restore_value: True
- platform: template
name: "${friendly_name} Zone 3 Occupancy Off Delay"
id: zone_3_off_delay
max_value: 600
min_value: 0
step: 1
optimistic: True
restore_value: True
unit_of_measurement: "s"
initial_value: 15
- platform: template
name: "${friendly_name} Zone 4 Begin X"
id: zone4_begin_x
max_value: 4000
min_value: -4000
unit_of_measurement: "mm"
step: 10
optimistic: True
restore_value: True
disabled_by_default: true
- platform: template
name: "${friendly_name} Zone 4 End X"
id: zone4_end_x
max_value: 4000
min_value: -4000
unit_of_measurement: "mm"
step: 10
optimistic: True
restore_value: True
disabled_by_default: true
- platform: template
name: "${friendly_name} Zone 4 Begin Y"
id: zone4_begin_y
max_value: 6000
min_value: 0
unit_of_measurement: "mm"
step: 10
optimistic: True
restore_value: True
disabled_by_default: true
- platform: template
name: "${friendly_name} Zone 4 End Y"
id: zone4_end_y
max_value: 6000
min_value: 0
unit_of_measurement: "mm"
step: 10
optimistic: True
restore_value: True
disabled_by_default: true
- platform: template
name: "${friendly_name} Zone 4 Occupancy Off Delay"
id: zone_4_off_delay
max_value: 600
min_value: 0
step: 1
optimistic: True
restore_value: True
unit_of_measurement: "s"
initial_value: 15
disabled_by_default: true
i2s_audio:
- id: i2s_in
i2s_lrclk_pin: GPIO7
i2s_bclk_pin: GPIO16
- id: i2s_out
i2s_lrclk_pin: GPIO8
i2s_bclk_pin: GPIO18
adf_pipeline:
- platform: i2s_audio
type: audio_out
id: adf_i2s_out
i2s_audio_id: i2s_out
i2s_dout_pin: GPIO17
- platform: i2s_audio
type: audio_in
id: adf_i2s_in
i2s_audio_id: i2s_in
i2s_din_pin: GPIO15
pdm: false
channel: right
sample_rate: 16000
bits_per_sample: 32bit
microphone:
- platform: adf_pipeline
id: adf_microphone
keep_pipeline_alive: true
pipeline:
- adf_i2s_in
- self
media_player:
- platform: adf_pipeline
id: adf_media_player
name: "${friendly_name} Media Player"
keep_pipeline_alive: true
internal: false
pipeline:
- self
- resampler
- adf_i2s_out
micro_wake_word:
models:
- model: ${wake_word}
on_wake_word_detected:
- media_player.stop:
- light.turn_on:
id: rgb_front_led
blue: 0%
red: 0%
green: 100%
brightness: 75%
effect: "Slow Pulse"
- voice_assistant.start:
voice_assistant:
microphone: adf_microphone
media_player: adf_media_player
use_wake_word: false
#vad_threshold: 3
#noise_suppression_level: 1
auto_gain: 31dBFS
#volume_multiplier: 15.0
on_client_connected:
- lambda: id(init_in_progress) = false;
- if:
condition:
switch.is_on: use_wake_word
then:
- micro_wake_word.start:
- lambda: id(voice_assistant_phase) = ${voice_assist_idle_phase_id};
- script.execute: reset_led
else:
- lambda: id(voice_assistant_phase) = ${voice_assist_muted_phase_id};
on_client_disconnected:
- lambda: id(voice_assistant_phase) = ${voice_assist_not_ready_phase_id};
- voice_assistant.stop
- micro_wake_word.stop
- light.turn_on:
id: rgb_front_led
blue: 0%
red: 100%
green: 100%
brightness: 50%
effect: connecting
on_listening:
- light.turn_on:
id: rgb_front_led
blue: 100%
red: 0%
green: 0%
brightness: 50%