Cameras & SecurityTechnician

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.

LevelTechnician
Time1.5 h
Est. cost~$172
Steps6

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.

⚠ SAFETY
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

  1. Have a Zigbee hub

    Complete the Home Assistant and Zigbee hub missions first.

  2. Pair the sensors

    Pair each contact sensor and rename it clearly, like 'Front door' or 'Kitchen window'.

  3. 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).

  4. Create the alarm panel

    Add the manual alarm panel and the trigger automation below to configuration.yaml, then restart.

  5. Add alerts and a siren

    Add a second automation that sends a phone notification when the alarm becomes 'triggered'; a Zigbee siren is optional.

  6. 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_alarm

Tip: 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.