I want to trigger an action in an automation every 5 seconds for 2 minutes long. Is this possible?
I am using DOODS (Dedicated Open Object Detection Service) and want it to scan every 5 seconds for objects when motion is detected on my camera. I already have the automation that triggers the action once:
Check out repeat, the docs can be found here. For a simple solution, you can add a five second delay as an action in the sequence and then just have it repeat 60 times.
Your formatting is not correct. If you want to use both an state condition and a count, you need to use either the “until” or “while” form… use a repeat.index template instead of using “count”.
Great, i will try. is there a way to see if an automation is stopped or still running?
EDIT: I am getting this error in the logs:
Template variable error: ‘repeat’ is undefined when rendering ‘’{{ repeat.index >= 20 or is_state(‘image_processing.doods_voortuin’, ‘off’) }}’
EDIT: looks like the repeat is working, it stops after 30 times. I can test tonight is it also stops when the state changes.
When an automation’s action is in progress, the value of the automation’s current attribute is 1 (I believe that means one instance of the automation is in progress). When it’s idle, the value is 0. Therefore you can use that (check if the value is greater than zero) to determine if the automation is busy or not.
Just tested it, looks like it stops after x times. But it does not stop when the state changes…
EDIT: i think i found the issue, looks like it stops the automation. But triggers it directly when the trigger goes again. Need to create an condition so it does not keep running again.