Series: Part 6/10

Home Assistant Automations: Triggers, Conditions, Scripts, Scenes, and Blueprints.

Home Assistant automations guide: Purpose-specific triggers, conditions, automation modes (restart/single), scripts vs scenes, target exclusions, and trace debugging.

Quick Jump to Sections (Table of Contents)16 sections
01What Is an Automation?02Triggers: What Starts an Automation?03Conditions: Should It Continue?04Actions and Building Blocks05Automation Modes06Scripts: Reusable Action Sequences07Scenes: A Snapshot in Time08Helpers09New in 2026.11: Excluding Targets10Blueprints: Ready-Made Automation Templates11Six Real-World Scenarios12Debugging: Why Didn't My Automation Run?13Rules for Writing Good Automations14Troubleshooting15Frequently Asked Questions16What's Next

Home Assistant Automations: Triggers, Conditions, Scripts, Scenes, and Blueprints

Series: Smart Home with Home Assistant — Part 6 of 10 Level: Beginner to intermediate Reading time: About 25 minutes Last verified: November 18, 2026 (Home Assistant 2026.11.2)

In earlier parts, we installed Home Assistant, organized the home into areas and floors, added Zigbee, Thread, and Z-Wave devices, and in Part 5 built our own CO2 sensor with ESPHome. Now it's time to make all of these devices work together.

Automation is what separates a smart home from a remote-controlled one. Turning on a light from your phone is nice. A light that turns on by itself the moment you step into the hallway, heating that switches off when you open a window, and a house that shuts everything down when the last person leaves are a completely different experience.

In this part we will:

  1. Learn the building blocks of an automation: triggers, conditions, and actions
  2. Get to know the purpose-specific triggers and conditions that arrived in 2025–2026
  3. Use automation modes and building blocks such as wait, choose, and repeat
  4. Understand the difference between scripts, scenes, and helpers
  5. Set up ready-made automations with blueprints
  6. Use the target exclusions introduced in 2026.11
  7. Debug with traces, the Activity panel, and Action history
  8. Build six real-world scenarios from start to finish

What Is an Automation?#

A Home Assistant automation is a rule that waits for something to happen in your home (a trigger), checks whether certain conditions are met (conditions), and, if they are, performs a series of tasks (actions). Every automation has at least one trigger and one action; conditions are optional (Home Assistant — Understanding automations).

In the automation editor, these three parts appear as three sections:

Editor sectionYAML keyQuestion it answers
Whentriggers:What should start it?
And ifconditions:Which conditions must be true to continue?
Then doactions:What should it do?

An automation checks its conditions first, then runs its actions from top to bottom (Home Assistant — Scripts).


Triggers: What Starts an Automation?#

A trigger is the event that starts the automation: the sun setting, a door opening, a button being pressed.

The golden rule: Triggers react to a moment

The most important sentence in the official documentation is this: "A trigger reacts at a specific moment, not while something is true." A door-opened trigger reacts when the door changes from closed to open, and doesn't react again while it stays open. If the door is already open when you save the automation, it won't react until the door closes and opens again (Home Assistant — Automation triggers).

This is the most common beginner mistake. If you mean "when the door is open and it's after 10 PM," the door opening is the trigger and the time is a condition. To act only when two things are both true, add a trigger for each change and a condition for each situation (Home Assistant — Automation triggers).

Purpose-specific triggers

Most automations used to be written with the generic state trigger: "when binary_sensor.front_door changes to on." Home Assistant now offers purpose-specific triggers that describe exactly what you want to happen. The documentation recommends picking them whenever possible: Door opened for a door sensor, Temperature crossed threshold for a temperature reading, or Power crossed threshold for a power reading (Home Assistant — Automation triggers).

Some examples from the trigger reference:

CategoryYAML names
Doors and windowsdoor.opened, door.closed, window.opened, window.closed
Motion and occupancymotion.detected, motion.cleared, occupancy.detected, occupancy.cleared
Lightslight.turned_on, light.turned_off, light.brightness_crossed_threshold
Measurementstemperature.crossed_threshold, humidity.crossed_threshold, power.crossed_threshold
Air qualityair_quality.co2_crossed_threshold, air_quality.pm25_crossed_threshold, air_quality.smoke_detected
Zoneszone.entered, zone.left, zone.occupancy_detected, zone.occupancy_cleared
Sunsun.sunset, sun.sunrise, sun.dusk, sun.golden_hour_started
Otherlock.jammed, battery.became_low, button.pressed, schedule.block_started, homeassistant.updated

