This post may contain affiliate links. Please see our disclaimer for more info.
I don’t know why I didn’t do this earlier.
This was by far one of the easiest home automation things I’ve implemented, and it yielded some of the best returns (approvals) from my wife and kids. If you have closets with lights and Home Assistant, this might be one of the better projects for you. Also as a parent with young kids, this 1) blows their mind that they can control the light with the doors and 2) helps teach good behavior of closing doors when they are done using them.
- Smart bulb (or smart switch)
- Contact sensor – I’m using an old Xfinity Home Alarm door sensor
- Easy HA automation (Feel free to use my Node Red flow)
Equipment & Integration
There’s not a whole lot to this. Simply attach a contact sensor to the closet doors. In the picture below where I have sliding/folding doors, the sensors still work when they are in close proximity. So you have some wiggle room if the doors are not super close.
For the lighting, I’m just using a Sengled Zigbee smart bulb – I use these all around my house. Cheap, reliable, and effective. I don’t have a light switch controlling my closets (just the pull cord), so this made most sense. If you have a switch to control the light, another option would be to install a smart switch (I use a lot of Lutron Casetas) instead of a smart bulb. However this is much more of a difficult install, more costly, and doesn’t really add much value if you are only controlling a single light. However if you don’t have a standard light socket (e.g. E26 base) or have a specialized light fixture, a smart switch could be the better option. See my post on smart switches if you’re looking for more info on them.
In terms of the automation, it’s pretty simple as well. Closet doors open, light goes on. Closet doors close, light goes off. In addition, I added an additional timer (wait until node in Node Red) that is triggered when the light goes on to turn the light off after 30 min. This is to deal with the use case when the door is left open by mistake or the light is manually turned on from Home Assistant. Find a time that works best for you; LED bulbs are enormously efficient, but there’s often no point in lighting an unoccupied closet.
If the closet needs to be occupied for extended times (spring cleaning!), either just open or close the door every time the light goes off, extend the timer, or add some sort of fancy automation to delay the auto-shutoff. Perhaps a open/close event 2x signals the light to stay on for a few hours. For my family, just open/closing the door again is not a large inconvenience. I’m a not a fan of overcomplicating automations that will only make .001% of my families’ lives better.
I do all my automations in Node Red – feel free to download my flow here. This could easily be done in the Home Assistant automations as well. Enjoy!