I have an automation that will set my heating to come on boost for 60minutes when motions detected. So every time motion is detected it goes back up to 60minutes.
How can I set the automation to not re run a 2nd time and instead wait until those 60minutes are up before running. I tried a 60minutes delay but that doesn’t help if there is only 1 minute left on the boost as the heating won’t come on for 61minutes minimum. I want it that it won’t come on but a minute later for instance any motion would start a new 60mins or if there was 30minutes left then an motion will not start a new counter for another 30minutes assuming there motion after those 30 minutes still.
The best approach is to use set a input_datetime with date and time one hour ahead and use that as a condition in the automation.
So if current time is more than this input_datetime then it’s allowed to run.
Using a condition on last_run time can be problematic when HA restarts, but if you are fine with that then that is probably a simpler solution since it doesn’t need a input_datetime.
Set the Automation to single and it wont trigger again when its busy. So if you have the 60min delay in the automation any new trigger wont activate it again. Only after the automation is done will it be able to trigger again.
single (Default) Do not start a new run. Issue a warning.
confused now, didnt the OP say he wanted a 60min boost? and at the end of the boost i can be triggered again. So if u use a Wait in the automation its still running and wont run again.
alias: Test
description: ''
trigger:
- platform: state
entity_id: switch_test
to: '1'
condition: []
action:
- service: knx.send
data:
address: 0/2/2
payload: 1
- delay:
hours: 0
minutes: 0
seconds: 30
milliseconds: 0
mode: single
In this case using switch_test will trigger the Automation and its delay of 30 seconds, after that i can spam the switch_test but nothing will happpen. Until the 30 seconds is up and then it will be able to run again.
But delaying automations more than a few seconds is always a risk that it will fail due to automation reload or restart of HA.
That is why the recommended way is to use a datetime.
The values of now() and last_triggered are datetime objects.
When you subtract datetime objects, the result is a timedelta object. The template simply subtracts the two datetime objects and compares the result to a timedelta object of 5 minutes.
If the template is within the automation it is testing then you can use calisro’s tip and replace automation.name with this.entity_id.
Hi! I’ve encountered a similar issue and was wondering if this would work with automation IDs? I have some pressure mats I’ve connected to HA via ESP that when detected, open op a doggy door (there are mats on either side of the door, grouped together in HA). However I want to avoid a double activation when the dog steps on both when he goes in or out, so I figured just setting a condition of “don’t activate if the automation was ran within 15 seconds prior.” I figured setting up a custom sensor would do the job.
Using the above provided code I’m getting an error, which I assume is only due to the automation ID. Any help would be appreciated!