-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathikea_remotes_control-light.yaml
More file actions
364 lines (353 loc) · 10.8 KB
/
Copy pathikea_remotes_control-light.yaml
File metadata and controls
364 lines (353 loc) · 10.8 KB
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
blueprint:
homeassistant:
min_version: 2024.10.0
author: damru
domain: automation
name: Ikea's Simple Remotes 💡 Light control
description: >
## 💡 Control a light with **IKEA Bilresa** or **IKEA RODRET** or **IKEA SOMRIG** or **IKEA TRADFRI ON/OFF** remotes
Only for use with [ZHA](https://www.home-assistant.io/integrations/zha/)
or Zigbee2MQTT (cf [MQTT](https://www.home-assistant.io/integrations/mqtt)
+ [Z2M addon](https://www.zigbee2mqtt.io/guide/installation/03_ha_addon.html)).
Available controls:
- Press **on** button to turn on the light
(Optional: set the target brightness by enabling **Force Brightness** and setting a **Brightness** value)
- Press **off** button to turn off the light
- Hold **on** button to increase the brightness
- Hold **off** button to decrease the brightness down to 1%
input:
remote_devices:
name: Remotes
description: >
IKEA remote (Bilresa, Rodret, Somrig, Tradfri) to use.
default: []
selector:
device:
filter:
- integration: zha
manufacturer: IKEA of Sweden
model: 09B9
- integration: zha
manufacturer: IKEA of Sweden
model: RODRET Dimmer
- integration: zha
manufacturer: IKEA of Sweden
model: RODRET wireless dimmer
- integration: zha
manufacturer: IKEA of Sweden
model: SOMRIG shortcut button
- integration: zha
manufacturer: IKEA of Sweden
model: TRADFRI on/off switch
- integration: mqtt
manufacturer: IKEA
model: BILRESA remote control with buttons
- integration: mqtt
manufacturer: IKEA
model: RODRET wireless dimmer/power switch
- integration: mqtt
manufacturer: IKEA
model: SOMRIG shortcut button
- integration: mqtt
manufacturer: IKEA
model: TRADFRI on/off switch
# DEPRECATED - for removal, keeping for z2m v1 backward compatibility
- integration: mqtt
manufacturer: IKEA
model: RODRET wireless dimmer/power switch (E2201)
# DEPRECATED - for removal, keeping for z2m v1 backward compatibility
- integration: mqtt
manufacturer: IKEA
model: SOMRIG shortcut button (E2213)
# DEPRECATED - for removal, keeping for z2m v1 backward compatibility
- integration: mqtt
manufacturer: IKEA
model: TRADFRI on/off switch (E1743)
multiple: true
light:
name: Light
description: Light to control
selector:
entity:
filter:
domain: light
multiple: false
brightness_section:
name: Brightness
icon: mdi:lightbulb-on-50
collapsed: true
input:
helper_force_brightness:
name: Force brightness
description: Force the brightness to **Brightness** value when light turns on.
default: false
selector:
boolean: {}
helper_brightness:
name: Brightness
description:
Target light brightness when turning on. Requires **Force brightness**
to be enabled.
default: 50
selector:
number:
unit_of_measurement: "%"
min: 1.0
max: 100.0
step: 1.0
mode: slider
mode: restart
max_exceeded: silent
trigger_variables:
mqtt_enabled: "{{ integration_entities('mqtt') != [] }}"
remote_devices: !input remote_devices
zha_enabled: "{{ integration_entities('zha') != [] }}"
triggers:
###########################
# SINGLE PRESSES
###########################
- trigger: event
event_type: zha_event
event_data:
command: "on"
cluster_id: 6
endpoint_id: 1
id: press-on-zha
enabled: "{{ zha_enabled }}"
- trigger: mqtt
topic: "+/+/action"
payload: "on"
id: press-on-z2m
enabled: "{{ mqtt_enabled }}"
- trigger: event
event_type: zha_event
event_data:
command: "off"
cluster_id: 6
endpoint_id: 1
id: press-off-zha
enabled: "{{ zha_enabled }}"
- trigger: mqtt
topic: "+/+/action"
payload: "off"
id: press-off-z2m
enabled: "{{ mqtt_enabled }}"
- trigger: event
event_type: zha_event
event_data:
command: short_release
endpoint_id: 1
id: press-on-zha-somrig
enabled: "{{ zha_enabled }}"
- trigger: mqtt
topic: "+/+/action"
payload: 1_short_release
id: press-on-z2m-somrig
enabled: "{{ mqtt_enabled }}"
- trigger: event
event_type: zha_event
event_data:
command: short_release
endpoint_id: 2
id: press-off-zha-somrig
enabled: "{{ zha_enabled }}"
- trigger: mqtt
topic: "+/+/action"
payload: 2_short_release
id: press-off-z2m-somrig
enabled: "{{ mqtt_enabled }}"
###########################
# LONG PRESSES
###########################
- trigger: event
event_type: zha_event
event_data:
command: move_with_on_off
cluster_id: 8
endpoint_id: 1
id: hold-on-zha
enabled: "{{ zha_enabled }}"
- trigger: mqtt
topic: "+/+/action"
payload: brightness_move_up
id: hold-on-z2m
enabled: "{{ mqtt_enabled }}"
- trigger: event
event_type: zha_event
event_data:
command: move
cluster_id: 8
endpoint_id: 1
id: hold-off-zha
enabled: "{{ zha_enabled }}"
- trigger: mqtt
topic: "+/+/action"
payload: brightness_move_down
id: hold-off-z2m
enabled: "{{ mqtt_enabled }}"
- trigger: event
event_type: zha_event
event_data:
command: stop_with_on_off
endpoint_id: 1
cluster_id: 8
id: release-zha
enabled: "{{ zha_enabled }}"
- trigger: mqtt
topic: "+/+/action"
payload: brightness_stop
id: release-z2m
enabled: "{{ mqtt_enabled }}"
- trigger: event
event_type: zha_event
event_data:
command: long_press
endpoint_id: 1
id: hold-on-zha-somrig
enabled: "{{ zha_enabled }}"
- trigger: mqtt
topic: "+/+/action"
payload: 1_long_press
id: hold-on-z2m-somrig
enabled: "{{ mqtt_enabled }}"
- trigger: event
event_type: zha_event
event_data:
command: long_press
endpoint_id: 2
id: hold-off-zha-somrig
enabled: "{{ zha_enabled }}"
- trigger: mqtt
topic: "+/+/action"
payload: 2_long_press
id: hold-off-z2m-somrig
enabled: "{{ mqtt_enabled }}"
- trigger: event
event_type: zha_event
event_data:
command: long_release
endpoint_id: 1
id: release-hold-on-zha-somrig
enabled: "{{ zha_enabled }}"
- trigger: mqtt
topic: "+/+/action"
payload: 1_long_release
id: release-hold-on-z2m-somrig
enabled: "{{ mqtt_enabled }}"
- trigger: event
event_type: zha_event
event_data:
command: long_release
endpoint_id: 2
id: release-hold-off-zha-somrig
enabled: "{{ zha_enabled }}"
- trigger: mqtt
topic: "+/+/action"
payload: 2_long_release
id: release-hold-off-z2m-somrig
enabled: "{{ mqtt_enabled }}"
variables:
helper_force_brightness: !input helper_force_brightness
helper_hold_delay: 0.1
helper_hold_dim_step: 4
is_mqtt: "{{ trigger.platform == 'mqtt' }}"
is_zha: "{{ trigger.platform == 'event' and trigger.event.event_type == 'zha_event' }}"
light: !input light
mqtt_topic: "{{ trigger.topic }}"
remote_devices: !input remote_devices
remote_devices_names: "{{ remote_devices | map('device_attr', 'name') | list }}"
condition:
- condition: template
value_template: >-
{{
(trigger.event.data.device_id in remote_devices if is_zha) or
(trigger.topic.split('/')[1] in remote_devices_names if is_mqtt)
}}
actions:
- choose:
- conditions:
- condition: trigger
id:
- press-on-zha
- press-on-z2m
- press-on-zha-somrig
- press-on-z2m-somrig
sequence:
- choose:
- conditions: "{{ helper_force_brightness }}"
sequence:
- action: light.turn_on
target:
entity_id: !input light
data:
brightness_pct: !input helper_brightness
default:
- action: light.turn_on
target:
entity_id: !input light
data: {}
- conditions:
- condition: trigger
id:
- press-off-zha
- press-off-z2m
- press-off-zha-somrig
- press-off-z2m-somrig
sequence:
- action: light.turn_off
target:
entity_id: !input light
data: {}
- conditions:
- condition: trigger
id:
- hold-on-zha
- hold-on-z2m
- hold-on-zha-somrig
- hold-on-z2m-somrig
sequence:
- repeat:
while:
- condition: trigger
id:
- hold-on-zha
- hold-on-z2m
- hold-on-zha-somrig
- hold-on-z2m-somrig
sequence:
- parallel:
- action: light.turn_on
target:
entity_id: !input light
data:
brightness_step_pct: "{{ helper_hold_dim_step }}"
transition: "{{ helper_hold_delay }}"
- delay: "{{ helper_hold_delay }}"
- conditions:
- condition: trigger
id:
- hold-off-zha
- hold-off-z2m
- hold-off-zha-somrig
- hold-off-z2m-somrig
sequence:
- variables:
brightness_pct: "{{ iif(is_state(light, 'on'), state_attr(light, 'brightness'), 0) * 100 / 255 }}"
total_iterations_to_zero: "{{ (brightness_pct / helper_hold_dim_step) | round(0, 'ceil') }}"
- repeat:
count: "{{ total_iterations_to_zero - 1 }}"
sequence:
- parallel:
- action: light.turn_on
target:
entity_id: !input light
data:
brightness_step_pct: "{{ helper_hold_dim_step | int * -1 }}"
transition: "{{ helper_hold_delay }}"
- delay: "{{ helper_hold_delay }}"
- action: light.turn_on
target:
entity_id: !input light
data:
brightness_pct: 1
transition: "{{ helper_hold_delay }}"