home-assistant.github.io/source/_components/persistent_notification.markdown
andrew-curtis 34b0bdedfa Update persistent_notification.markdown (#619)
included a little 'gotcha' that caught me out for a bit. =)
2016-07-05 06:16:05 -07:00

2.4 KiB

layout title description date sidebar comments sharing footer logo ha_category ha_release
page Persistent notification Instructions on how to integrate persistant notifications into Home Assistant. 2016-06-25 10:00 true false true true home-assistant.png Other 0.23

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

{% linkable_title 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 persistant_notification component 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: persistant_notification.create
  data:
    message: "Your message goes here"
    title: "Custom subject"

{% linkable_title Create a persistant notification %}

Choose service developer tool icon Services from the Developer Tools to call the persistant_notification service. Select persistant_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.

NOTE: if you have defined a default_view: in your Groups: configuration you will need to include persistent_notification.<notification_id> e.g. persistent_notification.1234 as per the example above, to your Groups configuration, in order to see the notification after creating it.