I have written a rule to accommodate failures with launching Alexa routines via a virtual contact switch. The Alexa failures are probably caused by our poor rural Internet service and are not the reason for my request for help.
Rather, it is the "While... repeat every" block that is confusing me.
The rule that I've written is found below. I believe that it should throw a virtual contact switch every 10 seconds until the terminating condition occurs i.e. Alexa routine finally fires. However, as you can see in my notification it is firing without regard to the 10 second requirement built into the "While" statement.
I suspect that I don't understand the actual functionality of the "While... Repeat every" loop structure? Perhaps I am mistaken about the "every" portion on the loop structure?
Help to understand this, as always, appreciated.
You'll get a better idea of what's happening if you enable all logging and look at that output--or provide it here to give more clues to others.
Guessing based on your actions without that: one of your actions could cause the rule to re-trigger at least once (turning on the switch that appears to be a trigger device...which is a bit odd since it turning on in the first place is the trigger and this action just turns it on, which it should already be--note that triggers are from events and not commands--but, yeah, logs). Nothing is preventing re-entrant execution, and it looks like you might have a few in a row.
Yes, logging is enabled and very hard to read since it appears to timestamp based on event time as opposed to execution time
Nevertheless, I believe that you solved it for me. I mistakenly presumed safety since I only turn on the switch that is also the trigger event when that switch is off. Of course that was foolish as it will retrigger when the switch is off which occurs automatically 5 seconds after turning on.
Sometimes you can stare at code too long to be able to see
They are logged at approximately the same time the actions run (for action logging). Actions are not events (triggers normally are), so I'm not sure exactly what you mean or what you'd want instead. Most action lines will run a command, which might result in an event (which may be logged for the device, depending on your settings). Knowing if one happened but the other didn't is sometimes helpful for troubleshooting. So, this behavior is generally desirable.
Could be it. But logs will show you for sure.
Just a comment that logs can be difficult to read especially in a case like this. I did not immediately see the reentrant event trigger.
Nevertheless, you did peg it thank you!
In summary, a While... Repeat in unnecessary in a situation like this as the triggering event creates a looping condition by default since an action that occurs within the body of the rule retriggers the rule. So simple enough to fix by simply switching the loop to a condition as seen below.