Hello, I have a Time Trigger automation setup to turn my thermostat down at 22:00, but sometimes I am still awake and moving around in my apartment. I’d like the action at 22:00 to delay until it hasn’t seen movement for 10 minutes.
My plain Time Trigger looks like this:
- id: '1579145331076'
alias: Living Room Temperature Schedule Evening Off
description: ''
trigger:
- at: '22:00:00'
platform: time
condition: []
action:
- data:
entity_id: climate.remote_temp
temperature: 16
service: climate.set_temperature
I think I could add a “condition” like:
- condition: state
entity_id: binary_sensor.living_room_sensor_motion
state: 'off'
…but this would just skip the action altogether if there is still movement*. How can I get it to keep checking for movement after 22:00 and when there’s no longer any motion, continue the automation action to turn down the heat?
* Also the motion is only ever “on” for a few seconds every time it detects motion, so there’s still some likelihood that that condition wouldn’t stop it from continuing anyway because there are little windows where motion isn’t detected; it really needs to be “motion hasn’t been detected for x minutes.”
Thanks for any guidance you can help me with here!
Situations like this are a little tricky, so not sure this is the BEST option - as specific time triggers and then waiting FOR an event is tricky.
Anyhow if you used 3 automations and a timer.
Automation 1) TRIGGER: Time at 22:00:00. ACTION: Start the timer (set the time for whatever 'motion not detected for x minutes)
Automation 2) TRIGGER: Motion in the living_room. CONDITION: After 22:00:00. ACTION: Reset the timer
Automation 3) TRIGGER: Timer reaches 0. CONDITION: After 22:00:00. ACTION: Set the temperature.
Always a ton of ways to skin a cat in HA, and sometimes trying to reduce # of automations and such comes at the expense of simplicity. Anyhow, biggest issue I see w/ the above is that if there’s motion from 22:00 until after 23:59 - the for conditions would be invalidated - though you could use OR conditions and put Time AFTER 22:00:00 OR Time Before 03:00:00 (or whatever morning time you wanted).
Oh that’s a great idea! I can just integrate the movement into a timer and have the whole process kicked off at 22:00. I’m going to give it a try, thanks for the suggestion.
- id: '1579145331076'
alias: Living Room Temperature Schedule Evening Off
trigger:
- platform: time
at: '22:00:00'
- platform: state
entity_id: binary_sensor.living_room_sensor_motion
to: 'off'
for:
minutes:10
condition:
- condition: state
entity_id: binary_sensor.living_room_sensor_motion
state: 'off'
for:
minutes:10
- condition: time
after: '21:59:59'
action:
- data:
entity_id: climate.remote_temp
temperature: 16
service: climate.set_temperature
By including both triggers in the conditions you effectively make the triggers AND logic. It has to be after 10pm and no motion for ten minutes before the action will be performed.
Edit: there is one caveat. You must stop movement before 23:50 for this to work. Crossing the midnight boundary with the 10 minute condition will cause problems. You could write another automation that turns down the heating at midnight without conditions to force you to go to bed
Bah, silly yaml! I parse these files in my day job and I still don’t understand how the damn spaces are supposed to work. Thank you very much, I set it to an earlier time just to check and it appears to work!
Thank you both, I’ve learned a lot and I’m excited to keep at it.