-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.yaml
64 lines (64 loc) · 2.36 KB
/
main.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
blueprint:
name: Short long double click
description: Different Actions on Short, Long and Double click
domain: automation
input:
switch_id:
name: Binary sensor entity
description: The binary_sensor used to trigger the automation
selector:
entity:
domain: binary_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: 'off'
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, 'on') }}"
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