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

New Zone Calculation #17

Merged
merged 1 commit into from
Nov 11, 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
35 changes: 31 additions & 4 deletions Integrations/ESPHome/Core.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
substitutions:
name: apollo-msr-2
version: "24.9.12.1"
version: "24.11.10.1"
device_description: ${name} made by Apollo Automation - version ${version}.

esp32:
Expand Down Expand Up @@ -245,17 +245,38 @@ 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_still_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
name: "Radar Zone 1 Occupancy"
id: radar_zone_1_occupancy
device_class: occupancy
icon: mdi:motion-sensor
lambda: |-
if ((id(radar_has_target).state) && ((id(radar_detection_distance).state < id(radar_z1_end).state) && (id(radar_detection_distance).state > id(radar_z1_start).state))){
bool still_in_zone = id(radar_has_still_target).state && (id(still_distance).state >= id(radar_z1_start).state) && (id(still_distance).state <= id(radar_z1_end).state);
bool moving_in_zone = id(radar_has_moving_target).state && (id(moving_distance).state >= id(radar_z1_start).state) && (id(moving_distance).state <= id(radar_z1_end).state);

if (still_in_zone || moving_in_zone) {
return true;
} else {
return false;
Expand All @@ -266,7 +287,10 @@ binary_sensor:
device_class: occupancy
icon: mdi:motion-sensor
lambda: |-
if ((id(radar_has_target).state) && ((id(radar_z1_end).state < id(radar_detection_distance).state) && (id(radar_detection_distance).state < id(radar_z2_end).state))) {
bool still_in_zone = id(radar_has_still_target).state && (id(still_distance).state > id(radar_z1_end).state) && (id(still_distance).state <= id(radar_z2_end).state);
bool moving_in_zone = id(radar_has_moving_target).state && (id(moving_distance).state > id(radar_z1_end).state) && (id(moving_distance).state <= id(radar_z2_end).state);

if (still_in_zone || moving_in_zone) {
return true;
} else {
return false;
Expand All @@ -277,7 +301,10 @@ binary_sensor:
device_class: occupancy
icon: mdi:motion-sensor
lambda: |-
if ((id(radar_has_target).state) && ((id(radar_z2_end).state < id(radar_detection_distance).state) && (id(radar_detection_distance).state < id(radar_z3_end).state))) {
bool still_in_zone = id(radar_has_still_target).state && (id(still_distance).state > id(radar_z2_end).state) && (id(still_distance).state <= id(radar_z3_end).state);
bool moving_in_zone = id(radar_has_moving_target).state && (id(moving_distance).state > id(radar_z2_end).state) && (id(moving_distance).state <= id(radar_z3_end).state);

if (still_in_zone || moving_in_zone) {
return true;
} else {
return false;
Expand Down
Loading