RM Compare/Interact with Triggered Device in Action

I have the following rule trigger event setup in Rules 5.1.

Select Trigger Events

Garage Door Sensor, Front Door Sensor any contact *changed*

What I would like to do is in the action determine what device event fired, in this example Garage or Front Door sensor. Is it possible to compare the event device to a string or another device? Example of the IF expression:

IF (%device% === "Garage Door Sensor") THEN
  Then run only when the event fired for the garage door sensor.
END-IF

I'd just setup two rules.

1 Like

I'd question why you want to go this route, but, it's your hub...so I'll just offer the answer. Add a local variable to your rule. Have the first action be to set the local variable to '%device%' and use that in the if condition.

Showing that when test-1 was opened, the rule trigger, but the if condition evaluated to false. When test-0 was opened, the condition was met.

2 Likes

Thank you! That works based on the example you provided. Yes, this example doesn't seem relevant or useful, but yet again it was just an example and not suppose to be practical. I have a much larger problem that I'm trying to solve. As a programmer I tend to lean towards encapsulation, I rather not have 5 - 10 rules that do almost the same thing, instead of one rule that handles all the redundant code and allows for scaling out the logic. Much easier for me to maintain. :slight_smile:

After thinking about this, it would be useful to load the device that triggered the event as an object that you could interact with at the Action level. So instead of selecting a Device from the drop down, you can use the current event device, which I believe that's how Webcore implemented it in their application.

1 Like

This is possible if you want to command the device.

Yes, I would want to command the device that triggered the event in the action. Do you have an example, or documentation that explains how to configure that? Much appreciated.

1 Like

It's in Custom Action. It allows you to select the Last Event Device, and then give it any command it supports.

Thank you so much! That's what I was looking for... :slight_smile:

1 Like

Is it possible to use the Last Event Device for a Custom Attribute comparison? I don't see that option there.

No, just for Custom Action.

Would be great if a variable could be created that was Last Event Device related so it could remember something about the last device causing the trigger for an app. Is that possible?
Can a variable name include another variable name such as "Level-Last Event Device"?

The point being to use the last event related variable when that last device triggers another event but to use it only for that device not some other last device which would have it's own relative variable.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.