Closet light automation


#1

1) Give a description of the problem
I have a piston that turns on my closet light when the door opens and my automation switch is set to on. If the door closes it turns off the light. If the door stays open for X minutes it turns off the light.

If the light was turned off by the piston and I then turn it on with the switch while the door is open I want the light to turn off again after X minutes. I am not sure how to go about adding that piece to this piston or even if it needs to be its own piston.

2) What is the expected behavior?

3) What is happening/not happening?

**4) Post a Green Snapshot of the piston!

**5) Attach any logs (From [ST IDE]


#2

@cmg75 if I understood what you want correctly,

add this as a new IF after line 38

IF switch4 CHANGES TO ON
with switch 5
Turn ON
WAIT 30 seconds
TURN OFF

But with IF I believe you need to choose task cancellation NEVER CANCEL

to do that click on the IF
when menu opens find the little wheel icon and click
look down, you will see TASK CANCELLATION POLICY
Choose NEVER CANCEL TASK

if you did it correctly, there will be an N somewhere around your IF

But the problem with this one is,
Your switch is already ON
how do you turn on something is already ON?

if you want this it might be easier
get rid of line 21

so you open the door and ligh turns ON
Waits 30 seconds turns OFF
you turn ON switch 4 light turns ON
waits 30 seconds and turns OFF

let me give you example:

you can donwload this with the code and play around.


#3

and is this the only piston?
because this piston won’t turn the light off when it closes???


#4

This is the only piston.

The goal is:
Turn on when open
Turn off if left open for x minutes
Turn off if closed

That all worked. The piece I want to add is for the scenario where the light is off but the door is open and I turn on the light. I want the light to turn off again after x minutes or the door closes


#5

ok I am pretty sure the part I added would do that
starting from line 37

the only concern I have is
the door is open
light was off
Switch 4 is turned on by you
light turned on…

Now the first part will be triggered…

to stop that I would recomment change the first DOOR IS OPEN
to
DOOR CHANGES TO OPEN

this will give you the scenario you want I believe.
But its always best to test and see.


#6

Thx! Seems to be working! This is what I ended up with. The only thing is I am guessing there is probably a better way to handle switch 4 since I only want to execute any part of the pistion if it is on since its my automation control switch for the room.