How to use variable in Luup action

In a Reactor sensor, I have defined a variable, “Heat_Day_Sun”, and it is showing the correct value in the status tab.

How can I use this variable in a luup statement in the Actions tab? I currently have this statement:


The logic summary says “ERROR: Using uninitialized global variable Heat_Day_Sun”.

I read that variable defined in the Expressions tab could be used in Lua code, but I cannot figure out how to do it.

Your variable should be available to your Run Lua action code as Reactor.variables.Heat_Day_Sun.

Your action would need to look like this (note correction to your parameter table): luup.variable_set(“urn:upnp-org:serviceId:TemperatureSetpoint1_Heat”,“SetCurrentSetpoint”,{NewCurrentSetpoint=Reactor.variables.Heat_Day_Sun},14)

But you do not need to do this in a Run Lua action. You can also set the setpoint to an expression/variable value directly in a Device Action by choosing the device, Set Heating Setpoint action, and then typing {Heat_Day_Sun} as the value.

Thanks for the quick reply!

I have tried that, and have not been able to get it to work with my Honeywell TH8320ZW1000 thermostat (installed as a generic Z-wave device because Vera does not have a configuration for this thermostat). The list of device actions given in the Actions tab has 2 identical choices “SetCurrentSetpoint”. I have read elsewhere on this forum that one is for heat and one for cool, but I can’t get them to work. Sometimes if I manually trip the sensor twice, the setpoint will get set, but it is not reliable. So now I am trying to use luup to set the variable using the name from the list of variables in the “Advanced” section of the thermostat device.

I’ll let you know if it works.

You can’t just set the variable on most devices, you have to use the action call, which itself sets the variable as part of its work.