A simple blueprint for expediting the process of doing different things based on the edge of a toggle switch. Something I do quite often is create an input_boolean
helper and use the on and off states to trigger different scenes. I wanted to share a simple yet versatile blueprint I created for quickly setting this up and adding multiple actions based on the state of this input_boolean
. This blueprint allows you to add actions that will be executed when the input_boolean
is turned on and different actions for when itβs turned off.
How It Works
- Input Boolean: Select the
input_boolean
entity that you want to use as the toggle. - Actions When On: Define the actions you want to perform when the
input_boolean
is turned on. - Actions When Off: Define the actions you want to perform when the
input_boolean
is turned off.
How to Use
- Import the Blueprint to your instance of HA using the button above or save the YAML blueprint into a new file under the
blueprints/automation
directory in your Home Assistant configuration (e.g.,blueprints/automation/input_boolean_toggle_actions.yaml
). - Create an
input_boolean
helper that you want to use to toggle scenes/actions/lights on and off - Create a new automation based on this blueprint, selecting the desired
input_boolean
and defining the actions to perform for both theon
andoff
states.
MY OTHER BLUEPRINTS
Adaptive fan speed control based on temperature and speed range
blueprint:
name: Input Boolean Toggle Actions
description: Perform multiple actions based on the state of an input boolean.
domain: automation
input:
toggle_boolean:
name: Input Boolean
description: The input boolean to control actions
selector:
entity:
domain: input_boolean
actions_on:
name: Actions When On
description: Actions to perform when the input boolean is turned on (optional).
default: []
selector:
action: {}
actions_off:
name: Actions When Off
description: Actions to perform when the input boolean is turned off (optional).
default: []
selector:
action: {}
trigger:
- platform: state
entity_id: !input toggle_boolean
action:
- choose:
- conditions:
- condition: state
entity_id: !input toggle_boolean
state: 'on'
sequence: !input actions_on
- conditions:
- condition: state
entity_id: !input toggle_boolean
state: 'off'
sequence: !input actions_off