|
| 1 | +--- |
| 2 | +layout: page |
| 3 | +title: "Alert" |
| 4 | +description: "Instructions how to setup automatic alerts within Home Assistant." |
| 5 | +date: 2017-01-15 20:00 |
| 6 | +sidebar: true |
| 7 | +comments: false |
| 8 | +sharing: true |
| 9 | +footer: true |
| 10 | +logo: home-assistant.png |
| 11 | +ha_category: Automation |
| 12 | +ha_release: 0.37 |
| 13 | +--- |
| 14 | + |
| 15 | +The `alert` component is designed to notify you when problematic issues arise. |
| 16 | +For example, if the garage door is left open, the `alert` component can be |
| 17 | +used remind you of this by sending you repeating notifications at customizable |
| 18 | +intervals. This is also useful for low battery sensors, water leak sensors, |
| 19 | +or any condition that may need your attention. |
| 20 | + |
| 21 | +Alerts will add an entity to the front end only when they are firing. This |
| 22 | +entity allows you to silence an alert until it is resolved. |
| 23 | + |
| 24 | +### {% linkable_title Basic Example %} |
| 25 | + |
| 26 | +The `alert` component makes use of any of the `notifications` components. |
| 27 | +To setup the `alert` component, first, you must setup a `notification` |
| 28 | +component. Then, add the following to your configuration file: |
| 29 | + |
| 30 | +```yaml |
| 31 | +# Example configuration.yaml entry |
| 32 | +alert: |
| 33 | + garage_door: |
| 34 | + name: Garage is open |
| 35 | + entity_id: input_boolean.garage_door |
| 36 | + state: 'on' # Optional, 'on' is the default value |
| 37 | + repeat: 30 |
| 38 | + backoff: 1.0 # Optional, default is 1 |
| 39 | + max_repeat: 120 # Optional, default is 1440 |
| 40 | + min_repeat: 15 # Optional, default is 1 |
| 41 | + can_acknowledge: True # Optional, default is True |
| 42 | + skip_first: True # Optional, false is the default |
| 43 | + notifiers: |
| 44 | + - ryans_phone |
| 45 | + - kristens_phone |
| 46 | +``` |
| 47 | +Configuration variables: |
| 48 | +
|
| 49 | +- **name** (*Required*): The friendly name of the alert. |
| 50 | +- **entity_id** (*Required*): The ID of the entity to watch. |
| 51 | +- **state** (*Optional*): The problem condition for the entity. |
| 52 | +- **repeat** (*Required*): Number of minutes the notification should be repeated. |
| 53 | +- **backoff** (*Optional*): Factor to allow the repeat delay to be dynamically changed. |
| 54 | +- **max_repeat** (*Optional*): Maximum possible delay when `backoff` is used. |
| 55 | +- **min_repeat** (*Optional*): Minimum possible delay when `backoff` is used. |
| 56 | +- **can_acknowledge** (*Optional*): Allows the alert to be unacknowledgable. |
| 57 | +- **skip_first** (*Optional*): Controls whether the notification should be sent immediately. |
| 58 | +- **notifiers** (*Required*): List of `notification` components to use for alerts. |
| 59 | + |
| 60 | +In this example, the garage door status (`input_boolean.garage_door`) is |
| 61 | +watched and this alert will be triggered when its status is equal to `on`. |
| 62 | +This indicates that the door has been opened. Because the `skip_first` |
| 63 | +option was set to `True`, the first notification will not be delivered |
| 64 | +immediately. However, every 30 minutes, a notification will be delivered until |
| 65 | +either `input_boolean.garage_door` no longer has a state of `on` or until the |
| 66 | +alert is acknowledged using the Home Assistant frontend. |
| 67 | + |
| 68 | +### {% linkable_title Complex Alert Criteria %} |
| 69 | + |
| 70 | +By design, the `alert` component only handles very simple criteria for firing. |
| 71 | +That is, is only checks if a single entity's state is equal to a value. At some |
| 72 | +point, it may be desireable to have an alert with a more complex criteria. |
| 73 | +Possibly, when a battery percentage falls below a threshold. Maybe you want to |
| 74 | +disable the alert on certain days. Maybe the alert firing should depend on more |
| 75 | +than one input. For all of these situations, it is best to use the alert in |
| 76 | +conjunction with a `Template Binary Sensor`. The following example does that. |
| 77 | + |
| 78 | +```yaml |
| 79 | +binary_sensor: |
| 80 | + - platform: template |
| 81 | + sensors: |
| 82 | + motion_battery_low: |
| 83 | + value_template: {% raw %}'{{ states.sensor.motion.attributes.battery < 15 }}'{% endraw %} |
| 84 | + friendly_name: 'Motion battery is low' |
| 85 | +
|
| 86 | +alert: |
| 87 | + motion_battery: |
| 88 | + - name: Motion Battery is Low |
| 89 | + entity_id: binary_sensor.motion_battery_low |
| 90 | + repeat: 30 |
| 91 | + notifiers: |
| 92 | + - ryans_phone |
| 93 | + - kristens_phone |
| 94 | +``` |
| 95 | + |
| 96 | +This example will begin firing as soon as the entity `sensor.motion`'s |
| 97 | +`battery` attribute falls below 15. It will continue to fire until the battery |
| 98 | +attribute raises above 15 or the alert is acknowledged on the frontend. |
| 99 | + |
| 100 | +### {% linkable_title Dynamic Notification Delay Times %} |
| 101 | + |
| 102 | +In some use cases, you may desire a notification to become either more or less |
| 103 | +frequent every time it is sent. The alert component supports this with a |
| 104 | +configuration option called `backoff`. This is a factor that the repeat |
| 105 | +interval is multiplied by every time the notification is sent. A `backoff` |
| 106 | +factor greater than 1 will elongate the delays between notifications. |
| 107 | +Similarly, a backoff factor less than 1 will make the notification more |
| 108 | +frequent as time goes on. To prevent the notifications from becoming too |
| 109 | +freequent or too far apart, the `min_repeat` and `max_repeat` options are used. |
| 110 | +By default, the notifications are allowed as frequently as every minute or as |
| 111 | +infrequently as one per day. |
| 112 | + |
| 113 | +If you desire you delays to become incresingly further apart, start with a |
| 114 | +`backoff` factor of 1.5 and adjust to fit your needs. If you desire reducing |
| 115 | +delays, start with a factor of 0.75 and tweak as necessary. |
0 commit comments