Turn lights on when a door opens

Open the closet or pantry, and the light comes on. If the automation is unavailable, the familiar wall switch still works.

Best for: Closets, pantries, linen cupboards, and utility spaces where opening one door clearly means someone needs light.

Not for: A shared room or exterior door where normal door traffic would make the light surprising. Use a motion or presence recipe when the door does not reliably mean someone entered the lit space.

Why this exists

The pantry or utility-room light should be on before anyone has to reach for the switch. A contact sensor sees the action that starts the task - opening the door - more decisively than a motion sensor in a small enclosed space. The physical switch remains the Level 1 fallback for guests, maintenance, and every failure mode.

What I used

Job Good enough Never think about it Notes
Detect an open door SONOFF SenseGuard Gen2 Zigbee contact sensor Zooz ZSE41 800LR Open/Close XS Sensor Test the closed state before relying on it.
Dim a fixed light TP-Link Tapo S505D Matter Smart Dimmer Switch UltraPro Z-Wave Long Range Dimmer Verify hub compatibility. Keep the physical paddle usable.
Switch a fixed light on or off Leviton DG15S Zigbee switch UltraPro Z-Wave Long Range On/Off Switch Keep the physical paddle usable.

See recommended gear for the job-first checklist. Product links on this page are direct, non-affiliate Amazon links. Product recommendations and any future affiliate relationships are explained in the disclosure.

Logic

IF the closet door opens AND the closet is dark THEN turn on the closet light

Setup notes

Mount and test

  • Mount the magnet and sensor where the door closes consistently.
  • Open and close the door ten times and confirm every state change appears in the hub.

Start simply

  • Turn the light on when the door opens.
  • Add a light-level condition only after the basic trigger is reliable.

Choose a safe off rule

  • For a closet, turn off after the door is closed for one minute.
  • For a pantry, start with a longer delay so it does not turn off during a quick return trip.

Advanced features

Day vs. night brightness

Adjust brightness based on time of day:

  • Nighttime (10 PM - 6 AM): 30% brightness, warm white (2200K)
  • Daytime: 100% brightness

Auto turn-off when door closes

Turn off light 2 minutes after door closes:

  • Prevents lights turning off while door swings closed
  • Avoids rapid on/off cycles during multiple trips
  • Still energy efficient

Failure modes

Done when

FAQ

Should the light turn off as soon as the door closes?

Only for a small closet where the light is visible from outside. For a pantry or room, use a short delay and keep the wall switch as the immediate fallback.

Why does the light turn on when nobody is using the closet?

Check magnet alignment and make sure the sensor reports closed reliably. A loose sensor or a door that flexes can create false open events.

Can this work when the internet is down?

It can when the hub and devices support local automation. Regardless, the physical wall switch should always work normally.