Home Assistant -- Automations¶
Last Updated: YYYY-MM-DD Status:
1. Design Principles¶
- One automation per concern - don't mix logic
- Helper-driven state - use
input_boolean,input_datetimeetc. as single source of truth - Test before production - notifications first, actions later
- Rate-limit notifications - use cooldowns to avoid spam
- Document the "why" - each automation should explain its purpose and design decisions
2. Helper Entities¶
Helpers provide shared state between automations. Define them before writing automations that depend on them.
| Helper | Type | Purpose |
|---|---|---|
| input_boolean.alarm_armed | Toggle | Alarm system state (armed/disarmed) |
| input_boolean.guest_mode | Toggle | Disable certain automations for guests |
3. Automation Categories¶
3.1 Security¶
Automations related to alarm, doors, and presence.
Door Monitoring (Example)¶
Purpose: Notify when a monitored door opens while alarm is armed.
Triggers: Door contact sensor state change
Conditions: input_boolean.alarm_armed is ON
Actions: Push notification with door status
Design Notes: - Use entry delay (e.g., 30 seconds) to avoid false alarms from GPS presence lag - Physical sensors trigger instantly; GPS presence takes seconds to minutes - After delay, re-check if alarm is still armed before notifying
# TODO: Add your automation YAML here
3.2 Lighting¶
Automations related to light control, scenes, and schedules.
Bedtime Lights (Example)¶
Purpose: Dim lights at a scheduled time.
Triggers: Time trigger
Actions: Set light brightness, turn off unnecessary lights
# TODO: Add your automation YAML here
3.3 Environmental¶
Automations related to temperature, humidity, and climate.
3.4 Devices¶
Automations related to specific devices (TVs, plugs, buttons).
3.5 Network¶
Automations related to internet connectivity and network health.
Internet Connection Lost (Example)¶
Purpose: Notify when WAN connectivity drops.
Triggers: Router integration reports WAN disconnected for 2 minutes
Actions: Push notification
3.6 System¶
Automations related to HA itself, backups, and infrastructure.
- HA startup notification
- Low disk space warning
- Backup failure alerts
- Low battery device notifications
- Heartbeat pings to Healthchecks.io
3.7 UPS / Power¶
Automations related to UPS events and power management.
- Power lost notification
- Power restored notification
- Battery critically low warning
4. Rate Limiting & Anti-Spam Strategy¶
Prevent notification fatigue with cooldowns:
| Automation Type | Cooldown | Reason |
|---|---|---|
| Door alerts | 5 min | Doors open/close frequently |
| UPS events | 15 min | Power can flicker |
| System health | 1 hour | Avoid spam during ongoing issues |
| Presence | 5 min | GPS can bounce |
Implementation pattern:
# Use last_triggered to implement cooldowns
conditions:
- condition: template
value_template: >
{{ (now() - state_attr('automation.my_automation', 'last_triggered')).total_seconds() > 300 }}
5. Testing Strategy¶
Before Deploying¶
- Trace mode: Use HA Developer Tools -> Traces to debug
- Notification only: Start with notifications before adding actions
- Single device: Test with one device before expanding
- Edge cases: Consider: what if device is unavailable? What if condition is already true?
Common Pitfalls¶
- YAML multi-line templates (
|) include whitespace - use single-line or| trim - GPS presence detection is slow (seconds to minutes) vs sensor triggers (milliseconds)
- String comparison vs boolean: use
| boolinstead of comparing to"True"/"False"
6. Future Automations¶
- Vacation mode (randomize lights)
- Guest mode (disable alarms, enable guest WiFi)
- Energy optimization (turn off standby devices)
7. Related Documentation¶
- Architecture: home_assistant.md
- Scripts: scripts.md
- Integrations: integrations.md
- Dashboards: dashboards.md