Guest User

esphome-ld2410

a guest
Aug 19th, 2024
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.43 KB | None | 0 0
  1. esphome:
  2. name: "stairspresence"
  3. friendly_name: "stairspresence"
  4. platformio_options:
  5. board_build.f_flash: 40000000L
  6. board_build.flash_mode: dio
  7. board_build.flash_size: 4MB
  8.  
  9. esp32:
  10. board: esp32-c3-devkitm-1
  11. framework:
  12. type: arduino
  13.  
  14. # Enable logging
  15. #logger:
  16.  
  17. # Enable Home Assistant API
  18. api:
  19. encryption:
  20. key: ""
  21.  
  22. ota:
  23. - platform: esphome
  24. password: ""
  25.  
  26. wifi:
  27. ssid: !secret wifi_ssid
  28. password: !secret wifi_password
  29.  
  30. # Enable fallback hotspot (captive portal) in case wifi connection fails
  31. ap:
  32. ssid: "${name} Hotspot"
  33. password: !secret hotspot_password
  34.  
  35. captive_portal:
  36.  
  37. #improv_serial:
  38.  
  39. web_server:
  40. port: 80
  41.  
  42. esp32_ble_tracker:
  43. scan_parameters:
  44. active: true
  45.  
  46. bluetooth_proxy:
  47. active: true
  48.  
  49. ld2410:
  50. id: ld2410_radar
  51. # throttle: 1500ms
  52.  
  53. uart:
  54. tx_pin: GPIO04
  55. rx_pin: GPIO05
  56. baud_rate: 256000
  57. parity: NONE
  58. stop_bits: 1
  59.  
  60. i2c:
  61. #- id: bus_b
  62. # sda: GPIO06 #brown
  63. # scl: GPIO07 #red
  64. # scan: true
  65. - id: bus_a
  66. sda: GPIO18
  67. scl: GPIO19
  68. scan: true
  69.  
  70. number:
  71. - platform: ld2410
  72. timeout:
  73. name: Radar Timeout
  74. max_move_distance_gate:
  75. name: Max Move Distance
  76. max_still_distance_gate:
  77. name: Max Still Distance
  78. g0:
  79. move_threshold:
  80. name: g0 move threshold
  81. still_threshold:
  82. name: g0 still threshold
  83. g1:
  84. move_threshold:
  85. name: g1 move threshold
  86. still_threshold:
  87. name: g1 still threshold
  88. g2:
  89. move_threshold:
  90. name: g2 move threshold
  91. still_threshold:
  92. name: g2 still threshold
  93. g3:
  94. move_threshold:
  95. name: g3 move threshold
  96. still_threshold:
  97. name: g3 still threshold
  98. g4:
  99. move_threshold:
  100. name: g4 move threshold
  101. still_threshold:
  102. name: g4 still threshold
  103. g5:
  104. move_threshold:
  105. name: g5 move threshold
  106. still_threshold:
  107. name: g5 still threshold
  108. g6:
  109. move_threshold:
  110. name: g6 move threshold
  111. still_threshold:
  112. name: g6 still threshold
  113. g7:
  114. move_threshold:
  115. name: g7 move threshold
  116. still_threshold:
  117. name: g7 still threshold
  118. g8:
  119. move_threshold:
  120. name: g8 move threshold
  121. still_threshold:
  122. name: g8 still threshold
  123. # Setting start of zone 1 occupancy
  124. - platform: template
  125. name: "Zone 1 Start"
  126. id: radar_z1_start
  127. device_class: distance
  128. min_value: 0
  129. max_value: 800
  130. step: 1
  131. mode: box
  132. update_interval: never
  133. optimistic: true
  134. restore_value: true
  135. initial_value: 0
  136. icon: "mdi:arrow-collapse-right"
  137. entity_category: CONFIG
  138. unit_of_measurement: "cm"
  139.  
  140. # Setting ending of zone 1 occupancy
  141. - platform: template
  142. name: "End Zone 1"
  143. id: radar_z1_end
  144. device_class: distance
  145. min_value: 0
  146. max_value: 800
  147. step: 1
  148. mode: box
  149. update_interval: never
  150. optimistic: true
  151. restore_value: true
  152. initial_value: 50
  153. icon: "mdi:arrow-collapse-right"
  154. entity_category: CONFIG
  155. unit_of_measurement: "cm"
  156.  
  157. # Setting ending of zone 2 occupancy
  158. - platform: template
  159. name: "End Zone 2"
  160. id: radar_z2_end
  161. device_class: distance
  162. min_value: 0
  163. max_value: 800
  164. step: 1
  165. mode: box
  166. update_interval: never
  167. optimistic: true
  168. restore_value: true
  169. initial_value: 150
  170. icon: "mdi:arrow-collapse-right"
  171. entity_category: CONFIG
  172. unit_of_measurement: "cm"
  173.  
  174. # Setting ending of zone 3 occupancy
  175. - platform: template
  176. name: "End Zone 3"
  177. id: radar_z3_end
  178. device_class: distance
  179. min_value: 0
  180. max_value: 800
  181. step: 1
  182. mode: box
  183. update_interval: never
  184. optimistic: true
  185. restore_value: true
  186. initial_value: 250
  187. icon: "mdi:arrow-collapse-right"
  188. entity_category: CONFIG
  189. unit_of_measurement: "cm"
  190.  
  191. binary_sensor:
  192. - platform: ld2410
  193. has_target:
  194. name: Presence
  195. id: radar_has_target
  196. # lambda: |-
  197. # if (id(radar_has_target).state){
  198. # id(blink_light)->execute(500);
  199. # } else {
  200. # id(blink_light)->execute(100);
  201. # }
  202. has_moving_target:
  203. name: Moving Target
  204. has_still_target:
  205. name: Still Target
  206. out_pin_presence_status:
  207. name: out pin presence status
  208. ## Set Up Radar Zones Based On Distance
  209. - platform: template
  210. name: "Zone 1 Occupancy"
  211. id: radar_zone_1_occupancy
  212. device_class: occupancy
  213. icon: mdi:motion-sensor
  214. lambda: |-
  215. if ((id(radar_has_target).state) && ((id(radar_detection_distance).state < id(radar_z1_end).state) && (id(radar_detection_distance).state > id(radar_z1_start).state))){
  216. return true;
  217. } else {
  218. return false;
  219. }
  220. - platform: template
  221. name: "Zone 2 Occupancy"
  222. id: radar_zone_2_occupancy
  223. device_class: occupancy
  224. icon: mdi:motion-sensor
  225. lambda: |-
  226. if ((id(radar_has_target).state) && ((id(radar_z1_end).state < id(radar_detection_distance).state) && (id(radar_detection_distance).state < id(radar_z2_end).state))) {
  227. return true;
  228. } else {
  229. return false;
  230. }
  231. - platform: template
  232. name: "Zone 3 Occupancy"
  233. id: radar_zone_3_occupancy
  234. device_class: occupancy
  235. icon: mdi:motion-sensor
  236. lambda: |-
  237. if ((id(radar_has_target).state) && ((id(radar_z2_end).state < id(radar_detection_distance).state) && (id(radar_detection_distance).state < id(radar_z3_end).state))) {
  238. return true;
  239. } else {
  240. return false;
  241. }
  242.  
  243. sensor:
  244. - platform: internal_temperature
  245. name: "ESP Temperature"
  246. id: sys_esp_temperature
  247. - platform: uptime
  248. name: Uptime
  249. id: sys_uptime
  250. update_interval: 60s
  251. - platform: ltr390
  252. uv_index:
  253. name: "UV Index"
  254. light:
  255. name: "Light"
  256. filters:
  257. - multiply: 1.2
  258. i2c_id: bus_a
  259. address: 0x53
  260.  
  261. - platform: ld2410
  262. moving_distance:
  263. name: Moving Distance
  264. id: moving_distance
  265. still_distance:
  266. name: Still Distance
  267. id: still_distance
  268. moving_energy:
  269. name: Move Energy
  270. still_energy:
  271. name: Still Energy
  272. detection_distance:
  273. name: Detection Distance
  274. id: radar_detection_distance
  275. g0:
  276. move_energy:
  277. name: g0 move energy
  278. still_energy:
  279. name: g0 still energy
  280. g1:
  281. move_energy:
  282. name: g1 move energy
  283. still_energy:
  284. name: g1 still energy
  285. g2:
  286. move_energy:
  287. name: g2 move energy
  288. still_energy:
  289. name: g2 still energy
  290. g3:
  291. move_energy:
  292. name: g3 move energy
  293. still_energy:
  294. name: g3 still energy
  295. g4:
  296. move_energy:
  297. name: g4 move energy
  298. still_energy:
  299. name: g4 still energy
  300. g5:
  301. move_energy:
  302. name: g5 move energy
  303. still_energy:
  304. name: g5 still energy
  305. g6:
  306. move_energy:
  307. name: g6 move energy
  308. still_energy:
  309. name: g6 still energy
  310. g7:
  311. move_energy:
  312. name: g7 move energy
  313. still_energy:
  314. name: g7 still energy
  315. g8:
  316. move_energy:
  317. name: g8 move energy
  318. still_energy:
  319. name: g8 still energy
  320.  
  321. switch:
  322. - platform: ld2410
  323. engineering_mode:
  324. name: "engineering mode"
  325. bluetooth:
  326. name: "control bluetooth"
  327.  
  328. select:
  329. - platform: ld2410
  330. distance_resolution:
  331. name: "distance resolution"
  332.  
  333. button:
  334. - platform: ld2410
  335. restart:
  336. name: "restart"
  337. query_params:
  338. name: query params
  339.  
  340. text_sensor:
  341. - platform: wifi_info
  342. ip_address:
  343. name: "ESP IP Address"
  344. ssid:
  345. name: "ESP Connected SSID"
  346.  
  347. light:
  348. - platform: esp32_rmt_led_strip
  349. id: rgb_light
  350. name: "RGB Light"
  351. pin: GPIO8
  352. rmt_channel: 0
  353. default_transition_length: 0s
  354. chipset: WS2812
  355. num_leds: 3
  356. rgb_order: grb
  357. effects:
  358. - addressable_fireworks:
  359. name: Fireworks Effect With Custom Values
  360. update_interval: 32ms
  361. spark_probability: 10%
  362. use_random_color: false
  363. fade_out_rate: 120
  364.  
  365. script:
  366. - id: blink_light
  367. parameters:
  368. delay_ms: int
  369. then:
  370. - light.turn_on: rgb_light
  371. # The param delay_ms is accessible using a lambda
  372. - delay: !lambda return delay_ms;
  373. - light.turn_off: rgb_light
Add Comment
Please, Sign In to add comment