Home Assistant

The Home Assistant trigger is useful when you want an automation to run when Home Assistant starts or begins shutting down. Use it to restore part of your setup after a restart, send a status message, or save state before maintenance.

Using this trigger from the user interface

If you prefer building automations visually, Home Assistant walks you through this trigger step by step. You pick what to watch, tweak a few options, and save. No YAML knowledge required.

To use this trigger in an automation:

  1. Go to Settings > Automations & scenes.
  2. Open an existing automation, or select Create automation > Create new automation.
  3. In the When section, select Add trigger.
  4. Select the type of trigger to add.
  5. Select Home Assistant.
  6. Under Event:, select Start or Shutdown.
  7. Select Save.

Options in the UI

Event

Select whether the automation should run when Home Assistant starts or shuts down.

Using this trigger in YAML

If you work directly in YAML, or you want to know exactly what Home Assistant does under the hood, this section has the technical reference. It lists the field names you use in YAML, their types, and which ones are required.

In YAML, use trigger: homeassistant with event: start or event: shutdown. A basic example looks like this:

TriggerA trigger is a set of values or conditions of a platform that are defined to cause an automation to run. [Learn more]
trigger: homeassistant
event: start

This runs when Home Assistant starts.

Options in YAML

trigger string Required

The trigger type. For this trigger, use homeassistant.

event string Required

The Home Assistant lifecycle event to watch. Use start or shutdown.

Good to know

  • Use start to run an automation after Home Assistant finishes starting.
  • Use shutdown to run an automation before Home Assistant stops. Shutdown automations have 20 seconds to run.
  • This trigger does not use a target because it applies to the Home Assistant instance itself.

Try it yourself

Ready to test this? Go to Settings > Automations & scenes, create a new automation, and add this trigger. Save the automation, then change the state of the targeted entity to watch the trigger fire on your actual entitiesAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more].

For this trigger, there is no target entity to change. To test it, restart Home Assistant from Settings > System > Restart.

More examples

Real scenarios where this trigger fires in automations and scripts. Copy any example and adapt it to your setup.

Tip

You don’t need to edit YAML to use these examples. Copy a YAML snippet from this page, open the automation editor in Home Assistant, and press Ctrl+V (or Cmd+V on Mac). Home Assistant automatically converts the pasted YAML into the visual editor format, whether it’s a full automation, a single trigger, a condition, or an action.

Automation: send a notification when Home Assistant starts

If you restart Home Assistant for an update or maintenance, this automation lets you know when it is ready again.

  • Trigger: Home Assistant
    • Event: Start
  • Action: Send a notification message
    • Target: My Device (notify.my_device)
YAML example for notifying when Home Assistant starts
AutomationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more]
alias: "Notify when Home Assistant starts"
triggers:
  - trigger: homeassistant
    event: start
actions:
  - action: notify.send_message
    target:
      entity_id: notify.my_device
    data:
      message: "Home Assistant has started."

Automation: save persistent states before Home Assistant shuts down

If you are about to restart or stop Home Assistant, this automation tells Home Assistant to save persistent states right away.

  • Trigger: Home Assistant
    • Event: Shutdown
  • Action: Save persistent states
YAML example for saving persistent states before shutdown
AutomationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more]
alias: "Save persistent states before shutdown"
triggers:
  - trigger: homeassistant
    event: shutdown
actions:
  - action: homeassistant.save_persistent_states

Still stuck?

The Home Assistant community is quick to help: join Discord for real-time chat, post on the community forum with the trigger you’re using and what you expected to happen, or share on our subreddit /r/homeassistant.

Tip

AI assistants like ChatGPT or Claude can also explain triggers or suggest the right one when you describe what you want in plain language.

Related triggers

These triggers work well alongside this one:

  • Manual event received: Triggers when an event is received.

  • Time: Triggers at a specific time, or from a date/time helper or timestamp-style sensor.