Virtual switch/routines questions

I have about 10 zwave light switches in my basement. I have created a virtual switch called Basement Lights.
I have created 2 routines for this switch to trigger
bsment lights on - which is set to turn all 10 lights “ON” when virtual switch Basement Lights is turned on
bsment lights off - which is set to turn all 10 lights “OFF” when virtual switch Basement Lights is turned off
This works fine as long a smartthings (or alexa) control everything. However…
If any of the basement lights has been turned on manually at the physical switch, while the Basement Lights switch was off (which happens all the time) then if you go to the virtual switch Basement Lights in smartthings and hit “off” or if you tell alexa to turn the basement lights off, nothing happens to any light that was turned on manually. Seems to be because the virtual switch is already in the “off” postion, that neither smartthings nor alexa will actually send the off command to the switch that it already thinks is off. The only work around to this is to say (or do in smartthings) Basement lights on, wait for them all to come on and then say basement lights off and then they all go off. I realize that is a workable work around and I realize that my desire to turn all the basement lights off from upstairs before I go to bed rather the walking down there to see what has been left on is lazy (but isn’t that part of the point of home automation). But I am wondering if there is a better way to do this so that I don’t have to trigger the virtual switch Basement Lights “on” first, thus turning all the lights on, in order to be able to them turn them off with the Basement Lights off command.

Have I missed something, or is this just the way it is when trying to use a virtual switch to control devices that can also be controlled physically outside of ST?

Sounds like a perfect use for the stock SmartApp “Smart Lighting”. This will make it far less complicated than you have it now, and will do as you explained perfectly.


As suggested by @merrick777 , if you use the official smart lighting feature instead of routines, the problem may just go away. But it depends on the exact details.

You can leave your existing routines in place and just try setting up a smartlighting automation and see if it works. You only need one because with smartlighting you can set it up so the switches “follow” the virtual switch, turning on when it turns on and turning off when it turns off. :sunglasses:

There’s a how to article in the community – created wiki on how to group lights which explains this set up and has Screenshots:

And, yes, we all agree that there should be an easier official way to group lights together. Until there is, there are multiple other ways to do it, it’s just they each have slightly different results as you have found.

If you have Alexa (which seems to be true), you can put them all in whatever groups you wish. So if you have ten lights in the basement and you create a ‘basement’ group in Alexa and you say “Alexa, turn off the basement”, it will send an ‘off’ command to everything in the basement. The devices that are already off will stay off, and the ones that are on will turn off.

Far better than the scenario with the virtual switch.

1 Like

I originally had this set up in the smart lighting app, which is where I ususally do this kind of thing because it has a lot more variables than the routines. I had the same problem, a light turned on manually could not be turned off is the virtual switch was already off. I switched to using ST routines because I thought maybe the native application would send the off signal even if the switch was off. But, they both performed exactly the same in this scenerio.

That is a good suggestion. I forget that Alexa now has some enhanced, native automation functions, since it did not when I stared all this and I tend to use ST for all this. But, I will try the group option. Sounds like that would work, and I really am more concerned about controlling it via Alexa than the ST app. But, I likely will keep my virtual switches just as an override if I need to go around Alexa or I’m in a room with does not have a dot.