· 6 months ago · Mar 21, 2025, 09:45 AM
1external_components:
2 - source:
3 type: git
4 url: https://github.com/Rihan9/LD2412
5 ref: main
6 components: [LD2412]
7
8esphome:
9 name: presence
10 friendly_name: presence
11
12esp32:
13 board: esp32-s3-devkitc-1
14 framework:
15 type: arduino
16
17# Enable logging
18logger:
19 level: VERBOSE
20 baud_rate: 0
21
22# Enable Home Assistant API
23api:
24 encryption:
25 key: "KKW3/SDHmRtsABvOJZU0auD8in/6JWcw+K5SvucWQzA="
26
27ota:
28 - platform: esphome
29 password: "84c2ea524669d38cb881c50ecd14b333"
30
31wifi:
32 ssid: !secret wifi_ssid
33 password: !secret wifi_password
34
35 # Enable fallback hotspot (captive portal) in case wifi connection fails
36 ap:
37 ssid: "Presencetest Fallback Hotspot"
38 password: "mnevv5Ey3fQo"
39
40
41web_server:
42 port: 80
43
44
45captive_portal:
46
47uart:
48 id: uart_bus
49 rx_pin: GPIO6
50 tx_pin: GPIO7
51 baud_rate: 115200
52 parity: NONE
53 stop_bits: 1
54
55LD2412:
56 id: ld2412
57 throttle: 3s
58
59binary_sensor:
60 - platform: LD2412
61 has_target:
62 name: Presence
63 has_moving_target:
64 name: Moving Target
65 has_still_target:
66 name: Still Target
67
68sensor:
69 - platform: LD2412
70 moving_distance:
71 name : Moving Distance
72 still_distance:
73 name: Still Distance
74 moving_energy:
75 name: Move Energy
76 still_energy:
77 name: Still Energy
78 detection_distance:
79 name: Detection Distance
80 light:
81 name: light
82 g0:
83 move_energy:
84 name: g00 move energy
85 still_energy:
86 name: g00 still energy
87 g1:
88 move_energy:
89 name: g01 move energy
90 still_energy:
91 name: g01 still energy
92 g2:
93 move_energy:
94 name: g02 move energy
95 still_energy:
96 name: g02 still energy
97 g3:
98 move_energy:
99 name: g03 move energy
100 still_energy:
101 name: g03 still energy
102 g4:
103 move_energy:
104 name: g04 move energy
105 still_energy:
106 name: g04 still energy
107 g5:
108 move_energy:
109 name: g05 move energy
110 still_energy:
111 name: g05 still energy
112 g6:
113 move_energy:
114 name: g06 move energy
115 still_energy:
116 name: g06 still energy
117 g7:
118 move_energy:
119 name: g07 move energy
120 still_energy:
121 name: g07 still energy
122 g8:
123 move_energy:
124 name: g08 move energy
125 still_energy:
126 name: g08 still energy
127 g9:
128 move_energy:
129 name: g09 move energy
130 still_energy:
131 name: g09 still energy
132 g10:
133 move_energy:
134 name: g10 move energy
135 still_energy:
136 name: g10 still energy
137 g11:
138 move_energy:
139 name: g11 move energy
140 still_energy:
141 name: g11 still energy
142 g12:
143 move_energy:
144 name: g12 move energy
145 still_energy:
146 name: g12 still energy
147 g13:
148 move_energy:
149 name: g13 move energy
150 still_energy:
151 name: g13 still energy
152
153number:
154 - platform: LD2412
155 timeout:
156 name: "presence holding"
157 min_distance_gate:
158 name: "min distance gate"
159 max_distance_gate:
160 name: "max distance gate"
161 g0:
162 move_threshold:
163 name: g00 move threshold
164 still_threshold:
165 name: g00 still threshold
166 g1:
167 move_threshold:
168 name: g01 move threshold
169 still_threshold:
170 name: g01 still threshold
171 g2:
172 move_threshold:
173 name: g02 move threshold
174 still_threshold:
175 name: g02 still threshold
176 g3:
177 move_threshold:
178 name: g03 move threshold
179 still_threshold:
180 name: g03 still threshold
181 g4:
182 move_threshold:
183 name: g04 move threshold
184 still_threshold:
185 name: g04 still threshold
186 g5:
187 move_threshold:
188 name: g05 move threshold
189 still_threshold:
190 name: g05 still threshold
191 g6:
192 move_threshold:
193 name: g06 move threshold
194 still_threshold:
195 name: g06 still threshold
196 g7:
197 move_threshold:
198 name: g07 move threshold
199 still_threshold:
200 name: g07 still threshold
201 g8:
202 move_threshold:
203 name: g08 move threshold
204 still_threshold:
205 name: g08 still threshold
206 g9:
207 move_threshold:
208 name: g09 move threshold
209 still_threshold:
210 name: g09 still threshold
211 g10:
212 move_threshold:
213 name: g10 move threshold
214 still_threshold:
215 name: g10 still threshold
216 g11:
217 move_threshold:
218 name: g11 move threshold
219 still_threshold:
220 name: g11 still threshold
221 g12:
222 move_threshold:
223 name: g12 move threshold
224 still_threshold:
225 name: g12 still threshold
226 g13:
227 move_threshold:
228 name: g13 move threshold
229 still_threshold:
230 name: g13 still threshold
231
232select:
233 - platform: LD2412
234 out_pin_level:
235 name: 'Hardware output pin level'
236 distance_resolution:
237 name: 'Distance resolution'
238 baud_rate:
239 name: "baud rate"
240 on_value:
241 - delay: 3s
242 - lambda: |-
243 id(uart_bus).flush();
244 uint32_t new_baud_rate = stoi(x);
245 ESP_LOGD("change_baud_rate", "Changing baud rate from %i to %i",id(uart_bus).get_baud_rate(), new_baud_rate);
246 if (id(uart_bus).get_baud_rate() != new_baud_rate) {
247 id(uart_bus).set_baud_rate(new_baud_rate);
248 id(uart_bus).load_settings();
249 }
250 mode:
251 name: "Mode"
252button:
253 - platform: LD2412
254 factory_reset:
255 name: "factory reset"
256 restart:
257 name: "restart"
258 query_params:
259 name: query params
260
261text_sensor:
262 - platform: LD2412
263 version:
264 name: "firmware version"
265 mac_address:
266 name: "mac address"
267switch:
268 - platform: LD2412
269 bluetooth:
270 name: "Bluetooth"
271
272light:
273 - platform: status_led
274 name: "Status Led"
275 pin:
276 number: GPIO8
277 inverted: true