A door trigger in YAML is this simple (Home Assistant — Door opened):

trigger: door.opened
target:
  entity_id: binary_sensor.front_door

In YAML, settings specific to the trigger go under options:, while target and general settings like id, alias, enabled, and variables stay at the top level next to trigger (Home Assistant — Door opened).

Multiple targets: Each, First, All

The beauty of purpose-specific triggers is that they can target an area, floor, or label instead of a single entity. You can say "when any light in the living room turns on" or "when all windows on the ground floor close." With multiple targets, the Trigger when option (behavior) decides when it fires (Home Assistant — Light turned on):

OptionYAMLWhen it fires
Eacheach (default)Every time one of the targets changes
FirstfirstThe first time one of the targets changes; it fires again only after none of them is in that state anymore
AllallOnce all targets have made the change, that is, when the last one changes

(Home Assistant — Understanding automations)

Threshold triggers and unit conversion

Measurement triggers convert units automatically, so you can compare a Fahrenheit sensor with a Celsius threshold (Home Assistant — Automation triggers). A threshold comes in four types: above, below, between (crossing into a range), and outside (crossing out of a range). Instead of a fixed number, you can use an input_number helper as the threshold and change it from a dashboard (Home Assistant — Temperature crossed threshold).

trigger: temperature.crossed_threshold
target:
  entity_id: sensor.living_room_temperature
options:
  threshold:
    type: below
    value:
      number: 18
      unit_of_measurement: "°C"
  for: "00:05:00"

The for: option sets how long the reading must stay past the threshold. Here the trigger fires only if the temperature stays below 18 °C for 5 minutes, which prevents false triggers from brief fluctuations (Home Assistant — Temperature crossed threshold).

Generic triggers still work

Generic triggers like state, numeric_state, time, time_pattern, event, mqtt, template, webhook, tag, and homeassistant keep working. The documentation says to use them when you need to watch an exact state, use an attribute, or when no more specific option exists (Home Assistant — Automation triggers).

Important difference: Most triggers that target an entity don't react when the entity transitions from unavailable or unknown. For example, light.turned_on doesn't fire when a light that lost its connection comes back as on, while the generic State changed trigger does react to that transition (Home Assistant — Automation triggers). This is usually a good thing, because it prevents unwanted triggers after a power outage.

What's new in 2026.11: Triggers

  • "Is not" option: In the state trigger, From and To gained an Is not option, so an automation can start when an entity changes to any state except the one you pick, with no YAML needed (Home Assistant 2026.11).
  • After-update trigger: homeassistant.updated fires once after Home Assistant starts on a different version than it ran before. It doesn't fire on a normal restart, and it provides the trigger.from_version and trigger.to_version variables (Home Assistant — Home Assistant updated).
  • People in the target picker: When adding a trigger or condition, you'll find People under Other, next to Time and Sun. That makes "when someone comes home" rules easier to build (Home Assistant 2026.11).

Breaking change: In 2026.11, the sign of offset for sun.* triggers and the calendar.event_started / calendar.event_ended triggers now decides the direction: negative fires before the event, positive fires after. If you wrote one of these in YAML with an offset but without offset_type, flip the sign. Triggers created in the UI always wrote offset_type, so they're not affected (Home Assistant 2026.11).

Trigger IDs

An automation can have multiple triggers, and any of them can start it. To do different things depending on which one fired, give triggers an id. If you omit the ID, Home Assistant uses the trigger's position in the list. You can reference IDs with the Triggered by condition or in templates as trigger.id (Home Assistant — Automation triggers). As of 2026.11, you can set a trigger's ID from its menu again (Home Assistant 2026.11).


Conditions: Should It Continue?#

Conditions check the current state after a trigger has fired. A door opening is an event; "is it night right now" or "is anyone home" are states.

Purpose-specific and generic conditions

As with triggers, conditions have purpose-specific options (Home Assistant — Conditions):

