DIY Home Alarm with Zigbee Door and Window Sensors
Arm and disarm from your phone or a wall tablet, with entry delays and alerts when a door or window opens.
Battery-powered Zigbee contact sensors last a year or more and cost little. Home Assistant's built-in manual alarm panel adds arming modes, exit and entry delays, and a code — all running locally.
This is a self-monitored alarm: nobody calls emergency services for you. If you need professional monitoring or your insurer requires it, use a licensed alarm company.
Mission steps
Have a Zigbee hub
Complete the Home Assistant and Zigbee hub missions first.
Pair the sensors
Pair each contact sensor and rename it clearly, like 'Front door' or 'Kitchen window'.
Mount them
Stick the sensor on the frame and the magnet on the door or window, with the gap the instructions allow (usually under 1 cm).
Create the alarm panel
Add the manual alarm panel and the trigger automation below to configuration.yaml, then restart.
Add alerts and a siren
Add a second automation that sends a phone notification when the alarm becomes 'triggered'; a Zigbee siren is optional.
Test every sensor
Arm the alarm, open each door and window one by one and confirm the alert arrives.
Code
alarm_control_panel:
- platform: manual
name: Home Alarm
code: "1234" # change this
arming_time: 30
delay_time: 20
trigger_time: 120
automation:
- alias: Alarm - door or window opened
triggers:
- trigger: state
entity_id:
- binary_sensor.front_door_contact
- binary_sensor.kitchen_window_contact
to: "on"
conditions:
- condition: state
entity_id: alarm_control_panel.home_alarm
state: [armed_away, armed_home]
actions:
- action: alarm_control_panel.alarm_trigger
target:
entity_id: alarm_control_panel.home_alarmTip: test every script on the bench before installing it in a moving machine.
Questions
What if the power or internet goes out?
Put the Pi and router on a UPS (see the UPS mission). Without internet, the alarm still works locally but phone notifications cannot be delivered.