Piston to turn on light based on contact


#1

So I’ve tried creating a piston that will do the following:

If garage door contact changes
Then with garage lights
Turn on
Wait 5 minutes
Turn off

This works fine. When I tried to add additional statements in the pistons to perform the same action on additional contacts/switches it fails. Any ideas? Ideally I’d like to have one piston named Lighting - Contact Change that monitors 10 or so contacts and performs lighting automations. Cheers!


#2


This piston does just that. And gives you a tile. Check this one out and see if that helps. It’s based on 3 contact sensors and a motion sensor. Any of 3 sensors open and the light turns on. Turns off after 5 minutes as long as the door is closed and motion stops. Hope this will help? I noticed that you want a complex piston to do more than just the garage door? You’d need a new If/then Block to do that. Post your piston and I’ll see if you’re on the right track.


#3

Thanks! I’ll play with it tonight and post my resulting piston in the morning.


#4

Here is what I’ve got. The first statement works fine, but the second one does nothing.


#5

You need to make the first IF statement async. The reason your second is not working is because it is subjected to the wait in the first IF.


#6

Thanks for the response! I understand what you’re saying, but I’m not sure what to move where in the code. Any pointers would be appreciated.


#7

Check this out for a little more detail on the execution methods. https://wiki.webcore.co/Execution_Method

As for what to do. Click on the first “with” then click the settings icon and change the execution method from synchronous to asynchronous.


#8

That did it! Thanks for the help!


#9

You’re welcome


#10

So after a couple of weeks using this, I just noticed the ‘switch 5’ lights are not turning off after 5 minutes. They just stay on. When I look at the recent activity, I see WebCoRE turn the lights on when the contact opens, but the lights never received the off command. Any thoughts?


#11

You need to set Task Cancellation Policy (TCP) to never.
Click on the settings cog for your ‘with’ and select it there.
When done you will see a red N next to it.