Add alias to condition syntax examples (#16697)

Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
Erik Montnemery 2021-02-22 21:22:11 +01:00 committed by GitHub
parent 2f6d2d9b88
commit c97f7fa715
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,12 +7,15 @@ Conditions can be used within a script or automation to prevent further executio
Unlike a trigger, which is always `or`, conditions are `and` by default - all conditions have to be true. Unlike a trigger, which is always `or`, conditions are `and` by default - all conditions have to be true.
All conditions support an optional `alias`.
## AND condition ## AND condition
Test multiple conditions in one condition statement. Passes if all embedded conditions are valid. Test multiple conditions in one condition statement. Passes if all embedded conditions are valid.
```yaml ```yaml
condition: condition:
alias: "Paulus home AND tempeterature below 20"
condition: and condition: and
conditions: conditions:
- condition: state - condition: state
@ -28,6 +31,7 @@ If you do not want to combine AND and OR conditions, you can list them sequentia
The following configuration works the same as the one listed above: The following configuration works the same as the one listed above:
```yaml ```yaml
alias: "Paulus home AND tempeterature below 20"
condition: condition:
- condition: state - condition: state
entity_id: "device_tracker.paulus" entity_id: "device_tracker.paulus"
@ -45,6 +49,7 @@ Test multiple conditions in one condition statement. Passes if any embedded cond
```yaml ```yaml
condition: condition:
alias: "Paulus home OR tempeterature below 20"
condition: or condition: or
conditions: conditions:
- condition: state - condition: state
@ -83,6 +88,7 @@ Test multiple conditions in one condition statement. Passes if all embedded cond
```yaml ```yaml
condition: condition:
alias: "Paulus not home AND alarm not disarmed"
condition: not condition: not
conditions: conditions:
- condition: state - condition: state
@ -101,6 +107,7 @@ If both `below` and `above` are specified, both tests have to pass.
```yaml ```yaml
condition: condition:
alias: "Temperature between 17 and 25 degrees"
condition: numeric_state condition: numeric_state
entity_id: sensor.temperature entity_id: sensor.temperature
above: 17 above: 17
@ -165,6 +172,7 @@ Tests if an entity is a specified state.
```yaml ```yaml
condition: condition:
alias: "Paulus not home for an hour and a bit"
condition: state condition: state
entity_id: device_tracker.paulus entity_id: device_tracker.paulus
state: "not_home" state: "not_home"
@ -243,6 +251,7 @@ The sun state can be used to test if the sun has set or risen.
```yaml ```yaml
condition: condition:
alias: "Sun up"
condition: state # 'day' condition: from sunrise until sunset condition: state # 'day' condition: from sunrise until sunset
entity_id: sun.sun entity_id: sun.sun
state: "above_horizon" state: "above_horizon"
@ -250,6 +259,7 @@ condition:
```yaml ```yaml
condition: condition:
alias: "Sun down"
condition: state # from sunset until sunrise condition: state # from sunset until sunrise
entity_id: sun.sun entity_id: sun.sun
state: "below_horizon" state: "below_horizon"
@ -342,6 +352,7 @@ The template condition tests if the [given template][template] renders a value e
```yaml ```yaml
condition: condition:
alias: "Iphone battery above 50%"
condition: template condition: template
value_template: "{{ (state_attr('device_tracker.iphone', 'battery_level')|int) > 50 }}" value_template: "{{ (state_attr('device_tracker.iphone', 'battery_level')|int) > 50 }}"
``` ```
@ -440,6 +451,7 @@ The time condition can test if it is after a specified time, before a specified
```yaml ```yaml
condition: condition:
alias: "Time 15~02"
condition: time condition: time
# At least one of the following is required. # At least one of the following is required.
after: "15:00:00" after: "15:00:00"
@ -476,6 +488,7 @@ Zone conditions test if an entity is in a certain zone. For zone automation to w
```yaml ```yaml
condition: condition:
alias: "Paulus at home"
condition: zone condition: zone
entity_id: device_tracker.paulus entity_id: device_tracker.paulus
zone: zone.home zone: zone.home