LD2412 传感器
ld2412 传感器平台允许您在 ESPHome 中使用 HI-LINK LD2412 运动和存在传感器。
此传感器需要在您的配置中设置 UART 才能工作;parity 和
stop_bits 必须分别为 NONE 和 1。
强烈建议使用硬件 UART,因为它能最好地支持传感器模块默认的 115200 波特率。

# Example configuration entryld2412:ld2412 二值传感器可帮助您快速确定传感器报告的多种状态。
binary_sensor: - platform: ld2412 has_target: name: Presence has_moving_target: name: Moving Target has_still_target: name: Still Target dynamic_background_correction_status: name: Dynamic Background Correction Status-
has_target (可选): 如果为 true,表示检测到静止或运动的目标。 来自 Binary Sensor 的所有选项。
-
has_moving_target (可选): 如果检测到运动目标则为 true。 来自 Binary Sensor 的所有选项。
-
has_still_target (可选): 如果检测到静止目标则为 true。 来自 Binary Sensor 的所有选项。
-
dynamic_background_correction_status (可选): 传感器执行动态背景 校正期间为 true。来自 Binary Sensor 的所有选项。
-
ld2412_id (可选,ID): 手动为组件指定 ID。使用多个 组件时为必需。
NOTE
默认情况下,上述每个目标 Binary Sensor 组件都包含 以下过滤器,以防止向 Home Assistant 大量推送状态更新:
- settle: 1000ms如果您已定义其他过滤器,此默认值将被覆盖;当然,如果您愿意,可以按照上述方式将其添加到自定义 过滤器中。
要移除任意给定二值传感器实例的默认过滤器,请在其配置中添加 filters: []。
ld2412 传感器可报告传感器采集的各种测量值。
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 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-
light (可选,int): 在工程模式下,指示灯光 灵敏度,否则指示
unknown。值介于0到255之间(含)。注意,这是任意单位,不对应于任何特定的强度测量单位。来自 Sensor 的所有选项。 -
moving_distance (可选,int): 检测到的运动目标的距离,单位为厘米。来自 Sensor 的所有选项。
-
still_distance (可选,int): 检测到的静止目标的距离,单位为厘米。来自 Sensor 的所有选项。
-
moving_energy (可选,int): 运动目标的能量。值介于
0到100之间(含)。来自 Sensor 的所有选项。 -
still_energy (可选,int): 静止目标的能量。值介于
0到100之间(含)。来自 Sensor 的所有选项。 -
detection_distance (可选,int): 目标的距离,单位为厘米。来自 Sensor 的所有选项。
-
gate_X (可选): 门 X 的能量值,其中 X 在 0 到 13 范围内。
-
ld2412_id (可选,ID): 手动为组件指定 ID。使用多个 组件时为必需。
NOTE
默认情况下,上述每个 Sensor 组件都包含以下 过滤器,以防止向 Home Assistant 大量推送状态更新:
- throttle_with_priority: 1000ms如果您已定义其他过滤器,此默认值将被覆盖;当然,如果您愿意,可以按照上述方式将其添加到自定义 过滤器中。
要移除任意给定传感器实例的默认过滤器,请在其配置中添加 filters: []。
ld2412 开关允许您在前端启用或禁用传感器功能。
switch: - platform: ld2412 engineering_mode: name: Engineering Mode bluetooth: name: Bluetooth-
bluetooth (可选): 打开/关闭蓝牙适配器。默认为
true。来自 Switch 的所有选项。 -
engineering_mode 打开/关闭工程模式。来自 Switch 的所有选项。
-
ld2412_id (可选,ID): 手动为组件指定 ID。使用多个 组件时为必需。
ld2412 数值允许您控制模块的配置。
number: - platform: ld2412 timeout: name: Presence Timeout min_distance_gate: name: Minimum Distance Gate max_distance_gate: name: Maximum Distance Gate light_threshold: name: Light Threshold 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-
timeout (可选,int): 不再检测到存在后存在状态保持的秒数。默认为
5s。来自 Number 的所有选项。 -
min_distance_gate (可选,int): 运动检测的最大距离门。值介于
1到12之间(含)。默认为1。来自 Number 的所有选项。 -
max_distance_gate (可选,int): 静止检测的最大距离门。值介于
2到13之间(含)。默认为13。来自 Number 的所有选项。 -
light_threshold (可选,int): 灯光激活传感器 OUT 引脚的阈值。来自 Number 的所有选项。
-
gate_X (可选): 门 X 的阈值,其中 X 在 0 到 13 范围内。
-
ld2412_id (可选,ID): 手动为组件指定 ID。使用多个 组件时为必需。
ld2412 按钮允许您对传感器执行操作。
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-
factory_reset (可选): 此命令用于将所有配置值恢复为原始值。 来自 Button 的所有选项。
-
restart (可选): 重启设备。来自 Button 的所有选项。
-
query_params (可选): 刷新设备的所有传感器值。来自 Button 的所有选项。
-
start_dynamic_background_correction (可选): 启动动态背景校正。来自 Button 的所有选项。
-
ld2412_id (可选,ID): 手动为组件指定 ID。使用多个 组件时为必需。
ld2412 文本传感器可报告传感器元数据。
text_sensor: - platform: ld2412 version: name: Firmware Version mac_address: name: Mac Address-
version (可选): 固件版本。来自 Text Sensor 的所有选项。
-
mac_address (可选): 蓝牙 MAC 地址。蓝牙关闭时将设为
unknown。来自 Text Sensor 的所有选项。 -
ld2412_id (可选,ID): 手动为组件指定 ID。使用多个 组件时为必需。
ld2412 选择器允许您配置传感器硬件。
select: - platform: ld2412 out_pin_level: name: Hardware Output Pin Level distance_resolution: name: Distance Resolution light_function: name: Light Function baud_rate: name: Baud Rate-
distance_resolution (可选): 控制门的距离分辨率。可为
0.75m、0.5m或0.2m。 默认为0.75m。来自 Select 的所有选项。 -
baud_rate (可选): 允许更改 LD2412 串口的波特率。默认为
115200。更改后, 传感器将停止工作,直到在设备的配置中更新 UART 组件 的波特率。来自 Select 的所有选项。 -
out_pin_level (可选): 允许选择传感器检测到存在时 LD2412 的 OUT 引脚行为。 可为
low或high。默认为low。来自 Select 的所有选项。 -
light_function (可选): 允许选择 LD2412 的 OUT 引脚对光水平的响应方式。可为
off、below或above。注意,此功能与存在检测配合使用。详见参考 手册。 -
ld2412_id (可选,ID): 手动为组件指定 ID。使用多个 组件时为必需。
OUT 引脚
Section titled “OUT 引脚”LD2412 的 OUT 引脚提供了一种简单的硬件机制,报告传感器是否检测到存在(和
灯光)。如果需要,可以设置一个 GPIO 二值传感器:
binary_sensor: - platform: gpio pin: GPIOXX name: LD2412 Out Pin Status device_class: presence要校准传感器,请执行以下操作:
或者,您也可以离开房间,打开”动态背景校正”,让它自行校准。