Loop a list of devices


#1

Hello

Trying to find if it’s possible with webcore to scan a list of device (light or switch), to find witch one is open/on.

Loop those devices and close them all
This piston will be use when I lock my front door lock, I want to close all the open light

please help :slight_smile:
thanks!


#2

This can be done easily - are you wanting your piston to send you a message with the devices that are open? Or merely close/shut off anything that’s on?

Want to make sure I’m following… close open light means turn them off?

What it sounds like you want to do is shut off a bunch of lights when a door closes. That can be done without a loop - you can send the same command to a bunch of devices at once.


#3

Yes, I just want to close a bunch of light, if they are open

If I add a new switch/light device to ST, it could be awesome to not have to update my piston with that new feature, is that possible to scan all switch/light existing device and close them all


#4

That can be done a number of ways. The simplest is to select each item in the Action part of your piston.

The next simplest is to create a Device variable, choose each of the devices you want included in it, and then run your actions against the variable.

Unfortunately that’s not possible. Even with a variable, you’ll need to go in and add items as you grow your automation network.


#5

thanks for the reply

Could you tell me where I can find information about that device variable?

thanks


#6

Check this out as an example. You can see I listed devices in a Device variable at the top, monitor all of them for changes in the top IF statement, and apply actions to the variable in the last IF statement.


#7

Awesome, thanks a lot!


#8

This thread is 2 years old – does anyone know if this has changed at all? i.e., be able to loop through a list of devices that automatically includes new devices as they’re added to the hub?

My motion sensors, in particular, seem prone to falling “offline” occasionally for no apparent reason, but I recently had a switch that went offline “silently” - it wasn’t involved in any automations, and the mechanical aspect still works OK. However since it’s offline I can’t turn the light on/off via the SmartThings app.

This would also be particularly helpful for managing a second home - run a daily “health check” on all the devices. If something is amiss, an alert would let me decide whether I need to reach out to my local emergency contact to stop by and fix the problem.


#9

No. New devices must still be added manually. You can create a piston that checks all devices to tell you which ones are offline.


#10

Thanks. That’s what I’ve done in the past. I like things that automatically protect me from my forgetfulness, though. :wink: