Rule in the Rule

I would like to run a rule. In a rule. For example. I have several rules the rules I would like to run with my button controls. Press button 1 and the rule " run for the hill" is execut
OR if I build a rule that says
"IF .... run this rule ELSE............ run this rule .."

Hope you understand what I mean.

Thanks in advance if I can get a simple example.

You can run the actions of one rule from another rule. Under the "Set Private Boolean, Run/Cancel/Pause Rules" category, you'll find the "Run Rule Actions" action, which will do this. (Note that rules do not need triggers; they won't get run in that case unless you invoke them from another rule, but that's fine because it's exactly what you'd be doing here, so I'm mentioning this because that may be a useful thing to know.)

I'm assuming this is what you're looking for, if not, feel free to ask again!


Mmm I think I understand.
But a little more code then.
If this happens turn this Variable to ......
In the rule IF Variable is ....
I have to test that.

But easier would be If ...... run rule "run for the hill"
Then I do not need to modify my rules. :slight_smile:

Can you outline exactly what you want to do? whats the exmaple. maybe we can help you net it out.

Let's see if I can explain.
I want to start a rule from a rule. For example
IF condition happen run Rule1
IF condition happen run Rule 2
IF condition happen run Rule 3
I have several good rules that I want to reuse.
For example, in a button controller. Button one run rule 1
(This question is not just about button controls, but it is probably the easiest to identify the problem.)
I don't want to write a rule that does the same thing several times but different conditions. One rule only

It may be possible to solve with global variable but how do I do?

If global variable is = 1
run "rule 1"
else if global variable = 2
run "rule 2"

Grateful for answers

Not sure I understand the reasoning behind this, but as @bertabcd1234 explained, your action of the “master rule” I guess we’ll call it, would run the actions of your other rules. Those other rules could do the same too if you like.

You could also trigger virtual switches to run the other rules, but that’s not necessary.

1 Like

Easy to do with some conditionals (ifthen/elseif statements). So just build an ifthen statement, and use elseif for your other options, and in each section of your conditional statement run your chosen "subroutine" rule as explained above. No need for global variables unless you explicitly need to pass some parameter/data from the main routine/rule down into the subroutines/rules &/or back again.

you can set multiple triggers on any of those rules. so that if ANY of the triggers happen the rule happens. wouldn't it it be easier to setup your already good rules with additional triggers then modify if needed?

1 Like

Sound good, i try that.