-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathtof_sensor.yaml
105 lines (90 loc) · 2.08 KB
/
tof_sensor.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
substitutions:
devicename: tof_sensor
friendly_name: tof sensor
esphome:
name: $devicename
platform: ESP8266
board: nodemcuv2
# board: d1_mini
# platform: ESP32
# board: nodemcu-32s
# board: esp32dev
includes:
- tof_people_counter/tof_vl53l1x_api.h
<<: !include common/common.yaml
# Enable logging
logger:
level: ERROR
esp8266_store_log_strings_in_flash: False
i2c:
switch:
- platform: restart
name: $friendly_name Restart
binary_sensor:
- platform: status
name: $friendly_name Status
- platform: template
name: "Door sensor"
lambda: |-
if (id(tof_distance_avg).state < 1400) {
// someone standing in door
return true;
} else {
// no-one there
return false;
}
filters:
- delayed_off: 100ms
sensor:
- platform: wifi_signal
name: $friendly_name RSSI
update_interval: 60s
- platform: uptime
name: $friendly_name Uptime
- platform: custom
lambda: |-
auto people_counter = new PeopleCountSensor();
App.register_component(people_counter);
return {people_counter->people_sensor};
sensors:
- name: People
id: people_count
icon: "mdi:counter"
accuracy_decimals: 0
unit_of_measurement: "people"
- platform: mqtt_subscribe
name: "People reset"
id: people_reset
topic: $devicename/sensor/people/reset
internal: true
on_value:
then:
- lambda: |-
resetCounter = 1;
- platform: template
name: tof distance
id: tof_distance
accuracy_decimals: 0
icon: "mdi:ruler"
unit_of_measurement: "mm"
#device_class: None
update_interval: 1s
lambda: |-
return distance[1];
filters:
- delta: 100.0
- platform: template
name: tof distance avg
id: tof_distance_avg
accuracy_decimals: 0
icon: "mdi:ruler"
unit_of_measurement: "mm"
internal: true
#device_class: None
update_interval: 0.1s
lambda: |-
return distance[1];
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 10