-
Notifications
You must be signed in to change notification settings - Fork 0
/
m5stack-atom-lite-with-radar-LD1115H.yml
338 lines (307 loc) · 8.45 KB
/
m5stack-atom-lite-with-radar-LD1115H.yml
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
substitutions:
LOCATION: "change_me!!!"
friendly_name: "radar_${LOCATION}"
wifi:
api:
#############################################################################################################################
# Typical configuration:
# ======================
# delay_det_time=60
#
# ind_max=32
# ind_min=3
#
# th1 is motion threshold, don't report value lower than
# th1=1200
# mov_sn=1
#
# th1 is occupancy threshold, don't report value lower than
# th2=110
# occ_sn=1
#
# th3=50000 (long-range, higher value means detection at shorter range)
#############################################################################################################################
packages:
esphome.bluetooth-proxy: github://esphome/bluetooth-proxies/m5stack-atom-lite.yaml@main
esphome:
name: radar_${LOCATION}
name_add_mac_suffix: false
on_boot: #LD1115H Initial Setting
priority: -200
then:
- uart.write:
id: LD1115H_UART_BUS
data: !lambda |-
std::string th1st = "th1=" + str_sprintf("%.0f",id(th1_motion).state) +" \n";
return std::vector<uint8_t>(th1st.begin(), th1st.end());
- delay: 250ms
- uart.write:
id: LD1115H_UART_BUS
data: !lambda |-
std::string th2st = "th2=" + str_sprintf("%.0f",id(th2_occupancy).state) +" \n";
return std::vector<uint8_t>(th2st.begin(), th2st.end());
- delay: 250ms
- uart.write:
id: LD1115H_UART_BUS
data: !lambda |-
std::string th3st = "th3=" + str_sprintf("%.0f",id(th3_range).state) +" \n";
return std::vector<uint8_t>(th3st.begin(), th3st.end());
external_components:
- source:
type: git
url: https://github.com/ssieb/custom_components #Thanks for @ssieb components.
components: [ serial ]
# Configuration of M5 Atom Lite onboard RGB LED
light:
- platform: esp32_rmt_led_strip
rgb_order: GRB
pin: 27
num_leds: 1
rmt_channel: 0
chipset: SK6812
is_rgbw: true
id: m5stack_led
name: "Light"
icon: "mdi:led-outline"
effects:
- random:
- flicker:
- addressable_rainbow:
ota:
password: !secret ota_password
logger:
level: DEBUG
binary_sensor:
- platform: gpio
name: "Occupancy"
id: m5stack_occupancy
device_class: occupancy
icon: "mdi:radar"
pin:
number: 33 # ${INPUT_PIN}
mode:
input: true
pullup: false
- platform: template
name: "Motion"
id: m5stack_motion
icon: "mdi:motion-sensor"
- platform: gpio
name: "Button"
id: m5stack_button
pin:
number: 39 # button
inverted: true
- platform: ble_presence
ibeacon_uuid: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
name: "myphone-ibeacon"
id: m5stack_presence
device_class: presence
icon: "mdi:cellphone-basic"
uart:
id: LD1115H_UART_BUS
tx_pin: 21 # ${TX_PIN}
rx_pin: 25 # ${RX_PIN}
baud_rate: 115200
setup_priority: 200 #Set Priority To Prevent Boot Loop or Fail
number:
- platform: template
name: "th1 motion"
id: th1_motion
icon: "mdi:cogs"
optimistic: true
restore_value: true
initial_value: 120
min_value: 10
max_value: 65535
step: 10
mode: box
set_action:
then:
- uart.write:
id: LD1115H_UART_BUS
data: !lambda |-
std::string th1st = "th1=" + str_sprintf("%.0f",x) +" \n";
return std::vector<uint8_t>(th1st.begin(), th1st.end());
- delay: 250ms
- uart.write: "save\n"
- platform: template
name: "th2 occupancy"
id: th2_occupancy
icon: "mdi:cogs"
optimistic: true
restore_value: true
initial_value: 250
min_value: 10
max_value: 65535
step: 10
mode: box
set_action:
then:
- uart.write:
id: LD1115H_UART_BUS
data: !lambda |-
std::string th2st = "th2=" + str_sprintf("%.0f",x) +" \n";
return std::vector<uint8_t>(th2st.begin(), th2st.end());
- delay: 250ms
- uart.write: "save\n"
- platform: template
name: "th3 range"
id: th3_range
icon: "mdi:cogs"
min_value: 0
max_value: 65535
initial_value: 250
optimistic: true
step: 1
restore_value: true
mode: slider
set_action:
then:
- uart.write:
id: LD1115H_UART_BUS
data: !lambda |-
std::string th3st = "th3=" + str_sprintf("%.0f",x) +" \n";
return std::vector<uint8_t>(th3st.begin(), th3st.end());
- delay: 250ms
- uart.write: "save\n"
- platform: template
name: "dtime"
id: m5stack_delay_det_time
icon: "mdi:timer-sand-empty"
min_value: 1
max_value: 60
initial_value: 5
optimistic: true
step: 1
restore_value: true
mode: box
set_action:
- uart.write: !lambda
int cm = (int)x;
std::string cms = "dtime=" + to_string(cm) +" \n";
return std::vector<unsigned char>(cms.begin(), cms.end());
- delay: 250ms
- uart.write: "save\n"
- platform: template
name: "mov_sn"
id: m5stack_mov_sn
min_value: 0
max_value: 255
initial_value: 3
optimistic: true
step: 1
restore_value: true
mode: box
set_action:
- uart.write: !lambda
int cm = (int)x;
std::string cms = "mov_sn=" + to_string(cm) +" \n";
return std::vector<unsigned char>(cms.begin(), cms.end());
- delay: 250ms
- uart.write: "save\n"
- platform: template
name: "occ_sn"
id: m5stack_occ_sn
min_value: 0
max_value: 255
initial_value: 5
optimistic: true
step: 1
restore_value: true
mode: box
set_action:
- uart.write: !lambda
int cm = (int)x;
std::string cms = "occ_sn=" + to_string(cm) +" \n";
return std::vector<unsigned char>(cms.begin(), cms.end());
- delay: 250ms
- uart.write: "save\n"
- platform: template
name: "ind_min"
id: m5stack_ind_min
min_value: 0
max_value: 32
initial_value: 2
optimistic: true
step: 1
restore_value: true
mode: box
set_action:
- uart.write: !lambda
int cm = (int)x;
std::string cms = "ind_min=" + to_string(cm) +" \n";
return std::vector<unsigned char>(cms.begin(), cms.end());
- delay: 250ms
- uart.write: "save\n"
- platform: template
name: "ind_max"
id: m5stack_ind_max
min_value: 0
max_value: 32
initial_value: 32
optimistic: true
step: 1
restore_value: true
mode: box
set_action:
- uart.write: !lambda
int cm = (int)x;
std::string cms = "ind_max=" + to_string(cm) +" \n";
return std::vector<unsigned char>(cms.begin(), cms.end());
- delay: 250ms
- uart.write: "save\n"
text_sensor:
- platform: template
name: "mov"
id: mov
icon: "mdi:format-text"
- platform: template
name: "occ"
id: occ
icon: "mdi:format-text"
- platform: serial
uart_id: LD1115H_UART_BUS
name: "debug"
id: uart_text
icon: "mdi:format-text"
internal: true #If Don't Want to See UART Receive Data, Set To True
on_value:
lambda: |-
if ((id(uart_text).state.substr(0,3) == "occ") and id(m5stack_debug_switch).state) {
id(occ).publish_state(id(uart_text).state.substr(5).c_str());
}
else if (id(uart_text).state.substr(0,3) == "mov") {
id(m5stack_motion).state = true;
id(m5stack_motion).publish_state(true);
if (id(m5stack_debug_switch).state) {
id(mov).publish_state(id(uart_text).state.substr(5).c_str());
}
}
bluetooth_proxy:
active: true
esp32_ble_tracker:
esp32_improv:
authorizer: m5stack_button
# authorizer: none
switch:
- platform: factory_reset
name: Restart with Factory Default Settings
entity_category: "diagnostic"
- platform: template
name: Enable DEBUG
id: m5stack_debug_switch
optimistic: True
sensor:
- platform: wifi_signal
name: "WiFi Signal"
update_interval: 60s
interval:
- interval: 5s #Clearance Scan Time
setup_priority: -200
then:
lambda: |-
if (id(m5stack_motion).state) {
id(m5stack_motion).state = false;
id(m5stack_motion).publish_state(false);
}