Remove legacy script mode and simplify remaining modes (#13971)

This commit is contained in:
Phil Bruckner 2020-07-10 19:00:31 -05:00 committed by GitHub
parent 5a4fa2b528
commit 6845a316dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 47 deletions

View File

@ -57,37 +57,30 @@ automation:
### Automation Modes ### Automation Modes
The automation's `mode` configuration option controls what happens when the automation is triggered while the actions are still running from a previous trigger. The default mode is `legacy`. The automation's `mode` configuration option controls what happens when the automation is triggered while the actions are still running from a previous trigger.
Mode | Description Mode | Description
-|- -|-
`legacy` | See [below](#legacy-mode). `single` | Do not start a new run. Issue a warning.
`error` | Raise an error. Previous run continues normally.
`ignore` | Do not start a new run. Previous run continues normally.
`parallel` | Start a new, independent run in parallel with previous runs which continue normally.
`restart` | Start a new run after first stopping previous run. `restart` | Start a new run after first stopping previous run.
`queue` | Start a new run after all previous runs complete. Runs are guaranteed to execute in the order they were queued. The maximum number of queued up runs is controlled by the `queue_size` configuration option, which defaults to 10. `queued` | Start a new run after all previous runs complete. Runs are guaranteed to execute in the order they were queued.
`parallel` | (Default) Start a new, independent run in parallel with previous runs.
For both `queued` and `parallel` modes, configuration option `max` controls the maximum
number of runs that can be executing and/or queued up at a time. The default is 10.
#### Example Setting Automation Mode #### Example Setting Automation Mode
```yaml ```yaml
automation: automation:
- mode: queue - trigger:
queue_size: 5 - ...
trigger: mode: queued
... max: 25
action:
- ...
``` ```
#### Legacy Mode
<div class='note'>
This mode is deprecated, and a warning to that effect will be issued at startup unless `mode: legacy` is specified.
</div>
This mode maintains the legacy script behavior. That is, the actions will run until a `delay` step, or a `wait_template` step (that actually waits) is executed, at which point the actions will suspend. If the automation is triggered while the actions are suspended, it will abort the delay/wait_template and continue immediately to the next step, or finish if there are no more steps.
### Deleting Automations ### Deleting Automations
When automations remain visible in the Home Assistant Dashboard, even after having deleted in the YAML file, you have to delete them in the UI. When automations remain visible in the Home Assistant Dashboard, even after having deleted in the YAML file, you have to delete them in the UI.

View File

@ -68,12 +68,12 @@ fields:
description: An example value for PARAMETER_NAME. description: An example value for PARAMETER_NAME.
type: string type: string
mode: mode:
description: "Controls what happens when script is run while it is still running from one or more previous invocations. See [Script Modes](#script-modes)." description: "Controls what happens when script is invoked while it is still running from one or more previous invocations. See [Script Modes](#script-modes)."
required: false required: false
type: string type: string
default: legacy default: single
queue_size: max:
description: "Controls maximum number of queued runs waiting for previous run to complete. Only valid with `mode: queue`." description: "Controls maximum number of runs executing and/or queued up to run at a time. Only valid with modes `queued` and `parallel`."
required: false required: false
type: integer type: integer
default: 10 default: 10
@ -87,27 +87,15 @@ sequence:
Mode | Description Mode | Description
-|- -|-
`legacy` | See [below](#legacy-mode). `single` | Do not start a new run. Issue a warning.
`error` | Raise an error. Previous run continues normally.
`ignore` | Do not start a new run. Previous run continues normally.
`parallel` | Start a new, independent run in parallel with previous runs which continue normally.
`restart` | Start a new run after first stopping previous run. `restart` | Start a new run after first stopping previous run.
`queue` | Start a new run after all previous runs complete. Runs are guaranteed to execute in the order they were queued. `queued` | Start a new run after all previous runs complete. Runs are guaranteed to execute in the order they were queued.
`parallel` | Start a new, independent run in parallel with previous runs.
<p class='img'> <p class='img'>
<img src='/images/integrations/script/script_modes.jpg'> <img src='/images/integrations/script/script_modes.jpg'>
</p> </p>
#### Legacy Mode
<div class='note'>
This mode is deprecated, and a warning to that effect will be issued at startup unless `mode: legacy` is specified.
</div>
This mode maintains the legacy script behavior. That is, the script will run until it executes a `delay` step, or a `wait_template` step (that actually waits), at which point the script will suspend. If the script is run while suspended, it will abort the delay/wait_template and continue immediately to the next step, or finish if there are no more steps. Also, calling a legacy script that is still running (and not suspended) will result in an error.
### Full Configuration ### Full Configuration
{% raw %} {% raw %}
@ -240,11 +228,3 @@ script:
# Do some things at the same time as the first script... # Do some things at the same time as the first script...
``` ```
{% endraw %} {% endraw %}
Note that this is only guaranteed to work if the called script uses a non-legacy mode.
### In the Overview
Legacy scripts in the Overview panel will be displayed with an **EXECUTE** button if the script has no `delay:` or `wait_template:` statement, and as a toggle switch if it has either of those. Scripts configured for any other mode than `legacy` will also be displayed with a toggle switch.
This is to enable you to stop a running script.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 53 KiB