Smart Lighting On/Off when a Portion of Lights are On/Off

I’m using smart lighting with virtual switches to control groups of lights with a single virtual switch. I’m observing a strange behavior and looking for a solution. I have a virtual switch called “Inside Lights” which is paired to all the inside lights in my home. The “Insight Lights” virtual switch is recognized when syncing to my Echo. Here’s the problem: if I have a partial amount of my lights in my home turned on and then say “Alexa, Inside Lights Off”, she doesn’t turn off the portion that are on. If I say “Alexa, Inside Lights On”, they all come on and then, the “Alexa, Inside Lights Off” works fine. I think this happens because the ‘Inside Lights’ virtual switch state isn’t shown as ‘On’ unless I turn them all on via the switch. This is different behavior from the old Dashboard Lights & Switches I used with my original V1. In that situation, the Alexa command would turn all on or off, regardless of the state of those lights contained within the larger group. I could setup a “All Lights Off” routine, and trigger via “Alexa, set All Lights Off”, but that’s lame compared to using voice commands to control virtual switches.

Would love any suggestions you might have to solve this problem. This community has been really helpful and I’m finally digging into writing some device handlers after all this time with SmartThings.

Great idea! Thanks Robin - I’ll try it out tonight.

If you don’t need the virtual switch for anything except Alexa. Could you make a light group in Alexa?

I haven’t really used that much so not sure. May not even work. Just thinking out loud

Good observation. Yeah that will work and I had done that with my V1 hub. It’s just that adding any switches to a group requires work in both Alexa and SmartThings, which I was hoping to avoid. I did get this working using CoRE but it was cumbersome. I feel the simplicity of Alexa to accomplish this should be available within SmartThings more easily. Another reason to do this within SmartThings is to be able to use my Homebridge and trigger via my Apple Watch

Could you use 2 separate virtual switches. One for on one for off. Make them push buttons so every time you tell Alexa or whatever to push that button it will see the pushbutton cycle.

Then make 2 basic core pistons, that every time they see the respective pushbutton cycle they send the all ON or all OFF command to the lights?

Just thinking out loud. Hard to do early in the morning. I’m not near my system so I could test this out.

I did something similar to this to trigger my goodnight routine. I have a virtual pushbutton. Every time I push that button by what every means, core, Alexa, physical button connected through program, phone app the hub runs my goodnight routine. I could just run the goodnight routine, this just made it easy for things that could not start a routine to do it.

Here’s how I handled it. The virtual switch state becomes the tricky part.

Created the following 4 pistons in CoRE

  • Kitchen Lights Off
    If Kitchen Lights switch change to Off
    Turn Off Kitchen Can Lights, Kitchen Sink Light, Kitchen Undercabinet Lights

  • Kitchen Lights On
    If Kitchen Lights switch changes to On
    Each of Kitchen Can Lights, Kitchen Sink Light, Kitchen Undercabinet Lights switch is Off
    Turn On Kitchen Can Lights, Kitchen Sink Light, Kitchen Undercabinet Lights.

Note I had to add the AND content because I change the state of the Kitchen Light Switch (virtual) to On if any of the Kitchen light switches are turned on. So, if the Can lights are turned on, I change the mode of the virtual switch to On, so that I can easily turn that virtual switch off to turn off any kitchen lights that are on at that time.

  • Kitchen Light Switch On
    If Any of Kitchen Can Lights, Kitchen Sink Light, Kitchen Undercabinet Light switch to On
    Turn On Kitchen Lights (virtual switch)
    [when any of the kitchen lights are switched to On, I change the kitchen light switch to On]

  • Kitchen Light Switch Off
    If Each of Kitchen Can Lights, Kitchen Sink Light, Kitchen Undercabinet Light switch is Off
    Turn Off Kitchen Lights (virtual switch)
    [when all of the kitchen lights are in the ‘off’ mode, I automatically change the kitchen light switch to Off]

Using Alexa is definitely simpler. You just create a group, add the appropriate switches to that group, and then tell Alexa “Alexa, Turn Off Kitchen Lights” and it just works, regardless of the state of each of the Kitchen Light switches.

So, functionally the above works but as I add the other rooms in my home using similar logic, I’m definitely taking a performance hit. There is a bit of a delay between switching the virtual switch on and off and the actual completion of the command.

Yeah, I would say the Alexa group is a better option.

Another idea that may or may not work. Earlier you said you could use a routine to turn on / off all the lights.

Could you access that routine using “ask Alexa” or "Echosistant " also use that routine using other interfaces? There may be another smart app designed for something like this too?

Seems like if you have this type of setup in CoRE in several places that’s a bunch of pistions.