CategoryYAML names
Zones and occupancyzone.in_zone, zone.not_in_zone, zone.occupancy_is_detected, zone.occupancy_is_not_detected
Sunsun.is_up, sun.is_set, sun.is_night, sun.elevation
Doors, windows, motiondoor.is_open, window.is_open, motion.is_detected, motion.is_not_detected
Lights and temperaturelight.is_on, light.is_off, light.is_brightness, temperature.is_value
Schedulesschedule.is_on, schedule.is_off
Genericstate, numeric_state, time, template, trigger, and, or, not

For conditions that target several entities, the Condition passes if option (behavior) decides whether at least one (any, the default) or every one (all) must match (Home Assistant — Light is on).

In Part 5, we checked "is anyone home" using the number of people in zone.home. Here's a more readable version of the same check (Home Assistant — Zone occupancy is detected):

condition: zone.occupancy_is_detected
options:
  zone: zone.home

The time condition and midnight

The time window starts exactly at After and ends just before Before. If Before is earlier than After, the window goes past midnight, so 22:00–06:00 covers the night. Days of the week checks the current day; in a window that goes past midnight, the hours after midnight belong to the next day (Home Assistant — Time condition).

condition: time
after: "22:00:00"
before: "06:00:00"
weekday:
  - mon
  - tue
  - wed
  - thu
  - fri

And, Or, Not

All conditions in the And if section are combined with "and" by default. For more complex logic, there are blocks: Or passes if at least one inside is met, and Not passes if none are. The And block is typically used inside an Or or Not block (Home Assistant — Automation conditions).


Actions and Building Blocks#

An action makes Home Assistant do something: turn on a light, send a notification, activate a scene. Actions run in order from top to bottom; if one fails, the ones after it don't run (Home Assistant — Actions).

Targets

An action can target entities, devices, areas, floors, and labels. If you target an area, all entities in it that support the action are affected. In YAML, use the lowercase IDs, not the names (Home Assistant — Actions):

action: light.turn_on
target:
  area_id: living_room
  entity_id:
    - light.hallway
data:
  brightness_pct: 60

This is why we set up areas and labels carefully in Part 3: when you add a new lamp to the living room, it's included in the target without touching the automation.

Continuing when a step fails

By default, a failed step stops the automation. For steps like an unreliable notification service, continue_on_error: true moves on to the next step anyway. It doesn't ignore configuration errors such as broken templates (Home Assistant — Scripts). If a target is unavailable or doesn't exist, Home Assistant skips that target and logs a warning, which doesn't count as a failure (Home Assistant — Scripts).

Building blocks

Automations and scripts use the same building blocks. A building block controls whether, when, or in what order other steps run (Home Assistant — Scripts). The most common ones:

BlockYAMLWhat it does
DelaydelayWaits for a set time
Wait for triggerwait_for_triggerWaits until something happens, with an optional timeout
Wait for templatewait_templateWaits until a template is true
If-thenif / then / elseBranches on one condition
Choosechoose / defaultRuns the first option whose conditions are met
Repeatrepeat (count, while, until, for_each)Repeats steps
ParallelparallelRuns steps at the same time
VariablesvariablesDefines values for later steps
StopstopEnds the run; scripts can return a response

Every step can have an alias, which is the name shown in the editor and in traces. You can turn a step off without deleting it using enabled: false (Home Assistant — Scripts).


Automation Modes#

The mode decides what happens if an automation is triggered again while it's still running (Home Assistant — Automation modes):

ModeBehaviorTypical use
single (default)Doesn't start a new run while running; logs a warningNotifications, one-off tasks
restartStops the current run, including a running delay or wait, and starts overMotion lighting: each motion resets the timer
queuedStarts the new run after previous runs finish, in orderTasks that must happen in sequence
parallelStarts an independent new run right awayUnrelated events

In queued and parallel modes, max defaults to 10 and has a minimum of 2. The log level used when the limit is exceeded is set by max_exceeded, which defaults to warning (Home Assistant — Automation modes).

Practical tip: If your logs show "Already running" warnings and that's expected, silence them with max_exceeded: silent. If it's unexpected, review the mode.


Scripts: Reusable Action Sequences#

A script is a sequence of actions without a trigger. It doesn't start by itself; you run it from a dashboard, an automation, or the Assist voice assistant. A script has no conditions section; its Sequence steps run right away (Home Assistant — Scripts).

When should you use a script?

  • When the same action sequence is used in several automations, like a "good night" routine
  • When you want to run a sequence from a dashboard button
  • When you want to start a routine by voice

A script that takes parameters (fields)

