SmartThings Community

Do you guys use virtual switches for groups of lights?


Try using a smart app called Trend Setter. It worked good for me when I used it.


(Adam) #9

fair enough but consider this race condition

My switch controls lights A and B

I have rule machine set to turn on my switch IF A OR B == ON

If I tell alexa however to turn on light A, rule machine will turn on the switch. But this will then turn on Light B as well.

See my problem? What am I missing here? I am doing something fundamentally wrong!



Your race condition is caused by being able to control them both individually and as a group, As such, you should anticipate that the group state can become out of sync due to individual control. One possible solution is to force a sync when you want to control the group, by simply toggling to the opposite state first. e.g. when you want to turn the group off, you first turn the virtual switch on, then turn it off.

EDIT: I haven’t yet used one myself, but “Simulated Button” might be what you’re looking for. Apparently it’s like a switch, but performs its actions without regard to state.


(Jason "The Enabler" as deemed so by @Smart) #11

This is how I control my 5 kitchen bulbs via ST and Alexa.

In the ST environment, I have a virtual switch called kitchen lights. Using rule machine the VS controls all five kitchen bulbs. This is here strictly due to the GE link bulb firmware where the lights will only set to 25% when turned on. This switch turns on all of the bulbs at once to 100%.

In the Alexa environment, I can say turn on kitchen lights and Alexa turns on the VS, which turns on the five bulbs. Alexa can also control each bulb individually.


(John) #12

What bulbs/switches are they? Also, what exactly is your end goal? In the OP, you said you wanted a “IF light A OR light B is on, turn on the switch”

Rule machine will do this. However you’re now saying that won’t work because you want to control the bulbs individually as well? What is the exact setup, in regards to bulb type, switch type. I’m also assuming these are two different lamps/fixtures/ceiling lights and not one fixture with multiple bulbs…right?

Once we have some more info on the actual use of the lights, we can better help you find a solution.


(Adam) #13

@LedGecko I had thought about something similar to your suggesetion, however I was going to use two momentary button tiles where one button was on, and one button was off. In this instance, state would be ignored.

@Jnick, I have two Lightify bulbs, each in separate lamps. I currently have them tied to a single virtual switch. It works fine if I ONLY use the switch. However, if I start turning bulbs on and off individually, or even as a group with Alexa, the switch state can get out of sync.

A current issue with this setup looks something like this. My daughter comes through and tells Alexa to “Turn on the living room lights”. This uses the alexa group for those bulbs, however the virtual switch is not invoked (it still says off).

Then, later that night on my way to bed, I initiate my “Bed time routine” which checks and says “OK, living room switch is off, I don’t need to turn off the lights”. The issue here is that all my routines are tied to control the switch, but not the bulbs themselves.


(Bruno) #14

@adawalli that photo looks real familiar? Are you this is me?


(Adam) #15

It’s a photo from one of the greatest internet phenomenons of all time, the zombie kid that loves Turtles


(Bruno) #16

Lol ya I know. I thought you were him!


(Jason "The Enabler" as deemed so by @Smart) #17

Just add the virtual switch to the Alexa group.


(Adam) #18

@bamarayne, As mentioned above, that works fine until you turn on one both of the lights with alexa (but not via the virtual switch). Now the virtual switch is out of sync.


(Adam) #19

I basically have achieved the behavior I want, but it feels super hacky.

I have two momentary buttons. One for the on state of my lights and one for off state. No state needs to be maintained. I basically wish I could have a tri-switch. After hitting ON, it would go back to neutral. After hitting OFF it would go back to neutral.

1 Like

(Jason "The Enabler" as deemed so by @Smart) #20

For some reason I think you’re over thinking this.

What exactly are you using the virtual switch for?
Are your smart bulbs connected to the ST hub?



I don’t know for sure if this will help but Alexa Helper can create stateless virtual switches.


(John) #22

So you have a few options:

  1. Use Alexa Helper as stated above, more specifically, the ‘Alexa Switch’ as your virtual switch. It is stateless and therefore it will always send whatever command you ask it to. If the command is “OFF” but the switch is already off, it sends it anyway.

  2. Stop fragmenting your deployment. Either stick to using virtual switches for control or stick to using bulbs. By you trying to mix in both, you’re creating this sync issue. Within Alexa, you can tie the VS to the “Living Room Lights” group instead of the bulbs. Then Alexa and Routines are using the switch. In this case, everything is in Sync and will cause you less headaches.

  3. Get rid of the Virtual Switch and just define the bulbs for your routines as you are doing with the Alexa app.


(Jason "The Enabler" as deemed so by @Smart) #23

@adawalli I have to agree with @Jnick, especially point 3.

Reading through this again I think I understand what you’re doing.

This is what I recommend…

1- delete the virtual switch.
2- in the Alexa app create a group, name it kitchen lights. Put both of your lights in this group and click save.
3- in the ST app, in your bedtime routine add both lights to the turn off section.

Now, Alexa can control the bulbs individually and as a group. You just say, Alexa, turn on kitchen lights. Everything in that group will turn on.
Your bedtime routine will now turn off both kitchen lights.


(Adam) #24

The stateless alexa switch is EXACTLY what I was looking for. Thank you all!

1 Like

(Jason "The Enabler" as deemed so by @Smart) #25

Will you explain why you need a virtual switch for third? I’m just trying to figure out why you are adding the extra steps.


(Adam) #26

I wanted the virtual switch because I have a button on my harmony remote that would turn on both lights at once. Originally, this virtual switch was also used for my night time routine. I have mostly moved the virtual switch out of the mix as you folks suggested, but the alexa switch does do what I had originally wanted.

1 Like

(Jason "The Enabler" as deemed so by @Smart) #27

Ahhhhh got it. Thanks! I appreciate the clarification.