Testing on Specific Trigger

When a Rule has several Triggers, is there a way within the Actions to test which Trigger was triggered?

Something like:
ACTION:
If Trigger1 then action
If Trigger2 then action
etc.

And if so, would a trigger for a specific device, and that same device with a "sticky" be the same?

I seem to recall that you can log something like %device%, %state% and get that information.

EDIT: maybe %device%, %value% or even just %device%

1 Like

Sort of: the possibility mentioned above, the built-in %device% variable, would be the key. But it's just a string variable representing the display name of the last triggering device. Any conditional you make using that will thus be a bit "fragile" (what if you change the device name?). IMHO, it's better suited for just using as part of a string, often for speech or notification purposes. That being said, it's there.

But...this seems like poor rule design. If you want to perform different actions based on different triggers, then different rules are probably the way to go. Of course, this is all generalization, and it's hard to say more without knowing what your actual goal is.

1 Like

Yes that will work. I have a number of rules with multiple triggers that use If Then statements according to the specific trigger. I do that to avoid using separate rules, though I try not to make the rules too complicated.

Not sure what your trying to do but if you mean have two similar triggers, one without and one with the ‘stays that way’ checked, the ‘stays that way’ one would just be an additional trigger and I’m not sure (but haven’t checked) whether you can go on to specify the ‘stays that way’ attribute specifically within an actions If/Then statement.

It’s probably best to outline what you’re trying to do so that someone can advise whether one or multiple rules is the way to go.

1 Like

This is a rough example of one giving me different actions based on the triggers.
Trigger: Outside_Motion_Sensor is changed

If (Outside_Motion_Sensor is active and Time is between Sunset and Sunrise) Then
Run Rule : Flash_Outdoor_Lights_Start [<- Seperate Rule defining what this does]
End-If
If (Outside_Motion_Sensor is inactive and Time is between Sunset and Sunrise) Then
Run Rule : Flash_Outdoor_Lights_Stop -> Delay 5 Seconds [<- Seperate Rule defining what this does]
End-If

I have played with the Rule Machine 5.1 a lot; had to recreate rules many different times to learn it. Between the If-Statements, the Wait for..., and the Repeats one can create some complicated rules. I have decided I would go with many smaller rules than larger complicated ones. However, I do have some complicated rules.

I don't see different triggers in that rule, just one. Yo can create rules with only actions (no triggers), then "call"/trigger those rules from another rule, which is all I see above. That will work without the need to test for anything. But perhaps there is more than you showed?

The triggers are defined in the rule:

  1. Outside_Motion_Sensor is active
  2. Outside_Motion_Sensor is inactive

However, I admit I am just taking a wild guess as to the idea of what the OP is looking for.

As written, those are not triggers, just conditions used as part of an expression with an IF THEN (conditional action). They will not cause this rule's actions to run per se; only actual triggers--of which you do have one--will (or running the rule actions from another rule or the Rule Machine API).

Thank you for the lesson. :smile: I am still learning each day with this. :grin: