Skip to content

Commit

Permalink
Merge pull request #20 from bjw-s/patch-2
Browse files Browse the repository at this point in the history
Return NaN for distance when no target detected
  • Loading branch information
TrevorSchirmer authored Nov 15, 2024
2 parents f80916e + 1a9a91b commit 67a2f40
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions Integrations/ESPHome/Core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -246,26 +246,10 @@ binary_sensor:
has_moving_target:
name: Radar Moving Target
id: radar_has_moving_target
on_state:
then:
- if:
condition:
binary_sensor.is_off: radar_has_moving_target
then:
- lambda: |-
id(moving_distance).publish_state(0);
has_still_target:
name: Radar Still Target
id: radar_has_still_target
on_state:
then:
- if:
condition:
binary_sensor.is_off: radar_has_still_target
then:
- lambda: |-
id(still_distance).publish_state(0);


## Set Up Radar Zones Based On Distance
- platform: template
Expand Down Expand Up @@ -397,6 +381,11 @@ sensor:
static float last_reported_value = 0.0;
float current_value = x;
// Check if the radar_has_moving_target sensor is off
if (!id(radar_has_moving_target).state) {
return NAN;
}
// Check if the reduce_db_reporting switch is on
if (id(reduce_db_reporting).state) {
// Apply delta filter: only report if the value has changed by 2 or more
Expand All @@ -420,6 +409,11 @@ sensor:
static float last_reported_value = 0.0;
float current_value = x;
// Check if the radar_has_still_target sensor is off
if (!id(radar_has_still_target).state) {
return NAN;
}
// Check if the reduce_db_reporting switch is on
if (id(reduce_db_reporting).state) {
// Apply delta filter: only report if the value has changed by 2 or more
Expand Down Expand Up @@ -457,6 +451,11 @@ sensor:
static float last_reported_value = 0.0;
float current_value = x;
// Check if the radar_has_target sensor is off
if (!id(radar_has_target).state) {
return NAN;
}
// Check if the reduce_db_reporting switch is on
if (id(reduce_db_reporting).state) {
// Apply delta filter: only report if the value has changed by 2 or more
Expand Down

0 comments on commit 67a2f40

Please sign in to comment.