Create Piston to turn on Entrance Lights


#1

1) Give a description of the problem
Trying to design a piston that triggers secondary action based on certain conditions

2) What is the expected behaviour?
I would like to create a piston that when my Ring Doorbell button gets pushed, it turns on my entrance lights. If the front door sensor doesnt change to “open” it should turn off after 45 seconds. However if the front door changes to open, then the 45 second countdown should only start once the door is closed.


#2

Didn’t test it but I believe this should work.

First IF
Turns the lights ON and starts 45 second countdown… if nothing happens the lights will turn OFF

Second IF
Door opening stops the coundownt so the lights will never turn OFF as long as the door is open

Third IF
Door closes and new 45 seconds countdown starts…


#3

My draft might give you a hard time IF you close the door and re-open it right after.
But this is a good start


#4

You also might want to consider 2 pistons and a global variable for different solution.

I’ll write another draft with how I would do it for my house.,


#5

Thank you so much for all the guidance! Sorry, this a newbie question but on your 2nd IF statement, what does “Location” refer to?


#6

Stepping in here for @ike2018

‘Location’ is just the default when no device is selected. Doesn’t really refer to anything.


#7


OK, let me know if this looks good. I couldnt get the section with “location” to stay on the piston. As soon as I got to the next step to “cancel all pending tasks” it removed the “location” line
Thank you dso much for all the help!


#8

Swap places of line 20 and 18, your code would be healtier.
(Triggers first, conditions later)


#9

So Im encountering a problem that when my entrance lights are on and someone opens the door, teh lights turn off after 45 seconds. What is going wrong in my piston? The lights should only turn off if the ring button was pushed and triggered the sequence of events. Otherwise just closing the door should not cause the lights to turn off


#10

Nothing is going wrong with your piston per se. It runs from the top whenever the button or contact change state and it says to turn the light off after 45 seconds if the contact is closed.

You need to make the response to the contact changes conditional on the button having been pressed earlier. That might involve setting variables to track what state your piston is in. I can’t immediately suggest a solution as it needs thinking about. There may be an obvious solution but it isn’t leaping out at me.


#11


What do you think about this? Look at Line 36-38
Thanks


#12

I can see where you are going but I don’t think line 36 will ever be true, though 35-46 might perhaps work as a separate piston.