top of page

Smart Automation for Night time Lighting with Sonoff Door Sensor and Wi-Fi Bulb


Door sensor + WI-FI Bulb

Creating simple and functional automations is one of the great advantages of a smart home. With the right products, you can make everyday life more convenient and secure. In this article, I’ll explain how to set up an automation so that the outside light automatically turns on whenever the front door is opened at night and turns off 10 minutes after the door is closed. For this setup, we’ll use the Sonoff SNZB-04P door sensor and a Sonoff Wi-Fi bulb.

Materials Needed


To build this automation, you will need:

  • Sonoff SNZB-04P Door Sensor: A Zigbee sensor that detects the door’s open and closed state. It’s ideal for monitoring entrances and works efficiently with other Sonoff devices.

  • Sonoff Wi-Fi Bulb: A smart bulb remotely controllable through the eWeLink app, compatible with automations and scenarios.

  • Sonoff Zigbee Hub: This hub is essential for integrating the SNZB-04P sensor with your Wi-Fi network, enabling communication between Zigbee and Wi-Fi devices.

Steps to Set Up the Automation


Step 1: Pair the SNZB-04P Door Sensor

  1. Ensure the Zigbee Hub is set up and connected to your Wi-Fi network through the eWeLink app.

  2. Put the SNZB-04P sensor in pairing mode by pressing the side button until the LED light starts blinking.

  3. In the eWeLink app, select the Zigbee Hub and add a new device. Wait a few seconds for the sensor to be identified and paired.

  4. Once paired, place the sensor on the front door, aligning the main sensor and magnet for accurate detection of opening and closing.

Step 2: Pair the Sonoff Wi-Fi Bulb

  1. Screw in the Sonoff bulb at the desired location, ensuring it’s powered on.

  2. Open the eWeLink app and select the option to add a new device.

  3. Put the bulb in pairing mode (usually, turn it off and on quickly three times until the bulb starts blinking).

  4. Follow the app instructions to connect the bulb to your Wi-Fi network.

Step 3: Create the Automation in the eWeLink App

  1. With both devices paired, go to the automations menu in the eWeLink app.

  2. Choose the option to create a new automation and select the SNZB-04P Door Sensor as the trigger device.

  3. Set the condition so that, when the door is detected as open, the Wi-Fi bulb will turn on.

  4. Configure the time condition so this automation only works during the nighttime hours you prefer (e.g., 8:00 pm to 6:00 am).

  5. Add a second action so that when the sensor detects the door closing, the bulb will turn off after a 10-minute delay. You can set this delay in the app’s "Delay" setting, where you specify the desired time.


Testing and Adjustments


Once the automation is set up, do a few tests to ensure everything is working correctly. Open the front door at night and check that the bulb automatically turns on. Close the door and confirm that the light turns off after 10 minutes.

This automation not only improves safety and convenience but also optimizes energy consumption since the light turns off automatically.



bottom of page