you are right but I do not want to trigger an action on first movement.
I reduced the time it stays on to 3 secs, and I want to trigger an action once a person is detected more than once in a short amount of time. This is installed in stairs, where people tend to pass (1 or 2 sec) but if people stop i would like to trigger an action
Most sensors trigger every time a person passes by (within a time frame, for example 3 minutes) and that will reset the ‘off’ timer. So if the timer is 10 minutes the action will fire 10 minutes after the last person has triggered the sensor.
hey again, just did some tests but the increment is not going past 1.
also I am not understanding why the counter is being reseted before 60sec … any idea of what I might be doing wrong @Burningstone ?
I don’t know exactly how automations work technically under the hood. Perhaps the first Automation can only be triggered again after it has finished? So it isn’t triggered again if motion is detected within the delay?
You can always try to build complex joint automations but it sometimes is easier to have multiple.
In my view you need to monitor 3 events.
Increase a counter every time motion is detected
Reset the counter every 60 seconds (if desired only when counter greater than zero)
hi @metbril … i think you are correct. I just did a small test where I removed the “delay + reset” part of the automation, and the counter was incrementing each time the motion sensor was being triggered (see below). I think the solution is how you described it … to make an independent automation to reset the counter. I think I would change point 2. as reset the counter after 60 seconds the motion is detected. Hopefully this works.
- id: '1577118540943'
alias: Motion in Stairs Reset
description: Motion in Stairs Reset
trigger:
- entity_id: binary_sensor.commonstairs_movement
platform: state
to: 'on'
condition:
- above: '1'
condition: numeric_state
entity_id: counter.stairssensorcount
action:
- entity_id: counter.stairssensorcount
service: counter.reset
EDIT:
the above what tested and what is happening is that after the second detection (i.e. after condition > 1 reached), counter is being reseted to zero
The counter is being reset, because of the delay in your action. This is, some would say illogical, behaviour of HA. When you trigger an automation with a delay, the automation is “running” during the delay time. If the automation gets triggered again, while the automation is still “running” (waiting for the delay to finish and executing the other actions), it skips the delay part and therefore in your automation, resets the counter.
The code you used resets the counter every time when motion is detected and the counter is > 1.
To work around this I would suggest creating a timer and use a second automation to start this timer every time when motion has been detected. When the timer is started, while it is running, it will be reset automatically.