Skip to content

Commit 33905f4

Browse files
cooglefabaff
authored andcommitted
Add an example explaining complex notifications (home-assistant#2424)
The alert component docs were not clear at all on how to use a notification component that required something like `target` to function. The answer is to wrap it in a `group` notification component so this adds some documentation and examples on how to do that.
1 parent e963a18 commit 33905f4

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

source/_components/alert.markdown

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,29 @@ Configuration variables:
4646

4747
In this example, the garage door status (`input_boolean.garage_door`) is watched and this alert will be triggered when its status is equal to `on`. This indicates that the door has been opened. Because the `skip_first` option was set to `True`, the first notification will not be delivered immediately. However, every 30 minutes, a notification will be delivered until either `input_boolean.garage_door` no longer has a state of `on` or until the alert is acknowledged using the Home Assistant frontend.
4848

49+
For notifiers that require other parameters (such as `twilio_sms` which requires you specify a `target` parameter when sending the notification), you can use the `group` notification to wrap them for an alert. Simply create a `group` notification type with a single notification member (such as `twilio_sms`) specifying the required parameters other than `message` provided by the `alert` component:
50+
51+
```yaml
52+
- platform: group
53+
name: john_phone_sms
54+
services:
55+
- service: twilio_sms
56+
data:
57+
target: !secret john_phone
58+
```
59+
60+
```yaml
61+
freshwater_temp_alert:
62+
name: "Warning: I have detected a problem with the freshwater tank temperature"
63+
entity_id: binary_sensor.freshwater_temperature_status
64+
state: 'on'
65+
repeat: 5
66+
can_acknowledge: true
67+
skip_first: false
68+
notifiers:
69+
- john_phone_sms
70+
```
71+
4972
### {% linkable_title Complex Alert Criteria %}
5073

5174
By design, the `alert` component only handles very simple criteria for firing. That is, is only checks if a single entity's state is equal to a value. At some point, it may be desireable to have an alert with a more complex criteria. Possibly, when a battery percentage falls below a threshold. Maybe you want to disable the alert on certain days. Maybe the alert firing should depend on more than one input. For all of these situations, it is best to use the alert in conjunction with a `Template Binary Sensor`. The following example does that.

0 commit comments

Comments
 (0)