A Quick Question on "Run Actions" within Rule Machine

Hi all, I have a quick question about calling an App from within another App in RM5...

When I use "Run Actions: Test App" from with an RM5 app, does the Test App

  1. Get called from the beginning, evaluating any Required Expression and Trigger Events, and only executing the Actions if the conditions are met?

or

  1. Get called from the Actions, as if I were clicking the Run Actions button within Test App, so that the Actions execute regardless of the Required Expression and Trigger Events being met?

I suspect the latter, but I just wanted to clarify

If so, if there any way to call another App via method 1 above?

You suspect correctly.

2 Likes

Technically, it is always being “called” via method 1, so triggering this from an app would not do anything.

1 Like

OK, I'm a bit confused now with your answer and @aaiyar answer, which seem to be conflicting.

Is there a way to invoke an App from within another App, and have the second App only execute the Actions if all the Required Expression(s) and Trigger Event(s) have been evaluated and proven true?

Using Run Actions seems to execute the actions regardless of the pre-conditions of the second App

I'm not sure there's any discrepancy.

In any event, when you run a Rule from another Rule, the only choice you have is to Run Rule Actions. Required Expression and Triggered Events are not evaluated, unless you also evaluate them as an action.

2 Likes

When you say "app," do you mean "rule" specifically? Asking because there is also a Rule Machine API that non-Rule apps can use. It sounds like you're just doing rule-to-rule via "Run Rule Actions," and I don't really think there's a difference either way, but it might be worth noting.

In any case, the explanation from @aaiyar is correct--"Run Rule Actions" does just that, runs the actions of the specified rule. The required expression is not evaluated. Trigger events are also ignored. They can't be evaluated because they are just events; I'd think of "Run Rule Actions" as almost just another possible trigger for the rule (aside from the exception that, unlike with real triggers, the required expression does not matter).

All of which is also the same as if you just hit "Run Actions" inside the rule itself.

If you want something different, you can probably use conditional actions in your actions rather than, say, a required expression. If you need more help with that, then providing a real-world example of what you want to do would probably get you the best help. Good luck!

2 Likes

Well, you said that my method 2 was correct, whereas @Sebastien said it was always invoked via method 1

Maybe it makes more sense if I explain what I'm trying to do?

I have a light in the Hallway which changes colour depending on the status of HSM. This light is triggered by a motion sensor in the Hallway and shows whoever is in the Hallway what the status of HSM is at that time.

I'm now writing another rule (a different way to set HSM status) and I want to "re-use" the Hallway light to indicate what's happening, but only if someone is in the Hallway to see it

My intention was to invoke the Hallway Light App from within my HSM Setting App but it seems the light is coming on and changing colour whether there is someone in the Hallway or not, because the Trigger Event is not being evaluated in that App, only the Actions are being run

So it seems like what I want to do is not possible

I think it is possible. Just use a condition of motion being active within the actions section of the rule.

3 Likes

OK, so I would have "Hallway Motion Active" as a Trigger in the Hallway Light rule, and also "If Hallway Motion Active..." as a Conditional Action of the Hallway Light rule?

It seems like a duplication, but I guess that would work.

Thanks!

1 Like

The trigger will cause your rule to run with the path in option 1 above, and therefore the condition will always be true when it is what triggered the rule. It could be false when the rule is triggered by another rule by using “Run Actions” (which as @aaiyar indicated, will follow the path in option 2 above - He answered your first question, I answered your second one - hence the discrepancy - I should have been clearer in my answer…). The condition will also be false if you have multiple triggers for your rule.

Feel free to share a screenshot of your rule if you are having issues with it.

2 Likes

I think I've wrapped my head around it now! Thanks all for your help! :+1:

2 Likes

Download the Hubitat app