mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-23 01:06:52 +00:00
Documentation for home-assistant/core#70120 (#22408)
This commit is contained in:
parent
0fc6559f41
commit
9f04669f37
@ -19,15 +19,14 @@ automation:
|
||||
entity_id: sensor.office_motion_sensor
|
||||
to: "on"
|
||||
condition:
|
||||
- condition: or
|
||||
conditions:
|
||||
- condition: numeric_state
|
||||
entity_id: sun.sun
|
||||
attribute: elevation
|
||||
below: 4
|
||||
- condition: numeric_state
|
||||
entity_id: sensor.office_lux_sensor
|
||||
below: 10
|
||||
- or:
|
||||
- condition: numeric_state
|
||||
entity_id: sun.sun
|
||||
attribute: elevation
|
||||
below: 4
|
||||
- condition: numeric_state
|
||||
entity_id: sensor.office_lux_sensor
|
||||
below: 10
|
||||
action:
|
||||
- service: scene.turn_on
|
||||
target:
|
||||
|
@ -141,6 +141,19 @@ The `condition` action only stops executing the current sequence block. When it
|
||||
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
|
||||
|
||||
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.
|
||||
|
@ -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/).
|
||||
|
||||
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
|
||||
|
||||
Test multiple conditions in one condition statement. Passes if any embedded condition is valid.
|
||||
@ -65,6 +79,20 @@ condition:
|
||||
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
|
||||
|
||||
Test multiple AND and OR conditions in one condition statement. Passes if any embedded condition is valid.
|
||||
@ -87,6 +115,23 @@ condition:
|
||||
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
|
||||
|
||||
Test multiple conditions in one condition statement. Passes if all embedded conditions are **not** valid.
|
||||
@ -104,6 +149,20 @@ condition:
|
||||
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
|
||||
|
||||
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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user