Making a loop is a bitch. You need to use a counter and 2 scripts that call each other. One script would have a condition based on the count of the counter. @pnbruckner’s solution is the easiest solution by far.
I’m thinking we just need a new action/script object type. Something like - delay inside a script. It could be named loop contain 2 attributes: count and sequence:
also, this seems to be a burden on the system, it doesnt really flash regularly, and timing is rather off. Must be a better way to do this, maybe directly on the Hub (Hue or tradfri in my setting) and call a script activating that.
I would try creating a script that just blinks in a continuous loop. Then you can just use another script to turn on that blinking script for 1 minutes (or x blinks based on time) and then turn off that script. I use time as the counter
blink script
turn on light
wait 1 sec
turn off light
wait 1 sec
run blink script
to run the blinker
– turn on blink script
– wait x seconds for x blinks
– turn off blink script
Except this won’t work as I understand it, because a script that is already running can’t be started. So in your suggestion, when you get to the last line of your script it will fail because the script is already running. You would have to do this with at least two different scripts.
exactly, my thoughts.
need a for: in the action part and be done with it.
As i see it now, we’re beter of buying a strobe light you turn on and after some time off. This script at hand is really unreliable, and no more than an irregular on/off switch, no matter the delay.
Nice for an exercise in automating and scripting but not of great really life value imho.
must be the response time of the hub, and the timing on the Hassio instance.
leaving that to a dedicated light is far preferable.
I see we have similar thoughts on a new loop feature for animations and scripts. Please give your vote to this feature request if you are still interested in this: Add easier solution for loops in automations/scripts
I’m looking for the code to make the Xiaomi gateway LED flash red when a sensor goes to the off state, and to turn off the LED when the same sensor goes to the on state.
can you help me?^