Closet and pantry lights that turn on when the door opens

A pantry door opening with a door sensor on the frame and the light inside switching on

To make a closet or pantry light turn on when the door opens, put a door sensor (also called a contact sensor) on the door frame and control the light with a smart switch. When the sensor reports open, your hub turns the light on. When the door has been closed for a minute or two, it turns the light off. The wall switch keeps working the whole time. The turn lights on when a door opens recipe has the full rule.

The short answer

Your spaceWhat to useOff rule to start with
Small reach-in closetDoor sensor plus a smart switchOff about 1 minute after the door closes
Pantry you step intoDoor sensor plus a smart switchOff a few minutes after the door closes, so a quick return trip stays lit
Walk-in closet or a room with two doorsA motion or presence sensor insteadOff after no motion for a while
No hub and no smart homeA battery closet light with its own door or motion switchHandled by the light itself

A door is a clear signal in a small space. Opening it means someone wants light right now. In a bigger room, people stay inside with the door closed, so a door rule can leave them in the dark. Use motion lights there instead.

What you need

Amazon product links are affiliate links, and I earn from qualifying purchases. See the disclosure.

Where to mount the sensor

Pick a safe off rule

Turning the light on is the easy part. Turning it off is where people get annoyed.

Can a smart lock turn on lights when the door opens?

Sometimes, but unlocking is not the same as opening. A lock reports locked and unlocked, which does not tell you the door actually moved. Some smart locks also include a door position sensor that reports open and closed. If your lock shares that state with your hub, you can use it as the trigger. If not, add a regular door sensor next to the lock. For an entry door, an unlock is still a good signal to light the way in. The prepare the house when someone arrives recipe uses it that way.

Failure modes

FAQ

Do I need a smart switch, or will a smart bulb work?

A smart bulb works if the wall switch always stays on. If someone flips the switch off, the bulb loses power and the automation cannot turn it on. A smart switch avoids that, and the paddle still works for everyone.

How fast does the light turn on?

With a rule that runs locally on the hub, it usually feels close to instant. Cloud routines can lag a little. Test it a few times and judge it in the dark.

Will this work with Alexa?

It can. Use an Alexa routine with the door sensor opening as the trigger, if your sensor shows up as a trigger under When. Check that before you buy, because each integration decides what it shares. The Start an Alexa smart home guide covers the basics.