From f36774bfc97a0b8d25d7eb56fb3bf68bf2668a36 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sat, 16 Apr 2022 13:18:29 +0200 Subject: [PATCH] Allow disabling specific triggers/actions/conditions (#22401) --- source/_docs/automation/trigger.markdown | 20 +++++++++++++++++++ source/_docs/scripts.markdown | 25 ++++++++++++++++++++++++ source/_docs/scripts/conditions.markdown | 19 ++++++++++++++++++ 3 files changed, 64 insertions(+) diff --git a/source/_docs/automation/trigger.markdown b/source/_docs/automation/trigger.markdown index 13dbabb9ffe..c3709cbc51b 100644 --- a/source/_docs/automation/trigger.markdown +++ b/source/_docs/automation/trigger.markdown @@ -879,3 +879,23 @@ automation: - sensor.two - sensor.three ``` + +## Disabling a trigger + +Every individual trigger in an automation can be disabled, without removing it. +To do so, add `enabled: false` to the trigger. For example: + +```yaml +# Example script with a disabled trigger +automation: + trigger: + # This trigger will not trigger, as it is disabled. + # This automation does not run when the sun is set. + - enabled: false + platform: sun + event: sunset + + # This trigger will fire, as it is not disabled. + - platform: time + at: "15:32:00" +``` diff --git a/source/_docs/scripts.markdown b/source/_docs/scripts.markdown index 36e7d9ac2b4..c5f2d1ddb20 100644 --- a/source/_docs/scripts.markdown +++ b/source/_docs/scripts.markdown @@ -816,6 +816,31 @@ it encounters an error; it will continue to the next action. Please note that `continue_on_error` will not suppress/ignore misconfiguration or errors that Home Assistant does not handle. +## Disabling an action + +Every individual action in a sequence can be disabled, without removing it. +To do so, add `enabled: false` to the action. For example: + +```yaml +# Example script with a disabled action +script: + example_script: + sequence: + # This action will not run, as it is disabled. + # The message will not be sent. + - enabled: false + alias: "Notify that ceiling light is being turned on" + service: notify.notify + data: + message: "Turning on the ceiling light!" + + # This action will run, as it is not disabled + - alias: "Turn on ceiling light" + service: light.turn_on + target: + entity_id: light.ceiling +``` + [Script component]: /integrations/script/ [automations]: /getting-started/automation-action/ [Alexa/Amazon Echo]: /integrations/alexa/ diff --git a/source/_docs/scripts/conditions.markdown b/source/_docs/scripts/conditions.markdown index f9e97cd6d96..e004a8c7f8f 100644 --- a/source/_docs/scripts/conditions.markdown +++ b/source/_docs/scripts/conditions.markdown @@ -630,3 +630,22 @@ condition: ``` {% endraw %} + +## Disabling a condition + +Every individual condition can be disabled, without removing it. +To do so, add `enabled: false` to the condition configuration. + +This can be useful if you want to temporarily disable a condition, for example, +for testing. A disabled condition will always pass. + +For example: + +```yaml +# This condition will always pass, as it is disabled. +condition: + enabled: false + condition: state + entity_id: sun.sun + state: "above_horizon" +```