Scripts can accept values through fields. The example below is adapted from the wake-up script in the official documentation (Home Assistant — Scripts integration):

# scripts.yaml
wake_up:
  alias: "Wake-up routine"
  icon: "mdi:weather-sunset-up"
  description: "Turns on the bedroom lights, then the living room lights a few minutes later."
  mode: restart
  fields:
    minutes:
      name: "Minutes"
      description: "How long to wait before turning on the living room lights"
      default: 5
      selector:
        number:
          min: 0
          max: 60
          step: 1
          unit_of_measurement: minutes
          mode: slider
  sequence:
    - alias: "Bedroom lights"
      action: light.turn_on
      target:
        area_id: bedroom
      data:
        brightness_pct: 30
    - delay:
        minutes: "{{ minutes | default(5) }}"
    - alias: "Living room lights"
      action: light.turn_on
      target:
        area_id: living_room

Two ways to call a script

The difference looks small, but it matters (Home Assistant — Scripts integration):

  • Calling it directly (action: script.wake_up): every value in data becomes a variable in the script.
  • Turn on script (action: script.turn_on): values go under data.variables. The documentation recommends this when you want to start a second script, do other steps, and then wait for it to finish; that way, the first script isn't stopped if the second one fails.
actions:
  - action: script.wake_up
    data:
      minutes: 10

Like automations, scripts have a mode; the default is single (Home Assistant — Scripts integration).


Scenes: A Snapshot in Time#

A scene sets a group of entities to saved states in one step: in a "Movie" scene, the TV backlight is at half brightness, the ceiling light is off, and the TV is on HDMI 1. In a scene, you list the states entities should have, not the actions to get there (Home Assistant — Scenes).

# scenes.yaml
- id: movie_night
  name: "Movie night"
  icon: "mdi:movie-open"
  entities:
    light.tv_backlight:
      state: "on"
      brightness: 80
    light.living_room_ceiling: "off"
    media_player.living_room_tv:
      state: "on"
      source: "HDMI 1"

What you need to know about scenes (Home Assistant — Scenes):

  • A scene has no on or off state. Activating it sets its entities' states; there's nothing to turn off afterward. The scene entity's state is the date and time it was last activated.
  • Only scenes in scenes.yaml that have an id can be edited in the scene editor.
  • When you save a scene in the editor, comments in scenes.yaml are lost.
  • scene.turn_on accepts a transition for smoother changes; transitions only work on lights that support them.

On-the-fly scenes: save first, restore later

scene.create saves the current states of specified entities into a new scene (Home Assistant — Scenes). That's the key to scenarios like "flash the living room lights when the doorbell rings, then restore them." We'll use it in Scenario 6.


Helpers#

Helpers are virtual entities that give your automations "memory" and "settings knobs." You create them on the Settings > Devices & services > Helpers page. Common ones:

HelperEntityExample use
Toggleinput_boolean"Guest mode" or "Vacation mode" switch
Numberinput_numberA temperature or CO2 threshold you can change from a dashboard
Date and/or timeinput_datetimeA wake-up time set from a dashboard
SchedulescheduleWeekly time blocks; used with the schedule.is_on condition
TimertimerA countdown that survives restarts
Dropdowninput_selectHome mode: Home, Away, Sleep

Using helpers as thresholds or times lets you change an automation's behavior without editing it. For example, the time condition accepts an input_datetime helper directly (Home Assistant — Time condition), and a temperature threshold can be an input_number (Home Assistant — Temperature crossed threshold).


New in 2026.11: Excluding Targets#

The biggest automation-related change in 2026.11 is this: you can now exclude entities, devices, areas, floors, and labels from a target (Home Assistant 2026.11).

Scenario: "Turn off all ground-floor lights, but leave the kitchen lights and anything labeled as a night light alone."

In the UI

  • In a trigger, condition, or action, select Exclude target next to Add target, then choose what to leave out.
  • Or open a target's details, clear the checkboxes of the items to exclude, and select Apply.

Each exclusion is listed below the targets it affects, with the number of entities it removes. Exclusions that match nothing appear under Exclusions with no effect, where you can remove them (Home Assistant — Automation targets).

In YAML

Add an exclude block to the target. It uses the same keys as the target, but it can't use all or none, can't contain another exclude block, and isn't a valid target on its own (Home Assistant — Automation targets):

