Help with Piston: Bathroom Lighting

Hello!

I was wondering if I could enlist the help of this awesome community in a problem.

I have a piston that I use that controls bathroom lighting and a fan,
My goal was to have the light turn on when the motion sensor senses motion. I would like the light to stay on while someone is in the bathroom. If someone is in there for over 120 seconds then the fan would come on. I wanted the light to stay on an additional 60 seconds after the door is opened (ie no motion or person has left). And after 180 seconds the fan would turn off.

My problem is that my iris motion sensors time out if someone is sitting on the pot, and playing with their phone etc…
lights turn off, then back on.

Also the fan sometimes comes on sometimes does not.

Can any of you experts out there take a look at this piston and try and offer some tips for improving performance?
I am not asking for you guys to rewrite it, just help teach me how to write these better.

Thank You!

WebCore has its own forum and most of the core experts hang out over there these days. So if you post your piston questions over there you will probably get more responses. :sunglasses: