TillFleisch / ESPHome-HLK-LD2450

ESPHome support for the HI-Link HLK-LD2450 millimeter wave sensor (external component) with support for custom zones using convex polygons.
MIT License
105 stars 19 forks source link

filters on "occupancy" doesn't seem to work #18

Closed Rihan9 closed 5 months ago

Rihan9 commented 5 months ago

Hi,

I'm trying to add a small delay before the occupancy sensor goes off. Below, I have posted my configuration, but the delay_off filter doesn't seem to work.

Can I get some help?

Thanks!

LD2450:
  uart_id: uart_bus
  flip_x_axis: true
  fast_off_detection: true
  max_detection_tilt_angle:
    name: "Max Tilt Angle"
    initial_value: 40°
  min_detection_tilt_angle:
    name: "Min Tilt Angle"
    initial_value: -40°
  max_detection_distance:
    name: "Max Distance"
    initial_value: 4m
  max_distance_margin: 30cm
  tracking_mode_switch:
    name: "Multiple Target Tracking"
  occupancy:
    name: Occupancy
    filters:
      - delayed_off: 45s
  target_count:
    name: Target Count
  targets:
    - target:
        name: "T1"
        id: t1
        debug: true
        x_position:
            id: t1_xpos
        y_position:
            id: t1_ypos
        speed:
            id: t1_speed
        distance_resolution:
            id: t1_res
        angle:
            id: t1_angle
        distance:
            id: t1_distance
    - target:
        id: t2
        x_position:
            id: t2_xpos
        y_position:
            id: t2_ypos
        speed:
            id: t2_speed
        distance_resolution:
            id: t2_res
        angle:
            id: t2_angle
        distance:
            id: t2_distance
bsell93 commented 5 months ago

I haven't tried latest version of this repo, but my configuration below works for me:

Click here to see config ```yaml LD2450: uart_id: uart_bus flip_x_axis: true fast_off_detection: true max_detection_tilt_angle: id: ${node_id}_max_tilt_angle name: Max Tilt Angle initial_value: 60° unit_of_measurement: ° min_detection_tilt_angle: id: ${node_id}_min_tilt_angle name: Min Tilt Angle initial_value: -60° unit_of_measurement: ° max_detection_distance: id: ${node_id}_max_distance name: Max Distance initial_value: 4m unit_of_measurement: m max_distance_margin: 30cm restart_button: name: "Restart Sensor" factory_reset_button: name: "Factory Reset Sensor" tracking_mode_switch: name: "Multiple Target Tracking" bluetooth_switch: name: "Sensor Bluetooth" baud_rate_select: name: "Sensor Baud Rate" occupancy: id: ${node_id}_occupancy name: Occupancy filters: delayed_off: 5s target_count: id: ${node_id}_target_count name: Target Count targets: - target: name: "Target 1" id: t1 debug: true x_position: id: t1_xpos y_position: id: t1_ypos speed: id: t1_speed distance_resolution: id: t1_res angle: id: t1_angle distance: id: t1_distance - target: name: "Target 2" id: t2 x_position: id: t2_xpos y_position: id: t2_ypos speed: id: t2_speed distance_resolution: id: t2_res angle: id: t2_angle distance: id: t2_distance - target: name: "Target 3" id: t3 x_position: id: t3_xpos y_position: id: t3_ypos speed: id: t3_speed distance_resolution: id: t3_res angle: id: t3_angle distance: id: t3_distance ```
TillFleisch commented 5 months ago

I also can't reproduce this issue (latest esphome&external_component).

LD2450:
  uart_id: uart_bus
  occupancy:
    name: "Office"
    filters:
      delayed_off: 2min
  target_count:
    name: "Office"

This minimal configuraiton yields a log like this (binary sensor turns off 2 minutes after target count sensor):

[17:49:42][D][binary_sensor:036]: 'Office': Sending state ON
[17:49:42][D][sensor:094]: 'Office': Sending state 1.00000  with 0 decimals of accuracy
[17:49:49][D][sensor:094]: 'Office': Sending state 0.00000  with 0 decimals of accuracy
[17:51:49][D][binary_sensor:036]: 'Office': Sending state OFF

@Rihan9 can you post an excerpt from your logs when this happens? You should be able observe a similar behavirour with your target_count sensor. Maybe the LD2450 sensor is still tracking a taget (some moving objects such as doors or curtains moving in the wind). Try adding all 3 targets with debug sensors so you can observe what is happening more closely.

I will close this as can't reproduce, feel free to use this issue for further questions regarding this problem. Thanks @bsell93 for chiming in.