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:
DubhAd 2019-01-04 18:58:40 +00:00 committed by Fabian Affolter
parent 6ddc1c58f2
commit edef357100

View File

@ -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.
Unlike a trigger, which is always `or`, conditions are `and` by default - all conditions have to be true.
### {% linkable_title AND condition %}
Test multiple conditions in 1 condition statement. Passes if all embedded conditions are valid.
@ -28,7 +30,8 @@ condition:
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:
```yaml
@ -131,7 +134,7 @@ condition:
```yaml
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:
- condition: sun
after: sunset
@ -141,7 +144,7 @@ condition:
```yaml
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:
- condition: sun
before: sunset