Hey guys first post here, excited to start diving in! Here is the scenario that I am trying to make work and would love to see if you guys can help. I have a multipurpose sensor on the outside of my bathroom down downstairs. When the door opens the two smart bulbs turn on. After 10 minutes the bulbs turn off. I am adding a smart switch today for the bathroom as well (so you can manually turn off as well). What I would like to happen is when you open the door the lights turn on, then you close the door use the bathroom,but when the door opens to get out and you close for the second time the lights turn off. So it would be a open (lights on), close nothing happens, open nothing happens, close (lights off) How would i go about doing this?
You could use a variable.
When you open the door then X would increment by 1.
If X = 1 then turn light on. When you open the door the second time X increments again. So X = 2. If X = 2 then turn light off when door is closed and set X = 0. As long as that cycle is utilized then it would work. You could also add a motion sensor in the bathroom to keep the cycle in check when there is motion, but most motion sensors have a reset period. But not necessary for this basic functionality.
To add a bit to @logeox’s advice, I would also consider adding some kind of “auto-reset” to keep the numbers in sync. Otherwise, opening/closing the door to quickly grab a towel/etc will get your numbers out of sync.
Off the top of my head, (using your current devices) I am thinking maybe:
IF Contact stays unchanged for 30 minutes Then reset variable END IF
(but a motion sensor might be best for this advanced logic)