Change virtual switch status


#1

1) Give a description of the problem
I have a Piston that trigger a web request to turn on and off some lights.

2) What is the expected behaviour?
I have two triggers. One motion sensor and a virtual switch.

3) What is happening/not happening?
The Piston is working fine with both triggers in order to make that web request to turning ON and OFF the lights. But the problem is that when the piston is triggered with the motion sensor and turn the lights on the Virtual Switch status is not changing to ON.

So, how can I make to change the virtual switch status when I trigger this piston with the motion sensor?


#2

Double triggers can be a problem with this. I would remove all programming for the motion sensor piston except for this:

If Motion changes to active
    Then turn on Simulated Switch
END IF

If Motion changes to inactive
    Then turn off Simulated Switch
END IF

In the other piston, you can do:

IF Simulated Switch changes to on
    Then do cool stuff
END IF

IF Simulated Switch changes to off
    Then do other things
END IF

#3

Thank you WCmore, your answer was very fast but I don’t understand where I have to put that code.

I take off the virtual switch trigger and only left the motion sensor trigger.

Now, how can I change the state of the virtual switch that now is triggering from another piston?

Thank you!


#4

Thanks for posting your piston. It can be tricky to troubleshoot blind…

A few observations:

(1) You have ZERO triggers here, so all your conditions become triggers. (lightning bolts on the left) This often yields unexpected results. I usually recommend one trigger per piston, with as many conditions as you want beneath that.

(2) I encourage new user to avoid using ELSE for a few months, since it rarely does what you’d think it does. For reference, with ten thousand pistons under my belt, I use ELSE in less that 1% of them


So for clarification, I think that you want:
A motion sensor to send a GET request, and you want a Simulated switch to also send the exact same GET request??

Am I understanding you correctly?


#5

Thanks again for the speed you answered WCMORE! This is awesome.

1- My intention in that piston is to send the web request when the motion sensor become active at certain time of the day and when the Smartthings is disarmed. I believe this is a trigger with 3 conditions . Buy since I’m a newbie this can be very wrong.

2- Got it! I’m going to make more piston with basic programing, totally understand.

For your last concern… the thing is I have lights that turn on with a url so when I turn on those lights with the motion sensor I want to see the virtual switch changing the state to ON too.

I think I found the way to do this because I didn’t see that when you select an action you can select the virtual switch from the menu. If I cant do it I will post again.

Thank you man.


#6

For some reason, I originally thought that when you toggled the Simulated Switch, you wanted the same GET request sent. If the SimSwitch is only a visual indicator (and does not do anything when toggled) then your idea is rock solid!!

If, on the other hand, the SimSwitch takes action, then we have to do a bit of fancy footwork to make sure the two devices don’t clash.