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 <frenck@frenck.nl>

* Update source/_integrations/persistent_notification.markdown

Co-Authored-By: Franck Nijhof <frenck@frenck.nl>

* some nitpicking

Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
akasma74 2020-04-03 13:25:14 +01:00 committed by GitHub
parent 1b8a196e27
commit 9dbf58fc3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 |