action: light.turn_off
target:
  floor_id: ground_floor
  exclude:
    area_id: kitchen
    label_id: night_light

Exclusions stay smart too

Home Assistant works out exclusions every time the trigger, condition, or action runs. If you exclude the kitchen and add another light to it next month, that light is left out as well (Home Assistant 2026.11).

Details to watch (Home Assistant — Automation targets):

  • An entity excluded by an area, device, floor, or label can't be included again on its own; remove that exclusion instead.
  • If you exclude a group, only the group entity is excluded, not its members.
  • If you exclude an old-style group (like group.downstairs_lights): in actions, the group and all its members are excluded; in triggers and conditions, only the group entity is.

For blueprint authors: Users can add exclusions to a blueprint's target input. Pass the input to target as a whole, as in target: !input lights. A template that reads only part of it, such as lights.entity_id, ignores the exclude block, and the action then also runs on excluded entities (Home Assistant — Selectors).


Blueprints: Ready-Made Automation Templates#

A blueprint is a ready-made automation, often shared by the community, that you turn into your own by filling in a few fields. It's the easiest way to set up complex automations without writing YAML (Home Assistant — Using blueprints).

Built-in blueprints

Home Assistant ships with a few blueprints, such as Motion-activated Light and Zone Notification (Home Assistant — Using blueprints).

  1. Go to Settings > Automations & scenes > Blueprints.
  2. Select the automation blueprint you want; the Type column shows which ones are for automations.
  3. Fill in the fields and select Save.

Importing a blueprint

Home Assistant can import blueprints from the Home Assistant forums, GitHub, GitHub gists, and the Home Assistant website. When importing from another address, it asks you to continue only if you trust the source (Home Assistant — Using blueprints).

  1. On the Blueprints page, select Import blueprint in the bottom-right corner.
  2. Enter the blueprint address and select Preview.
  3. Finish with Import blueprint.

For community blueprints, the Blueprints Exchange category on the Home Assistant Community forum is a good place to start (Home Assistant — Using blueprints).

Updating and taking control

  • Re-import blueprint: When the author publishes a new version, you can re-import the blueprint. This overwrites your current version; if the new version isn't compatible, your automations may break (Home Assistant — Using blueprints).
  • Take control: To change more than a blueprint's fields allow, select Take control from the automation's menu. The automation becomes a regular one; the blueprint and other automations using it don't change. This can't be undone (Home Assistant — Using blueprints).

Security note: A blueprint is code that runs actions in your system. Read what it does in the preview before importing, and don't import blueprints from sources you don't know.

2026.11: Conditional forms

In 2026.11, a blueprint input, or a whole group of inputs, can depend on earlier answers. The blueprint asks only what still applies; a hidden field isn't required and its value isn't saved (Home Assistant 2026.11).

Writing your own blueprint

A simple blueprint skeleton looks like this. Fields to ask the user are defined under input with selectors and used in the automation with !input (Home Assistant — Selectors):

blueprint:
  name: "Alert when a door stays open"
  description: "Sends a notification if the selected door stays open for a while."
  domain: automation
  input:
    door:
      name: "Door sensor"
      selector:
        entity:
          filter:
            - domain: binary_sensor
              device_class: door
    duration:
      name: "Wait time (minutes)"
      default: 5
      selector:
        number:
          min: 1
          max: 60
          unit_of_measurement: minutes

triggers:
  - trigger: door.opened
    target:
      entity_id: !input door
    options:
      for:
        minutes: !input duration

actions:
  - action: notify.mobile_app_my_phone
    data:
      message: "The door has been open for {{ duration }} minutes."

variables:
  duration: !input duration

mode: single

Note: This example is a skeleton and hasn't been tested on a Home Assistant installation by us. Using !input inside options.for, and template support there, follow the limits described in the trigger's documentation. Always test your own blueprint before publishing it.


Six Real-World Scenarios#

In the examples below, entity IDs (like binary_sensor.hallway_motion), area and floor IDs, and the notification service name (notify.mobile_app_my_phone) are examples. If you pick entities in the visual editor, Home Assistant fills in the correct IDs for you. You can copy a YAML snippet and paste it into the visual editor with Ctrl+V (Cmd+V on a Mac) (Home Assistant — Door opened).

Scenario 1: Motion-activated light (restart mode)

