Put Device Name that triggered a rule into a variable

Hello!

I'm trying to figure out how to put the device name that triggered a rule into a variable. I have a rule I've set up, that there are several different devices that could trigger it. What I'd like to do is store the most recent device that triggered that rule into a hub variable.

Just can't quite figure out how to do that.

Thanks for any advise!

  1. Setup your variable. A hub variable would probably be best so that you could reference it in other rules. The variable needs to be a 'string' type.
  2. In your "device trigger" rule, set the first action to set the variable from step 1 to %device%.
    image

What is the rule doing out of curiosity? What are you triggering on? What's your intent with the device?

1 Like

That is pretty much already in a local variable "%device%" You should see that at the bottom of your rule after it has been triggered once

image
If you need to store it in a variable, just used the action set string, and set it to %device%

Or, just use it as %device% as needed

1 Like

Coming back to my issue! I have two short-term rental properties, that I've created a pseudo-presence monitor that looks at activity on various devices, and then sets a timer for moving things from present to away and back again.

I have a management company managing the properties, so I don't have direct access (programatically) to the calendar. So I use this so that when guests leave, it will automatically turn down thermostats (or up in the summer) to save energy.

My question was there so that I can figure out when the rule is triggered, what device was triggering the move from Away->Present

1 Like

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