diff --git a/source/_docs/automation/condition.markdown b/source/_docs/automation/condition.markdown index a780f41fc1e..9aac92158aa 100644 --- a/source/_docs/automation/condition.markdown +++ b/source/_docs/automation/condition.markdown @@ -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: diff --git a/source/_docs/scripts.markdown b/source/_docs/scripts.markdown index af9d685fa9f..65646ffd921 100644 --- a/source/_docs/scripts.markdown +++ b/source/_docs/scripts.markdown @@ -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. diff --git a/source/_docs/scripts/conditions.markdown b/source/_docs/scripts/conditions.markdown index e004a8c7f8f..90db938b10f 100644 --- a/source/_docs/scripts/conditions.markdown +++ b/source/_docs/scripts/conditions.markdown @@ -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.