Create a master switch to follow several lights in a room


#1

1) Give a description of the problem
I am using wall mounted tablets for a few rooms and trying to create a setup whereby groups of lights will be controlled by virtual switch on my tablet, including the ability to control individual lights separately.

2) What is the expected behavior?
I have 10 recessed lights and a lamp. I have a virtual switch that is currently set to turn on all lights in this room using the smart lighting smartapp (and off as well). But I’m looking to webcore to get a little more sophisticated where I can have my virtual switch follow and combination of light scenes in the room.

For example, I have 4 lights I’ve setup to turn on for a “reading” mode/scene. If I turn these lights on (whether ST app or Alexa) I would like to somehow trigger my virtual switch (which is the “all lights” switch) to change to on state without turning on all lights in the room. I realize I may have to kill my smart lighting control and move all to webcore, which is fine.

Can this be done? Or will I always be faced with the conundrum of my “master” switch turning all lights on when webcore tells it to change to on state?

I also believe and understand this could just be made into 2 switches, but I really don’t want to do that as that will further complicate the setup and hurt my WAF.

3) What is happening/not happening?
Have not built piston yet, wondering if possible.

4) Post a Green Snapshot of the pistonimage
(UPLOAD YOUR IMAGE HERE)

5) Attach any logs (From ST IDE and by turning logging level to Full)
(PASTE YOUR LOGS HERE BETWEEN THE MARKS THEN HIGHLIGHT ALL OF THE LOGS SND CLICK ON THE </> ICON TO FORMAT THEM)


#2

I have read and re-read your post four times, and I am still not clear on your goals.

A Simulated Switch can be the master switch to control a bunch of lights
- or -
a bunch of lights can control a Simulated Switch

If you actually want both possibilities with the same SimSwitch, you are in for a real challenge in programming.


I have to ask though… Why would you want to turn on your SimSwitch (which normally turns on all lights) yet keep half the lights off? It sounds so illogical to me.


#3

My initial thought was that this can be handled in two ways.

  1. Use Ask Alexa and pass the parameters you desire - “reading”, “all”, etc. (more complicated I think)
  2. Use a different virtual switch for each setup and use those switches with Alexa routines. And use webcore to do the heavy lifting of turning those lights on.
    1. Virtual_Reading_Switch for “reading lights” with an “Alexa, turn on the reading lights”
    2. Virtual_All_Switch for “all” with “Alexa, turn on all of the lights” or just “Alexa, turn on the lights”

#4

So this is the living room and there are times where we’ll have some of the 10 recessed lights on (bc they are all hue lights and individually controlled) and possibly a lamp or not. If someone goes and turns on half the lights in the room, I’d still like a one click switch option to turn off all lights. But if all lights are already off, I’d really like the same switch to turn them on at a default setting. I know I may be over-engineering but I also know that if I continue to have to create multiple switches or routines to handle a typical room switch function, it’ll get crazy trying to maintain.

So after I posted the topic, I jumped into webcore and I think I’m on the right track. I’ve got the switch rules in place, but I just need to add logic to say “hey, if all lights are off and switch is off, when switch is turned on, set lights to these settings”

I’ll post what I have later or tomorrow.


#5

@WCmore, Like you said, I read it several times and maybe I did not address what the OP wanted.


#6

I think this covers all of those scenarios:

IF SimSwitch changes to on    <-- Trigger
Then
    IF ALL 10 lights are off  <-- Condition
    Then
        Turn on 10 lights
        Turn off SimSwitch    <-- Resets SimSwitch
    ELSE
        Turn off 10 lights
        Turn off SimSwitch    <-- Resets SimSwitch
    END IF
END IF

This piston assumes that you are no longer controlling the SimSwitch with your “smart lighting smartapp”


#7

Yes, I’ve killed anything tied to the switch in order to focus in webcore. I think your sample is on the right track but I think it’s missing the logic to “follow” lights in my room. So that if I say turn on my couch lamp and some of the recessed lights, my SimSwitch is watching and turns on accordingly - so that I may use that switch to then turn off all lights.

