Can the new 5.1 Rule Machine template actions for the same trigger when have multiple of the same device?

For example, if I have multiple identical dimmer switches, can I have a single rule do the same action to the respective dimmer switch that triggered a doubletap event? Or do I still need multiple rules, one for each switch? Thx

This feature has existed for a few years, so it's been a while since you would have needed to do that. What you're looking for is "Run Custom Action" using the "Last event device" option, available in both RM (since some 4.x update) and Button Controller. Choose this action, choose some "exemplar" device (won't be used; just something with similar capabilities, say any switch), and choose the command. When the rule is triggered, this action will run the specified command on the trigger event device.

3 Likes

Got that to work. Thx! Now I need to figure out how to remember the dim level so that when again doing a single tap, I can return to the previous dim level before the doubletap. And hopefully to do so per triggered device.

I did not understand your comment about choosing some "exemplar" device as I don't seem to get that choice beyond selecting switches for the trigger events, though maybe you meant it shows me one of the trigger switches in the rule.

Uploading a snapshot of my rule in case I did something other than what you suggested. Thx again!

My bad, I mis-remembered the exact information it asks you for in this case -- which is just the capability, and then it seems to figure out the rest based on your trigger devices (presumably because it knows it has to be one of them). Looks like you got it figured out!

I'm not sure exactly what you're thinking for how this would be set up, but in general, you'd have two options for this:

  • the "capture" and "restore" rule actions will capture all relevant states for the light (color/CT, level, switch state) with a "capture" and restore them on a "restore" -- but note that this includes all states, not just level, if that is what you're after (and really it only includes all states if the device is on; otherwise, it just captures that it's off)
  • create a local or hub variable, save the value there, and use that variable later when setting the level -- similar to the above, just doing so yourself and allowing maybe finer control over what you capture when

Either would need some way to know when you want to capture/save the state -- and restore, but it sounds like the button "pushed" event would be what you want for this.

Would, could, this switch state or local variable be Last Event Device specific?

Hmm...I'm not sure "Last Event Device" is an option when setting a variable to a device value. (I'm also not sure how you'd keep track with multiple devices and multiple possible saved stats without separate rules, thinking about this more...)

Can a variable name include another variable name as part of the name?

I don't think so.

I've updated a few posts that have a somewhat similar need and may post this problem directly. Thx again for your help Bert!