diff --git a/source/_docs/scripts.markdown b/source/_docs/scripts.markdown index 5489252fbab..36e7d9ac2b4 100644 --- a/source/_docs/scripts.markdown +++ b/source/_docs/scripts.markdown @@ -689,6 +689,76 @@ automation: {% endraw %} +## Parallelizing actions + +By default, all sequences of actions in Home Assistant run sequentially. This +means the next action is started after the current action has been completed. + +This is not always needed, for example, if the sequence of actions doesn't rely +on each other and order doesn't matter. For those cases, the `parallel` action +can be used to run the actions in the sequence in parallel, meaning all +the actions are started at the same time. + +The following example shows sending messages out at the time (in parallel): + +```yaml +automation: + - trigger: + - platform: state + entity_id: binary_sensor.motion + to: "on" + action: + - parallel: + - service: notify.person1 + data: + message: "These messages are sent at the same time!" + - service: notify.person2 + data: + message: "These messages are sent at the same time!" +``` + +It is also possible to run a group of actions sequantially inside the parallel +actions. The example below demonstrates that: + +```yaml +script: + example_script: + sequence: + - parallel: + - sequence: + - wait_for_trigger: + - platform: state + entity_id: binary_sensor.motion + to: "on" + - service: notify.person1 + data: + message: "This message awaited the motion trigger" + - service: notify.person2 + data: + message: "I am sent immediately and do not await the above action!" +``` + +