mirror of
https://github.com/esphome/esphome.git
synced 2025-06-16 07:16:58 +02:00
Add tests, move consts, fix case
This commit is contained in:
parent
016bcf8bec
commit
ffaddcf5b6
@ -15,7 +15,7 @@ from esphome.const import (
|
||||
|
||||
from . import CONF_LD2412_ID, LD2412Component
|
||||
|
||||
DEPENDENCIES = ["LD2412"]
|
||||
DEPENDENCIES = ["ld2412"]
|
||||
|
||||
CONF_OUT_PIN_PRESENCE_STATUS = "out_pin_presence_status"
|
||||
|
||||
|
@ -3,6 +3,8 @@ from esphome.components import number
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import (
|
||||
CONF_ID,
|
||||
CONF_MOVE_THRESHOLD,
|
||||
CONF_STILL_THRESHOLD,
|
||||
CONF_TIMEOUT,
|
||||
DEVICE_CLASS_DISTANCE,
|
||||
DEVICE_CLASS_SIGNAL_STRENGTH,
|
||||
@ -22,8 +24,6 @@ MaxDistanceTimeoutNumber = LD2412_ns.class_("MaxDistanceTimeoutNumber", number.N
|
||||
CONF_LIGHT_THRESHOLD = "light_threshold"
|
||||
CONF_MAX_DISTANCE_GATE = "max_distance_gate"
|
||||
CONF_MIN_DISTANCE_GATE = "min_distance_gate"
|
||||
CONF_MOVE_THRESHOLD = "move_threshold"
|
||||
CONF_STILL_THRESHOLD = "still_threshold"
|
||||
|
||||
TIMEOUT_GROUP = "timeout"
|
||||
|
||||
|
@ -3,6 +3,7 @@ from esphome.components import sensor
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import (
|
||||
CONF_LIGHT,
|
||||
CONF_MOVING_DISTANCE,
|
||||
DEVICE_CLASS_DISTANCE,
|
||||
DEVICE_CLASS_ILLUMINANCE,
|
||||
ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
@ -20,7 +21,6 @@ DEPENDENCIES = ["ld2412"]
|
||||
|
||||
CONF_DETECTION_DISTANCE = "detection_distance"
|
||||
CONF_MOVE_ENERGY = "move_energy"
|
||||
CONF_MOVING_DISTANCE = "moving_distance"
|
||||
CONF_MOVING_ENERGY = "moving_energy"
|
||||
CONF_STILL_DISTANCE = "still_distance"
|
||||
CONF_STILL_ENERGY = "still_energy"
|
||||
|
@ -1,14 +1,18 @@
|
||||
import esphome.codegen as cg
|
||||
from esphome.components import switch
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import DEVICE_CLASS_SWITCH, ENTITY_CATEGORY_CONFIG, ICON_BLUETOOTH
|
||||
from esphome.const import (
|
||||
CONF_BLUETOOTH,
|
||||
DEVICE_CLASS_SWITCH,
|
||||
ENTITY_CATEGORY_CONFIG,
|
||||
ICON_BLUETOOTH,
|
||||
)
|
||||
|
||||
from .. import CONF_LD2412_ID, LD2412_ns, LD2412Component
|
||||
|
||||
BluetoothSwitch = LD2412_ns.class_("BluetoothSwitch", switch.Switch)
|
||||
# EngineeringModeSwitch = LD2412_ns.class_("EngineeringModeSwitch", switch.Switch)
|
||||
|
||||
CONF_BLUETOOTH = "bluetooth"
|
||||
CONF_ENGINEERING_MODE = "engineering_mode"
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
|
@ -11,7 +11,7 @@ from esphome.const import (
|
||||
|
||||
from . import CONF_LD2412_ID, LD2412Component
|
||||
|
||||
DEPENDENCIES = ["LD2412"]
|
||||
DEPENDENCIES = ["ld2412"]
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
cv.GenerateID(CONF_LD2412_ID): cv.use_id(LD2412Component),
|
||||
|
226
tests/components/ld2412/common.yaml
Normal file
226
tests/components/ld2412/common.yaml
Normal file
@ -0,0 +1,226 @@
|
||||
uart:
|
||||
- id: uart_ld2412
|
||||
tx_pin: ${tx_pin}
|
||||
rx_pin: ${rx_pin}
|
||||
baud_rate: 9600
|
||||
|
||||
ld2412:
|
||||
id: my_ld2412
|
||||
throttle: 3s
|
||||
|
||||
binary_sensor:
|
||||
- platform: ld2412
|
||||
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
|
||||
|
||||
number:
|
||||
- platform: ld2412
|
||||
timeout:
|
||||
name: Presence timeout
|
||||
min_distance_gate:
|
||||
name: Minimum distance gate
|
||||
max_distance_gate:
|
||||
name: Maximum distance gate
|
||||
g0:
|
||||
move_threshold:
|
||||
name: Gate 0 move threshold
|
||||
still_threshold:
|
||||
name: Gate 0 still threshold
|
||||
g1:
|
||||
move_threshold:
|
||||
name: Gate 1 move threshold
|
||||
still_threshold:
|
||||
name: Gate 1 still threshold
|
||||
g2:
|
||||
move_threshold:
|
||||
name: Gate 2 move threshold
|
||||
still_threshold:
|
||||
name: Gate 2 still threshold
|
||||
g3:
|
||||
move_threshold:
|
||||
name: Gate 3 move threshold
|
||||
still_threshold:
|
||||
name: Gate 3 still threshold
|
||||
g4:
|
||||
move_threshold:
|
||||
name: Gate 4 move threshold
|
||||
still_threshold:
|
||||
name: Gate 4 still threshold
|
||||
g5:
|
||||
move_threshold:
|
||||
name: Gate 5 move threshold
|
||||
still_threshold:
|
||||
name: Gate 5 still threshold
|
||||
g6:
|
||||
move_threshold:
|
||||
name: Gate 6 move threshold
|
||||
still_threshold:
|
||||
name: Gate 6 still threshold
|
||||
g7:
|
||||
move_threshold:
|
||||
name: Gate 7 move threshold
|
||||
still_threshold:
|
||||
name: Gate 7 still threshold
|
||||
g8:
|
||||
move_threshold:
|
||||
name: Gate 8 move threshold
|
||||
still_threshold:
|
||||
name: Gate 8 still threshold
|
||||
g9:
|
||||
move_threshold:
|
||||
name: Gate 9 move threshold
|
||||
still_threshold:
|
||||
name: Gate 9 still threshold
|
||||
g10:
|
||||
move_threshold:
|
||||
name: Gate 10 move threshold
|
||||
still_threshold:
|
||||
name: Gate 10 still threshold
|
||||
g11:
|
||||
move_threshold:
|
||||
name: Gate 11 move threshold
|
||||
still_threshold:
|
||||
name: Gate 11 still threshold
|
||||
g12:
|
||||
move_threshold:
|
||||
name: Gate 12 move threshold
|
||||
still_threshold:
|
||||
name: Gate 12 still threshold
|
||||
g13:
|
||||
move_threshold:
|
||||
name: Gate 13 move threshold
|
||||
still_threshold:
|
||||
name: Gate 13 still threshold
|
||||
|
||||
select:
|
||||
- platform: ld2412
|
||||
out_pin_level:
|
||||
name: Hardware output pin level
|
||||
distance_resolution:
|
||||
name: Distance resolution
|
||||
mode:
|
||||
name: Mode
|
||||
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
|
||||
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
|
||||
light:
|
||||
name: light
|
||||
g0:
|
||||
move_energy:
|
||||
name: Gate 0 move energy
|
||||
still_energy:
|
||||
name: Gate 0 still energy
|
||||
g1:
|
||||
move_energy:
|
||||
name: Gate 1 move energy
|
||||
still_energy:
|
||||
name: Gate 1 still energy
|
||||
g2:
|
||||
move_energy:
|
||||
name: Gate 2 move energy
|
||||
still_energy:
|
||||
name: Gate 2 still energy
|
||||
g3:
|
||||
move_energy:
|
||||
name: Gate 3 move energy
|
||||
still_energy:
|
||||
name: Gate 3 still energy
|
||||
g4:
|
||||
move_energy:
|
||||
name: Gate 4 move energy
|
||||
still_energy:
|
||||
name: Gate 4 still energy
|
||||
g5:
|
||||
move_energy:
|
||||
name: Gate 5 move energy
|
||||
still_energy:
|
||||
name: Gate 5 still energy
|
||||
g6:
|
||||
move_energy:
|
||||
name: Gate 6 move energy
|
||||
still_energy:
|
||||
name: Gate 6 still energy
|
||||
g7:
|
||||
move_energy:
|
||||
name: Gate 7 move energy
|
||||
still_energy:
|
||||
name: Gate 7 still energy
|
||||
g8:
|
||||
move_energy:
|
||||
name: Gate 8 move energy
|
||||
still_energy:
|
||||
name: Gate 8 still energy
|
||||
g9:
|
||||
move_energy:
|
||||
name: Gate 9 move energy
|
||||
still_energy:
|
||||
name: Gate 9 still energy
|
||||
g10:
|
||||
move_energy:
|
||||
name: Gate 10 move energy
|
||||
still_energy:
|
||||
name: Gate 10 still energy
|
||||
g11:
|
||||
move_energy:
|
||||
name: Gate 11 move energy
|
||||
still_energy:
|
||||
name: Gate 11 still energy
|
||||
g12:
|
||||
move_energy:
|
||||
name: Gate 12 move energy
|
||||
still_energy:
|
||||
name: Gate 12 still energy
|
||||
g13:
|
||||
move_energy:
|
||||
name: Gate 13 move energy
|
||||
still_energy:
|
||||
name: Gate 13 still energy
|
||||
|
||||
switch:
|
||||
- platform: ld2412
|
||||
bluetooth:
|
||||
name: Bluetooth
|
||||
|
||||
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
|
Loading…
x
Reference in New Issue
Block a user