Turn on the hallway light when motion is detected, and turn it off after 2 minutes without motion. Only run when the sun has set.

alias: "Hallway - Motion light"
description: "Turns the light on with motion and off after 2 minutes without motion."
mode: restart
triggers:
  - trigger: motion.detected
    target:
      entity_id: binary_sensor.hallway_motion
conditions:
  - condition: state
    entity_id: sun.sun
    state: below_horizon
actions:
  - action: light.turn_on
    target:
      area_id: hallway
    data:
      brightness_pct: 40
  - wait_for_trigger:
      - trigger: motion.cleared
        target:
          entity_id: binary_sensor.hallway_motion
        options:
          for:
            minutes: 2
  - action: light.turn_off
    target:
      area_id: hallway

Why restart? If new motion is detected while the light is on, the automation starts over and the wait resets. In single mode, the new motion would be ignored. The for option of the motion.cleared trigger sets how long the sensor must stay clear (Home Assistant — Motion cleared).

Alternative: You can do the same job without YAML using the built-in Motion-activated Light blueprint.

Scenario 2: Ventilate when CO2 rises (continuing Part 5)

We're using the sensor we built in Part 5. When CO2 stays above 1200 ppm for 10 minutes, turn on ventilation and send a notification.

alias: "Living room - High CO2, ventilate"
mode: single
triggers:
  - trigger: air_quality.co2_crossed_threshold
    target:
      entity_id: sensor.living_room_air_quality_co2
    options:
      threshold:
        type: above
        value:
          number: 1200
      for: "00:10:00"
conditions:
  - condition: zone.occupancy_is_detected
    options:
      zone: zone.home
actions:
  - action: fan.turn_on
    target:
      entity_id: fan.living_room_ventilation
  - action: notify.mobile_app_my_phone
    continue_on_error: true
    data:
      title: "Living room air is getting stuffy"
      message: "CO2 is at {{ states('sensor.living_room_air_quality_co2') }} ppm. Ventilation turned on."

The CO2 threshold is in ppm; a sensor that reports CO2 in another unit never matches (Home Assistant — CO2 crossed threshold). The ESPHome SCD4x component reports ppm, so that's fine.

Scenario 3: Turn everything off when the last person leaves (with exclusions)

If everyone has been away for 10 minutes, turn off all lights, but leave the aquarium light labeled "always on" alone.

alias: "Home empty - Lights off"
mode: single
triggers:
  - trigger: zone.occupancy_cleared
    options:
      zone: zone.home
      for: "00:10:00"
actions:
  - action: light.turn_off
    target:
      floor_id:
        - ground_floor
        - first_floor
      exclude:
        label_id: always_on
  - action: notify.mobile_app_my_phone
    data:
      message: "Nobody is home anymore, so the lights were turned off."

zone.occupancy_cleared fires when a zone goes from occupied to unoccupied, and for sets how long it must stay empty (Home Assistant — Zone occupancy cleared). If you buy another aquarium light tomorrow and give it the "always on" label, you don't need to touch the automation.

Presence tracking caveat: This scenario relies on the person and mobile app location tracking set up in Part 3. Someone who leaves their phone at home or turns off location permissions won't appear to have left. For critical tasks, like arming an alarm, combining several signals is safer.

Scenario 4: Heating off when a window opens, back on when it closes (trigger IDs)

Two triggers and a choose block in one automation:

alias: "Living room - Heating off while window open"
mode: restart
triggers:
  - trigger: window.opened
    target:
      area_id: living_room
    options:
      for: "00:02:00"
    id: window_opened
  - trigger: window.closed
    target:
      area_id: living_room
    options:
      behavior: all
    id: window_closed
actions:
  - choose:
      - conditions:
          - condition: trigger
            id: window_opened
        sequence:
          - action: climate.set_hvac_mode
            target:
              entity_id: climate.living_room
            data:
              hvac_mode: "off"
      - conditions:
          - condition: trigger
            id: window_closed
        sequence:
          - action: climate.set_hvac_mode
            target:
              entity_id: climate.living_room
            data:
              hvac_mode: heat

Here, behavior: all makes heating come back on only when all living room windows are closed. The Triggered by condition (condition: trigger) checks which trigger started the automation and is usually used inside a Choose or If-then block (Home Assistant — Triggered by).

