I have an LD2410 connected to an ESP32 in a room with a ceiling fan. I’m using the ld2410 to detect presence and from there manage lighting.
When the fan is running, detection_distance consistently hovers between 348-352.
Can anyone give me pointers to how I can configure the device in ESPHome such that any time the detection distance is between the two numbers, the has_target binary sensor reports as clear?
Answering my own question for anyone else looking for a solution. Occupancy is now based on state of binary_sensor.study_mmwave_fudged_presence:
uart:
id: ld2410_uart
tx_pin: GPIO1
rx_pin: GPIO3
baud_rate: 256000
parity: NONE
stop_bits: 1
ld2410:
uart_id: ld2410_uart
binary_sensor:
- platform: ld2410
has_target:
name: Presence
id: presence
has_moving_target:
name: Moving Target
has_still_target:
name: Still Target
- platform: template
name: Fudged Presence
lambda: !lambda |-
if (id(presence).state && id(detection_distance).state >339 && id(detection_distance).state < 361) {
return 0;
} else {
return id(presence).state;
}
sensor:
- platform: ld2410
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
id: detection_distance
number:
- platform: ld2410
timeout:
name: timeout
max_move_distance_gate:
name: max move distance gate
max_still_distance_gate:
name: max still distance gate
1 Like
muktheo
(Muktheo)
June 9, 2024, 10:39pm
3
Hi, @whingingpom , glad to find your thread! Ive faced this problem all the time since the beginning i used this ld2410, and its quite hard to fine tuning my room with wall fan
Anyway can you please kindly teach me how you define the value inside you lamdba condition? Maybe a little decription about your noisy fan distance in your room will be help me to define mine.
Thanks!
athua
(Gus)
June 10, 2024, 3:56am
4
Neat idea.
If you don’t mind, I’ve enhanced this exlusion feature by making the begin and end of the exclusion distance configurable.
Here is what you need to do to implement it:
Add the id values to the following existing entities:
number:
- platform: ld2410
timeout:
name: "timeout"
id: timeout
binary_sensor:
- platform: ld2410
has_target:
name: "Presence"
id: presence
sensor:
- platform: ld2410
detection_distance:
name: "Distance Detection (cm)"
id: detection_distance
Then add the following:
number:
- platform: template
name: Exclusion Begin
id: ex_start
min_value: 0
max_value: 900
mode: box
device_class: distance
entity_category: config
unit_of_measurement: cm
icon: mdi:arrow-right-bold
step: 1
optimistic: True
initial_value: 0
restore_value: True
- platform: template
name: Exclusion End
id: ex_end
min_value: 0
max_value: 900
mode: box
device_class: distance
entity_category: config
unit_of_measurement: cm
icon: mdi:arrow-left-bold
step: 1
optimistic: True
initial_value: 0
restore_value: True
binary_sensor:
- platform: template
name: Presence with Exclusion
device_class: occupancy
filters:
- delayed_off: !lambda |-
return id(timeout).state * 1000.0;
lambda: !lambda |-
if (id(presence).state && id(detection_distance).state >= id(ex_start).state && id(detection_distance).state <= id(ex_end).state) {
return 0;
} else {
return id(presence).state;
}
1 Like
@athua @whingingpom
Thanks for your implementation to exclude the ceiling fan. I just tried it and it worked for my room
If you don’t mind me asking:
What’s the optimal location to position the sensor in a room? Before this I’ve only been using this in bathroom where it’s just mounted on the ceiling
i haven’t really followed up with the other variants of ld2410. Is the ld2411s a better version with more antennas?