Grouping conditions into functions

I’m wondering if this is possible or maybe something that can be considered on an update for RM.

I have several scenarios and comparisons which require to jump back and fort between several conditions. Right now, RM is linear in processing the instructions.

Is there a way to build a condition set, under a name that can be called out from the “master” rule?

My rules are extremely complex and long and it’s difficult to follow a chain of conditions when the same thing repeats itself under a different step.

I’m thinking something like this

If a is true
If b is true
If c is true and var is 0
End if

and then somewhere within, one defines said functions

I’m currently McGyver-ing it with another rule per “function” but that adds clutter.

Is there a more elegant way to achieve that?

1 Like

Not that I can think of, but you would not be alone if you just ran one rule's action from another rule.

Alternatively, if you are getting this complex, it's possible you have some coding experience. In that case, keep in mind that you can write custom apps in Groovy for Hubitat (Rule Machine just exists so you don't have to and is quite powerful on its own, though was ultimately written using this same environment). The developer docs, particularly the app primers under "App Structure," would be a good starting point if you aren't sure how: Developer Documentation | Hubitat Documentation. Just another idea -- because there, of course, you can literally use methods (as Groovy calls what some other languages call functions).


I would aver that WebCoRE strikes a very good balance between the elegant modularity of coding (e.g. Groovy) at one extreme and the point-and-click ease and linearity of Rule Machine at the other.

WC's learning curve is modest, reliability and system integration very high, sporting a feature set that's fairly rich for having begun as a community app. That includes powerful conditionals like SWITCH and CASE. It has a wide install base of users.

WC gets my vote for operations of above-average complexity. For everything else, there's still RM.


I mean, "Run Rule Actions" basically is a function call. Create a rule with no triggers, name it something like "[Function] BlahBlah" and call it from other rules.

Alternatively, consider collapsing the other direction -- have your complex set of criteria turn on/off a virtual switch, and have other rules that react to the switch turning on/off.


That’s how I am currently doing it with run rule actions :blush:

If you’d see my Rule Machine, you’d probably understand the clutter pain I have.

It does what i need as is. I was hoping that maybe there is a way of which i’m not aware of, on nesting the trigger-less functions under the main one.

No way of making child rules, no. I think you could install a second Rule Machine instance to hold subordinate rules, though I don't see a way to rename the instances.

I’ll use number sequence in the rule name and group them accordingly.

001 NAME
001 Function1

That should make it easier to follow …

1 Like

Download the Hubitat app