Note: We wrote the options.behavior usage for window.closed based on the same structure shown on the light.turned_on and door.opened pages. Verify it on your system by selecting Trigger when > All in the visual editor. Because climate.turn_on behavior changed for some integrations in 2026.11, setting the mode explicitly with climate.set_hvac_mode is safer (Home Assistant 2026.11).

Regional note (HVAC vs. Hydronic Systems): The climate.set_hvac_mode automation above works identically whether climate.living_room represents a North American forced-air central thermostat, a mini-split heat pump, or a European/UK/Turkish hydronic radiator TRV (such as Sonoff TRVZB). On multi-room combi boiler systems, avoid turning the main boiler relay completely off if only one room's window is open—prefer adjusting that room's TRV target instead.

Scenario 5: Notification after an update

alias: "System - Notify after update"
triggers:
  - trigger: homeassistant.updated
actions:
  - action: notify.mobile_app_my_phone
    data:
      message: >
        Home Assistant was updated from {{ trigger.from_version }}
        to {{ trigger.to_version }}.
        Remember to check your automations and logs.

This trigger fires only when the version changes, not on normal restarts (Home Assistant — Home Assistant updated). It's a handy reminder of the "check after updating" habit we've recommended throughout the series.

Scenario 6: Flash the lights when the doorbell rings, then restore them

alias: "Doorbell - Living room light alert"
mode: single
triggers:
  - trigger: state
    entity_id: binary_sensor.doorbell
    to: "on"
actions:
  - action: scene.create
    data:
      scene_id: before_doorbell
      snapshot_entities:
        - light.living_room_ceiling
        - light.tv_backlight
  - repeat:
      count: 3
      sequence:
        - action: light.turn_on
          target:
            entity_id: light.living_room_ceiling
          data:
            brightness_pct: 100
        - delay:
            milliseconds: 500
        - action: light.turn_off
          target:
            entity_id: light.living_room_ceiling
        - delay:
            milliseconds: 500
  - action: scene.turn_on
    target:
      entity_id: scene.before_doorbell

scene.create saves the lights' current state, repeat flashes three times, and the last step restores the saved scene (Home Assistant — Scenes). The doorbell here is a binary sensor, the same structure as the doorbell example in the official documentation (Home Assistant — Light is on). If your doorbell exposes an event entity instead, select it in the visual editor and use the Event received trigger (event.received) (Home Assistant — Triggers).


Debugging: Why Didn't My Automation Run?#

The first advice in the official troubleshooting guide: "Most problems show up in the trace of the automation, so open the trace first" (Home Assistant — Troubleshooting automations).

Traces

Open the automation and select Traces from the menu in the top right. A trace shows every step of the run as a graph:

What you see in the traceWhat it meansWhat to do
No trace at the expected timeThe trigger didn't reactCheck the trigger and whether the entity actually changed
Stopped because a condition failedA condition didn't passSelect the condition that ends the path and check Step details
Stopped on errorAn action failedSelect the failed action and read the error
Finished but had no effectThe action ran, but the target wasn't what you expectedSelect the action; Step details shows its target

The top of the trace shows which trigger started the run (Triggered by the) (Home Assistant — Troubleshooting automations).

The "Run actions" trap

Run actions skips triggers and conditions and runs only the actions. A manual run has no trigger data: templates like {{ trigger.to_state.state }} have no value, and a Triggered by condition doesn't pass. If the actions work with Run actions but not when the trigger happens, the problem is usually in a trigger or condition (Home Assistant — Troubleshooting automations). Test automations that rely on trigger IDs, like Scenario 4, by making the real event happen.

Debugging tools added in 2026.11

  • "Triggered by" filter in Activity: The Activity panel can show only what a person did, what your automations or scripts did, or what an integration did, like HomeKit or Google Assistant. Accounts that don't belong to a person, such as the one Node-RED uses, count as integrations; entries without a known cause are listed under Other (Home Assistant 2026.11). "Who turned this light on at 3 AM?" is now a few clicks away.
  • Action history: A new Action history tab under Settings > Tools lists the actions called in Home Assistant, with their targets, what caused them, and when. You can copy an entry's data as YAML with one button and open its trace with View trace when there is one (Home Assistant 2026.11).
  • Follow a trace into the run it called: When an automation runs a script or triggers another automation, the step in its trace now has a View trace of link to exactly that run (Home Assistant 2026.11).
  • Integration logs: While debug logging is enabled for an integration, its page banner shows a Show logs button with only that integration's lines (Home Assistant 2026.11).

