Dynamic script to get Device Names into a variable for batteries attribute


#1

1) Give a description of the problem
(PUT YOUR INFO HERE)
Need to create global variable of all devices with battery attribute
2) What is the expected behaviour?
(PUT YOUR INFO HERE)
When running a battery check the script will go through the array and check battery levels
3) What is happening/not happening?
(PUT YOUR INFO HERE)
Cannot create variable to pick up devices
4) Post a Green Snapshot of the pistonimage
(UPLOAD YOUR IMAGE HERE)
Have not created it yet, but it will work when I can create a variable to list device names with a battery attribute.
5) Attach logs after turning logging level to Full
(PASTE YOUR LOGS HERE THEN HIGHLIGHT ALL OF THE LOGS AND CLICK ON THE </> ICON TO FORMAT THEM CORRECTLY)

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


#2

I seem to recall that Globals can’t be dynamic lists (someone correct me if I’m wrong). However, you could still save the aggregate data as a list (@Global = device1,batterylvl1,device2,batterylvl2), and then find a way to parse out the data (Shift left, shift right, etc.)

Or you could have two Globals:

Global A = device1, device2, etc
Global B = bttrylvl1, bttrylvl2, etc

Is there a reason why this data has to be in a global?