Here’s where I’ve landed. I dont know how to group my rules or nest them all under one trigger. I’ve got a piston somewhat working, just need to do a couple more tweaks tonight and then I’ll post for feedback.

IF any of my 10 lights turn on

Then Turn SimSwitch on

ELSE IF

ALL of my 10 lights are off

Then Turn SimSwitch off

ELSE IF

(Not ALL lights are on AND SimSwitch is on) <-- restriction??

SimSwitch changes away from on

Turn all my lights off

ELSE IF

(NO lights are on AND SimSwitch is off) <-- restriction??

SimSwitch changes away from off

Then turn on all lights at set values

END IF

#8

My previous post does this precisely. Using ELSE IF will over-complicate things


#9

I do not see where your logic would turn my SimSwitch to ON state if I were to manually turn on half the lights in the room by another means. I have some scenes which do not use all lights. So my switch would be in the off state and thus not able to turn off the lights that are on.

Did you mean for your logic to turn the switch off here?

Then
Turn on 10 lights
Turn off SimSwitch <-- Resets SimSwitch

The goal is to keep my SimSwitch in an on state when any or all lights are turned on by whatever means.

I’ll try to plug in what you have tonight as another test.


#10

The logic in my piston above keeps the SimSwitch in the off position 99% of the time… Whenever you turn it on, it examines the 10 lights, and acts according to your earlier request:


#11

I came across this post when I was trying to figure out a timing issue with my piston (fixed and explained below). Although the post didn’t help me with the timing issue, it looks like my finished piston may do what you wanted. It both turns on or off all the lights in the “LightsUpstairs” group as well as shows if ANY of the lights are on (switch shows on) or if ALL of the lights are off (switch shows off).

I use ActionTiles and I made this to put on the tablet by the front door. Although the example is a simplified version with only upstairs lights, I wanted to have a way to easily see if any upstairs lights, downstairs lights, or fans were on in the house and turn them on or off as needed. This way, I can tap three virtual switches as I leave and turn off all the lights/fans in the house. The only “issue” is that if I wanted to turn on all the lights in a group and less than all of them are already on, I would have to turn the virtual switch off, wait ten seconds, then turn the virtual switch on. However, my main goal was to be able to turn off any forgotten lights/switches on my way out so that’s not a big deal to me.

The original issue ended up being the fact that the dimmer switch was taking about 5 seconds to fully turn off (it dims its way off). Because of this, my original 5 second “SwitchWaitTime” ended up always being true and in turn turning on the rest of the lights in the group. After making the “SwitchWaitTime” 10, it works as I intended.


#12

This is the piston with all three light/switch groups. I needed to add separate “SwitchTime” variables for each group or else I’d need to wait for “SwitchWaitTime” seconds between switches to turn them all off.


#13

Is this what you are looking for?

I’ve created a Virtual Switch called “Living Room Lights Alexa”.

I added the switch to the Alexa App. Went into the setup of this switch (in the Alexa App) and changed the device type to ‘Light’.

In the Alexa App, I added this fake ‘Light’ to the Living Room group. So, when I’m in the Living room and say “Lights On”, the real lights come on, and this fake ‘Light’ also comes on.

You can then use this in many ways.
I have a few more complicated things around this ‘fake Light’, but the above is what got me started.

I also have another Virtual Switch called “Living Room Lights Control” that is used as the main control of the Living Room Lights.

I will have to put all of this down in writing some day, because it’s pretty slick the way it works.

I’ve done these things, because I also have ActionTiles, and these are used in there as well. Example: (see 3rd Pic below) A Tile in ActionTiles called “Toggle Lights On/Off”; when pressed, it activates the “Living Room Lights Control” mentioned above…so I don’t have to turn on each light individually. (See 2nd Piston below)

If Alexa turns on the lights, the “Toggle Lights On/Off” gets turned on as well, but does not affect the actual lights due to the variable. (See 1st Piston below)