Webcore Global Variable Expression


#1

I needed to create a global variable and use an expression to set its value. However, when I choose expression and enter an expression the global variable returns (not set).


#2

Can you give us a screen shot of your code?


#3

You can use the evaluation console to calculate the result of an expression, then store that value as a global variable. If you need it to update, use a timer in a piston to update the global variable value as needed. Otherwise, global variables do not support being defined as expressions, just static values.

Is this a cross-post from the Hubitat community?


#4

I think so…


#5

When you say you enter the expression, are you setting the variable within your piston or at the start of the execution? it would help if you posted a green screenshot of your whole piston to see what you might be doing wrong.

Also, your global variable will most likely not be an expression but a value. Then you would use an expression to set that variable to a particular value when you want to update it. Setting a global variable to an expression does not mean that it will update every time the component of the expression is updated.