Persistent notification

The Persistent notification trigger is useful when you want an automation to react to the notifications that Home Assistant shows in the sidebar under Notifications. For example, Home Assistant adds a notification when someone fails to log in. With this trigger, you can forward that notification to your phone, so you don’t miss it.

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. Search for and select the Persistent notification trigger.
  5. Optional: In Notification ID, enter the ID of the notification to react to.
    • Leave it empty to react to all notifications.
  6. Under Update type, select the changes to react to: added, removed, or updated.
    • current is also in the list, but it doesn’t make the trigger react. For details, refer to Good to know.
    • By default, added and removed are selected.
  7. Select Save.

Options in the UI

Notification ID (Optional)

The ID of the notification to react to. Leave it empty to react to all notifications.

Update type (Optional)

The changes to react to:

  • added: A new notification is added.
  • updated: A notification with the same ID is added again, which replaces the existing notification.
  • removed: A notification is dismissed.
  • current: Doesn’t make the trigger react. For details, refer to Good to know.

Default is added and removed.

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.

When this trigger starts an automation, it passes data about what happened to the automation. You can use this trigger data in the templates of your conditions and actions. To see which data is available, refer to Trigger data in templates.

In YAML, use trigger: persistent_notification. A basic example looks like this:

TriggerA trigger is the part of an automation that makes the automation start when something specific happens, for example, when the sun sets, a door opens, or a button is pressed. [Learn more]
trigger: persistent_notification
notification_id: http-login
update_type:
  - added
  - updated

This runs when Home Assistant adds or updates the notification about a failed login attempt.

Options in YAML

trigger string Required

The trigger type. For this trigger, use persistent_notification.

notification_id string (Optional)

The ID of the notification to react to. If you leave it out, the trigger reacts to all notifications.

update_type string | list (Optional)

The changes to react to. You can use added, updated, and removed. current is also accepted, but it doesn’t make the trigger react. If you leave it out, the trigger reacts to all changes.

Good to know

  • The update type current doesn’t make the trigger react. Home Assistant only uses it to send the list of current notifications to the UI. Use added to react to new notifications.
  • When you add a notification with an ID that already exists, it replaces the existing notification. The trigger then reacts with the update type updated, not added.
  • When you dismiss all notifications at once, the trigger reacts once for each notification.
  • The trigger only reacts to changes after the automation starts. When Home Assistant starts, it sets up integrations before it starts automations. Notifications that it adds during startup don’t make the trigger react.
  • For the data that this trigger passes to your conditions and actions, such as trigger.notification.message, refer to Persistent notification triggers.

Try it yourself

Ready to test this? Go to Settings > Automations & scenes, create a new automation, and add this trigger. Save the automation, and then make the trigger react. For example, change the state of the targeted entityAn 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], turn on a light that the trigger monitors, or change its brightness. To check whether the automation ran, open its traces.

For this trigger, create a notification with the Create persistent notification action, for example, in Settings > Tools > Actions. If the trigger has a Notification ID, use the same ID in the action. To test removed, dismiss the notification afterward.

More examples

Real scenarios where this trigger fires in automations and scripts. Copy any example and adapt it to your setup. In the visual editor, select the UI options listed in the example when they are available, or paste the YAML code.

Tip

You don’t need to edit YAML to use these examples. Copy a YAML snippet from this page, open the visual 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 a login attempt fails

When someone fails to log in to Home Assistant, or an app sends a request with invalid authentication, Home Assistant adds a notification with the ID http-login and the title Login attempt failed. If it happens again, Home Assistant updates that notification. This automation sends the message of the notification to your phone. The message includes the address that the request came from.

  • Trigger: Persistent notification
    • Notification ID: http-login
    • Update type: added and updated
  • Action: Send a notification message
    • Target: My Device (notify.my_device)
    • Message: {{ trigger.notification.message }}
YAML example for sending a notification when a login attempt fails
AutomationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more]
alias: "Notify when a login attempt fails"
triggers:
  - trigger: persistent_notification
    notification_id: http-login
    update_type:
      - added
      - updated
actions:
  - action: notify.send_message
    target:
      entity_id: notify.my_device
    data:
      message: "{{ trigger.notification.message }}"

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

Explore related triggers: