From 9dbf58fc3a5035a86783e8e2378ef1d8fc30eac3 Mon Sep 17 00:00:00 2001 From: akasma74 Date: Fri, 3 Apr 2020 13:25:14 +0100 Subject: [PATCH] change service call description (#12647) * Update persistent_notification.markdown Based on this topic - https://community.home-assistant.io/t/changing-input-number-doesnt-work/183335 I think it's better to have notes about templates in the service data description rather than separately (so easy to miss it) I also added an example with templates just to give users a practical idea as this "This will allow you to use the current state of Home Assistant in your notifications" sounds very abstract ;) * Update source/_integrations/persistent_notification.markdown Co-Authored-By: Franck Nijhof * Update source/_integrations/persistent_notification.markdown Co-Authored-By: Franck Nijhof * some nitpicking Co-authored-by: Franck Nijhof --- .../persistent_notification.markdown | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/source/_integrations/persistent_notification.markdown b/source/_integrations/persistent_notification.markdown index 097a1f7ab74..4a273ff1313 100644 --- a/source/_integrations/persistent_notification.markdown +++ b/source/_integrations/persistent_notification.markdown @@ -22,13 +22,11 @@ The service `persistent_notification.create` takes in `message`, `title`, and `n | Service data attribute | Optional | Description | | ---------------------- | -------- | ----------- | -| `message` | no | Body of the notification. -| `title` | yes | Title of the notification. +| `message` | no | Body of the notification. Accepts [templates](/topics/templating/). +| `title` | yes | Title of the notification. Accepts [templates](/topics/templating/). | `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](/topics/templating/) 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](/getting-started/automation-action/) of your [automation setup](/getting-started/automation/) it could look like this with a customized subject. +Here is how an [action](/getting-started/automation-action/) of your [automation setup](/getting-started/automation/) with static content could look like. ```yaml action: @@ -38,6 +36,21 @@ action: title: "Custom subject" ``` +If you want to show some runtime information, you have to use [templates](/topics/templating/ inside `data_template`. + +{% raw %} + +```yaml +action: + service: persistent_notification.create + data_template: + title: > + Thermostat is {{ state_attr('climate.thermostat', 'hvac_action') }} + message: "Temperature {{ state_attr('climate.thermostat', 'current_temperature') }}" +``` + +{% endraw %} + The service `persistent_notification.dismiss` requires a `notification_id`. | Service data attribute | Optional | Description |