Automation

An automation in Home Assistant is a rule that runs one or more actions automatically when a trigger condition is met — the core mechanism behind every smart home behaviour.

An automation in Home Assistant is a rule that executes one or more actions automatically when a specified trigger occurs. Every automated behaviour in a smart home — a light that turns on when motion is detected, a notification sent when a door opens, a heating system that adjusts based on weather forecast — is an automation at its core. Home Assistant’s automation engine is the mechanism that makes all of it possible, and understanding how it works unlocks the full potential of the platform.

Every automation is built from three components. The trigger defines what starts the automation: a state change in an entity, a time of day, a sunrise or sunset offset, an MQTT message, a numeric threshold being crossed, or a webhook being called. The condition is an optional filter that must be true at the moment the trigger fires for the automation to proceed — the time is within a certain window, a person is home, a device is in a specific state. The action is what happens when the trigger fires and all conditions are met: call a service, turn a device on or off, send a notification, run a script, or trigger another automation. A single automation can chain multiple actions in sequence, in parallel, or with delays between them.

Home Assistant automation flow: a trigger, then a condition, then an action

Automations are created and edited in the Home Assistant automation editor, which provides a visual interface for building trigger, condition, and action blocks without writing YAML. The editor covers the most common use cases with a point-and-click form, while the underlying YAML — accessible via the editor’s code view — gives full access to every available option including templating, repeat loops, choose branches, and parallel action execution. Most users start in the visual editor and move to YAML selectively as their automations grow more complex. Automations can also be imported and shared as Blueprints, which abstract the entity-specific details into a reusable template that anyone can configure for their own installation.

Pro Tip: Use the trace tool to debug failing automations
When an automation doesn’t fire as expected, Home Assistant’s automation trace tool shows you exactly what happened: which trigger fired, whether conditions passed or failed, and which actions executed. Each trace is a step-by-step record of the automation’s execution path, with the actual values of every entity and template at the moment the automation ran. It’s the fastest way to diagnose why an automation behaved unexpectedly — far faster than adding log entries or guessing at timing issues.

Home Assistant distinguishes between automations and scripts, which are closely related but serve different purposes. An automation is always triggered by an event — it runs in response to something that happens. A script is a reusable sequence of actions that must be called explicitly, either from an automation, from the dashboard, or from another script. For logic that needs to run in multiple automations, extracting it into a script and calling it from each automation keeps the configuration clean and avoids duplication. Node-RED offers a third approach for automations that require branching logic, loops, or data transformation that the built-in editor handles poorly.

🏠 Fun Fact: Home Assistant’s automation engine has been rewritten twice since the platform launched in 2013 — first in 2016 to introduce the trigger/condition/action model that still exists today, and again in 2021 to add the visual editor and the trace debugging tool. The 2021 rewrite reduced the most common automation support questions on the community forum by a significant margin, largely because the trace tool made self-diagnosis possible for the first time.

Related Articles

Sources