LD2410 传感器
ld2410 传感器平台允许您在 ESPHome 中使用 HI-LINK LD2410 运动和存在传感器。
有以下三种通信协议相似的变体:
此传感器需要在您的配置中设置 UART 才能工作,parity 和
stop_bits 必须分别为 NONE 和 1。
强烈建议使用硬件 UART 引脚,以最佳支持传感器出厂默认的 256000 波特率。

# Example configuration entryld2410:ld2410 二值传感器可帮助您快速确定传感器报告的多种状态。
binary_sensor: - platform: ld2410 has_target: name: Presence has_moving_target: name: Moving Target has_still_target: name: Still Target out_pin_presence_status: name: Out pin presence status-
has_target (可选): 如果为 true,表示检测到静止或运动的目标。 来自 Binary Sensor 的所有选项。
-
has_moving_target (可选): 如果为 true,表示检测到运动目标。 来自 Binary Sensor 的所有选项。
-
has_still_target (可选): 如果为 true,表示检测到静止目标。 来自 Binary Sensor 的所有选项。
-
out_pin_presence_status (可选): 在工程模式下,指示 OUT 引脚的状态,否则为
false。OUT 引脚指示取决于 灯光功能 配置。可能需要更新到最新固件才能使用此功能。 来自 Binary Sensor 的所有选项。
NOTE
默认情况下,上述每个 Binary Sensor 组件都包含 以下过滤器,以防止向 Home Assistant 大量推送状态更新:
- settle: 1000ms如果您已定义其他过滤器,此默认值将被覆盖;当然,如果您愿意,可以按照上述方式将其添加到自定义 过滤器中。
要移除任意给定二值传感器实例的默认过滤器,请在其配置中添加 filters: []。
ld2410 传感器可报告传感器采集的各种测量值。
sensor: - platform: ld2410 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 g0: move_energy: name: G0 move energy still_energy: name: G0 still energy g1: move_energy: name: G1 move energy still_energy: name: G1 still energy g2: move_energy: name: G2 move energy still_energy: name: G2 still energy g3: move_energy: name: G3 move energy still_energy: name: G3 still energy g4: move_energy: name: G4 move energy still_energy: name: G4 still energy g5: move_energy: name: G5 move energy still_energy: name: G5 still energy g6: move_energy: name: G6 move energy still_energy: name: G6 still energy g7: move_energy: name: G7 move energy still_energy: name: G7 still energy g8: move_energy: name: G8 move energy still_energy: name: G8 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 的所有选项。
-
gX (可选): 第 X 个门(X => 0 到 8)的能量。
NOTE
默认情况下,上述每个 Sensor 组件都包含以下 过滤器,以防止向 Home Assistant 大量推送状态更新:
- throttle_with_priority: 1000ms如果您已定义其他过滤器,此默认值将被覆盖;当然,如果您愿意,可以按照上述方式将其添加到自定义 过滤器中。
要移除任意给定传感器实例的默认过滤器,请在其配置中添加 filters: []。
ld2410 开关允许您在前端启用或禁用传感器功能。
switch: - platform: ld2410 engineering_mode: name: Engineering mode bluetooth: name: Control bluetooth-
engineering_mode (可选): 启用/禁用工程模式。注意,此模式需要更多资源,不建议 在不需要时启用。来自 Switch 的所有选项。
-
bluetooth (可选): 打开/关闭蓝牙适配器。默认为
true。 来自 Switch 的所有选项。
ld2410 数值允许您控制 Ld2410 的配置。
number: - platform: ld2410 timeout: name: Timeout light_threshold: name: Light threshold max_move_distance_gate: name: Max move distance gate max_still_distance_gate: name: Max still distance gate g0: move_threshold: name: G0 move threshold still_threshold: name: G0 still threshold g1: move_threshold: name: G1 move threshold still_threshold: name: G1 still threshold g2: move_threshold: name: G2 move threshold still_threshold: name: G2 still threshold g3: move_threshold: name: G3 move threshold still_threshold: name: G3 still threshold g4: move_threshold: name: G4 move threshold still_threshold: name: G4 still threshold g5: move_threshold: name: G5 move threshold still_threshold: name: G5 still threshold g6: move_threshold: name: G6 move threshold still_threshold: name: G6 still threshold g7: move_threshold: name: G7 move threshold still_threshold: name: G7 still threshold g8: move_threshold: name: G8 move threshold still_threshold: name: G8 still threshold-
timeout (可选,int): 离开后存在状态保持存在的秒数。默认为
5s。 来自 Number 的所有选项。 -
light_threshold (可选,int): 设置灯光功能的灯光阈值。 值介于
0到255之间(含)。默认为128。 来自 Number 的所有选项。 -
max_move_distance_gate (可选,int): 运动检测的最大距离门。 值介于
2到8之间(含)。默认为8。 来自 Number 的所有选项。 -
max_still_distance_gate (可选,int): 静止检测的最大距离门。 值介于
2到8之间(含)。默认为8。 来自 Number 的所有选项。 -
gX (可选): 第 X 个门(X => 0 到 8)的阈值。
门阈值的默认值
Section titled “门阈值的默认值”| 门 | 默认运动阈值 | 默认静止阈值 |
|---|---|---|
| 0 | 50 | 0 |
| 1 | 50 | 0 |
| 2 | 40 | 40 |
| 3 | 30 | 40 |
| 4 | 20 | 30 |
| 5 | 15 | 30 |
| 6 | 15 | 20 |
| 7 | 15 | 20 |
| 8 | 15 | 20 |
ld2410 按钮允许您对传感器执行操作。
button: - platform: ld2410 factory_reset: name: Factory reset restart: name: Restart query_params: name: Query params-
factory_reset (可选): 此命令用于将所有配置值恢复为原始值。 来自 Button 的所有选项。
-
restart (可选): 重启设备。 来自 Button 的所有选项。
-
query_params (可选): 刷新设备的所有传感器值。 来自 Button 的所有选项。
ld2410 文本传感器可报告传感器元数据。
text_sensor: - platform: ld2410 version: name: Firmware version mac_address: name: MAC address-
version (可选): 固件版本。 来自 Text Sensor 的所有选项。
-
mac_address (可选): 蓝牙 MAC 地址。蓝牙关闭时将设为
unknown。 来自 Text Sensor 的所有选项。
ld2410 选择器允许您配置传感器硬件。
select: - platform: ld2410 distance_resolution: name: Distance resolution baud_rate: name: Baud rate light_function: name: Light function out_pin_level: name: Out pin level-
distance_resolution (可选): 控制门的距离分辨率。可为
0.75m或0.2m。 默认为0.75m。来自 Select 的所有选项。 -
baud_rate (可选): 控制串口波特率。默认为
256000。更改后,所有传感器将 停止工作,直到您使用更新的 UART 组件 配置重新安装配置。 来自 Select 的所有选项。 -
light_function (可选): 如果设置,将根据 灯光阈值 影响 OUT 引脚值。可为
off、low或above。默认为off。 来自 Select 的所有选项。 -
out_pin_level (可选): 控制 OUT 引脚的
away值。可为low或high。默认为low。 来自 Select 的所有选项。
bluetooth_password.set 操作
Section titled “bluetooth_password.set 操作”这是一个用于设置蓝牙密码的操作。
- bluetooth_password.set: id: my_ld2410 password: "HiLink"配置变量:
要从 HA 更改密码,可以使用以下示例配置:
ld2410: id: my_ld2410
api: actions: - action: set_ld2410_bluetooth_password variables: password: string then: - bluetooth_password.set: id: my_ld2410 password: !lambda 'return password;'OUT 引脚
Section titled “OUT 引脚”如果您将 LD2410 的 OUT 引脚连接到 GPIO 引脚,可以设置一个 GPIO 二值传感器
来监测传感器指示的存在状态,如果启用了其
灯光功能,则可能包括其状态:
binary_sensor: - platform: gpio pin: GPIOXX name: GPIO Out pin presence device_class: presence要校准 ld2410 传感器,请执行以下步骤:
Home Assistant 卡片
Section titled “Home Assistant 卡片”为了简化校准过程,可以使用以下自定义手动卡片。
type: vertical-stacktitle: 'DEVICE'cards: - type: horizontal-stack cards: - type: entities entities: - entity: 'switch.DEVICE_engineering_mode' name: engineering mode - type: vertical-stack cards: - type: entities entities: - entity: 'number.DEVICE_timeout' name: timeout - entity: 'number.DEVICE_max_move_distance_gate' name: max move distance gate - entity: 'number.DEVICE_max_still_distance_gate' name: max still distance gate - entity: 'select.DEVICE_light_function' name: light function - entity: 'number.DEVICE_light_threshold' name: light threshold - type: horizontal-stack cards: - type: entity entity: 'sensor.DEVICE_detection_distance' name: distance - type: entity entity: 'sensor.DEVICE_moving_distance' name: move - type: entity entity: 'sensor.DEVICE_still_distance' name: still - type: horizontal-stack cards: - type: entity entity: 'sensor.DEVICE_move_energy' name: move energy - type: entity entity: 'sensor.DEVICE_still_energy' name: still energy - type: horizontal-stack cards: - type: entity entity: 'binary_sensor.DEVICE_gpio_out_pin_presence_status' name: gpio presence state_color: true - type: entity entity: 'binary_sensor.DEVICE_presence' name: presence state_color: true - type: entity entity: 'binary_sensor.DEVICE_moving_target' name: movement state_color: true - type: entity entity: 'binary_sensor.DEVICE_still_target' name: still state_color: true - type: conditional conditions: - entity: 'switch.DEVICE_engineering_mode' state: 'on' card: type: vertical-stack cards: - type: horizontal-stack cards: - type: entity entity: 'sensor.DEVICE_light' name: light - type: entity entity: 'binary_sensor.DEVICE_out_pin_presence_status' name: out pin presence state_color: true - type: horizontal-stack cards: - type: entity entity: 'sensor.DEVICE_g0_move_energy' name: 'g0' - type: entity entity: 'number.DEVICE_g0_move_threshold' name: ' ' - type: entity entity: 'sensor.DEVICE_g0_still_energy' name: ' ' - type: entity entity: 'number.DEVICE_g0_still_threshold' name: ' ' - type: horizontal-stack cards: - type: entity entity: 'sensor.DEVICE_g1_move_energy' name: 'g1' icon: ' ' - type: entity entity: 'number.DEVICE_g1_move_threshold' name: ' ' icon: ' ' - type: entity entity: 'sensor.DEVICE_g1_still_energy' name: ' ' icon: ' ' - type: entity entity: 'number.DEVICE_g1_still_threshold' name: ' ' icon: ' ' - type: horizontal-stack cards: - type: entity entity: 'sensor.DEVICE_g2_move_energy' name: 'g2' icon: ' ' - type: entity entity: 'number.DEVICE_g2_move_threshold' name: ' ' icon: ' ' - type: entity entity: 'sensor.DEVICE_g2_still_energy' name: ' ' icon: ' ' - type: entity entity: 'number.DEVICE_g2_still_threshold' name: ' ' icon: ' ' - type: horizontal-stack cards: - type: entity entity: 'sensor.DEVICE_g3_move_energy' name: 'g3' icon: ' ' - type: entity entity: 'number.DEDEVICE_g3_move_threshold' name: ' ' icon: ' ' - type: entity entity: 'sensor.DEVICE_g3_still_energy' name: ' ' icon: ' ' - type: entity entity: 'number.DEVICE_g3_still_threshold' name: ' ' icon: ' ' - type: horizontal-stack cards: - type: entity entity: 'sensor.DEVICE_g4_move_energy' name: 'g4' icon: ' ' - type: entity entity: 'number.DEVICE_g4_move_threshold' name: ' ' icon: ' ' - type: entity entity: 'sensor.DEVICE_g4_still_energy' name: ' ' icon: ' ' - type: entity entity: 'number.DEVICE_g4_still_threshold' name: ' ' icon: ' ' - type: horizontal-stack cards: - type: entity entity: 'sensor.DEVICE_g5_move_energy' name: 'g5' icon: ' ' - type: entity entity: 'number.DEVICE_g5_move_threshold' name: ' ' icon: ' ' - type: entity entity: 'sensor.DEVICE_g5_still_energy' name: ' ' icon: ' ' - type: entity entity: 'number.DEDEVICE_g5_still_threshold' name: ' ' icon: ' ' - type: horizontal-stack cards: - type: entity entity: 'sensor.DEVICE_g6_move_energy' name: 'g6' icon: ' ' - type: entity entity: 'number.DEVICE_g6_move_threshold' name: ' ' icon: ' ' - type: entity entity: 'sensor.DEDEVICE_g6_still_energy' name: ' ' icon: ' ' - type: entity entity: 'number.DEVICE_g6_still_threshold' name: ' ' icon: ' ' - type: horizontal-stack cards: - type: entity entity: 'sensor.DEVICE_g7_move_energy' name: 'g7' icon: ' ' - type: entity entity: 'number.DEVICE_g7_move_threshold' name: ' ' icon: ' ' - type: entity entity: 'sensor.DEVICE_g7_still_energy' name: ' ' icon: ' ' - type: entity entity: 'number.DEVICE_g7_still_threshold' name: ' ' icon: ' ' - type: horizontal-stack cards: - type: entity entity: 'sensor.DEVICE_g8_move_energy' name: 'g8' icon: ' ' - type: entity entity: 'number.DEVICE_g8_move_threshold' name: ' ' icon: ' ' - type: entity entity: 'sensor.DEVICE_g8_still_energy' name: ' ' icon: ' ' - type: entity entity: 'number.DEVICE_g8_still_threshold' name: ' ' icon: ' '然后将所有 DEVICE 实例替换为您的设备名称。
结果如下: