-
Notifications
You must be signed in to change notification settings - Fork 185
/
control_switches.yaml
548 lines (505 loc) · 18.6 KB
/
control_switches.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
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
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
---
#-
# _ _ _ _ _
# ___ ___ _ __ | |_ _ __ ___ | | _____ _(_) |_ ___| |__ ___ ___
# / __/ _ \| '_ \| __| '__/ _ \| | / __\ \ /\ / / | __/ __| '_ \ / _ \/ __|
# | (_| (_) | | | | |_| | | (_) | | \__ \\ V V /| | || (__| | | | __/\__ \
# \___\___/|_| |_|\__|_| \___/|_|___|___/ \_/\_/ |_|\__\___|_| |_|\___||___/
# |_____|
#
#- from github.com/basnijholt/home-assistant-config
- alias: "Control switches: living room Philips Hue dimmer switch"
mode: parallel
trigger:
platform: mqtt
topic: "zigbee2mqtt/Dimmer Switch (Living room)"
variables:
action: "{{ trigger.payload_json.action }}"
action:
choose:
# Next color
- conditions: "{{ action == 'off_press' }}" # Lowest button
sequence:
service: script.next_colors
data:
input_select: input_select.last_script_living_room
# Bright lights
- conditions:
- "{{ action == 'up_press' }}" # Second from highest button
- condition: state
entity_id: light.living_room_lights
state: "on"
sequence:
- service: script.white_lights_living_room
- service: light.turn_on
entity_id: light.living_room_lights
data:
brightness: "255"
# Increase brightness
- conditions: "{{ action == 'on_press' }}" # Top button
sequence:
service: script.increase_brightness
data:
group: light.living_room_lights
# Turn on
- conditions:
- "{{ action == 'up_press' }}" # Second from highest button
- condition: state
entity_id: light.living_room_lights
state: "off"
sequence:
- service: light.turn_on
entity_id: light.living_room_lights
# Turn off
- conditions:
- "{{ action == 'down_press' }}" # Second from lowest button
- condition: state
entity_id: light.living_room_lights
state: "on"
sequence:
- service: light.turn_off
entity_id: light.living_room_lights
# Reset adaptive_lighting
- conditions:
- "{{ action == 'up_hold' }}" # Second from highest button
- "{{ trigger.payload_json.action_duration > 2 }}" # Hold for more than two seconds
sequence:
- service: script.reset_adaptive_lighting
- alias: "Control switches: bedroom Philips Hue dimmer switch"
mode: parallel
trigger:
platform: mqtt
topic: "zigbee2mqtt/Dimmer Switch (Bedroom)"
variables:
action: "{{ trigger.payload_json.action }}"
action:
choose:
# Next color
- conditions: "{{ action == 'off_press' }}" # Lowest button
sequence:
service: script.next_colors
data:
input_select: input_select.last_script_bedroom
# Bright lights
- conditions:
- "{{ action == 'up_press' }}" # Second from highest button
- condition: state
entity_id: light.bedroom_lights
state: "on"
sequence:
- service: script.white_lights_bedroom
- service: light.turn_on
entity_id: light.bedroom_lights
data:
brightness: "255"
# Increase brightness
- conditions: "{{ action == 'on_press' }}" # Top button
sequence:
service: script.increase_brightness
data:
group: light.bedroom_lights
# Turn on
- conditions:
- "{{ action == 'up_press' }}" # Second from highest button
- condition: state
entity_id: light.bedroom_lights
state: "off"
sequence:
- service: light.turn_on
entity_id: light.bedroom_lights
# Turn off
- conditions:
- "{{ action == 'down_press' }}" # Second from lowest button
- condition: state
entity_id: light.bedroom_lights
state: "on"
sequence:
- service: light.turn_off
entity_id: light.bedroom_lights
# Reset adaptive_lighting
- conditions:
- "{{ action == 'up_hold' }}" # Second from highest button
- "{{ trigger.payload_json.action_duration > 2 }}" # Hold for more than two seconds
sequence:
- service: script.reset_adaptive_lighting
# This automation is set up to control the lighting in your bedroom using two different IKEA remotes.
# Here's a simplified explanation of the different actions that the automation performs:
# 1. **Bright Lights:** If you hold the top button on the remote and the bedroom lights are already on, the lights will become brighter, mimicking a bright daylight environment.
# 2. **Increase Brightness:** If you press the top button on the remote and the bedroom lights are already on, the brightness of the lights will increase.
# 3. **Turn On:** If you press the top button on the remote and the bedroom lights are off, the bedroom lights will turn on.
# 4. **Turn Off:** If you press the 'off' button on the remote and the bedroom lights are on, the bedroom lights will turn off.
# 5. **Next Color:** If you press the 'arrow left' button on the remote, the color of the bedroom lights will cycle to the next color in a predefined sequence.
# 6. **Turn on bedside light:** If you press the 'arrow right' button on the remote, a personal light (either the 'bamboo' light if using the first remote, or the 'philips go' light if using the second remote) will toggle on or off. If the personal light is already on, pressing the 'arrow right' button will increase the brightness of the personal light.
# 7. **Turn off everything (no guests):** If you hold the bottom button on the remote and there are no guests in the house (as determined by the status of 'guest mode'), all lights in the house will turn off.
# 8. **Turn off baby room and bedroom (with guests):** If you hold the bottom button on the remote and there are guests in the house, the lights in the bedroom, baby room, and the baby sphere light will turn off.
- alias: "Control switches: bedroom IKEA dimmer switch"
mode: parallel
trigger:
- platform: mqtt
topic: "zigbee2mqtt/IKEA Remote (Bedroom)"
- platform: mqtt
topic: "zigbee2mqtt/IKEA Remote (Bedroom Marcella)"
variables:
action: "{{ trigger.payload_json.action }}"
personal_light: >-
{% if trigger.topic == 'zigbee2mqtt/IKEA Remote (Bedroom)' %}
light.bed_led
{% elif trigger.topic == 'zigbee2mqtt/IKEA Remote (Bedroom Marcella)' %}
light.philips_go
{% endif %}
action:
choose:
# Bright lights
- conditions:
- "{{ action == 'brightness_move_up' }}" # Hold top button
- condition: state
entity_id: light.bedroom_lights
state: "on"
sequence:
- service: script.white_lights_bedroom
- service: light.turn_on
entity_id: light.bedroom_lights
data:
brightness: "255"
kelvin: 5500
# Increase brightness
- conditions:
- "{{ action == 'on' }}" # Top button
- condition: state
entity_id: light.bedroom_lights
state: "on"
sequence:
service: script.increase_brightness
data:
group: light.bedroom_lights
# Turn on
- conditions:
- "{{ action == 'on' }}"
- condition: state
entity_id: light.bedroom_lights
state: "off"
sequence:
- service: light.turn_on
entity_id: light.bedroom_lights
# Turn off
- conditions:
- "{{ action == 'off' }}"
- condition: state
entity_id: light.bedroom_lights
state: "on"
sequence:
- service: light.turn_off
entity_id: light.bedroom_lights
# Next color
- conditions: "{{ action == 'arrow_left_click' }}"
sequence:
service: script.next_colors
data:
input_select: input_select.last_script_bedroom
# Turn on bedside light
- conditions:
- "{{ action == 'arrow_right_click' }}"
- "{{ is_state(personal_light, 'off') }}"
sequence:
service: light.toggle
data:
entity_id: "{{ personal_light }}"
- conditions:
- "{{ action == 'arrow_right_click' }}"
- "{{ is_state(personal_light, 'on') }}"
sequence:
service: script.increase_brightness
data:
group: "{{ personal_light }}"
# Turn off everything (no guests)
- conditions:
- "{{ action == 'brightness_move_down' }}" # Hold lowest button
- "{{ is_state('input_boolean.guest_mode', 'off') }}"
sequence:
- service: input_select.select_option
data:
entity_id: input_select.sleep_mode
option: total
- service: script.turn_off_everything
# Turn off baby room and bedroom (with guests)
- conditions:
- "{{ action == 'brightness_move_down' }}" # Hold lowest button
- "{{ is_state('input_boolean.guest_mode', 'on') }}"
sequence:
- service: input_select.select_option
data:
entity_id: input_select.sleep_mode
option: total
- service: light.turn_off
data:
entity_id:
- light.bedroom_lights
- light.baby_room_lights
- alias: "Control switches: living room Aqara Wireless Mini Switch"
mode: parallel
trigger:
platform: event
event_type: deconz_event
event_data:
id: smart_switch_living_room
action:
choose:
# Next color
- conditions: "{{ trigger.event.data.event == 1004 }}" # Double click
sequence:
service: script.next_colors
data:
input_select: input_select.last_script_living_room
# Increase brightness
- conditions: "{{ trigger.event.data.event == 1002 }}" # Single click
sequence:
service: script.increase_brightness
data:
group: light.living_room_lights
# Turn off everything in the living room
- conditions:
- "{{ trigger.event.data.event == 1007 }}" # Shake button
- condition: state
entity_id: light.living_room_lights
state: "on"
sequence:
- service: light.turn_on
data:
flash: "short"
entity_id: light.cabinet_led
- service: media_player.turn_off
entity_id: media_player.tv
- wait_template: "{{ is_state('media_player.tv', 'off') }}"
timeout: "00:00:30"
- service: media_player.turn_off
entity_id: media_player.kef_ls50
- service: light.turn_off
entity_id: light.living_room_lights
data:
transition: 30
# Fix the sounds on the TV (LG TV sound sync bug 🐛)
- conditions: "{{ trigger.event.data.event == 1001 }}" # Long click
sequence:
service: script.fix_sound
- alias: "Control switches: bedroom Aqara Wireless Mini Switch"
mode: parallel
trigger:
- platform: event
event_type: deconz_event
event_data:
id: smart_switch_bedroom_bas
- platform: event
event_type: deconz_event
event_data:
id: smart_switch_bedroom_marcella
action:
choose:
# Next color
- conditions: "{{ trigger.event.data.event == 1004 }}" # Double click
sequence:
service: script.next_colors
data:
input_select: input_select.last_script_bedroom
# Increase brightness
- conditions: "{{ trigger.event.data.event == 1002 }}" # Single click
sequence:
service: script.increase_brightness
data:
group: light.bedroom_lights
# Turn off lights in and next to bedroom
- conditions: "{{ trigger.event.data.event == 1001 }}" # Long click
sequence:
service: light.turn_off
entity_id:
- light.hall_lights
- light.bedroom_lights
- light.bathroom_ceiling
- light.stairs_lights
# Turn on sleep mode, else, turn all lights off
- conditions: "{{ trigger.event.data.event == 1007 }}" # Shake button
sequence:
choose:
- conditions: > # In the morning just turn lights off
{% set h, m = states("sensor.ten_minutes_before_alarm").split(":") %}
{% set t_diff = as_timestamp(now()) - as_timestamp(now().replace(hour=h|int(0), minute=m|int(0))) %}
{% set is_near_alarm = (t_diff|abs) < 1800 %}
{% set is_morning = now().replace(hour=6, minute=0) < now() < now().replace(hour=12, minute=0) %}
{{ is_near_alarm or is_morning }}
sequence:
service: light.turn_off
entity_id: all
- conditions: # off -> half
condition: state
entity_id: input_select.sleep_mode
state: "off"
sequence:
- service: light.turn_off
entity_id:
- light.hall_lights
- light.bedroom_lights
- light.bathroom_ceiling
- light.stairs_lights
- service: input_select.select_option
entity_id: input_select.sleep_mode
data:
option: half
- conditions: # half -> total
condition: state
entity_id: input_select.sleep_mode
state: half
sequence:
- service: script.turn_off_everything
- service: input_select.select_option
entity_id: input_select.sleep_mode
data:
option: total
- conditions: # on total, just turn lights off
condition: state
entity_id: input_select.sleep_mode
state: total
sequence:
service: light.turn_off
entity_id: all
- alias: "Control switches: bathroom Aqara Wireless Mini Switch"
mode: parallel
trigger:
platform: event
event_type: deconz_event
event_data:
id: smart_switch_bathroom
action:
choose:
# Toggle lights
- conditions: "{{ trigger.event.data.event == 1002 }}" # Single click
sequence:
service: light.toggle
entity_id: light.bathroom_lights
# Flash all lights
- conditions: "{{ trigger.event.data.event == 1004 }}" # Double click
sequence:
- service: light.turn_on
data:
entity_id: light.living_room_lights
flash: "short"
- alias: "Control switches: door Aqara Wireless Mini Switch"
mode: parallel
trigger:
platform: event
event_type: deconz_event
event_data:
id: smart_switch_door
action:
choose:
# Leaving: turn off everything
- conditions: "{{ trigger.event.data.event == 1002 }}" # Single click
sequence:
- service: light.turn_on
data:
entity_id: light.living_room_lights
flash: "short"
- service: script.turn_off_everything_non_automatic
- service: script.set_low_temperature
- if: "{{ is_state_attr('media_player.spotify', 'source', 'KEF LS50') and is_state('media_player.spotify', 'playing') }}"
then:
- service: media_player.media_pause
entity_id: media_player.spotify
# Arriving: turn on music and cozy lights
- conditions: "{{ trigger.event.data.event == 1004 }}" # Double click
sequence:
- service: light.turn_on
data:
flash: "short"
entity_id: light.ceiling_kitchen
- service: script.turn_on
data:
entity_id: light.living_room_lights
- service: script.arriving
- service: script.start_spotify
data:
source: KEF LS50
id: 'playlist:{{ states("sensor.favorite_playlist_of_nearest_person") }}'
volume: 0.25
- alias: "Control switches: guest room IKEA Switch"
mode: parallel
trigger:
platform: mqtt
topic: "zigbee2mqtt/IKEA Switch (Guest room)"
variables:
action: "{{ trigger.payload_json.action }}"
action:
choose:
# Turn on
- conditions: "{{ action == 'on' }}" # Lowest button
sequence:
service: light.turn_on
entity_id: light.guest_room_lights
# Turn off
- conditions: "{{ action == 'off' }}" # Lowest button
sequence:
service: light.turn_off
entity_id: light.guest_room_lights
- alias: "Control switches: Guest Room Light"
mode: parallel
trigger:
platform: mqtt
topic: "zigbee2mqtt/Smart Switch (Guest Room)"
variables:
action: "{{ trigger.payload_json.action }}"
action:
choose:
# Toggle
- conditions: "{{ action == 'single' }}"
sequence:
service: light.toggle
data:
entity_id: light.guest_room_lights
- alias: "Control switches: Baby Room Light"
mode: parallel
trigger:
platform: mqtt
topic: "zigbee2mqtt/Smart Switch (Baby Room)"
variables:
action: "{{ trigger.payload_json.action }}"
action:
choose:
# Toggle light
- conditions: "{{ action == 'single' }}"
sequence:
service: light.toggle
data:
entity_id:
- light.baby_room_lights
# Toggle sleep mode
- conditions: "{{ action == 'double' }}"
sequence:
service: switch.toggle
entity_id: switch.adaptive_lighting_sleep_mode_baby_room
- alias: "Control switches: Mid Room Changing Table Light"
mode: parallel
trigger:
platform: mqtt
topic: "zigbee2mqtt/Smart Switch (Mid Room)"
variables:
action: "{{ trigger.payload_json.action }}"
action:
choose:
# Toggle
- conditions: "{{ action == 'single' }}"
sequence:
service: light.toggle
data:
entity_id: light.mid_room
brightness_pct: 100
rgb_color: [255, 15, 38]
# Change brightness
- conditions: "{{ action == 'double' }}"
sequence:
service: script.increase_brightness
data:
group: light.mid_room
# Next colors
- conditions: "{{ action == 'hold' }}"
sequence:
service: script.next_colors
data:
input_select: input_select.last_script_living_room