Rule Machine device name as a variable help please

Is it possible to set a device name to a hub variable and then use that hub variable to perform an action on that device?

Example:
Hub Variable: foo
Switch Name: bar
foo = bar

In the rule I want to use foo to to turn on the switch ( in this case bar ).

Hopefully this makes sense.

Others may be able to, but unfortunately, I am not able to properly understand your ask.

Could you provide a real-life example or requirement describing what you are trying to do, and in which situations you want it to happen?

Users of a the logic engine WebCore will read your question as: "Do hub variables come in a 'device' flavor?" The short answer is "No."

For Rule Machine to target different devices based on the contents of a Hub Variable (be it of type String, Number, Boolean, whatever...), you are essentially constrained to using a series of IF-THEN statements in your rule.

IF (this makes sense) == TRUE
  THEN hope it works with conditionals
  ELSE show us a screenshot of your rule
END-IF :-)
1 Like

Ha! I feel like youā€™re following me on here. You answered a Webcore question I had in another post.

Youā€™re either going to get tired of me or weā€™re about to become best friends. LOL

Thanks for the reply. I assumed that you couldnā€™t do it, but there are so many things about Hubitat I am learning every day that I donā€™t want to assume. :slight_smile:

Actually really enjoying your questions, though I'm much more of an RM user than WC. But what I appreciate most are slightly off-label uses of logic engines; the more obfuscated the better IMHO.

Would enjoy seeing your evolving rule regardless, in case there are any pointers worth sharing.

1 Like

One potential consolation I can offer here, if your hub var were instead of type Number, and your target devices were all registered with Maker API for this purpose, you could theoretically do the following (calling them by device ID rather than Name):

Hub Variable ā–ŗ devNum = 51
Maker App ā–ŗ include device #51
Rule Machine ā–ŗ Send GET request:
http://hub.ip/apps/api/36/devices/%devNum%/[Command]/[Secondary value]?access_token=edec259a

Is this solution elegant? No. Would it work? Yep! But only with similar devices who share a common target capability; for example, where [Command] is setTemperature and [Secondary value] is a ##.

Maker API and, more generally speaking, endpoints may enable you to do this kind of end run, but my example kind of pushes the boundaries a bit. I'm merely illustrating how flexible this platform is for those who believe "Where there's a will, there's a way."

1 Like

Three more things, since IMO they so closely align with "doing different stuff in RM based on which device triggered the rule"...

EVENT VARIABLES (a Special Feature of RM's Local Variables section)


Especially useful for sending custom Notifications.

LAST EVENT DEVICE (a special Trigger Event Condition exposed within Run Custom Action)

CONDITIONAL TRIGGERS (determines whether a Trigger actually executes the rule)


NOTE: Requires at least one Condition to be defined in rule before Conditional Trigger becomes available.