Light on and off with door sensor


#1

1) Give a description of the problem
I have created a piston to turn on a light in my pantry when the door opens. It will turn off after 5 minutes of being open. I want to be able to still utilize the switch if I want to lets say if there is enough ambient light inside the house.

2) What is the expected behaviour?
Open pantry door light turns on, close pantry door and light turns off. If door is left open for 5 minutes light automatically turns off. If I want to turn the light off before 5 minutes and leave the door open I want to use the switch to turn it off.

3) What is happening/not happening?
Light turns on and off but cannot use the switch because I do not have a code that I know how to use for that to work.

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach logs after turning logging level to Full
(PASTE YOUR LOGS HERE THEN HIGHLIGHT ALL OF THE LOGS AND CLICK ON THE </> ICON TO FORMAT THEM CORRECTLY)

REMOVE BELOW AFTER READING


#2

I’m thinking this will work for what you want or at least give you some ideas.


#3

Firstly, please be careful with where you position changes to triggers.

If you have contact changes to closed you need that trigger to be evaluated every time the piston runs in response to that contact changing. If it doesn’t see the old value it can’t know it has changed. So watch out for and or or groups. If the first condition in an and is false, or the first condition in an or is true, there is no need for the other conditions to be evaluated, so they aren’t. Similarly don’t nest them in other if conditions without considering the implications.

As for your problem, what exactly is the switch? If it is a smart dimmer switch with a dumb bulb then it will turn off your light when used physically. So the piston doesn’t need to consider it at all.

If you wanted to use the switch to keep the light on it would be different.