How to Set Up SONOFF DW2-Wi-Fi Door/Window Sensor with Home Assistant for Instant Security Alerts
By ITEAD STUDIO OFFICIAL | | Published: 2026-07-26
Category: How-to Guides
Learn how to integrate the SONOFF DW2-Wi-Fi wireless door/window sensor with Home Assistant to create a DIY alarm system. Step-by-step guide for configuration and automation.
A smart home isn’t complete without a reliable security system that alerts you the moment a door or window opens unexpectedly. The SONOFF DW2-Wi-Fi Wireless Door/Window Sensor is a compact, battery-powered contact sensor that detects open/close events and sends real-time notifications to your phone or Home Assistant dashboard. Unlike traditional wired sensors, the DW2 is easy to install anywhere—no drilling or complex wiring required.
In this guide, you’ll learn how to pair the DW2 with Home Assistant (using either ZHA or Zigbee2MQTT), create automations for security alerts, and expand your setup with other SONOFF Zigbee devices like the SONOFF Zigbee Wireless Switch SNZB-01P for arming/disarming or the SONOFF Zigbee Human Presence Sensor SNZB-06P for motion detection. Whether you’re building a whole-home alarm system or just want peace of mind when you’re away, this tutorial covers everything you need.
What You’ll Need for This Setup
Before you begin, ensure you have the following hardware and software ready. The core component is the SONOFF DW2-Wi-Fi Wireless Door/Window Sensor, which uses Zigbee 3.0 for communication. You’ll also need a Home Assistant instance (version 2023.8 or newer) and a Zigbee coordinator such as a Sonoff ZBDongle-P, Conbee II, or a Zigbee hub like the SONOFF ZBBridge. If you don’t have a coordinator yet, check compatible options in the ITEAD store.
Optionally, you can add the SONOFF Zigbee Wireless Switch SNZB-01P to act as a physical arming/disarming button, or the SONOFF BBQ Meat Thermometer BMT01 if you want environmental monitoring near doors. For accurate motion detection near entry points, the SONOFF Zigbee Human Presence Sensor SNZB-06P is an excellent companion. Make sure your Home Assistant is updated and your Zigbee coordinator is properly configured before proceeding.
- Tip: Use a fresh CR2032 battery in the DW2 to avoid pairing issues. The sensor has a battery life of up to 2 years under normal use.
Step 1: Pair the DW2 with Home Assistant
Start by putting the sensor into pairing mode. Remove the plastic tab from the battery compartment if it’s your first use. The LED should flash rapidly—if not, hold the small button on the side for 5 seconds until the LED blinks. On your Home Assistant dashboard, open the Integrations page. If you’re using ZHA, click “Add Integration” and select “ZHA” then “Add Device”. For Zigbee2MQTT, go to the Zigbee2MQTT web interface and click “Permit Join (All)”. Within 30 seconds, the DW2 should appear as a new device named “Door/Window Sensor”.
Once discovered, assign it to a room (e.g., “Front Door” or “Garage Window”) and note the entity ID (e.g., binary_sensor.door_window_sensor_contact). The sensor exposes a binary contact sensor state: ‘on’ when the magnet is separated (door open) and ‘off’ when closed. Optionally, you can also see battery level and link quality. If the sensor doesn’t join, move it closer to the coordinator and try again—Zigbee has a range of about 30 meters indoors.
- Troubleshooting: If the sensor fails to pair, check that your Zigbee coordinator is not busy with too many devices. Remove other devices temporarily if needed.
Step 2: Create Your First Security Alert Automation
Now that the sensor is online, let’s build an automation that triggers an alert when a door opens. In Home Assistant, go to Configuration > Automations & Scenes and click “Create Automation”. Choose “State” as the trigger, then select your DW2’s contact sensor entity and set state to “on”. For the action, you have several options: send a push notification to your phone using the “Notifications” action, flash a smart light (like the SONOFF L1 Smart LED Light Strip) if you have one, or sound a siren via a smart plug. You can also set a condition so the automation only runs when you’re not home—use the “Home/Away” helper or a presence sensor like the SNZB-06P.

For example, create two automations: one for “Door Open While Away” that sends a critical alert, and another for “Door Open While Home” that simply logs the event. Test the automation by opening the door—your phone should buzz within seconds. You can also add a delay before triggering to avoid false alarms (e.g., only alert if the door is open for 10 seconds). The DW2’s instant response makes it ideal for real-time security.
- Pro tip: Use the “And” condition in the trigger to require both the sensor being open and a specific time period (e.g., after sunset) to reduce daytime nuisance alerts.
Step 3: Expand Your DIY Security System
A single door/window sensor is a great start, but you can build a comprehensive alarm system by adding more DW2 sensors on every entry point. For example, place one on the front door, one on the back door, and one on each ground-floor window. To monitor indoor movement, integrate the SONOFF Zigbee Human Presence Sensor SNZB-06P in hallways or living rooms. This sensor detects human presence using millimeter-wave radar and can trigger automations when someone is in a room—even if they are stationary.
You can also use the SONOFF Zigbee Wireless Switch SNZB-01P as a physical arming/disarming switch. Place it near your door: a single press arms the system, a double press disarms it. Combine this with the DW2 sensors, and you have a fully functional DIY home security system that rivals commercial solutions—at a fraction of the cost. All devices integrate seamlessly into Home Assistant, allowing you to create complex automations like “If front door opens and system is armed, sound alarm and send notification”.
- Remember: The DW2-Wi-Fi works with any Zigbee 3.0 coordinator and is fully compatible with Home Assistant, openHAB, and other smart home platforms.
Troubleshooting Common Issues
Even with straightforward setup, you may encounter occasional hiccups. If the sensor stops responding, replace the battery first—low voltage causes connection drops. Ensure the magnet and sensor are aligned within 2 cm of each other; misalignment can cause false triggers. In Home Assistant, if the state doesn’t update, check the Zigbee network health by viewing the device’s ‘Last Seen’ timestamp. If it’s more than 5 minutes old, try re-pairing the sensor.
For automation issues, enable debug logging for the ZHA or Zigbee2MQTT integration to see raw sensor events. Sometimes, a delay in the trigger action can be fixed by adding a short wait (e.g., 500 ms) before the automation runs. Finally, ensure your Zigbee coordinator firmware is up to date—older firmware versions may have compatibility problems with the DW2’s temperature reporting feature. If you still face problems, consult the ITEAD support page or community forums.
- Quick fix: If the sensor reports ‘unknown’ state, remove it from ZHA/Zigbee2MQTT and re-pair it after a power cycle of the coordinator.
Setting up the SONOFF DW2-Wi-Fi Door/Window Sensor with Home Assistant is a straightforward way to add reliable security alerts to your smart home. With just a few steps, you can receive instant notifications whenever a door or window is opened, and by combining it with other Zigbee devices like the SONOFF Zigbee Wireless Switch SNZB-01P or the SONOFF Zigbee Human Presence Sensor SNZB-06P, you can create a powerful DIY alarm system that fits your needs. Ready to get started? Explore the SONOFF DW2-Wi-Fi in the ITEAD store and begin building your smart security system today.



