Can RM store matching devices from a trigger into a variable?

Anyone know if storing matching devices (into a variable) from a trigger is possible in Rule Machine? See my example screenshots on how it's done in webCoRE.

From what I can seem to find it isn't doable in RM. Just curious in case I ever want to do this sort of thing in RM.

Not exactly: RM doesn't support arrays/lists/collections as variable types, and there's no built-in "matching devices" filter. However, there is a string variable %device% that contains the display name of device that triggered the rule. Even in your webCoRE piston, it looks like it will only respond to one person at a time (the one that "change[d] to present"), so if that's the case, you could do something like this in RM, too:

Trigger: Presence 1 arrives OR Presence 2 arrives


Send notification: "%device% arrived!"
Set Thermostat A/C Cooling to 77

Note that I would write the triggers in the way I did, with two separate triggers (RM puts OR there for you automatically to hint that any event matching any trigger will run the actions), not one single trigger like "Presence 1, Presence 2 any arrives." It's not clear to me whether they consider this a bug or not, but that trigger will still match if one sensor goes away while the other is still present (i.e., if any of the devices match the state, not necessarily the one that generated the event). The way above avoids this.

There may be complexities to your piston that I'm not seeing, but otherwise it looks like this would work for you. (If you do need multiple device names, I've done something like that by building a string variable, but that gets unwieldy quickly, and I eventually just wrote an app to do it instead.) Hope it helps!


Thanks. Good to know about the %device% global variable. That will work for this rule. For others where I need multiple devices supported, I can just continue to use webCoRE.

1 Like

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