Timeout on closet lights?


#1

Hi all,
I’ve been puttering around with this idea: So we’ve got a few walk-in closets around the house and for the S&G’s I rigged them up with contact sensors and some cheap smart bulbs. Door opens, light comes on and the other way around. Nothing too fancy.

Next problem, someone (myself) usually forgets to close a closet door and then the light stays on, duh. I understand there’s an Age function one can use to query a bulb how long it’s been on? I guess I just need to see a working example. Anyone?

Thanks a bunch,
Max


#2

Perhaps something like this:

IF Contact changes to open
Then
    Turn on light
    Wait X minutes    \ Delay and
    Turn off light    / Safety net
END IF

IF Contact changes to closed
Then
    Turn off light    > Immediate action
END IF

Note:
The first WITH block has to have Task Cancellation Policy set to “Never” for this piston to work.

Also, make sure that whatever number you use for “X” is 5-10 minutes longer than you’d ever expect to be using the closet light. If you set it too small, you may occasionally find yourself in the dark. (remedied by closing & opening the door, and increasing “X” for better results in the future)


#3

Thanks for the ideas, I’ll try and mess a bit more with it. So far I’ve just been using SmartLightning to deal with the bulbs, which leaves a lot to be desired.


#4

For what it’s worth, I try to keep all of my programming logic here in webCoRE. It makes debugging so much easier if you only have to look in one spot.