Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return NaN for distance when no target detected #20

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading