I have an automation that are triggered by a motion detection.
What I want to achieve are;
Turn on the automation, upon state = on it will automatically run the automation
The automation should be looping until I turn off the automation
Can this be achieved?
Why do I want to loop the automation? I have a TTS message being broadcasted as an alarm over my media_player entities and I want to have the message being re-read until I turn of the automation.
It uses initial_state: false to ensure that, upon startup, the automation is off.
It is triggered when the state of automation.looper (thatās its own entity_id) changes from off to on.
It creates a persistent_notification, waits 10 seconds, then repeats this operation.
The repetitions continue for a maximum of 50 times or until automation.looper is turned off (whichever comes first). You could make it repeat indefinitely but itās a better practice to include a self-limiting safeguard.
For your purposes, you will need to replace persistent_notification with your preferred service (to call TTS).
My preference would be to use the template in the original example and simply change the maximum value from 50 to something higher like 500. Thatās sufficiently āindefiniteā for most applications yet has a definitive end. However, you know your requirements best so if you need a never-ending loop, you can use {{ true }}.
NOTE
If the automation is looping and you restart Home Assistant, the initial_state: false option will cause the āindefiniteā looping to stop (because the automation is set to off on startup).
I am trying to use your automation to send a series of increase/decrease commands to reduce the temperature of a vaporizer from an input_number slider. It should send the command and update a sensor showing the temperature. I canāt seem to get it to loop, though it will send the command to the device once and doesnāt affect the same sensor. The same code attached to a button works flawlessly to do both, but as the vaporizer requires a series of events to decrease or increase temperature beyond a few presets, I was hoping to automate for fine tuning.
I see one sensor and two input_numbers but I donāt know how they interact. The while checks one input_number but the action sets another. Unfortunately I donāt understand how this is supposed to work.
Ah, well input_number.vape_target_temp is the slider that I intend to use to fine-tune the temperatures. input_number.vape_actual_temp is the input number that gets increased or decreased by increments of +/- 1 with button clicks - it can also be set by some pre-set temperature buttons. However, these preset temperatures arenāt to my liking so I would rather be able to set it with an automation that handles the button clicks of +/- 1.
The sensor.arizer_vape_temp is just a front-end display read-out of the input_number.vape_actual_temp.
Wow, great solution. Until i found this post it wasnāt so easy.
For flashing siren with pause i had to write 3 scripts and 2 automations. Incredible good jobTaras!
Happy anniwersary with Home Assistant to Me