Triggered rule - How to tell which trigger fired

In a triggered rule where there are more than one trigger that can fire a rule, how can I tell from the rule which trigger caused it to fire? I'd like to perform one extra task if the rule was triggered by the motion event compared to being triggered by the switch event.


That is, I'd like it to do:

If (motion event triggered the rule)
Action 1
End If
Action 2

So action 1 would only be performed if triggered by motion but action 2 would be performed for any trigger event.

I could do it by checking the state of of the switch (if it's off, then it must have been the motion event that triggered it), but I'd like to know if I would be able determe which trigger fired the rule some other way.

The way I would do it is though THEN - IF in that true section.
THEN - IF Motion action
(Action) do something.
(Action) do something else.

THEN - IF Light off
(Action) do something.
Is this what you are trying to achieve?

Yep, I can do it that way.

However, what I really want to know is if there is a way to determine from the rule which trigger fired the rule and being able to use that information within the rule for different actions. I've got a rule in mind that potentailly would have 5 different triggers and it would be much easier if I could use some built in way of determining which one triggered the rule rather than rattleling of various IF statments just to determine that in a round-about way

Maybe use global variables.
If trigger A set GV A boolean to true reset to false after 5 seconds.
If trigger B set GV B boolean to true reset to false after 5 seconds.
Then use these variables in your rules.

Yes, but even with this I would have to first determine what triggered the rule. If this information is already available within the rule that would simplify things. I can of course easily do this in separate rules as well, but I'm trying to do this from just one rule.

1 Like

Wait, how do you do this in rule machine? I wasn't aware it had any IF ELSE functionality. That would greatly improve its options.

It was introduced in Rule Machine 3.0 which came with HE 2.0.9. It's great! :slight_smile: