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.
Ingredients
- 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.
Automation
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!
Hi, how did you have the smart switch and the sensor talk to Home Assistant? I have a smart switch and a ring door contact sensor. How can i use them to automate the light using HA? thanks in advance.
Hi Rick! In my setup, I’m using the ZHA integration as both devices are Zigbee compatible and talk to Home Assistant.
For Ring, it appears there is an official HA integration but it doesn’t support contact sensors. There is however a 3rd party add-on that I’ve looked at (not tried yet) that supports many more devices including contact sensors. So if you want to to use the contact sensor via Ring, this would be the way.
Depending on the device, it could be connected directed to HA completely disregarding Ring. However each device can have compatibility nuances. It might not work well. I’d recommend searching around to see if others have tested the device to determine compatibility.
For the smart switch – same idea. Need to get it integrated with home assistant based on the device type and manufacturer.
Once both devices can talk to HA, then you can create automations like I have. Hope this helps!