diff --git a/source/_docs/automation/trigger.markdown b/source/_docs/automation/trigger.markdown
index 6db3bc2918e..32afab597a9 100644
--- a/source/_docs/automation/trigger.markdown
+++ b/source/_docs/automation/trigger.markdown
@@ -24,7 +24,7 @@ automation:
- Starting 0.42, it is no longer possible to listen for event `homeassistant_start`. Use the 'homeassistant' platform below instead.
+Starting 0.42, it is no longer possible to listen for event `homeassistant_start`. Use the 'homeassistant' platform below instead.
@@ -50,8 +50,8 @@ automation:
platform: mqtt
topic: living_room/switch/ac
# Optional
- payload: 'on'
- encoding: 'utf-8'
+ payload: "on"
+ encoding: "utf-8"
```
### Numeric state trigger
@@ -59,13 +59,14 @@ automation:
Triggers when numeric value of an entity's state crosses a given threshold. On state change of a specified entity, attempts to parse the state as a number and triggers once if value is changing from above to below or from below to above the given threshold.
{% raw %}
+
```yaml
automation:
trigger:
platform: numeric_state
entity_id: sensor.temperature
# Optional
- value_template: '{{ state.attributes.battery }}'
+ value_template: "{{ state.attributes.battery }}"
# At least one of the following required
above: 17
below: 25
@@ -76,6 +77,7 @@ automation:
minutes: 10
seconds: 5
```
+
{% endraw %}
@@ -86,25 +88,28 @@ In the example above, a numeric_state that goes to 17.1-24.9 (from 17 or below,
The `for:` can also be specified as `HH:MM:SS` like this:
{% raw %}
+
```yaml
automation:
trigger:
platform: numeric_state
entity_id: sensor.temperature
# Optional
- value_template: '{{ state.attributes.battery }}'
+ value_template: "{{ state.attributes.battery }}"
# At least one of the following required
above: 17
below: 25
# If given, will trigger when condition has been for X time.
- for: '01:10:05'
+ for: "01:10:05"
```
+
{% endraw %}
You can also use templates in the `for` option.
{% raw %}
+
```yaml
automation:
trigger:
@@ -122,6 +127,7 @@ automation:
message: >
{{ trigger.to_state.name }} too high for {{ trigger.for }}!
```
+
{% endraw %}
The `for` template(s) will be evaluated when an entity changes as specified.
@@ -136,23 +142,24 @@ automation:
platform: state
entity_id: device_tracker.paulus, device_tracker.anne_therese
# Optional
- from: 'not_home'
+ from: "not_home"
# Optional
- to: 'home'
+ to: "home"
# If given, will trigger when state has been the to state for X time.
- for: '01:10:05'
+ for: "01:10:05"
```
You can also use templates in the `for` option.
{% raw %}
+
```yaml
automation:
trigger:
platform: state
entity_id: device_tracker.paulus, device_tracker.anne_therese
- to: 'home'
+ to: "home"
for:
minutes: "{{ states('input_number.lock_min')|int }}"
seconds: "{{ states('input_number.lock_sec')|int }}"
@@ -160,14 +167,14 @@ automation:
service: lock.lock
entity_id: lock.my_place
```
+
{% endraw %}
The `for` template(s) will be evaluated when an entity changes as specified.
-
- Use quotes around your values for `from` and `to` to avoid the YAML parser interpreting values as booleans.
+Use quotes around your values for `from` and `to` to avoid the YAML parser interpreting values as booleans.
@@ -181,7 +188,7 @@ An optional time offset can be given to have it trigger a set time before or aft
-Since the duration of twilight is different throughout the year, it is recommended to use [sun elevation triggers][sun_elevation_trigger] instead of `sunset` or `sunrise` with a time offset to trigger automations during dusk or dawn.
+Since the duration of twilight is different throughout the year, it is recommended to use [sun elevation triggers][sun_elevation_trigger] instead of `sunset` or `sunrise` with a time offset to trigger automations during dusk or dawn.
@@ -194,7 +201,7 @@ automation:
# Possible values: sunset, sunrise
event: sunset
# Optional time offset. This example will trigger 45 minutes before sunset.
- offset: '-00:45:00'
+ offset: "-00:45:00"
```
#### Sun elevation trigger
@@ -202,6 +209,7 @@ automation:
Sometimes you may want more granular control over an automation than simply sunset or sunrise and specify an exact elevation of the sun. This can be used to layer automations to occur as the sun lowers on the horizon or even after it is below the horizon. This is also useful when the "sunset" event is not dark enough outside and you would like the automation to run later at a precise solar angle instead of the time offset such as turning on exterior lighting. For most things intended to trigger during dusk or dawn, a number between 0° and -6° is suitable; -4° is used in this example:
{% raw %}
+
```yaml
automation:
alias: "Exterior Lighting on when dark outside"
@@ -215,6 +223,7 @@ automation:
service: switch.turn_on
entity_id: switch.exterior_lighting
```
+
{% endraw %}
If you want to get more precise, start with the US Naval Observatory [tool](http://aa.usno.navy.mil/data/docs/AltAz.php) which will help you estimate what the solar elevation will be at any specific time. Then from this, you can select from the defined twilight numbers.
@@ -224,6 +233,7 @@ Although the actual amount of light depends on weather, topography and land cove
- Civil twilight: 0° > Solar angle > -6°
This is what is meant by twilight for the average person: Under clear weather conditions, civil twilight approximates the limit at which solar illumination suffices for the human eye to clearly distinguish terrestrial objects. Enough illumination renders artificial sources unnecessary for most outdoor activities.
+
- Nautical twilight: 6° > Solar angle > -12°
- Astronomical twilight: 12° > Solar angle > -18°
@@ -235,6 +245,7 @@ Template triggers work by evaluating a [template](/docs/configuration/templating
With template triggers you can also evaluate attribute changes by using is_state_attr (`{% raw %}{{ is_state_attr('climate.living_room', 'away_mode', 'off') }}{% endraw %}`)
{% raw %}
+
```yaml
automation:
trigger:
@@ -242,13 +253,15 @@ automation:
value_template: "{% if is_state('device_tracker.paulus', 'home') %}true{% endif %}"
# If given, will trigger when template remains true for X time.
- for: '00:01:00'
+ for: "00:01:00"
```
+
{% endraw %}
You can also use templates in the `for` option.
{% raw %}
+
```yaml
automation:
trigger:
@@ -257,17 +270,13 @@ automation:
for:
minutes: "{{ states('input_number.minutes')|int(0) }}"
```
+
{% endraw %}
The `for` template(s) will be evaluated when the `value_template` becomes `true`.
-<<<<<<< HEAD
-
-=======
->>>>>>> current
Rendering templates with time (`now()`) is dangerous as trigger templates only update based on entity state changes.
-
### Time trigger
@@ -279,7 +288,7 @@ automation:
trigger:
platform: time
# Military time format. This trigger will fire at 3:32 PM
- at: '15:32:00'
+ at: "15:32:00"
```
### Time pattern trigger
@@ -297,19 +306,19 @@ automation 2:
trigger:
platform: time_pattern
# Trigger once per minute during the hour of 3
- hours: '3'
- minutes: '*'
+ hours: "3"
+ minutes: "*"
automation 3:
trigger:
platform: time_pattern
# You can also match on interval. This will match every 5 minutes
- minutes: '/5'
+ minutes: "/5"
```
- Do not prefix numbers with a zero - using `'00'` instead of '0' for example will result in errors.
+Do not prefix numbers with a zero - using `'00'` instead of '0' for example will result in errors.
@@ -326,7 +335,6 @@ automation:
You could test triggering the above automation by sending a POST HTTP request to `http://your-home-assistant:8123/api/webhook/some_hook_id`. An example with no data sent to a SSL/TLS secured installation and using the command-line curl program is `curl -d "" https://your-home-assistant:8123/api/webhook/some_hook_id`.
-
### Zone trigger
Zone triggers can trigger when an entity is entering or leaving the zone. For zone automation to work, you need to have setup a device tracker platform that supports reporting GPS coordinates. This includes [GPS Logger](/components/device_tracker.gpslogger/), the [OwnTracks platform](/components/device_tracker.owntracks/) and the [iCloud platform](/components/device_tracker.icloud/).
@@ -338,7 +346,7 @@ automation:
entity_id: device_tracker.paulus
zone: zone.home
# Event is either enter or leave
- event: enter # or "leave"
+ event: enter # or "leave"
```
### Geolocation trigger
@@ -353,7 +361,7 @@ automation:
source: nsw_rural_fire_service_feed
zone: zone.bushfire_alert_zone
# Event is either enter or leave
- event: enter # or "leave"
+ event: enter # or "leave"
```
### Multiple triggers
@@ -363,7 +371,7 @@ When your want your automation rule to have multiple triggers, just prefix the f
```yaml
automation:
trigger:
- # first trigger
+ # first trigger
- platform: time_pattern
minutes: 5
# our second trigger is the sunset