Trigger Piston When Device Is Target of Command


#1

1) Give a description of the problem
I’m setting up a group of lights for a room. I am using a virtual dimmer switch to control all lights in a room.
Problem is, if I turn on any lights individually, the Virtual Switch doesn’t change state. So if I have one light on, and then try to turn the room off nothing happens because WebCore doesn’t see any change in the Virtual Switch.

2) What is the expected behavior?
When I say “turn room on” or “turn room off” I want all lights in that room to turn on or off regardless of current virtual switch state.

3) What is happening/not happening?
See above.

I’m not sure what the best solution is to this, but I was thinking if there is a way to determine if a device is the target of a command even if it doesn’t trigger a change.

so something like:

if

  • VirtualRoom is TargetOfCommand

then

  • with (all lights in room)
  • set switches to VirtualRoom’s switch

Any help would be great!


#2

Try disabling command optimization.

Options > Show piston settings > Click settings > Click cog (wheel icon)


#3

Thanks for the reply, i went ahead and gave that a shot. But I still get no response. I’ve tried several comparisons, but I can’t find one that registers true without actually changing the state of the virtual switch…
Here is a simplified version of what I’m looking at.


#4

Hmm, so you want virtual switch to turn on if any of say switch1, switch2, or switch3 turn on? (just trying to understand the end result :slight_smile: )

Turning off virtual switch turns off whatever switches are on?


#5

Yes, I can set up a piston that turns on and off switch A, B, etc… with a virtual switch.
But if I turn ‘A’ on, and then say “Turn off my Room” ‘A’ will not be switched off because initially I did not turn “My Room” virtual switch on. So essentially I turned “My Room” from off to off. which has no effect. I would like it to always turn all lights, A B etc… On or Off no matter what the initial state of the “My Room” virtual switch is.


#6

Try this, just did minor testing with virtual devices. See if it is what you’re looking for. Switch 7 is the virtual switch.


#7

This works for part of the problem with a couple caveats;
Either.

  1. if i turn switch 4 on, then want to turn the room on by saying “turn on room” the virtual switch is already on and none of the rest of the lights come on.
    Or.
  2. If there is a rule that turns all lights in that room on when switch 7 (Virtual Switch) is turned on, then when the first ‘if’ statement resolves, switch 4,5 and 6 all come on.

#8

I believe there was a topic similar to this just a few days ago and the consensus was there needs to be another ALL switch for the All On/Off function. I will have to look for it later when I get home.

I do have another idea though, I use an app called URI Switch that I use to control the volume of my my dumb receiver, I am able to issue back to back “turn on volume up” to Alexa and the ON command keeps getting sent thus increasing the volume. See if you can find that app and maybe apply it to your piston.

Link to app (man this is old):


#9

Thanks! I’ll take a look :wink:


#10

Try this. Not sure if I am reading your desired effect correctly. However this will turn on virtual switch if any light is turned on. If all lights are off and virtual switch turns on it will turn all lights on. If virtual switch is turned off all lights will turn on.


#11

The way “virtual swtiches” are handled in “webCoRE” is different from how they were handled with “CoRE”.

In a “CoRE” piston, I had the following conditions for a Virtual Switch named “Upstairs”:

If “Upstairs” changes to ON, turn on both upstairs lights and set them to 100% brightness.
If “Upstairs” changes to OFF, turn off both upstairs lights, turn off my TV and turn off my Sonos.

This worked no matter what the current status was of the “Upstairs” virtual switch. If the switch was already on and I told my Amazon Echo to turn it on, it would still trigger and turn the lights on to 100%. And even if the switch was already off and I told my Amazon Echo to turn it off, it would still turn off all the lights, my TV and my Sonos.

It would be nice if webCoRE could be updated to work the way CoRE used to (when it comes to virtual switches). If not, could webCoRE be updated as follows:

PROPOSED CHANGE (to webCoRE): When adding a condition to a piston for a virtual switch, add a checkbox for “change attempted”. That way, if you try to change a virtual switch to ON and it was already ON, or try to change a virtual switch to OFF and it was already OFF, it would still trigger the condition (just like it used to in CoRE, but doesn’t currently do in webCoRE).


#12

@SrLANGuy, Is command optimization what you are looking for?


#13

Thanks Pantheon, but command optimization has no effect on this issue. I tested it myself to be sure.


#14

As @Pantheon said, you’re looking for ‘Command Optimization’. In webCoRE, Command Optimization is enabled by default. This means that if you send an ‘On’ or ‘Off’ command to a switch that is already in that state, the command is ignored for optimization reasons. However, the Command Optimization default of ‘enabled’ can be changed within the piston by clicking on the settings line (top of piston). In the window that pops up, click the little cog to the bottom right. One of the choices in the new pop-up is ‘Command Optimizations’. You’ll note that it’s set to ‘Enabled (default)’. Change that setting to “disabled” and then save the piston. You’ll then see that commands are always sent to the switch, no matter what the switch’s current state is.


#15

Thanks lflorack, but command optimization being set to disabled does not make a difference.


#16

Making this change doesn’t work as you expected for your piston? I’m confused. I must be missing what your issue in this instance is then.


#17

Here is my TEST piston and my Virtual Switch is “Dimmer 8”. If “Dimmer 8” is already on and I tell my Amazon Echo to turn on “Dimmer 8”, nothing happens. I can repeat the command multiple times and it does nothing. But then when I tell my Amazon Echo to turn the switch off, the piston works and when I tell it to turn it back on, it works. It just doesn’t work if the virtual switch is already in the state you’re telling the Amazon Echo to change it to.

I have the same piston setup in the old CoRE system and it works perfectly, even if the virtual switch is already in that state.


#18

If the virtual switch is on and you send it another on command, I would expect nothing to happen since it’s already on. Why would you expect it to do something else (i.e., turn off) if it’s already in the on state and that’s what your telling it to do (i.e., turn on)?


#19

As I mentioned earlier, in CoRE, if the switch was already on and I told the Amazon Echo to turn the virtual switch on, it would still see this as “Changes to on”. But when I started switching pistons to webCoRE, it didn’t work the same way. So if we can’t change it to the way it was before with CoRE, it would be nice if we could at least add an option to the condition. Here’s what I suggested earlier:

PROPOSED CHANGE (to webCoRE): When adding a condition to a piston for a virtual switch, add a checkbox for “change attempted”. That way, if you try to change a virtual switch to ON and it was already ON, or try to change a virtual switch to OFF and it was already OFF, it would still trigger the condition (just like it used to in CoRE, but doesn’t currently do in webCoRE).


#20

…in the meantime…

What I do for Simulated Switches is let the piston return the switch to the previous state. IE:

IF Dimmer 8's switch changes to on
Then 
    Change color etc
    Turn off Dimmer 8
END IF

This resets the SimSwitch for the next use.

Unfortunately, this only lets Alexa trigger one direction per SimSwitch.


Another advance trick that I sometimes use is with a “Simulated Dimmer Switch”.

IF SimDimSwitch's level changes
Then
    IF SimDimSwitch level is greater than 50%
    Then
        Set color to Red
    ELSE
        Set color to Blue
    END IF
END IF

This way, you can say:
“Alexa, set switch to 80%” to turn the light red, and
“Alexa, set switch to 20%” to turn the light blue.
Of course, you can build upon this with more colors, if you can remember which numbers equals which colors.

Two caveats with this method:

  • Avoid using zero
  • You can not ask for the same number twice in a row.