banner
News center
Our company provides you with a diverse portfolio of outstanding products and world-class services.

Build a DIY Door Status Sensor for Home Security

Jul 15, 2023

A smart door sensor can send its open or closed status to your Home Assistant server for enhanced home security.

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 can 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.

To build a smart Wi-Fi-based door status sensor, you will need the following components:

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:

To flash the firmware, follow these steps:

After flashing the firmware, you can connect the magnetic switch to the microcontroller by following these steps:

You can now integrate and add this DIY smart Wi-Fi door sensor to your Home Assistant by following these steps:

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.

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.

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.

Ravi is an expert tech explainer, an IoT enthusiast, and a Linux lover with a background in big data and app development. He's a tech geek with over 7 years of experience in creating DIY tech and how-to guides on data recovery, file repair, Exchange Server, Outlook, Microsoft 365, Windows, Mac, Linux, iOS, and smart home.

SettingsAdd-onsAdd-On StoreESPHomeInstallStartStart on BootWatchdog Open Web UI+New DeviceContinueNextSkipEDIT captive_portalSave InstallPlug into this computer. Download project door-status.binInstall ESPHome via the browserOpen ESPHome Web ConnectCOMConnectInstallChoose FileInstallSettings > Devices & Servicesdoor-sensorLogsLogsSettings > Devices & ServicesAdd IntegrationESPHomeSetup another instance of ESPHomeSubmitFinishdoor-status Door Show asUpdate