In this tutorial, we demonstrate how to set up a DIY automation system that triggers a light alarm if a door remains open too long or for more than a set number of minutes. If the door is closed within the configured time, the light alarm will not be triggered, and if the door is closed afterward, the light alarm will stop.
Devices Required:
- Sonoff DW2 WiFi Door Sensors: 2 units
- Sonoff or eWelink Smart Switches (e.g., Sonoff Basic, Mini): 2 units
- Output Devices (e.g., AC230V lights or alarm devices): 2 units
Note: In this demonstration, we used sensors for both the front and back doors. You can follow the same procedure to set up a single sensor for one door or more, as needed.
Wiring Diagram
Below is the wiring diagram for connecting the Sonoff switch to the power for the light.
Step-by-Step Setup
Step 1: Configure Door Sensors with WiFi and Add Them to the App
- Install Batteries:
- Open the back cover to install the batteries in their designated positions, ensuring the correct polarity.
- To ensure the sensor is powered, press and hold the reset button for 3 seconds until the yellow LED indicates power.
- Repeat for the other sensor.
- Add Sensors to the eWelink App:
- Ensure your mobile phone is connected to a 2.4GHz Wi-Fi network, as Sonoff devices currently only support this frequency.
- Register and log in to the eWelink App using your email or mobile number.
- Under the homepage, add the device using the ‘Add Device’ option or click the ‘+’ symbol.
- Enter the Wi-Fi password when the Wi-Fi SSID is displayed.
- If devices are not listed, press and hold the reset button to reset the sensors to factory mode.
- Click the ‘+’ icon to add devices one by one or select ‘Add All’ to connect all sensors to the Wi-Fi router.
- Name the devices according to their placements, then click ‘Done’.
- Check the sensors’ working state to ensure proper functionality.
Step 2: Configure the Sonoff Switch with WiFi and Add It to the App
- Reset the Smart Switch:
- Press and hold the reset button on the smart switch to reset it to factory mode. The light will blink faster when it is in pairing mode.
- Select ‘Add Device’, enter the Wi-Fi password, and connect to the Wi-Fi network.
- Click ‘Add All’ to add the devices to the app.
- Name the devices according to the corresponding door sensor names, then click ‘Done’.
- Check if the smart switches can be controlled via the app.
Step 3: Create Scenes to Execute the Door Remain Open Alarm Setup
- Create a Scene to Trigger the Alarm:
- Under the ‘Scene’ menu, click on the ‘+’ symbol or select ‘Build now’ to create a scene.
- On the ‘Add’ screen, select the ‘If’ condition, choose the first door sensor device, and set the state to ‘Remain opened for a duration’ under ‘Smart Device’.
- Set the time duration for how long the door can remain open before triggering the alarm. For example, set the duration for the front door to 3 minutes.
- Save the configuration after applying each condition.
- Add an action under the ‘Then’ condition by selecting the smart switch and setting it to ‘ON’.
- Configure the effective period, for example, from 11 AM to 6 PM.
- Save the scene with a name of your choice.
- Repeat the same steps for the second door sensor with a unique open time and effective period.
- Create a Scene to Stop the Alarm:
- Create a scene for ‘Front Door Close’. Under the ‘If’ condition, select the ‘Smart Device’ option to choose the ‘Front Door Sensor’ and select ‘Door Sensor Closed’.
- Under the ‘Then’ condition, select the ‘Smart Device’ option to choose the ‘Front Door Switch’ and set it to ‘OFF’.
- Save the scene with a name of your choice.
- Repeat for the second door sensor.
Testing the Setup
Trigger the door sensors to the open state to test the automation:
- The alarm light for the second door sensor will turn ‘ON’ after 2 minutes.
- The alarm light for the first door sensor will turn ‘ON’ after 3 minutes.
- If the door is closed within the configured time, the alarm light will not turn ‘ON’.
- When the door is closed, the alarm light will turn ‘OFF’.
Once configuration and testing are complete, fix the door sensors and position the smart switch alarm lights as per your convenience.
Final Note
Instead of a light, you can use an AC230V siren, hooter, or any other device connected to the output of the smart switch device. We believe this DIY automation may be helpful for you. Please support us by liking, sharing, and subscribing to our channel to encourage us to create more content like this.