Skip to main content
Automations are the heart of Home Assistant’s smart home capabilities. They allow you to automatically respond to events and conditions in your home by executing actions.

What is an Automation?

An automation is a rule that consists of three main components:
  1. Triggers: What starts the automation
  2. Conditions: Optional checks that must pass for actions to execute
  3. Actions: What happens when triggered (and conditions pass)

Automation Structure

Automations in Home Assistant are represented as entities with the domain automation. The automation component is implemented in homeassistant/components/automation/.

Automation Entity

Each automation is an entity that extends ToggleEntity and RestoreEntity:

Key Properties

  • entity_id: Format is automation.<automation_name>
  • state: Either “on” (enabled) or “off” (disabled)
  • last_triggered: Timestamp of last execution
  • mode: Execution mode (single, restart, queued, parallel)

Triggers

Triggers define when an automation should run. Common trigger types include:

State Triggers

Fire when an entity changes state:

Time Triggers

Fire at specific times:

Event Triggers

Fire when an event occurs:

Numeric State Triggers

Fire when a numeric value crosses a threshold:
Home Assistant supports many more trigger types including sun, zone, template, webhook, and more.

Conditions

Conditions are optional checks that must evaluate to true for the automation’s actions to execute.

Common Condition Types

Actions

Actions define what happens when the automation is triggered (and conditions pass).

Service Calls

Sequences

Actions can include delays and multiple steps:

Conditional Actions

Use choose for conditional action execution:

Automation Modes

Automations support different execution modes when triggered while already running:

Variables

Automations can use variables for dynamic behavior:

Trigger Variables

Variables available in automation context:
  • trigger.platform: Trigger platform that fired
  • trigger.entity_id: Entity that triggered
  • trigger.from_state: Previous state object
  • trigger.to_state: New state object
  • trigger.event: Event object (for event triggers)

Managing Automations

Services

Automations respond to standard services:

Reload Automations

Automation Helper Functions

The automation component provides helper functions for working with automations:

Tracing and Debugging

Home Assistant provides tracing capabilities for automations:
Traces show:
  • Execution path through the automation
  • Trigger data
  • Variable values at each step
  • Action results
  • Timing information

Blueprints

Blueprints allow you to create reusable automation templates:

Creating Automations Programmatically

Best Practices

Meaningful Names

Use descriptive aliases that explain what the automation does.

Use Conditions

Avoid unnecessary action executions by using appropriate conditions.

Choose the Right Mode

Select an execution mode that matches your automation’s behavior requirements.

Enable Tracing

Use trace storage for debugging complex automations.

Test Thoroughly

Test automations manually using the trigger service before relying on them.

Events

Automations fire events that can be used for monitoring:
  • automation_triggered: Fired when an automation is triggered
  • automation_reloaded: Fired when automations are reloaded

Scripts

Learn about reusable action sequences

Scenes

Understand scene activation and management

Triggers

Explore available trigger platforms

Conditions

Learn about condition types