blueprint:
name: Short long double click
description: Different Actions on Short, Long and Double click
domain: automation
input:
switch_id:
name: Sensor entity
description: The sensor used to trigger the automation
selector:
entity:
domain: sensor
long_click_action:
name: Long click action
description: The action(s) to launch for a long click
default: []
selector:
action:
short_click_action:
name: Short click action
description: The action(s) to launch for a single short click
default: []
selector:
action:
double_click_action:
name: Double click action
description: The action(s) to launch for a double click
default: []
selector:
action:
delay:
name: Delay in seconds
description: The time in seconds (can contain decimals) used as a delay for the double or long click detection
default: 0.3
selector:
number:
min: 0.0
max: 10.0
unit_of_measurement: seconds
trigger:
- platform: state
entity_id: !input switch_id
to: 'on'
action:
- variables: # create variable cause we need those in templates
switch_id: !input switch_id
double_click_action: !input double_click_action
- wait_template: "{{ is_state(switch_id, 'off') }}"
timeout: !input delay
continue_on_timeout: true
- choose:
- conditions: "{{ not wait.completed }}" # long click
sequence: !input long_click_action
default:
- choose:
- conditions: "{{ double_click_action | length > 0 }}" #only wait for second click if a n action is defined for it to be more reactive
sequence:
- wait_template: "{{ is_state(switch_id, 'on') }}" # second click?
timeout: !input delay
continue_on_timeout: true
- choose:
- conditions: "{{ not wait.completed }}" #single click
sequence: !input short_click_action
default: !input double_click_action # double click
default: !input short_click_action