Loop (while) in rule engine

Could be nice in automation to be able to use a loop (while … do…)

Was using this to loop on a variable until that variable value change

Nice when one event get triggered to have more flexibility

Can you share more details on the use case? You can use Variables as triggers in rules and react to them changing.

was using this principle on a piston when turning off light in the bathroom when receiving an event from a motion sensor (motion change to inactive)

I don’t want to close light if i’m sitting doing my thing, so I combine it with my door sensor, the light will turn off only if the door is open

see my piston

It seems like something you could achieve today without looping.

Whatever the triggering event is should be used as the Trigger in SharpTools, then you can use an IF condition in the flow. Then anytime the the trigger occurs, the condition will be checked. In some cases, that may require you to ‘invert’ some of the logic compared to what you have in webCoRE.

Since the inactive motion should happen only once, I was getting sure the light close when the door open

But I understand that it’s and edge case, since It should see motion again before getting an active motion event again (like if i’m standing up from the toilet)

i also have a while loop in a piston that i’m trying to recreate here. yes, it technically can be written with if statements, but the while loop is a more efficient way of coding it. (but i also get that changing Rules Engine and adding a big feature like that is not easy and may not be a priority if there are alternate existing ways to accomplish the task)

i have it check if my tv or soundbar are off, and while any of them are off, to turn them on and wait 2 seconds. this lets it possibly loop/repeat the command if it takes more than 2 seconds for a device to turn on and be ready to accept the next command to change input source.

[now slightly deviating from the thread topic to discuss my own personal case that’s related to this question]

i made a version of this in the rules engine using an if statement to check if any of those devices were on. i have some concerns about the speed of execution. it took 5 seconds to evaluate the if statement, 3 seconds each to send the two “on” commands, 3 seconds to pause for 2 seconds, and 3 seconds each again to send next two commands. is that normal speed of the engine or a limit because im not on premium yet?

and last question: i see lots of capabilities of these devices, similar to what webcore sees. will that change once groovy is gone?

I just checked your account and it looks like you’re still on the legacy connection. I would try switching to the next gen connection as there are significant improvements in performance.

If devices are running on custom Groovy DTHs and switch to built-in Edge drivers, the devices may lose some functionality. In that case, you would likely need to switch to a community developed driver to restore that custom functionality… but as long as the functionality remains in the device after Groovy is shutoff, then it will still be accessible.

ha, thanks man. just getting back into this so i’m a bit behind. i’ll try to do more reading before peppering you with more questions!

I sent you a PM with access to the beta as well. :slight_smile: