Skip to content

Instantly share code, notes, and snippets.

@Twanne
Last active October 17, 2024 14:18
Show Gist options
  • Save Twanne/c928236ab8fc98f34151d5e097f78890 to your computer and use it in GitHub Desktop.
Save Twanne/c928236ab8fc98f34151d5e097f78890 to your computer and use it in GitHub Desktop.
Home Assistant Blueprint: Multi Click Button
blueprint:
name: Multi Click Button
author: AntonH
description: |
**Version 1.2**
Allows multi-click actions to take place on a button.
Upon reaching the number of required clicks, it executes user defined actions.
There are 3 entity types supported:
- button
- input_button
- switch
**NOTE:** *Every state change is counted as a click. Therefore, in switch entity types, both turning it on or off is counted as a 'click'.*
source_url: https://gist.github.com/Twanne/c928236ab8fc98f34151d5e097f78890
domain: automation
input:
#Select the button
button_entity:
name: Button entity
description: |
The button you want to use.
**Supported entity types:**
- button
- input_button
- switch
default: []
selector:
entity:
domain:
- button
- input_button
- switch
#Number of clicks
number_of_clicks:
name: How many clicks?
description: How many clicks before the action is executed.
default: 2
selector:
number:
min: 1
max: 100
step: 1
unit_of_measurement: clicks
mode: slider
#Maximum allowed time between clicks
time_between_clicks:
name: Time between clicks
description: How much time is allowed between any 2 clicks?
default: []
selector:
duration:
enable_millisecond: true
#Action conditions
action_conditions:
name: Action condition
description: These conditions need to be met before the actions are executed.
default: []
selector:
condition:
#Actions to execute
actions:
name: Actions
description: Which actions to execute when the button has been pressed the set number of times.
default: []
selector:
action:
#Mode
mode: single
#Variables
variables:
number_of_clicks: !input number_of_clicks
time_between_clicks: !input time_between_clicks
#Trigger
trigger:
- platform: state
entity_id: !input button_entity
#Action
action:
#count clicks
- repeat:
sequence:
- wait_for_trigger:
- platform: state
entity_id: !input button_entity
to: null
timeout: '{{ time_between_clicks }}'
continue_on_timeout: false
count: '{{ (number_of_clicks | int ) - 1 }}'
#execute actions
- choose:
- conditions: !input action_conditions
sequence: !input actions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment