A door status sensor is one of the most important but often overlooked elements of home security. Door sensors are tiny devices that detect whether your door or window is open or closed and then send a signal to your smart home server.
By integrating the door sensors with Home Assistant system on Raspberry Pi, you may detect real-time instant changes in door status and receive notifications on your smartphone or sound an alarm on your Alexa Echo smart speakers.

Read on to learn how to build and set up a Wi-Fi-based smart door status sensor for your Home Assistant to improve home security.
Components Needed
To build a smart Wi-Fi-based door status sensor, you will need the following components:
Preparing the Microcontroller
We need to first compile firmware for our D1 mini (ESP8266) using the ESPHome add-on. Follow these steps to install the ESPHome add-on in your Home Assistant server and then use it to compile and download the firmware:
Flash the Firmware to Microcontroller
To flash the firmware, follow these steps:
Wire the Magnetic Switch to Microcontroller
After flashing the firmware, you can connect the magnetic switch to the microcontroller by following these steps:
Integrate the Door Sensor Into Home Assistant
you’re able to now integrate and add this DIY smart Wi-Fi door sensor to your Home Assistant by following these steps:
Install Door Sensor on Door
Determine the optimal location for the magnetic switch. Place the wired part on the door and the magnet part on the brick mold, door frame, or casing of the door. You can also do it vice versa based on your requirements as you will need to power the sensor with a USB power supply.
Alternatively, you could run it on battery, but for that you need to enable deep sleep which requires the use of additional components.

Test and Finalize
You will need to test your door status sensor. For this, turn on the device and open and close the door to observe whether its status updates on the Home Assistant dashboard.
If the switch is working, you can create an automation to receive notifications on your smartphone whenever the door is open or closed.

Enhance Your Home Security With a DIY Door Sensor
Building a door status sensor for Home Assistant is a valuable addition to your smart home setup. With this DIY project, you can enhance your home’s security by staying informed about the status of your doors in real time. Moreover, it serves as a foundation for more advanced automation, such as triggering lights or HVAC systems when a door opens or closes.
You can also set up automation to receive notifications via the Home Assistant app on your smartphone device whenever the door status changes.

