Cannot set Global variable to experssion


#1

1) Give a description of the problem
Trying to set a global boolean that evaluates to an expression [device name: attribute] > value

so e.g [energymeter:power] > 500

2) What is the expected behavior?
the expression is supposed to be saved and evaluated to true or false .

3) What is happening/not happening?
in the expression entry box it evaluates just fine but when i click save on global variable it just shows not set for global variable.

I have checked this with different global variable and trying to set an expression as value - and the expression editor show and evaluates fine but when i save variable is not set. Works fine for local variables in pistons but not global variables.

even generic expressions like 3 > 4 or 200-100 evaluate fine but those expressions are not getting saved. really weir - just started with webcore

4) Post a Green Snapshot of the pistonimage
(UPLOAD YOUR IMAGE HERE)

5) Attach any logs (From ST IDE and by turning logging level to Full)
(PASTE YOUR LOGS HERE BETWEEN THE MARKS THEN HIGHLIGHT ALL OF THE LOGS SND CLICK ON THE </> ICON TO FORMAT THEM)

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

Picture? And you’re setting the global variable like this?


#3

yes going to top right and setting it

not sure if the picture added or not


#4

when i click save this is the screen - it says not set


#5

Its very odd behavior when i go through the same process for a local variable it works fine


#6

Global variables (or local for that matter) won’t be set until the piston is run. The expression box is just a preview so you can foresee what it WOULD be set to.

Are you executing the part of the piston that should set the global variable?


#7

I can understand that - but I would at least expect the expression to be saved.

For local variables expression is saved and I can see that in the IDE but for global variables expression is not being saved. When I click to edit again expression field is empty.

Also the global variable is not being set by the piston. Based on a devices state it shoul set to true or false. I am assuming when engine executes it should be set by related event on that device


#8

Ok, that’s different. If you are executing the part of the Piston that should set the global variable, you should see it stored and you are webcore screen. I was only referring to variables that had been created but no values assigned to them yet.


#9

Any help anybody?


#10

Can you post a screenshot of your piston (green one), the logs from it executing, and then a screen capture of your global variables like you did before?

With that info, any number of people here can and will help… usually quickly.


#11

Okay for now I had to do a workaround. @supply is the global variable. Basically depending on whether my solar panels are producing power i want it to be set to true or false. So the global variable expression i would have liked is @supply = [solar:power] > 10 or something similar. I would have assumed if a global variable is an expression it would be evaluated by the engine independent of a piston (I am realizing i might be wrong - but can someone correct me; also then why allow an expression for a global expression, when will the expression be evaluated outside of a piston? anyway i cannot save an expression to @supply).

Depending on the state of this global variable I then execute my piston to turn things on or off.

attached image of piston.
Image of global variable failure to set expression already posted before.
image of a workaround piston to set value of said global variable



#12

Ah, gotcha. Variables in webCoRE are only designed to hold values as far as I know. So you’d need a piston to set your variable true or false depending on consumption, rather than having the variable hold the condition/expression.


#13

I am guessing that my be the case too - do you know for sure or are you in the same boat as I?
The odd is if that were the case why allow to enter expression value for global variable?


#14

Hey, any better answer here? It makes me think they are not going variables, but rather global values :slight_smile:

I have modes in ST and really want to just have morning, afternoon and evening global variables. Then have isBetween expressions defining each variable. I guess I have to do that last part in a piston?

Fyi, total noob here who doesn’t code.