Documentation for home-assistant/core#70120 (#22408)

This commit is contained in:
Thomas Lovén 2022-04-18 22:09:40 +02:00 committed by GitHub
parent 0fc6559f41
commit 9f04669f37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 80 additions and 9 deletions

View File

@ -19,15 +19,14 @@ automation:
entity_id: sensor.office_motion_sensor entity_id: sensor.office_motion_sensor
to: "on" to: "on"
condition: condition:
- condition: or - or:
conditions: - condition: numeric_state
- condition: numeric_state entity_id: sun.sun
entity_id: sun.sun attribute: elevation
attribute: elevation below: 4
below: 4 - condition: numeric_state
- condition: numeric_state entity_id: sensor.office_lux_sensor
entity_id: sensor.office_lux_sensor below: 10
below: 10
action: action:
- service: scene.turn_on - service: scene.turn_on
target: target:

View File

@ -141,6 +141,19 @@ The `condition` action only stops executing the current sequence block. When it
state: "home" state: "home"
``` ```
`condition` can also be a list of conditions and execution will then only continue if ALL conditions return `true`.
```yaml
- alias: "Check if Paulus ishome AND temperature is below 20"
condition:
- condition: state
entity_id: "device_tracker.paulus"
state: "home"
- condition: numeric_state
entity_id: "sensor.temperature"
below: 20
```
## Delay ## Delay
Delays are useful for temporarily suspending your script and start it at a later moment. We support different syntaxes for a delay as shown below. Delays are useful for temporarily suspending your script and start it at a later moment. We support different syntaxes for a delay as shown below.

View File

@ -48,6 +48,20 @@ condition:
Currently you need to format your conditions like this to be able to edit them using the [automations editor](/docs/automation/editor/). Currently you need to format your conditions like this to be able to edit them using the [automations editor](/docs/automation/editor/).
The AND condition also has a shorthand form. The following configuration works the same as the ones listed above:
```yaml
condition:
alias: "Paulus home AND temperature below 20"
and:
- condition: state
entity_id: "device_tracker.paulus"
state: "home"
- condition: numeric_state
entity_id: "sensor.temperature"
below: 20
```
### OR condition ### OR condition
Test multiple conditions in one condition statement. Passes if any embedded condition is valid. Test multiple conditions in one condition statement. Passes if any embedded condition is valid.
@ -65,6 +79,20 @@ condition:
below: 20 below: 20
``` ```
The OR condition also has a shorthand form. The following configuration works the same as the one listed above:
```yaml
condition:
alias: "Paulus home OR temperature below 20"
or:
- condition: state
entity_id: "device_tracker.paulus"
state: "home"
- condition: numeric_state
entity_id: "sensor.temperature"
below: 20
```
### Mixed AND and OR conditions ### Mixed AND and OR conditions
Test multiple AND and OR conditions in one condition statement. Passes if any embedded condition is valid. Test multiple AND and OR conditions in one condition statement. Passes if any embedded condition is valid.
@ -87,6 +115,23 @@ condition:
below: 20 below: 20
``` ```
Or in shorthand form:
```yaml
condition:
and:
- condition: state
entity_id: "device_tracker.paulus"
state: "home"
- or:
- condition: state
entity_id: sensor.weather_precip
state: "rain"
- condition: numeric_state
entity_id: "sensor.temperature"
below: 20
```
### NOT condition ### NOT condition
Test multiple conditions in one condition statement. Passes if all embedded conditions are **not** valid. Test multiple conditions in one condition statement. Passes if all embedded conditions are **not** valid.
@ -104,6 +149,20 @@ condition:
state: disarmed state: disarmed
``` ```
The NOT condition also has a shorthand form. The following configuration works the same as the one listed above:
```yaml
condition:
alias: "Paulus not home AND alarm not disarmed"
not:
- condition: state
entity_id: device_tracker.paulus
state: "home"
- condition: state
entity_id: alarm_control_panel.home_alarm
state: disarmed
```
## Numeric state condition ## Numeric state condition
This type of condition attempts to parse the state of the specified entity or the attribute of an entity as a number, and triggers if the value matches the thresholds. This type of condition attempts to parse the state of the specified entity or the attribute of an entity as a number, and triggers if the value matches the thresholds.