Do you guys use virtual switches for groups of lights?

Hello ST braintrust!

Do you guys tend to use virtual switches for your smart lights? I have a couple of scenarios where I feel like the virual switch breaks down.

Scenario: I have a virtual switch controlling my two smart bulbs.

Now that I have the bulbs integrated with Amazon Echo, Harmony, etc. I find that sometimes I control the bulbs directly which leaves the switch state incorrect. This stinks because my Goodnight routine turns off my Living Room switch. Well, if Alexa had turned on the lights as a group (not via the switch), the switch state is left in off state and my lights stay on.

  • Is there a smartapp to maintain proper switch state (if Bulb A OR Bulb B on, switch = on, else off)? This would be trivial for me to write, but I just want to check first
  • Do you guys recommend doing away with the virtual switch completely?

Thanks all!

Are you familiar with Rule Machine written by Bruce (bravenel)? It’s the bees knees and sounds like what you are looking for.

Rick

1 Like

I hadn’t tried it yet, however it looks like a lot of code for simple control of lights. I am trying to find out best practices for light control :slight_smile:

I just thought of something…if I turn one light one and use rule machine to control my switch, it’s going to automatically turn on the second light.

Anyone else have a suggestion of best practices for lights?

Hey Adam,

There is basically no coding when you use rule machine. The code written by Bruce integrates into the ST app on your phone where you write “Rules” to control “Things” that fit your needs

Don’t be afraid to give it a go
Rick

Hey Rick, I am a software dev, so it’s not the coding aspect of it that worries me. I feel like I have a simple situation that I am overcomplicating, and again, just trying to find out what most folks are doing. Thanks for the Rules Machine suggestion. I will certainly use that if something simpler doesn’t surface.

I am a developer also but if Smart Things came with Rule Machine out of the box I probably never would have started any ST development (well I would still have to write/re-write ALL of my devices code) but you know what I am trying to say :slight_smile:

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

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.

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.

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.

@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.

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

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

Lol ya I know. I thought you were him!

Just add the virtual switch to the Alexa group.

@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.

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

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?