Use device state variable in rules?

I submitted the request below to Hubitat support and was told that it'd require feature development...so I'm wondering if anyone on the community has tried to do the same thing and has a workaround? Thanks in advance!

Is it possible to use a device attribute / state variable (not sure I'm using the right name) in a rule?

For example, if I wanted to make a rule to synchronize thermostat set points, would it be possible to have a rule action that would set a given thermostat's set point to the set point on another? Using pseudo code, I'd want to have a rule action that would set a thermostat's set point but instead of setting it to a number value like '74', set it to something like 'OtherThermostat:CoolSetPoint'. Is something like that possible?

Possibly. I believe you could capture the other thermostat's set point into a variable and then set the triggered thermostat to the variable.

1 Like

Yes, it is. First you need to capture the device attribute you want into a variable. Suppose it's a decimal variable that you might use for temperature. You set a variable like this:

Then you would use that variable to set the other thermostat. You include the variable for the set thermostat action with %Alpha% (or whatever variable name you have inside %)

1 Like

Attribute, yes...that is easy to do. State variable, no, you cannot do that with rule machine. The only thing you would have to do is use the Set Variable command.

image

Got it...I created a Global Variable for the cooling setpoint, and created a rule that triggers when the first thermostat's cooling setpoint changes. The rule updates the variable with the first thermostat's cooling setpoint, waits 5 seconds, and then sets the second thermostat's cooling setpoint to the variable value. Seems to work...thanks all!

1 Like