Are ‘But Only If’ conditions considered in the order presented in the GUI? I.e., if the first in the GUI list is false, does the rule immediately stop? Or all evaluated, and if any are false, then the rule stops?
If the order does matter, then is there a way to reorder directly in the GUI?
Hey,
Greg is correct.
The trigger “When” is an OR condition. Everything listed will start the rule.
The “But only if” is an AND condition. Everything listed must be fullfiled, so the order doesn’t matter.
@ubeaut and @dirkdirk have the answer to your specific question. But I wanted to add that if you need something more complex, you’ll need to implement that as code in a Script Condition where you can make the conditions OR instead of AND or make the condition as complex as you need to.
I realize I could stuff everything into the script condition. But I’m still interested in knowing how the conditions behave as it will simplify the script. Yes, I could check the time and the state of a switch in the script, but it’s easy to set that up in the GUI, then run my script if they pass as the final condition. And since the script can do anything, it is important to know if it will always be executed or only if prior conditions are satisfied. In this particular case I have some logging that I only want when the prior conditions are satisfied. But I could have other actions in the condition script.
From my observations so far:
the conditions are executed in order
if any are false, the remaining conditions are not tested
there is no way in the GUI to reorder - you must delete conditions and re-add to get the order you want
These are only from observation, not from code review.
If you switch over to the code tab you will see the yaml definition of the rule. The conditions are presented in the GUI editor in the order they are listed in the yaml. All you need to do is a quick cut and paste to reorder the conditions if that matters to you.