mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-26 02:37:03 +00:00
Making the default and
more obvious (#8043)
With the default of `and` being hidden away in the `and` block, it's not obvious. Pulling that out. Also highlighting that after sunset/before sunrise is the same as a single state check, and same for before sunset/after sunrise.
This commit is contained in:
parent
6ddc1c58f2
commit
edef357100
@ -12,6 +12,8 @@ redirect_from: /getting-started/scripts-conditions/
|
|||||||
|
|
||||||
Conditions can be used within a script or automation to prevent further execution. A condition will look at the system right now. For example a condition can test if a switch is currently turned on or off.
|
Conditions can be used within a script or automation to prevent further execution. A condition will look at the system right now. For example a condition can test if a switch is currently turned on or off.
|
||||||
|
|
||||||
|
Unlike a trigger, which is always `or`, conditions are `and` by default - all conditions have to be true.
|
||||||
|
|
||||||
### {% linkable_title AND condition %}
|
### {% linkable_title AND condition %}
|
||||||
|
|
||||||
Test multiple conditions in 1 condition statement. Passes if all embedded conditions are valid.
|
Test multiple conditions in 1 condition statement. Passes if all embedded conditions are valid.
|
||||||
@ -28,7 +30,8 @@ condition:
|
|||||||
below: 20
|
below: 20
|
||||||
```
|
```
|
||||||
|
|
||||||
If you do not want to combine AND and OR conditions, you can also just list them sequentially, by default all conditions have to be true.
|
If you do not want to combine AND and OR conditions, you can also just list them sequentially.
|
||||||
|
|
||||||
The following configuration works the same as the one listed above:
|
The following configuration works the same as the one listed above:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@ -131,7 +134,7 @@ condition:
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
condition:
|
condition:
|
||||||
condition: or # 'when dark' condition: either after sunset or before sunrise
|
condition: or # 'when dark' condition: either after sunset or before sunrise - equivalent to a state condition on `sun.sun` of `below_horizon`
|
||||||
conditions:
|
conditions:
|
||||||
- condition: sun
|
- condition: sun
|
||||||
after: sunset
|
after: sunset
|
||||||
@ -141,7 +144,7 @@ condition:
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
condition:
|
condition:
|
||||||
condition: and # 'when light' condition: before sunset and after sunrise
|
condition: and # 'when light' condition: before sunset and after sunrise - equivalent to a state condition on `sun.sun` of `above_horizon`
|
||||||
conditions:
|
conditions:
|
||||||
- condition: sun
|
- condition: sun
|
||||||
before: sunset
|
before: sunset
|
||||||
|
Loading…
x
Reference in New Issue
Block a user