Skip to content

Commit 408ff51

Browse files
nwesterhausenfabaff
authored andcommitted
Add name template example (home-assistant#7716)
Mention that templates can be used in both alert name and message. Add example for alert name templating. Addresses home-assistant#6550 .
1 parent 9f4ed6c commit 408ff51

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

source/_components/alert.markdown

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ sent at 2:15, 2:45, 3:45, 4:45, etc., continuing every 60 minutes.
205205
### {% linkable_title Message Templates %}
206206

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

@@ -230,4 +231,27 @@ alert:
230231

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

234+
The next example uses a template for the alert name.
235+
236+
{% raw %}
237+
```yaml
238+
alert:
239+
garage_door:
240+
name: Garage has been open for {{ relative_time(states.binary_sensor.garage.last_changed) }}
241+
done_message: Garage is closed
242+
entity_id: binary_sensor.garage
243+
state: 'on'
244+
repeat:
245+
- 30
246+
- 60
247+
- 120
248+
can_acknowledge: True
249+
skip_first: True
250+
notifiers:
251+
- ryans_phone
252+
```
253+
{% endraw %}
254+
255+
The resulting title of the alert could be `Garage has been open for 30 min`.
256+
233257
[template]: /docs/configuration/templating/

0 commit comments

Comments
 (0)