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 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.
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.
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.
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.
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.