-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.yaml
236 lines (236 loc) · 7.58 KB
/
test.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
blueprint:
name: Philips Hue Dimmer switch v2 (Zigbee2MQTT)
description:
"Tested with Philips Hue Smart Wireless Dimmer Switch V2 (929002398602).
\n\n To have different actions on short press and on hold (long press), use 'button
release' (`*_press_release`) and 'button hold once' (`*_hold_once`) commands,
as 'press' (`*_press`) will always trigger before 'button hold' (`*_hold`). \n\n
When you hold a button, 'button hold' (`*_hold`) command is repeated roughly once
per second. This may not work as desired with actions like toggling light/switch.
If you want an action to run only once when the button hold action is registered,
use 'button hold once' (`*_hold_once`). It's better than using 'button hold release'
as the result can be observed before releasing the button after holding. \n\n
As 'button hold' action is repeated by the device while you keep holding the button,
it's a good way to run actions which increment / decrement some value (such as
light dimming). To make it react as soon as the button is pressed, copy the same
action to 'button press' (press action occurs immediately, while hold action occurs
after a delay). \n\n Make sure to manually create a separate Text Helper per dimmer
device 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 once' actions. "
domain: automation
input:
mqtt_topic:
name: MQTT Topic
description: Topic of the Philips Hue Motion
default: zigbee2mqtt/<device name>
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
on_press:
name: ON button press
description: Action to run
default: []
selector:
action: {}
on_press_release:
name: ON button release
description: Action to run
default: []
selector:
action: {}
on_hold:
name: ON button hold
description: Action to run (repeat while holding)
default: []
selector:
action: {}
on_hold_once:
name: ON button hold once
description: Action to run only once (no repeat)
default: []
selector:
action: {}
on_hold_release:
name: ON button hold release
description: Action to run
default: []
selector:
action: {}
up_press:
name: UP button press
description: Action to run
default: []
selector:
action: {}
up_press_release:
name: UP button release
description: Action to run
default: []
selector:
action: {}
up_hold:
name: UP button hold
description: Action to run (repeat while holding)
default: []
selector:
action: {}
up_hold_once:
name: UP button hold once
description: Action to run only once (no repeat)
default: []
selector:
action: {}
up_hold_release:
name: UP button hold release
description: Action to run
default: []
selector:
action: {}
down_press:
name: DOWN button press
description: Action to run
default: []
selector:
action: {}
down_press_release:
name: DOWN button release
description: Action to run
default: []
selector:
action: {}
down_hold:
name: DOWN button hold
description: Action to run (repeat while holding)
default: []
selector:
action: {}
down_hold_once:
name: DOWN button hold once
description: Action to run only once (no repeat)
default: []
selector:
action: {}
down_hold_release:
name: DOWN button hold release
description: Action to run
default: []
selector:
action: {}
off_press:
name: OFF/HUE button press
description: Action to run
default: []
selector:
action: {}
off_press_release:
name: OFF/HUE button release
description: Action to run
default: []
selector:
action: {}
off_hold:
name: OFF/HUE button hold
description: Action to run (repeat while holding)
default: []
selector:
action: {}
off_hold_once:
name: OFF/HUE button hold once
description: Action to run only once (no repeat)
default: []
selector:
action: {}
off_hold_release:
name: OFF/HUE button hold release
description: Action to run
default: []
selector:
action: {}
source_url: https://gist.github.com/CrazyCoder/28d660d9e2e8464458e591ad79b3698e
mode: restart
max_exceeded: silent
trigger:
- platform: mqtt
topic: !input mqtt_topic
condition:
- condition: template
value_template: "{{ 'action' in trigger.payload_json and trigger.payload_json.action != '' }}"
action:
- variables:
helper_last_controller_event: !input helper_last_controller_event
command: "{{ trigger.payload_json.action }}"
prev_command: "{{ states(helper_last_controller_event) }}"
- service: input_text.set_value
data:
entity_id: !input helper_last_controller_event
value: "{{ command }}"
- choose:
- conditions:
- '{{ command == "on_press" }}'
sequence: !input on_press
- conditions:
- '{{ command == "on_press_release" }}'
sequence: !input on_press_release
- conditions:
- '{{ command == "on_hold" }}'
sequence: !input on_hold
- conditions:
- '{{ command == "on_hold_release" }}'
sequence: !input on_hold_release
- conditions:
- '{{ command == "up_press" }}'
sequence: !input up_press
- conditions:
- '{{ command == "up_press_release" }}'
sequence: !input up_press_release
- conditions:
- '{{ command == "up_hold" }}'
sequence: !input up_hold
- conditions:
- '{{ command == "up_hold_release" }}'
sequence: !input up_hold_release
- conditions:
- '{{ command == "down_press" }}'
sequence: !input down_press
- conditions:
- '{{ command == "down_press_release" }}'
sequence: !input down_press_release
- conditions:
- '{{ command == "down_hold" }}'
sequence: !input down_hold
- conditions:
- '{{ command == "down_hold_release" }}'
sequence: !input down_hold_release
- conditions:
- '{{ command == "off_press" }}'
sequence: !input off_press
- conditions:
- '{{ command == "off_press_release" }}'
sequence: !input off_press_release
- conditions:
- '{{ command == "off_hold" }}'
sequence: !input off_hold
- conditions:
- '{{ command == "off_hold_release" }}'
sequence: !input off_hold_release
- choose:
- conditions:
- '{{ command == "on_hold" and prev_command == "on_press" }}'
sequence: !input on_hold_once
- conditions:
- '{{ command == "up_hold" and prev_command == "up_press" }}'
sequence: !input up_hold_once
- conditions:
- '{{ command == "down_hold" and prev_command == "down_press" }}'
sequence: !input down_hold_once
- conditions:
- '{{ command == "off_hold" and prev_command == "off_press" }}'
sequence: !input off_hold_once