Skip to content

Instantly share code, notes, and snippets.

@agdamsbo
Last active August 24, 2023 03:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save agdamsbo/f49277bd8dd9bbada055c49600bea9e2 to your computer and use it in GitHub Desktop.
Save agdamsbo/f49277bd8dd9bbada055c49600bea9e2 to your computer and use it in GitHub Desktop.
Blueprint with different multi click actions based on text_sensor in ESPhome switch. Controls single, double and triple click as well as hold.
blueprint:
name: ESPhome switch SDTH
description: |
Different actions for different clicks.
Based on text_sensor in ESPhome switch.
ESPhome configuration example: https://gist.github.com/agdamsbo/819c27a5b986c38327d4b19057cbfb6d
## Inspiration ##
ESPhome decoupled approach: https://www.esphome-devices.com/devices/Shelly-1/
ESPhome text_sensor approach: https://gist.github.com/albertnis/f33066b0b3623a9839a3429c8f19f4d4
Blueprint: https://community.home-assistant.io/t/trigger-different-actions-on-a-single-double-or-double-click-on-a-binary-sensor/255902/15
domain: automation
input:
text_sensor_id:
name: Binary sensor entity
description: The text sensor used to trigger the automation
selector:
entity:
domain: sensor
single_action:
name: Single click action
description: The action(s) to launch for a single short click
default: []
selector:
action: {}
double_action:
name: Double click action
description: The action(s) to launch for a double click
default: []
selector:
action: {}
triple_action:
name: Triple click action
description: The action(s) to launch for a triple click
default: []
selector:
action: {}
hold_action:
name: Hold action
description: The action(s) to launch for a long hold
default: []
selector:
action: {}
source_url: https://gist.github.com/agdamsbo/f49277bd8dd9bbada055c49600bea9e2
trigger:
- platform: state
entity_id: !input 'text_sensor_id'
to: 'single'
- platform: state
entity_id: !input 'text_sensor_id'
to: 'double'
- platform: state
entity_id: !input 'text_sensor_id'
to: 'triple'
- platform: state
entity_id: !input 'text_sensor_id'
to: 'hold'
action:
- choose:
- conditions:
- condition: state
entity_id: !input 'text_sensor_id'
state: 'single'
sequence: !input 'single_action'
- conditions:
- condition: state
entity_id: !input 'text_sensor_id'
state: 'double'
sequence: !input 'double_action'
- conditions:
- condition: state
entity_id: !input 'text_sensor_id'
state: 'triple'
sequence: !input 'triple_action'
- conditions:
- condition: state
entity_id: !input 'text_sensor_id'
state: 'hold'
sequence: !input 'hold_action'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment