-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPTM_216Z_v2.yaml
238 lines (234 loc) · 8.75 KB
/
PTM_216Z_v2.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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
blueprint:
homeassistant:
min_version: 2024.10.0
name: EnOcean PTM 216Z (MQTT trigger) (v2)
description: |
Controller automation for executing **press/hold/release** after hold actions triggered by EnOcean PTM 216Z switch.
**Elapsed** has to be enabled in Zigbee2mqtt (Settings --> Advanced).
Make sure to manually create a separate **Text Helper** and define its entity in the automation. It's used to store the last controller event to filter and handle 'button hold' actions.
**SETTINGS**
In this tab, there is the possibility to change different parameters.
- **Base topic**
- **Hold delay**
- **Text Helper**
ℹ️ Version 2025.02.19
domain: automation
input:
controller:
name: Controller Name
description: The name of the controller as defined in Z2M (e.g. Livingroom_Switch)
default: []
settings_section:
name: Settings
icon: mdi:cog-outline
collapsed: true
input:
base_topic:
name: Base topic (MQTT)
description: The base topic as configured in z2m
default: zigbee2mqtt
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
helper_last_controller_event:
name: 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
ptm216z_actions:
name: PTM216Z - Actions
icon: mdi:gesture-tap
collapsed: true
input:
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 after long press.
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 after long press.
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 after long press.
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 after long press.
default: []
selector:
action: {}
button_1_and_3_pressed:
name: Buttons 1 and 3 Pressed
description: Action to run, when buttons 1 and 3 are pressed.
default: []
selector:
action: {}
button_1_and_3_held:
name: Buttons 1 and 3 Held
description: Action to run, when buttons 1 and 3 are held.
default: []
selector:
action: {}
button_1_and_3_released:
name: Buttons 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: Buttons 2 and 4 Pressed
description: Action to run, when buttons 2 and 4 are pressed.
default: []
selector:
action: {}
button_2_and_4_held:
name: Buttons 2 and 4 Held
description: Action to run, when buttons 2 and 4 are held.
default: []
selector:
action: {}
button_2_and_4_released:
name: Buttons 2 and 4 Released
description: Action to run, when buttons 2 and 4 are released after long press.
default: []
selector:
action: {}
source_url: https://github.com/chris-1243/HA---Blueprint/blob/main/PTM_216Z_v2.yaml
mode: restart
max_exceeded: silent
trigger_variables:
base_topic: !input base_topic
controller: !input controller
triggers:
- trigger: mqtt
topic: '{{ base_topic ~ "/" ~ controller }}'
conditions:
and:
- '{{ trigger.payload_json.action is defined }}'
- '{{ trigger.payload_json.action.split("_", 1)[0] in ("press", "release") }}'
actions:
- variables:
helper_last_controller_event: !input helper_last_controller_event
hold_delay: !input hold_delay
command: '{{ trigger.payload_json.action }}'
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:
- delay:
milliseconds: !input "hold_delay"
- 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:
- if: '{{ trigger.payload_json.elapsed | int > hold_delay }}'
then:
- 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
else:
- choose:
- conditions: '{{ prev_command == "press_1" }}'
sequence: !input button_1_pressed
- conditions: '{{ prev_command == "press_2" }}'
sequence: !input button_2_pressed
- conditions: '{{ prev_command == "press_3" }}'
sequence: !input button_3_pressed
- conditions: '{{ prev_command == "press_4" }}'
sequence: !input button_4_pressed
- conditions: '{{ prev_command == "press_1_and_3" }}'
sequence: !input button_1_and_3_pressed
- conditions: '{{ prev_command == "press_2_and_4" }}'
sequence: !input button_2_and_4_pressed