Hi folks,
This has probably been covered, but couldn’t see it (my poor searching likely).
I have an automation I’d like to
run at a specified time (turn a bunch of stuff off/on) based on time of day.
BUT I only want that to run if no motion is detected (for say 7minutes) from 2x PIR sensors (up & downstairs).
If condition (2 x PIR’s clear) is not met, then wait say 10 minutes, then check again (or however many times needed), until clear.
Once clear execute turn stuff off/on.
Seems simple, have the parts working no problem, but can’t seem to combine them into a single script/automation…
I’ve looked at this too long and am no longer thinking sensibly.
trigger:
- platform: time_pattern # trigger every ten minutes
minutes: "/10"
- platform: time
at: '10:10:00' # Also trigger at 10:10am, or whatever time you want.
condition:
- condition: state
entity_id: sensor.movement_1 # must be no movement here for at least 7 minutes
state: 'off'
for:
minutes: 7
- condition: state
entity_id: sensor.movement_2 # AND must be no movement here for at least 7 minutes
state: 'off'
for:
minutes: 7
- condition: time # AND must be after your specified time (minus 1 second to be sure the 10:10 trigger fires)
after: '10:09:59'
action:
service: do_your_stuff
Thank you.
I’ll give that a punt - will let you know.
I’m using the automation front end, I simply don’t know what’s possible without reading a tonne of stuff and other people’s posts (which is fine, but I end up in circles).
Note that after 10:10am will only be true until midnight, i.e. 10:10:00 to 00:00:00, if you need it to run longer say to 2 am, add a before condition as well.
- condition: time
after: '10:09:59'
before: '02:00:00'
Unless you do something else, won’t this run the action every 10 minutes once there’s no motion for 7 minutes?
If I understand what’s wanted, I think the easiest way to implement this is to add a Template Binary Sensor that indicates when there has been no motion from either motion sensor for 7 minutes. Then use that in a wait_template.
automation:
- trigger:
platform: time
at: 'HH:MM:SS'
action:
- wait_template: "{{ is_state('binary_sensor.no_motion_7min', 'on') }}"
# The rest of the actions go here...
@tom_l I implemented your suggestion last night - actions worked a treat - Thanks!
I never considered the re-occurring turning off until midnight aspect…
I didn’t test for that.
I’ll save that automation and will build per @pnbruckner’s suggestion and test.
Thanks again folks - this community is awesome. I learn with every interaction.
I had to do a restore of my environment due to an update which broke a bunch of my Hue sensors on my bridges.
Unsurprisingly, I hadn’t captured a full snapshot, so had to redo a bunch of stuff.
When I get up in the morning all of my ‘dailylights’ are still on, and have been since the rebuild (i.e the wai_template doesn’t seem to be working for me anymore).
This is the excerpt of the configuration.yaml #this was to check my two motion sensors we idle for 7 minutes.