Hi.
I’m currently using a screek human presence 2a detector and trying to count how many people enter or exit the room at any given time.
The plan is to configure the sensor with two zones, one just before the door and one just after the door. The automation would look at the first zone 1 trigger instance and compare to when the person enters zone 2 - if less than 3 seconds, then a counter will be added to. The visa versa for when a person leaves the room from zone 2 to zone 1, the counter will be decremented.
I know I have my knickers in a twist on this code, trying to bodge bits of understanding from other post. There would be a second automation that would decrease the counter as well.
alias: Person count plus
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.screek_human_sensor_2a_d17d3c_zone2_presence
to: "on"
condition: []
action:
- condition: template
value_template: >-
'{% if -1 <
as_timestamp(states.binary_sensor.screek_human_sensor_2a_d17d3c_zone1_presence.last_changed)
-
as_timestamp(states.binary_sensor.screek_human_sensor_2a_d17d3c_zone2_presence.last_changed)
< 3 %}
true {% endif %}'
- service: counter.increment
metadata: {}
data: {}
target:
entity_id: counter.lounge_person_counter
mode: single
any direction would be welcomed