Assign matching devices to GLOBAL variable


#1

1) Give a description of the problem
I cannot assign matching devices to a GLOBAL variable. I have to assign the contents of the LOCAL variable to the GLOBAL variable later.

2) What is the expected behavior?
The GLOBAL variable is not listed in the drop down.

**4) Post a Green Snapshot of the piston![image|45x37]



Screenshot_2019-04-26%20webCoRE%20Dashboard(7)


#2

Did you ever resolve this? I am trying to do the same thing. It would be more “elegant” then my previous solution.


#3

If the same piston plans to do anything with that new data, then using a global is not recommended.
(Stick to locals)

The logic being, globals are not actually written until the very last line of code has processed. So if you need to be able to do something with that variable right now, then locals are the way to go.


#4

In some cases, I use it as the “last” thing I do so the list of matching (or not) devices is available to other pistons. E.G I manage my Sonos via multiple Virtual Switches (1 per Station) connected via IFTTT and wrote a piston to turn the other Stations/Virtual Switches OFF every time a new one is turned on. At the end I do a Matching to write to a NowPlaying variable that I want to be available in other pistons.

Same with Presence. I have a global variable for each of the list of who is home and who is not so it is accessible in other places. Not being able to use a global variable just seems to add extra overhead and extra steps.

Thanks.


#5

It really only adds a second step:

Save Devices to variable Sonos
Set variable @Sonos = Sonos