Editor conveniences

2026.11 added small but useful editor features (Home Assistant 2026.11):

  • Replace: Swap a trigger, condition, or action for another in the same place; compatible settings such as the target are kept.
  • Recently used: The add dialog starts with the items and targets you used recently.
  • Undo: Restore a step you cut by mistake from the notification.
  • Ctrl + Shift + Y (Cmd + Shift + Y on a Mac): Switch between the visual and YAML editors in the automation, script, and scene editors.

You can also explain why a step exists with Add note (Home Assistant — Automation editors). Six months from now, reading your own automation, you'll be glad you did.


Rules for Writing Good Automations#

  1. Prefer purpose-specific triggers. They're easier to read and don't fire falsely on unavailable transitions.
  2. Target areas, floors, and labels instead of entities. New devices are included automatically; manage exceptions with exclude.
  3. Give every automation a meaningful name and description. An "Area - What it does" pattern (for example, "Living room - High CO2, ventilate") keeps the list searchable.
  4. Choose the mode on purpose. restart for motion lighting, single for notifications.
  5. Filter noise with for:. Sensors fluctuate; a wait of 1–5 minutes greatly reduces false triggers.
  6. Run critical logic on the device. Like the CO2 LED in Part 5, logic that must work while Home Assistant is down belongs on the device itself where possible.
  7. Use the new template functions instead of friendly_name. As of 2026.11, the friendly_name attribute is going to be deprecated; use entity_name(), device_name(), and area_name() in templates (Home Assistant 2026.11).
  8. Read breaking changes before updating. Every release note lists changes that affect automations.
  9. Back up. Automations created in the UI are stored in automations.yaml (Home Assistant — Using blueprints), which is included in Home Assistant backups. We'll cover backup strategy in detail in Part 9.

Troubleshooting#

ProblemLikely causeFix
Automation never runsIt's disabled or the trigger didn't happenMake sure it's on; if there's no trace, review the trigger
Didn't run after savingThe entity was already in the trigger stateTriggers react to a moment; change the state and try again
"Already running" warningTriggered again in single modeUse restart or queued if appropriate, or max_exceeded: silent
Motion light turns off too earlyNew motion is ignored in single modeSwitch the mode to restart
Odd triggers after a power outageA generic state trigger reacts to unavailable transitionsUse a purpose-specific trigger or restrict the previous state with from
Sun trigger fires at the wrong timeThe 2026.11 offset sign changeIf written in YAML without offset_type, flip the offset sign
Works with "Run actions" but not for realThe problem is in a trigger or conditionLook for Stopped because a condition failed in the trace
An exclusion does nothingIt doesn't match anythingCheck the Exclusions with no effect list
No notification arrivesWrong service name or app permission offTest the notification alone from Settings > Tools > Actions

Frequently Asked Questions#

Do I need to know YAML to write automations? No. The visual editor now covers almost everything, including purpose-specific triggers and exclusions. YAML is useful for sharing and copying automations and for advanced features like templates.

What's the difference between an automation, a script, and a scene? An automation starts by itself when something happens. A script is an action sequence without a trigger that runs when called. A scene isn't actions at all; it's a saved set of states for a group of entities.

How many automations is too many? There's no official limit, and installations running hundreds of automations are common. The problem is disorder, not numbers; keep things tidy with naming, labels, and notes.

Blueprint or my own automation? If a blueprint you trust covers your need, use it. You can always convert it into a regular automation with Take control and customize it.

Should I use Node-RED? The built-in automation engine is enough for most homes today. If you like flow-based visual programming, Node-RED is a nice alternative; we'll cover it in Part 10.

Do automations work when the internet goes down? Automations that use local devices (Zigbee, Z-Wave, Thread, ESPHome) keep running without the internet. Actions that depend on cloud services, and mobile push notifications, need an internet connection.


What's Next#

Your home now runs itself. In Part 7, we'll focus on how to see and control it:

  • Dashboard design with the Sections view
  • Cards, badges, and the section copy, cut, and paste added in 2026.11
  • The mobile app, widgets, and notification channels
  • A kiosk dashboard for a wall tablet
Complete Guide Series (10 Parts)
10/10 parts published

Complete series overview for building an autonomous, privacy-first smart home: