-
Notifications
You must be signed in to change notification settings - Fork 0
/
PTM_216Z.yaml
218 lines (216 loc) · 7.64 KB
/
PTM_216Z.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
blueprint:
name: Controller - EnOcean PTM 216Z switch
description: |
Controller automation for executing **press/hold/release** after hold actions triggered by EnOcean PTM 216Z switch.
Make sure to manually create a separate **Text Helper** per controller and define its entity in the automation. It's used to store the last controller event to filter possible
empty events and handle 'button hold' actions.
ℹ️ Version 2024.11.13
domain: automation
input:
controller_entity:
name: (Zigbee2MQTT) Controller Entity
description: The action sensor of the controller to use for the automation.
default: ''
selector:
entity:
integration: mqtt
domain: sensor
helper_last_controller_event:
name: (Required) Helper - Last Controller Event
description:
Input Text used to store the last event fired by the controller.
You will need to manually create a text input Helper entity for this.
default: ""
selector:
entity:
domain: input_text
multiple: false
hold_delay:
name: Hold delay
description: If the button has been held more than the configured Hold delay, the corresponding held action is triggered.
default: 500
selector:
number:
min: 100.0
max: 1000.0
unit_of_measurement: milliseconds
mode: box
step: 10.0
button_1_pressed:
name: Button 1 Pressed
description: Action to run, when button 1 is pressed.
default: []
selector:
action: {}
button_1_held:
name: Button 1 Held
description: Action to run, when the button 1 is held.
default: []
selector:
action: {}
button_1_released:
name: Button 1 released
description: Action to run, when the button 1 is released.
default: []
selector:
action: {}
button_2_pressed:
name: Button 2 Pressed
description: Action to run, when the button 2 pressed.
default: []
selector:
action: {}
button_2_held:
name: Button 2 Held
description: Action to run, when the button 2 is held.
default: []
selector:
action: {}
button_2_released:
name: Button 2 released
description: Action to run, when the button 2 is released.
default: []
selector:
action: {}
button_3_pressed:
name: Button 3 Pressed
description: Action to run, when the button 3 is pressed.
default: []
selector:
action: {}
button_3_held:
name: Button 3 Held
description: Action to run, when the button 3 is held.
default: []
selector:
action: {}
button_3_released:
name: Button 3 released
description: Action to run, when the button 3 is released.
default: []
selector:
action: {}
button_4_pressed:
name: Button 4 Pressed
description: Action to run, when the button 4 is pressed.
default: []
selector:
action: {}
button_4_held:
name: Button 4 Held
description: Action to run, when the button 4 is held.
default: []
selector:
action: {}
button_4_released:
name: Button 4 released
description: Action to run, when the button 4 is released.
default: []
selector:
action: {}
button_1_and_3_pressed:
name: Button 1 and 3 Pressed
description: Action to run, when buttons 1 and 3 are pressed.
default: []
selector:
action: {}
button_1_and_3_held:
name: Button 1 and 3 Held
description: Action to run, when buttons 1 and 3 are held.
default: []
selector:
action: {}
button_1_and_3_released:
name: Button 1 and 3 released
description: Action to run, when buttons 1 and 3 are released after long press.
default: []
selector:
action: {}
button_2_and_4_pressed:
name: Button 2 and 4 Pressed
description: Action to run, when buttons 2 and 4 are pressed.
default: []
selector:
action: {}
button_2_and_4_held:
name: Button 2 and 4 Held
description: Action to run, when buttons 2 and 4 are held.
default: []
selector:
action: {}
button_2_and_4_released:
name: Button 2 and 4 released
description: Action to run, when buttons 2 and 4 are released after long press.
default: []
selector:
action: {}
mode: single
max_exceeded: silent
trigger:
- platform: event
event_type: state_changed
event_data:
entity_id: !input 'controller_entity'
conditions: '{{ trigger.event.data.new_state.state not in ("", "unknown", "unavailable", "None") }}'
actions:
- variables:
helper_last_controller_event: !input helper_last_controller_event
command: '{{ trigger.event.data.new_state.state }}'
prev_command: '{{ states(helper_last_controller_event) }}'
- action: input_text.set_value
data:
entity_id: !input helper_last_controller_event
value: '{{ command }}'
- choose:
- conditions: '{{ "press_" | string in command }}'
sequence:
- wait_for_trigger:
- trigger: state
entity_id: !input controller_entity
to: "release"
timeout:
milliseconds: !input hold_delay
- if: '{{ wait.trigger != None }}'
then:
- choose:
- conditions: '{{ command == "press_1" }}'
sequence: !input button_1_pressed
- conditions: '{{ command == "press_2" }}'
sequence: !input button_2_pressed
- conditions: '{{ command == "press_3" }}'
sequence: !input button_3_pressed
- conditions: '{{ command == "press_4" }}'
sequence: !input button_4_pressed
- conditions: '{{ command == "press_1_and_3" }}'
sequence: !input button_1_and_3_pressed
- conditions: '{{ command == "press_2_and_4" }}'
sequence: !input button_2_and_4_pressed
else:
- choose:
- conditions: '{{ command == "press_1" }}'
sequence: !input button_1_held
- conditions: '{{ command == "press_2" }}'
sequence: !input button_2_held
- conditions: '{{ command == "press_3" }}'
sequence: !input button_3_held
- conditions: '{{ command == "press_4" }}'
sequence: !input button_4_held
- conditions: '{{ command == "press_1_and_3" }}'
sequence: !input button_1_and_3_held
- conditions: '{{ command == "press_2_and_4" }}'
sequence: !input button_2_and_4_held
- conditions: '{{ "release" in command }}'
sequence:
- choose:
- conditions: '{{ prev_command == "press_1" }}'
sequence: !input button_1_released
- conditions: '{{ prev_command == "press_2" }}'
sequence: !input button_2_released
- conditions: '{{ prev_command == "press_3" }}'
sequence: !input button_3_released
- conditions: '{{ prev_command == "press_4" }}'
sequence: !input button_4_released
- conditions: '{{ prev_command == "press_1_and_3" }}'
sequence: !input button_1_and_3_released
- conditions: '{{ prev_command == "press_2_and_4" }}'
sequence: !input button_2_and_4_released