Using global variables in a trigger

So I am trying set up some global variables. Basically I am setting a global variable the holds the lights in in the bedroom.

If I put in a if statement that says if @bedroomLights do whatever, then the piston will never fire. Yet if I make a loval variable and use that instead of the global then the piston will fire.

The global variable will work farther down in the piston just not for the trigger. Am I missing something?


Do you have a sample?

Sorry about that. This is one for my garage door that has the same issue. The code is using the global variable for the if trigger. You will notice I have also set a local variable. If I switch to that the code runs fine.

The global and local are set to the same thing.

For now I will just use the local variable so it works and keep trying to figure out why the global isnt working.

But thanks for the warning statement. That will really help.

Global device variables do not subscribe to events by design - this is because a later update of said global variable would NOT cause all pistons to resubscribe to the newly contained devices, whereas a local variable would require the user to save the piston, hence resubscribing.

1 Like

Got ya! So use the local variable for a trigger.