home-assistant.io/source/_components/persistent_notification.markdown
Franck Nijhof c464056402
Making our website faster, cleaner and prettier (#9853)
* 🔥 Removes octopress.js

* 🔥 Removes use of root_url var

* 🔥 Removes Octopress generator reference from feed

* 🔥 Removes delicious support

* 🔥 Removes support for Pinboard

* 🔥 Removes support for Disqus

* 🔥 Removes support for Google Plus

* ↩️ Migrate custom after_footer to default template

* ↩️ Migrate custom footer to default template

* ↩️ Migrate custom header to default template

* 🔥 Removes unused template files

* 🚀 Places time to read directly in post template

* 🚀 Removes unneeded capture from archive_post.html template

* 🔥 🚀 Removes unused, but heaving sorting call in component page

* 🚀 Merged javascripts into a single file

* 🔥 Removes more uses of root_url

* 🚀 Removal of unneeded captures from head

* 🔥 🚀 Removal of expensive liquid HTML compressor

* 🔥 Removes unneeded templates

* 🚀 Replaces kramdown with GitHub's CommonMark 🚀

* 💄 Adds Prism code syntax highlighting

*  Adds support for redirect in Netlify

* ↩️ 🔥 Let Netlify handle all developer doc redirects

* ✏️ Fixes typo in redirects file: Netify -> Netlify

* 🔥 Removes unused .themes folder

* 🔥 Removes unused aside.html template

* 🔥 Removes Disqus config leftover

* 🔥 Removes rouge highlighter config

* 🔥 Removes Octopress 🎉

* 💄 Adjust code block font size and adds soft wraps

* 💄 Adds styling for inline code blocks

* 💄 Improve styling of note/warning/info boxes + div support

* 🔨 Rewrites all note/warning/info boxes
2019-07-15 22:17:54 +02:00

3.6 KiB

title, description, logo, ha_category, ha_release, ha_qa_scale
title description logo ha_category ha_release ha_qa_scale
Persistent notification Instructions on how to integrate persistent notifications into Home Assistant. home-assistant.png
Other
0.23 internal

The persistent_notification can be used to show a message on the frontend that has to be dismissed by the user.

Service

The service persistent_notification/create takes in message, title, and notification_id.

Service data attribute Optional Description
message no Body of the notification.
title yes Title of the notification.
notification_id yes If notification_id is given, it will overwrite the notification if there already was a notification with that ID.

The persistent_notification integration supports specifying templates for both the message and the title. This will allow you to use the current state of Home Assistant in your notifications.

In an action of your automation setup it could look like this with a customized subject.

action:
  service: persistent_notification.create
  data:
    message: "Your message goes here"
    title: "Custom subject"

The service persistent_notification/dismiss requires a notification_id.

Service data attribute Optional Description
notification_id no the notification_id is required to identify the notification that should be removed.

This service allows you to remove a notifications by script or automation.

action:
  service: persistent_notification.dismiss
  data:
    notification_id: "1234"

This automation example shows a notification when the Z-Wave network is starting and removes it when the network is ready.

- alias: 'Z-Wave network is starting'
  trigger:
    - platform: event
      event_type: zwave.network_start
  action:
    - service: persistent_notification.create
      data:
        title: "Z-Wave"
        message: "Z-Wave network is starting..."
        notification_id: zwave

- alias: 'Z-Wave network is ready'
  trigger:
    - platform: event
      event_type: zwave.network_ready
  action:
    - service: persistent_notification.dismiss
      data:
        notification_id: zwave

Markdown support

The message attribute supports the Markdown formatting syntax. Some examples are:

Type Message
Headline 1 # Headline
Headline 2 ## Headline
Newline \n
Bold **My bold text**
Cursive *My cursive text*
Link [Link](https://home-assistant.io/)
Image ![image](/local/my_image.jpg)

/local/ in this context refers to the .homeassistant/www/ folder.

Create a persistent notification

Choose service developer tool icon Services from the Developer Tools to call the persistent_notification service. Select persistent_notification/create from the list of Available services: and enter something like the sample below into the Service Data field and hit CALL SERVICE.

{
  "notification_id": "1234",
  "title": "Sample notification",
  "message": "This is a sample text"
}

This will create the notification entry shown above.