I created an automation that should activate an evening scene to turn on some lights. This should only happen when motion was detected in the past half hour.
The duration parameter in the conditions can be used to see if the state is active for the configured duration. But I want the opposite: if the PIR is at state ‘clear’ for 30 mins, apparently nobody has moved in the living room for 30 mins, so I consider the room empty. To my surprise, the lights were on though when we arrived home yesterday. So, what is my mistake? Why isn’t the NOT condition working as expected?
Device conditions are a little murky for me, but it looks the automation will only fire if there is not motion for 30 minutes. That is, the lights will only turn on when you don’t want them to!
I don’t know if what you want is available in “canned” automation functionality. One thing you could do is create a template binary sensor that goes “off” once there is no motion for 30 minutes, and you could use that as a condition in your automation. Here is a snippet from where I am doing something similar:
binary_sensor:
- platform: template
sensors:
motion_last_hour:
friendly_name: "Motion in last hour"
delay_off:
#56 minutes plus 4 minutes sensor update = 60 minutes
minutes: 56
value_template: "{{ is_state('sensor.living_room_multisensor_burglar', '8') }}"
If your PIR sensor has a last_updated attribute, you could also use the PIR being off and if it was last updated more than 30 minutes ago as a condition instead.
Hmm, I think I accidently changed my automation when writing this post, so I am confused myself now.
Anyways, I would prefer a ‘canned’ automation as you aptly call it. I am trying not to switch to evening mode (turning on a few lights) if nobody is home.