-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathathom-presence-sensor.yaml
More file actions
315 lines (290 loc) · 7.67 KB
/
Copy pathathom-presence-sensor.yaml
File metadata and controls
315 lines (290 loc) · 7.67 KB
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
---
substitutions:
name: "athom-presence-sensor"
friendly_name: "Athom Presence Sensor"
comment: "Athom mmWave Human Presence Sensor"
# Time between sensor updates
update_interval: "10s"
packages:
base: !include modules/base.yaml
esphome:
min_version: 2024.6.0
project:
name: "Athom Technology.Athom Presence Sensor"
version: "v1.0.3-scsole"
esp8266:
board: esp8285
restore_from_flash: true
dashboard_import:
package_import_url: github://scsole/esphome-device-configs/athom-presence-sensor.yaml
import_full_config: false
i2c:
sda: GPIO4
scl: GPIO5
scan: true
uart:
tx_pin: GPIO15
rx_pin: GPIO13
baud_rate: 115200
# debug:
# direction: BOTH
# dummy_receiver: true
# after:
# delimiter: "\n"
# sequence:
# - lambda: UARTDebug::log_string(direction, bytes);
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: true
name: Button
disabled_by_default: true
on_multi_click:
- timing:
- ON for at least 4s
then:
- button.press: factory_reset_device
- platform: gpio
pin:
number: GPIO14
mode:
input: true
pullup: true
name: PIR
id: pir
filters:
- delayed_on: 50ms
- delayed_off: 10s
device_class: motion
on_press:
if:
condition:
switch.is_on: occupancy_indicator
then:
- light.turn_on: led
- platform: gpio
pin:
number: GPIO12
mode:
input: true
pullup: true
name: mmWave
id: mmwave
filters:
- delayed_on: 50ms
device_class: motion
on_release:
then:
- light.turn_off: led
- platform: template
name: Occupancy
id: occupancy
device_class: occupancy
lambda: |-
if (id(mmwave).state and id(pir).state) {
return true;
} else if (id(mmwave).state == 0) {
return false;
} else {
return id(occupancy).state;
}
sensor:
- platform: bh1750
name: Illuminance
address: 0x23
update_interval: ${update_interval}
switch:
- platform: template
name: mmWave Sensor
id: mmwave_sensor
internal: true
entity_category: config
optimistic: true
restore_mode: DISABLED
turn_on_action:
- uart.write: "sensorStart\r\n"
turn_off_action:
- uart.write: "sensorStop\r\n"
- platform: template
name: Occupancy Indicator
id: occupancy_indicator
entity_category: config
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
on_turn_on:
if:
condition:
binary_sensor.is_on: occupancy
then:
- light.turn_on: led
on_turn_off:
- light.turn_off: led
number:
- platform: template
name: Farthest Detection
id: farthest_detection
entity_category: config
min_value: 1.9
max_value: 12
initial_value: 6
optimistic: true
step: 0.1
restore_value: true
unit_of_measurement: m
mode: slider
set_action:
- switch.turn_off: mmwave_sensor
- delay: 500ms
- uart.write: !lambda |-
std::string ranges = "setRange 1.8 " + str_sprintf("%.1f",id(farthest_detection).state) + "\r\n";
return std::vector<uint8_t>(ranges.begin(), ranges.end());
- delay: 500ms
- uart.write: "saveConfig\r\n"
- delay: 500ms
- switch.turn_on: mmwave_sensor
- platform: template
name: Maintain Sensitivity
id: maintain_sensitivity
entity_category: config
min_value: 0
max_value: 9
initial_value: 7
optimistic: true
step: 1
restore_value: true
mode: slider
set_action:
- switch.turn_off: mmwave_sensor
- delay: 500ms
- uart.write: !lambda |-
std::string sensitivitys = "setSensitivity " + str_sprintf("%.0f",id(maintain_sensitivity).state) + " " + str_sprintf("%.0f",id(trigger_sensitivity).state) + "\r\n";
return std::vector<uint8_t>(sensitivitys.begin(), sensitivitys.end());
- delay: 500ms
- uart.write: "saveConfig\r\n"
- delay: 500ms
- switch.turn_on: mmwave_sensor
- platform: template
name: Trigger Sensitivity
id: trigger_sensitivity
entity_category: config
min_value: 0
max_value: 9
initial_value: 5
optimistic: true
step: 1
restore_value: true
mode: slider
set_action:
- switch.turn_off: mmwave_sensor
- delay: 500ms
- uart.write: !lambda |-
std::string sensitivityss = "setSensitivity " + str_sprintf("%.0f",id(maintain_sensitivity).state) + " " + str_sprintf("%.0f",id(trigger_sensitivity).state) + "\r\n";
return std::vector<uint8_t>(sensitivityss.begin(), sensitivityss.end());
- delay: 500ms
- uart.write: "saveConfig\r\n"
- delay: 500ms
- switch.turn_on: mmwave_sensor
- platform: template
name: Detection Delay
id: detection_delay
entity_category: config
min_value: 0.1
max_value: 60
initial_value: 0.1
optimistic: true
step: 0.1
restore_value: true
unit_of_measurement: seconds
mode: slider
set_action:
- switch.turn_off: mmwave_sensor
- delay: 500ms
- uart.write: !lambda |-
std::string detections = "setLatency " + str_sprintf("%.1f",id(detection_delay).state) + " " + str_sprintf("%.0f",id(fading_time).state) + "\r\n";
return std::vector<uint8_t>(detections.begin(),detections.end());
- delay: 500ms
- uart.write: "saveConfig\r\n"
- delay: 500ms
- switch.turn_on: mmwave_sensor
- platform: template
name: Fading Time
id: fading_time
entity_category: config
min_value: 1
max_value: 300
initial_value: 15
optimistic: true
step: 1
restore_value: true
unit_of_measurement: seconds
mode: auto
set_action:
- switch.turn_off: mmwave_sensor
- delay: 500ms
- uart.write: !lambda |-
std::string fadings = "setLatency " + str_sprintf("%.1f",id(detection_delay).state) + " " + str_sprintf("%.0f",id(fading_time).state) + "\r\n";
return std::vector<uint8_t>(fadings.begin(), fadings.end());
- delay: 500ms
- uart.write: "saveConfig\r\n"
- delay: 500ms
- switch.turn_on: mmwave_sensor
- platform: template
name: Blockade Time
id: blockade_time
entity_category: config
min_value: 1
max_value: 255
initial_value: 1
optimistic: true
step: 1
restore_value: true
unit_of_measurement: seconds
mode: slider
set_action:
- switch.turn_off: mmwave_sensor
- delay: 500ms
- uart.write: !lambda |-
std::string blockades = "setInhibit " + str_sprintf("%.0f",x) + "\r\n";
return std::vector<uint8_t>(blockades.begin(), blockades.end());
- delay: 500ms
- uart.write: "saveConfig\r\n"
- delay: 500ms
- switch.turn_on: mmwave_sensor
button:
- id: !extend factory_reset_button
name: Factory Reset ESP
internal: true
- id: !extend restart_button
name: Restart ESP
internal: true
- platform: template
name: Factory Reset
icon: mdi:restart-alert
id: factory_reset_device
entity_category: config
on_press:
- switch.turn_off: mmwave_sensor
- delay: 500ms
- uart.write: "resetCfg\r\n"
- delay: 1s
- switch.turn_on: mmwave_sensor
- button.press: factory_reset_button
disabled_by_default: true
- platform: template
name: Restart
icon: mdi:restart
entity_category: config
on_press:
- uart.write: "resetSystem\r\n"
- delay: 1s
- button.press: restart_button
light:
- platform: status_led
name: Status LED
id: led
pin:
number: GPIO16
entity_category: config
disabled_by_default: true