How to Create Security Automations in Home Assistant
Learn to build advanced home security automations in Home Assistant with YAML, blueprints, and node-RED for local, private, and powerful protection.
Why Home Assistant for Security?
Home Assistant (HA) is the only major smart home platform that runs completely locally, stores no data in the cloud, and gives you full programmatic control over every device. For security, this means:
- Automations fire even if your internet is down
- Your security data never leaves your network
- You can build automations that no commercial platform supports
- Advanced logic: multi-condition chains, cooldown periods, state-history checks
Home Assistant runs on a Raspberry Pi 4, an Intel NUC, or a dedicated Home Assistant Green device. The HAOS (Home Assistant Operating System) installation is recommended for security use — it gets automatic updates and simplifies add-on management.
Setting Up the Alarm Control Panel
Home Assistant includes a built-in Alarm Control Panel integration that provides professional-grade armed/disarmed mode management.
Configuration in configuration.yaml
The alarm panel is configured using the manual platform. Key parameters include the disarm code, arming time (seconds after the arm command before the system goes live), delay time (seconds after trigger before the siren sounds), and trigger time (how long the siren runs). The armed_home mode can be set with zero arming and delay times for instant arm when you're home.
Key settings explained: - arming_time — seconds after "arm" command before system is live (lets you exit) - delay_time — seconds after trigger before alarm sounds (lets you disarm after entry) - trigger_time — seconds the alarm sounds before auto-reset
Core Security Automations
Automation 1: Trigger Alarm on Door Open (Armed Away Mode)
A critical automation watches all entry-point binary sensors. When any door opens while the alarm panel is in the armed_away state, it calls the alarm_trigger service and sends a critical mobile push notification. The iOS critical interruption level bypasses Do Not Disturb — essential for security alerts.
Key components: - Trigger: state change on all door/window binary sensors to "on" - Condition: alarm panel state is armed_away - Actions: trigger alarm service plus mobile notification with critical priority
Automation 2: Motion Detection Alert With Camera Snapshot
This automation fires only at night and only when armed away. When motion is detected, it first saves a camera snapshot to a timestamped file path, then sends a mobile notification with the snapshot image attached.
Key components: - Trigger: motion sensor state change to "on" - Conditions: alarm armed_away AND time is between 22:00 and 06:00 - Actions: camera.snapshot service then notify with image path
Automation 3: Auto-Arm Away When Everyone Leaves
This automation uses a family presence group. When everyone leaves, it waits 2 minutes (to prevent false arms when someone steps outside briefly), checks that everyone is still away, then arms the system and locks all doors.
Key components: - Trigger: family group state changes to "not_home" - 2-minute delay with re-check condition - Actions: alarm arm_away plus lock all Z-Wave doors
Using Blueprints for Security
Home Assistant Blueprints are pre-built automation templates you can import and configure without writing YAML. The community blueprint library includes dozens of security-focused templates:
| Blueprint | Function |
|---|---|
| Motion-activated camera alert | Photo notification on motion |
| Door open warning at night | Announce on speaker if door left open |
| Alarm triggered response | Multi-action response to alarm trigger |
| Person detection alert | Notify only when a person (not animal) detected |
To import a blueprint: 1. Go to Settings then Automations and Scenes then Blueprints then Import Blueprint 2. Paste the GitHub URL of the blueprint YAML file 3. Click Import, then configure the blueprint with your devices 4. Save as automation
Node-RED for Complex Security Logic
For advanced security flows that exceed YAML's readability, Node-RED (available as a Home Assistant add-on) provides a visual automation editor with more complex logic support.
Node-RED example flow: Intrusion with confirmation
- Trigger: Door sensor opens
- Check: Alarm is armed
- Wait 30 seconds
- Check again: Door still open? If yes, trigger alarm plus notify
- If door closed within 30 seconds: send "possible false alarm" notification only
This two-step confirmation pattern dramatically reduces false alarm sirens from delivery drivers opening a storm door.
Notification Best Practices
Configure multiple notification channels so no alert is missed:
- **Mobile app** — Home Assistant companion app push notifications (primary)
- **SMS via Twilio** — fallback if phone app fails
- **Telegram bot** — great for shared family group
- **Persistent notification** — stays in HA dashboard until acknowledged
Use the notify.notify service in automations to broadcast to all configured channels simultaneously with one action.
Home Assistant's security automation capability exceeds every commercial platform available — the investment in setup pays off in a system you fully control, understand, and trust.
For informational purposes only. Not legal advice. Consult a licensed attorney.