Skip to content

Add name template example #7716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion source/_components/alert.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ sent at 2:15, 2:45, 3:45, 4:45, etc., continuing every 60 minutes.
### {% linkable_title Message Templates %}

It may be desirable to have the alert notifications include information
about the state of the entity.
about the state of the entity. [Templates](/docs/configuration/templating/)
can be used in the message or name of the alert to make it more relevant.
The following will show for a plant how to include the problem `attribute`
of the entity.

Expand All @@ -230,4 +231,27 @@ alert:

The resulting message could be `Plant Officeplant needs help (moisture low)`.

The next example uses a template for the alert name.

{% raw %}
```yaml
alert:
garage_door:
name: Garage has been open for {{ relative_time(states.binary_sensor.garage.last_changed) }}
done_message: Garage is closed
entity_id: binary_sensor.garage
state: 'on'
repeat:
- 30
- 60
- 120
can_acknowledge: True
skip_first: True
notifiers:
- ryans_phone
```
{% endraw %}

The resulting title of the alert could be `Garage has been open for 30 min`.

[template]: /docs/configuration/templating/