mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	[ld2412] New component (#9075)
Co-authored-by: Keith Burzinski <kbx81x@gmail.com> Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
		
							
								
								
									
										233
									
								
								tests/components/ld2412/common.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										233
									
								
								tests/components/ld2412/common.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,233 @@ | ||||
| uart: | ||||
|   - id: uart_ld2412 | ||||
|     tx_pin: ${tx_pin} | ||||
|     rx_pin: ${rx_pin} | ||||
|     baud_rate: 9600 | ||||
|  | ||||
| ld2412: | ||||
|   id: my_ld2412 | ||||
|  | ||||
| binary_sensor: | ||||
|   - platform: ld2412 | ||||
|     dynamic_background_correction_status: | ||||
|       name: Dynamic Background Correction Status | ||||
|     has_target: | ||||
|       name: Presence | ||||
|     has_moving_target: | ||||
|       name: Moving Target | ||||
|     has_still_target: | ||||
|       name: Still Target | ||||
|  | ||||
| button: | ||||
|   - platform: ld2412 | ||||
|     factory_reset: | ||||
|       name: Factory reset | ||||
|     restart: | ||||
|       name: Restart | ||||
|     query_params: | ||||
|       name: Query params | ||||
|     start_dynamic_background_correction: | ||||
|       name: Start Dynamic Background Correction | ||||
|  | ||||
| number: | ||||
|   - platform: ld2412 | ||||
|     light_threshold: | ||||
|       name: Light Threshold | ||||
|     timeout: | ||||
|       name: Presence timeout | ||||
|     min_distance_gate: | ||||
|       name: Minimum distance gate | ||||
|     max_distance_gate: | ||||
|       name: Maximum distance gate | ||||
|     gate_0: | ||||
|       move_threshold: | ||||
|         name: Gate 0 Move Threshold | ||||
|       still_threshold: | ||||
|         name: Gate 0 Still Threshold | ||||
|     gate_1: | ||||
|       move_threshold: | ||||
|         name: Gate 1 Move Threshold | ||||
|       still_threshold: | ||||
|         name: Gate 1 Still Threshold | ||||
|     gate_2: | ||||
|       move_threshold: | ||||
|         name: Gate 2 Move Threshold | ||||
|       still_threshold: | ||||
|         name: Gate 2 Still Threshold | ||||
|     gate_3: | ||||
|       move_threshold: | ||||
|         name: Gate 3 Move Threshold | ||||
|       still_threshold: | ||||
|         name: Gate 3 Still Threshold | ||||
|     gate_4: | ||||
|       move_threshold: | ||||
|         name: Gate 4 Move Threshold | ||||
|       still_threshold: | ||||
|         name: Gate 4 Still Threshold | ||||
|     gate_5: | ||||
|       move_threshold: | ||||
|         name: Gate 5 Move Threshold | ||||
|       still_threshold: | ||||
|         name: Gate 5 Still Threshold | ||||
|     gate_6: | ||||
|       move_threshold: | ||||
|         name: Gate 6 Move Threshold | ||||
|       still_threshold: | ||||
|         name: Gate 6 Still Threshold | ||||
|     gate_7: | ||||
|       move_threshold: | ||||
|         name: Gate 7 Move Threshold | ||||
|       still_threshold: | ||||
|         name: Gate 7 Still Threshold | ||||
|     gate_8: | ||||
|       move_threshold: | ||||
|         name: Gate 8 Move Threshold | ||||
|       still_threshold: | ||||
|         name: Gate 8 Still Threshold | ||||
|     gate_9: | ||||
|       move_threshold: | ||||
|         name: Gate 9 Move Threshold | ||||
|       still_threshold: | ||||
|         name: Gate 9 Still Threshold | ||||
|     gate_10: | ||||
|       move_threshold: | ||||
|         name: Gate 10 Move Threshold | ||||
|       still_threshold: | ||||
|         name: Gate 10 Still Threshold | ||||
|     gate_11: | ||||
|       move_threshold: | ||||
|         name: Gate 11 Move Threshold | ||||
|       still_threshold: | ||||
|         name: Gate 11 Still Threshold | ||||
|     gate_12: | ||||
|       move_threshold: | ||||
|         name: Gate 12 Move Threshold | ||||
|       still_threshold: | ||||
|         name: Gate 12 Still Threshold | ||||
|     gate_13: | ||||
|       move_threshold: | ||||
|         name: Gate 13 Move Threshold | ||||
|       still_threshold: | ||||
|         name: Gate 13 Still Threshold | ||||
|  | ||||
| select: | ||||
|   - platform: ld2412 | ||||
|     light_function: | ||||
|       name: Light Function | ||||
|     out_pin_level: | ||||
|       name: Hardware output pin level | ||||
|     distance_resolution: | ||||
|       name: Distance resolution | ||||
|     baud_rate: | ||||
|       name: Baud rate | ||||
|       on_value: | ||||
|         - delay: 3s | ||||
|         - lambda: |- | ||||
|             id(uart_ld2412).flush(); | ||||
|             uint32_t new_baud_rate = stoi(x); | ||||
|             ESP_LOGD("change_baud_rate", "Changing baud rate from %i to %i",id(uart_ld2412).get_baud_rate(), new_baud_rate); | ||||
|             if (id(uart_ld2412).get_baud_rate() != new_baud_rate) { | ||||
|               id(uart_ld2412).set_baud_rate(new_baud_rate); | ||||
|             #if defined(USE_ESP8266) || defined(USE_ESP32) | ||||
|               id(uart_ld2412).load_settings(); | ||||
|             #endif | ||||
|             } | ||||
|  | ||||
| sensor: | ||||
|   - platform: ld2412 | ||||
|     light: | ||||
|       name: Light | ||||
|     moving_distance: | ||||
|       name: Moving Distance | ||||
|     still_distance: | ||||
|       name: Still Distance | ||||
|     moving_energy: | ||||
|       name: Move Energy | ||||
|     still_energy: | ||||
|       name: Still Energy | ||||
|     detection_distance: | ||||
|       name: Detection Distance | ||||
|     gate_0: | ||||
|       move_energy: | ||||
|         name: Gate 0 Move Energy | ||||
|       still_energy: | ||||
|         name: Gate 0 Still Energy | ||||
|     gate_1: | ||||
|       move_energy: | ||||
|         name: Gate 1 Move Energy | ||||
|       still_energy: | ||||
|         name: Gate 1 Still Energy | ||||
|     gate_2: | ||||
|       move_energy: | ||||
|         name: Gate 2 Move Energy | ||||
|       still_energy: | ||||
|         name: Gate 2 Still Energy | ||||
|     gate_3: | ||||
|       move_energy: | ||||
|         name: Gate 3 Move Energy | ||||
|       still_energy: | ||||
|         name: Gate 3 Still Energy | ||||
|     gate_4: | ||||
|       move_energy: | ||||
|         name: Gate 4 Move Energy | ||||
|       still_energy: | ||||
|         name: Gate 4 Still Energy | ||||
|     gate_5: | ||||
|       move_energy: | ||||
|         name: Gate 5 Move Energy | ||||
|       still_energy: | ||||
|         name: Gate 5 Still Energy | ||||
|     gate_6: | ||||
|       move_energy: | ||||
|         name: Gate 6 Move Energy | ||||
|       still_energy: | ||||
|         name: Gate 6 Still Energy | ||||
|     gate_7: | ||||
|       move_energy: | ||||
|         name: Gate 7 Move Energy | ||||
|       still_energy: | ||||
|         name: Gate 7 Still Energy | ||||
|     gate_8: | ||||
|       move_energy: | ||||
|         name: Gate 8 Move Energy | ||||
|       still_energy: | ||||
|         name: Gate 8 Still Energy | ||||
|     gate_9: | ||||
|       move_energy: | ||||
|         name: Gate 9 Move Energy | ||||
|       still_energy: | ||||
|         name: Gate 9 Still Energy | ||||
|     gate_10: | ||||
|       move_energy: | ||||
|         name: Gate 10 Move Energy | ||||
|       still_energy: | ||||
|         name: Gate 10 Still Energy | ||||
|     gate_11: | ||||
|       move_energy: | ||||
|         name: Gate 11 Move Energy | ||||
|       still_energy: | ||||
|         name: Gate 11 Still Energy | ||||
|     gate_12: | ||||
|       move_energy: | ||||
|         name: Gate 12 Move Energy | ||||
|       still_energy: | ||||
|         name: Gate 12 Still Energy | ||||
|     gate_13: | ||||
|       move_energy: | ||||
|         name: Gate 13 Move Energy | ||||
|       still_energy: | ||||
|         name: Gate 13 Still Energy | ||||
|  | ||||
| switch: | ||||
|   - platform: ld2412 | ||||
|     bluetooth: | ||||
|       name: Bluetooth | ||||
|     engineering_mode: | ||||
|       name: Engineering Mode | ||||
|  | ||||
| text_sensor: | ||||
|   - platform: ld2412 | ||||
|     version: | ||||
|       name: Firmware version | ||||
|     mac_address: | ||||
|       name: MAC address | ||||
							
								
								
									
										5
									
								
								tests/components/ld2412/test.esp32-ard.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								tests/components/ld2412/test.esp32-ard.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| substitutions: | ||||
|   tx_pin: GPIO17 | ||||
|   rx_pin: GPIO16 | ||||
|  | ||||
| <<: !include common.yaml | ||||
							
								
								
									
										5
									
								
								tests/components/ld2412/test.esp32-c3-ard.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								tests/components/ld2412/test.esp32-c3-ard.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| substitutions: | ||||
|   tx_pin: GPIO4 | ||||
|   rx_pin: GPIO5 | ||||
|  | ||||
| <<: !include common.yaml | ||||
							
								
								
									
										5
									
								
								tests/components/ld2412/test.esp32-c3-idf.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								tests/components/ld2412/test.esp32-c3-idf.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| substitutions: | ||||
|   tx_pin: GPIO4 | ||||
|   rx_pin: GPIO5 | ||||
|  | ||||
| <<: !include common.yaml | ||||
							
								
								
									
										5
									
								
								tests/components/ld2412/test.esp32-idf.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								tests/components/ld2412/test.esp32-idf.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| substitutions: | ||||
|   tx_pin: GPIO17 | ||||
|   rx_pin: GPIO16 | ||||
|  | ||||
| <<: !include common.yaml | ||||
							
								
								
									
										5
									
								
								tests/components/ld2412/test.esp8266-ard.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								tests/components/ld2412/test.esp8266-ard.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| substitutions: | ||||
|   tx_pin: GPIO4 | ||||
|   rx_pin: GPIO5 | ||||
|  | ||||
| <<: !include common.yaml | ||||
							
								
								
									
										5
									
								
								tests/components/ld2412/test.rp2040-ard.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								tests/components/ld2412/test.rp2040-ard.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| substitutions: | ||||
|   tx_pin: GPIO4 | ||||
|   rx_pin: GPIO5 | ||||
|  | ||||
| <<: !include common.yaml | ||||
		Reference in New Issue
	
	Block a user