-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsupersensor.yaml
979 lines (906 loc) · 27.5 KB
/
supersensor.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
---
###############################################################################
# SuperSensor v1.0 ESPHome configuration
###############################################################################
#
# Copyright (C) 2023 Joshua M. Boniface <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
###############################################################################
esphome:
name: supersensor
name_add_mac_suffix: true
friendly_name: "Supersensor"
project:
name: joshuaboniface.supersensor
version: "1.1"
on_boot:
- priority: 600
then:
- lambda: |-
id(supersensor_occupancy).publish_state(false);
id(pir_presence).publish_state(false);
id(light_presence).publish_state(false);
id(radar_presence).publish_state(false);
- light.turn_on:
id: output_led
effect: flash_white
- priority: -600
then:
- wait_until:
api.connected:
- delay: 5s
- if:
condition:
and:
- switch.is_on: enable_voice_support
then:
- switch.turn_on: voice_support_active
dashboard_import:
package_import_url: github://joshuaboniface/supersensor/supersensor.yaml
esp32:
board: esp32dev
framework:
type: esp-idf
version: 4.4.8
platform_version: 5.4.0
sdkconfig_options:
CONFIG_ESP32_DEFAULT_CPU_FREQ_240: "y"
CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ: "240"
CONFIG_ESP32_DATA_CACHE_64KB: "y"
CONFIG_ESP32_DATA_CACHE_LINE_64B: "y"
CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: "y"
CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ: "240"
CONFIG_ESP32S3_DATA_CACHE_64KB: "y"
CONFIG_ESP32S3_DATA_CACHE_LINE_64B: "y"
globals:
- id: gas_resistance_ceiling
type: int
restore_value: yes
initial_value: "200"
- id: pir_hold_time
type: int
restore_value: yes
initial_value: "15"
- id: light_presence_threshold
type: int
restore_value: yes
initial_value: "30"
- id: occupancy_detect_mode
type: int
restore_value: yes
initial_value: "0"
- id: occupancy_clear_mode
type: int
restore_value: yes
initial_value: "0"
script:
- id: pir_handler
then:
- lambda: |-
id(pir_presence).publish_state(true);
- while:
condition:
binary_sensor.is_on: pir_gpio
then:
- delay: !lambda 'return(id(pir_hold_time) * 1000);'
- lambda: |-
id(pir_presence).publish_state(false);
- id: light_handler
then:
- lambda: |-
if (id(tsl2591_lux).state >= id(light_presence_threshold)) {
id(light_presence).publish_state(true);
} else {
id(light_presence).publish_state(false);
}
- id: occupancy_detect_handler
then:
- lambda: |-
ESP_LOGD("occupancy_detect_handler", "Occupancy detect handler triggered");
// Get the current values of our presence sensors
bool pir = id(pir_presence).state;
bool radar = id(radar_presence).state;
bool light = id(light_presence).state;
// Determine if PIR counts (2nd bit of presence_type)
int pir_counts = (id(occupancy_detect_mode) & ( 1 << 2 )) >> 2;
// Determine if Radar counts (1st bit of presence_type)
int radar_counts = (id(occupancy_detect_mode) & ( 1 << 1 )) >> 1;
// Determine if Light counts (0th bit of presence_type)
int light_counts = (id(occupancy_detect_mode) & ( 1 << 0 )) >> 0;
// Determine our results
if (pir_counts & radar_counts & light_counts) {
// Logical AND of pir & radar & light
ESP_LOGD("occupancy_detect_handler", "PIR & Radar & Light: %i", pir & radar & light);
id(supersensor_occupancy).publish_state(pir & radar & light);
} else if (pir_counts & radar_counts) {
// Logical AND of pir & radar
ESP_LOGD("occupancy_detect_handler", "PIR & Radar: %i", pir & radar);
id(supersensor_occupancy).publish_state(pir & radar);
} else if (pir_counts & light_counts) {
// Logical AND of pir & light
ESP_LOGD("occupancy_detect_handler", "PIR & Light: %i", pir & light);
id(supersensor_occupancy).publish_state(pir & light);
} else if (radar_counts & light_counts) {
// Logical AND of radar & light
ESP_LOGD("occupancy_detect_handler", "Radar & Light: %i", radar & light);
id(supersensor_occupancy).publish_state(radar & light);
} else if (pir_counts) {
// Only pir
ESP_LOGD("occupancy_detect_handler", "PIR: %i", pir);
id(supersensor_occupancy).publish_state(pir);
} else if (radar_counts) {
// Only radar
ESP_LOGD("occupancy_detect_handler", "Radar: %i", radar);
id(supersensor_occupancy).publish_state(radar);
} else if (light_counts) {
// Only light
ESP_LOGD("occupancy_detect_handler", "Light: %i", light);
id(supersensor_occupancy).publish_state(light);
} else {
ESP_LOGD("occupancy_detect_handler", "None");
id(supersensor_occupancy).publish_state(false);
}
- id: occupancy_clear_handler
then:
- lambda: |-
ESP_LOGD("occupancy_clear_handler", "Occupancy clear handler triggered");
// Get the current values of our presence sensors
bool pir = id(pir_presence).state;
bool radar = id(radar_presence).state;
bool light = id(light_presence).state;
// Determine if PIR counts (2nd bit of presence_type)
int pir_counts = (id(occupancy_clear_mode) & ( 1 << 2 )) >> 2;
// Determine if Radar counts (1st bit of presence_type)
int radar_counts = (id(occupancy_clear_mode) & ( 1 << 1 )) >> 1;
// Determine if Light counts (0th bit of presence_type)
int light_counts = (id(occupancy_clear_mode) & ( 1 << 0 )) >> 0;
// Determine our results
if (pir_counts & radar_counts & light_counts) {
// Logical AND of pir & radar & light
ESP_LOGD("occupancy_clear_handler", "PIR & Radar & Light: %i", pir & radar & light);
id(supersensor_occupancy).publish_state(pir & radar & light);
} else if (pir_counts & radar_counts) {
// Logical AND of pir & radar
ESP_LOGD("occupancy_clear_handler", "PIR & Radar: %i", pir & radar);
id(supersensor_occupancy).publish_state(pir & radar);
} else if (pir_counts & light_counts) {
// Logical AND of pir & light
ESP_LOGD("occupancy_clear_handler", "PIR & Light: %i", pir & light);
id(supersensor_occupancy).publish_state(pir & light);
} else if (radar_counts & light_counts) {
// Logical AND of radar & light
ESP_LOGD("occupancy_clear_handler", "Radar & Light: %i", radar & light);
id(supersensor_occupancy).publish_state(radar & light);
} else if (pir_counts) {
// Only pir
ESP_LOGD("occupancy_clear_handler", "PIR: %i", pir);
id(supersensor_occupancy).publish_state(pir);
} else if (radar_counts) {
// Only radar
ESP_LOGD("occupancy_clear_handler", "Radar: %i", radar);
id(supersensor_occupancy).publish_state(radar);
} else if (light_counts) {
// Only light
ESP_LOGD("occupancy_clear_handler", "Light: %i", light);
id(supersensor_occupancy).publish_state(light);
} else {
ESP_LOGD("occupancy_clear_handler", "None");
id(supersensor_occupancy).publish_state(false);
}
preferences:
flash_write_interval: 15sec
logger:
level: INFO
baud_rate: 115200
api:
ota:
platform: esphome
web_server:
port: 80
captive_portal:
mdns:
disabled: false
wifi:
ap: {}
domain: ""
fast_connect: false
output_power: 8.5dB
reboot_timeout: 5min
uart:
id: ld2410_uart
rx_pin: GPIO19
tx_pin: GPIO18
baud_rate: 256000
data_bits: 8
stop_bits: 1
parity: NONE
i2c:
sda: GPIO16
scl: GPIO17
scan: true
i2s_audio:
i2s_lrclk_pin: GPIO26
i2s_bclk_pin: GPIO27
microphone:
- platform: i2s_audio
id: mic
adc_type: external
i2s_din_pin: GPIO14
pdm: false
interval:
- interval: 5s
then:
- if:
condition:
and:
- switch.is_on: voice_support_active
- not: voice_assistant.is_running
then:
- logger.log: "voice assistant not running; restarting"
- voice_assistant.start_continuous:
# Add optional microWakeWord support (on-device wake word)
# Doesn't work well as of 2024-07-04 so leave disabled
#micro_wake_word:
# model: hey_jarvis
# on_wake_word_detected:
# then:
# - voice_assistant.start:
# wake_word: !lambda return wake_word;
# Include the Espressif Audio Development Framework for VAD support
esp_adf:
external_components:
- source: github://pr#5230
components:
- esp_adf
refresh: 0s
voice_assistant:
microphone: mic
use_wake_word: false
noise_suppression_level: 3
auto_gain: 31dBFS
volume_multiplier: 8.0
id: assist
on_error:
- logger.log: "voice error"
- light.turn_off:
id: output_led
transition_length: 1s
- if:
condition:
and:
- switch.is_on: voice_support_active
- not: voice_assistant.is_running
then:
- voice_assistant.start_continuous:
on_end:
- logger.log: "voice ended"
- light.turn_off:
id: output_led
transition_length: 1s
- if:
condition:
and:
- switch.is_on: voice_support_active
- not: voice_assistant.is_running
then:
- voice_assistant.start_continuous:
on_client_connected:
- light.turn_off:
id: output_led
on_client_disconnected:
- light.turn_on:
id: output_led
effect: flash_white
on_wake_word_detected:
- light.turn_off:
id: output_led
- light.turn_on:
id: output_led
brightness: 100%
red: 0
green: 0
blue: 1
on_listening:
- light.turn_on:
id: output_led
brightness: 100%
red: 0
green: 0
blue: 1
on_stt_vad_end:
- light.turn_on:
id: output_led
brightness: 75%
red: 0
green: 1
blue: 1
on_stt_end:
- light.turn_off:
id: output_led
transition_length: 1s
on_tts_start:
- light.turn_off:
id: output_led
transition_length: 1s
- if:
condition:
lambda: return x == "Sorry, I couldn't understand that";
then:
- logger.log: "Command failed!"
- light.turn_on:
id: output_led
effect: hold
brightness: 100%
red: 1
green: 0
blue: 0
else:
- logger.log: "Command successful!"
- light.turn_on:
id: output_led
effect: hold
brightness: 100%
red: 0
green: 1
blue: 0
on_tts_end:
- light.turn_off:
id: output_led
transition_length: 1s
light:
- platform: rgb
id: output_led
red: rgb_r
green: rgb_g
blue: rgb_b
default_transition_length: 0.15s
flash_transition_length: 0.15s
effects:
- strobe:
name: flash_white
colors:
- state: true
brightness: 50%
red: 100%
green: 90%
blue: 90%
duration: 0.5s
- state: false
duration: 0.5s
- automation:
name: hold
sequence:
- delay: 5s
- light.turn_off:
id: output_led
transition_length: 1s
output:
- platform: ledc
id: rgb_r
pin: GPIO32
- platform: ledc
id: rgb_g
pin: GPIO33
- platform: ledc
id: rgb_b
pin: GPIO25
ld2410:
id: ld2410_radar
uart_id: ld2410_uart
# These default values are captured here for
# posterity. They are configured below.
# max_move_distance : 6m
# max_still_distance: 0.75m
# g0_move_threshold: 10
# g0_still_threshold: 20
# g1_move_threshold: 10
# g1_still_threshold: 20
# g2_move_threshold: 20
# g2_still_threshold: 21
# g3_move_threshold: 30
# g3_still_threshold: 31
# g4_move_threshold: 40
# g4_still_threshold: 41
# g5_move_threshold: 50
# g5_still_threshold: 51
# g6_move_threshold: 60
# g6_still_threshold: 61
# g7_move_threshold: 70
# g7_still_threshold: 71
# g8_move_threshold: 80
# g8_still_threshold: 81
binary_sensor:
- platform: template
name: "SuperSensor Occupancy"
id: supersensor_occupancy
device_class: occupancy
- platform: gpio
name: "PIR GPIO"
id: pir_gpio
pin: GPIO13
internal: false
device_class: motion
on_press:
- script.stop: pir_handler
- script.execute: pir_handler
- platform: template
name: "PIR Presence"
id: pir_presence
device_class: motion
on_press:
- script.execute: occupancy_detect_handler
on_release:
- script.execute: occupancy_clear_handler
- platform: template
name: "Light Presence"
id: light_presence
device_class: motion
on_press:
- script.execute: occupancy_detect_handler
on_release:
- script.execute: occupancy_clear_handler
- platform: ld2410
ld2410_id: ld2410_radar
has_target:
name: "LD2410C Presence"
id: radar_presence
icon: mdi:motion-sensor
device_class: motion
on_press:
- script.execute: occupancy_detect_handler
on_release:
- script.execute: occupancy_clear_handler
has_moving_target:
name: "LD2410C Moving Target"
has_still_target:
name: "LD2410C Still Target"
sensor:
- platform: bme680
address: 0x77
update_interval: 5s
iir_filter: 127x
temperature:
name: "BME680 Temperature"
id: bme680_temperature
oversampling: 16x
pressure:
name: "BME680 Pressure"
id: bme680_pressure
oversampling: 16x
humidity:
name: "BME680 Relative Humidity"
id: bme680_humidity
oversampling: 16x
gas_resistance:
name: "BME680 Gas Resistance"
id: bme680_gas_resistance
- platform: absolute_humidity
name: "BME680 Absolute Humidity"
temperature: bme680_temperature
humidity: bme680_humidity
id: bme680_absolute_humidity
- platform: template
name: "BME680 AQ"
id: bme680_aq
icon: "mdi:gauge"
unit_of_measurement: "%"
accuracy_decimals: 0
update_interval: 5s
# Calculation from https://github.com/thstielow/raspi-bme680-iaq
lambda: |-
float ph_slope = 0.03;
float comp_gas = id(bme680_gas_resistance).state * pow(2.718281, (ph_slope * id(bme680_absolute_humidity).state));
float gas_ratio = pow((comp_gas / (id(gas_resistance_ceiling) * 1000)), 2);
if (gas_ratio > 1) {
gas_ratio = 1.0;
}
float air_quality = gas_ratio * 100;
int normalized_air_quality = (int)air_quality;
if (normalized_air_quality > 100) {
normalized_air_quality = 100;
}
return normalized_air_quality;
- platform: tsl2591
address: 0x29
update_interval: 1s
integration_time: 200ms
power_save_mode: no
gain: auto
device_factor: 53
glass_attenuation_factor: 7.7
visible:
name: "TSL2591 Raw Visible"
infrared:
name: "TSL2591 Raw Infrared"
full_spectrum:
name: "TSL2591 Raw Full Spectrum"
calculated_lux:
id: tsl2591_lux
name: "TSL2591 Illumination"
unit_of_measurement: lx
on_value:
- script.execute: light_handler
actual_gain:
id: "actual_gain"
name: "TSL2591 Gain"
- platform: ld2410
ld2410_id: ld2410_radar
moving_distance:
name: "LD2410C Moving Distance"
id: moving_distance
icon: mdi:signal-distance-variant
still_distance:
name: "LD2410C Still Distance"
id: still_distance
icon: mdi:signal-distance-variant
moving_energy:
name: "LD2410C Move Energy"
icon: mdi:flash
still_energy:
name: "LD2410C Still Energy"
icon: mdi:flash
detection_distance:
name: "LD2410C Presence Distance"
icon: mdi:signal-distance-variant
- platform: uptime
name: "ESP32 Uptime"
icon: mdi:clock-alert
update_interval: 5s
entity_category: diagnostic
- platform: wifi_signal
name: "WiFi RSSI"
icon: mdi:wifi-strength-2
update_interval: 5s
entity_category: diagnostic
- platform: internal_temperature
name: "ESP32 Temperature"
icon: mdi:thermometer
unit_of_measurement: °C
device_class: TEMPERATURE
update_interval: 5s
entity_category: diagnostic
- platform: template
name: "ESP32 CPU Frequency"
icon: mdi:cpu-32-bit
accuracy_decimals: 1
unit_of_measurement: MHz
update_interval: 5s
lambda: |-
return ets_get_cpu_frequency();
entity_category: diagnostic
- platform: template
name: "ESP32 Free Memory"
icon: mdi:memory
unit_of_measurement: 'kB'
state_class: measurement
update_interval: 5s
lambda: |-
return heap_caps_get_free_size(MALLOC_CAP_INTERNAL) / 1024;
entity_category: diagnostic
text_sensor:
- platform: template
name: "BME680 AQ Classification"
icon: "mdi:air-filter"
update_interval: 5s
lambda: |-
int aq = int(id(bme680_aq).state);
if (aq >= 90) {
return {"Excellent"};
}
else if (aq >= 80) {
return {"Good"};
}
else if (aq >= 70) {
return {"Fair"};
}
else if (aq >= 60) {
return {"Moderate"};
}
else if (aq >= 50) {
return {"Bad"};
}
else {
return {"Terrible"};
}
- platform: wifi_info
ip_address:
name: "WiFi IP Address"
ssid:
name: "WiFi SSID"
bssid:
name: "WiFi BSSID"
mac_address:
name: "WiFi MAC Address"
- platform: ld2410
version:
name: "LD2410C Firmware Version"
mac_address:
name: "LD2410C MAC Address"
button:
- platform: ld2410
restart:
name: "LD2410C Restart"
icon: mdi:power-cycle
entity_category: diagnostic
factory_reset:
name: "LD2410C Factory Reset"
icon: mdi:restart-alert
entity_category: diagnostic
- platform: restart
name: "ESP32 Restart"
icon: mdi:power-cycle
entity_category: diagnostic
- platform: factory_reset
name: "ESP32 Factory Reset"
icon: mdi:restart-alert
entity_category: diagnostic
switch:
# Global enable/disable for voice support
- platform: template
name: "Enable Voice Support"
icon: mdi:account-voice
id: enable_voice_support
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
on_turn_on:
- switch.turn_on: voice_support_active
on_turn_off:
- switch.turn_off: voice_support_active
# Active voice support flag/switch
- platform: template
name: "Voice Support Active"
icon: mdi:account-voice
id: voice_support_active
optimistic: true
restore_mode: ALWAYS_OFF
entity_category: config
on_turn_on:
- lambda: id(assist).set_use_wake_word(true);
- voice_assistant.start_continuous:
on_turn_off:
- voice_assistant.stop:
- lambda: id(assist).set_use_wake_word(false);
- platform: ld2410
engineering_mode:
name: "LD2410C Engineering Mode"
entity_category: diagnostic
bluetooth:
name: "LD2410C Bluetooth"
entity_category: diagnostic
number:
- platform: template
name: "Gas Resistance Ceiling (kΩ)"
id: gas_resistance_ceiling_setter
min_value: 10
max_value: 500
step: 1
entity_category: config
lambda: |-
return id(gas_resistance_ceiling);
set_action:
then:
- globals.set:
id: gas_resistance_ceiling
value: !lambda 'return int(x);'
# PIR Hold Time:
# The number of seconds after motion detection for the PIR sensor to remain held on
- platform: template
name: "PIR Hold Time"
id: pir_hold_time_setter
min_value: 0
max_value: 60
step: 5
lambda: |-
return id(pir_hold_time);
set_action:
then:
- globals.set:
id: pir_hold_time
value: !lambda 'return int(x);'
# Light Presence Threshold
# The minimum Lux value to consider presence based on the ambient light level
- platform: template
name: "Light Presence Threshold"
id: light_presence_threshold_setter
min_value: 0
max_value: 200
step: 5
lambda: |-
return id(light_presence_threshold);
set_action:
then:
- globals.set:
id: light_presence_threshold
value: !lambda 'return int(x);'
- platform: ld2410
timeout:
name: "LD2410C Timeout"
light_threshold:
name: "LD2410C Light Threshold"
max_move_distance_gate:
name: "LD2410C Max Move Distance Gate"
max_still_distance_gate:
name: "LD2410C Max Still Distance Gate"
g0:
move_threshold:
name: "LD2410C Gate0 Move Threshold"
still_threshold:
name: "LD2410C Gate0 Still Threshold"
g1:
move_threshold:
name: "LD2410C Gate1 Move Threshold"
still_threshold:
name: "LD2410C Gate1 Still Threshold"
g2:
move_threshold:
name: "LD2410C Gate2 Move Threshold"
still_threshold:
name: "LD2410C Gate2 Still Threshold"
g3:
move_threshold:
name: "LD2410C Gate3 Move Threshold"
still_threshold:
name: "LD2410C Gate3 Still Threshold"
g4:
move_threshold:
name: "LD2410C Gate4 Move Threshold"
still_threshold:
name: "LD2410C Gate4 Still Threshold"
g5:
move_threshold:
name: "LD2410C Gate5 Move Threshold"
still_threshold:
name: "LD2410C Gate5 Still Threshold"
g6:
move_threshold:
name: "LD2410C Gate6 Move Threshold"
still_threshold:
name: "LD2410C Gate6 Still Threshold"
g7:
move_threshold:
name: "LD2410C Gate7 Move Threshold"
still_threshold:
name: "LD2410C Gate7 Still Threshold"
g8:
move_threshold:
name: "LD2410C Gate8 Move Threshold"
still_threshold:
name: "LD2410C Gate8 Still Threshold"
select:
# Occupancy Detect Mode:
# This selector defines the detection mode for the integrated occupancy sensor. Depending on the
# selected option, only the given sensor(s) will be used to judge when occupancy begins (i.e.
# when the given sensor(s) detect, occupancy detects).
# * PIR + Radar + Light:
# All 3 sensors reporting detection simultaneously will begin occupancy
# * PIR + Radar
# Both PIR and Radar sensors reporting detection simultaneously will begin occupancy
# * PIR + Light
# Both PIR and Light sensors reporting detection simultaneously will begin occupancy
# * Radar + Light
# Both Radar and Light sensors reporting detection simultaneously will begin occupancy
# * PIR Only
# PIR sensor reporting detection will begin occupancy
# * Radar Only
# Radar sensor reporting detection will begin occupancy
# * Light Only
# Light sensor reporting detection will begin occupancy
# * None
# No sensors will begin occupancy and the integrated occupancy functionality is disabled
# Values are reported as integers using bitwise logic:
# Bit 2: PIR
# Bit 1: Radar
# Bit 0: Light
- platform: template
name: "Occupancy Detect Mode"
id: occupancy_detect_mode_setter
options:
- "PIR + Radar + Light" # 111 = 7
- "PIR + Radar" # 110 = 6
- "PIR + Light" # 101 = 5
- "Radar + Light" # 011 = 3
- "PIR Only" # 100 = 4
- "Radar Only" # 010 = 2
- "Light Only" # 001 = 1
- "None" # 000 = 0
initial_option: "None"
optimistic: yes
restore_value: yes
set_action:
- globals.set:
id: occupancy_detect_mode
value: !lambda |-
ESP_LOGD("occupancy_detect_mode_setter", x.c_str());
if (x == "PIR + Radar + Light") {
return 7;
} else if (x == "PIR + Radar") {
return 6;
} else if (x == "PIR + Light") {
return 5;
} else if (x == "Radar + Light") {
return 3;
} else if (x == "PIR Only") {
return 4;
} else if (x == "Radar Only") {
return 2;
} else if (x == "Light Only") {
return 1;
} else {
return 0;
}
# Occupancy Clear Mode:
# This selector defines the clear mode for the integrated occupancy sensor. Depending on the
# selected option, only the given sensor(s) will be used to judge when occupancy ends (i.e.
# when the given sensor(s) clear, occupancy clears).
# * PIR + Radar + Light:
# Any of the 3 sensors clearing will end occupancy
# * PIR + Radar:
# Either of the PIR or Radar sensors clearing will end occupancy
# * PIR + Light:
# Either of the PIR or Light sensors clearing will end occupancy
# * Radar + Light:
# Either of the Radar or Light sensors clearing will end occupancy
# * PIR Only
# PIR sensor clearing will end occupancy
# * Radar Only
# Radar sensor clearing will end occupancy
# * Light Only
# Light sensor clearing will end occupancy
# * None
# No sensors will end occupancy; state will persist indefinitely once triggered
# Values are reported as integers using bitwise logic:
# Bit 0: PIR
# Bit 1: Radar
# Bit 2: Light
- platform: template
name: "Occupancy Clear Mode"
id: occupancy_clear_mode_setter
options:
- "PIR + Radar + Light" # 111 = 7
- "PIR + Radar" # 110 = 6
- "PIR + Light" # 101 = 5
- "Radar + Light" # 011 = 3
- "PIR Only" # 100 = 4
- "Radar Only" # 010 = 2
- "Light Only" # 001 = 1
- "None" # 000 = 0
initial_option: "None"
optimistic: yes
restore_value: yes
set_action:
- globals.set:
id: occupancy_clear_mode
value: !lambda |-
ESP_LOGD("occupancy_detect_mode_setter", x.c_str());
if (x == "PIR + Radar + Light") {
return 7;
} else if (x == "PIR + Radar") {
return 6;
} else if (x == "PIR + Light") {
return 5;
} else if (x == "Radar + Light") {
return 3;
} else if (x == "PIR Only") {
return 4;
} else if (x == "Radar Only") {
return 2;
} else if (x == "Light Only") {
return 1;
} else {
return 0;
}
- platform: ld2410
distance_resolution:
name: "LD2410C Distance Resolution"