-
Notifications
You must be signed in to change notification settings - Fork 185
/
scripts.yaml
618 lines (594 loc) · 17.6 KB
/
scripts.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
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
#-
# _ _
# ___ ___ _ __(_)_ __ | |_ ___
# / __|/ __| '__| | '_ \| __/ __|
# \__ \ (__| | | | |_) | |_\__ \
# |___/\___|_| |_| .__/ \__|___/
# |_|
#
#- from github.com/basnijholt/home-assistant-config
start_speakers:
alias: Start speakers
description: Start a Spotify playlist on KEF speakers
fields:
volume:
description: Volume at which to play
example: "0.3"
source:
description: Which source to use on the speakers
example: Wifi
entity_id:
description: entity_id of the speaker
example: media_player.kef_ls50
sequence:
- service: media_player.turn_on
data:
entity_id: "{{ entity_id }}"
- service: media_player.select_source
data:
entity_id: "{{ entity_id }}"
source: "{{ source }}"
- wait_template: '{{ is_state("media_player.kef_ls50", "on") }}'
timeout: 00:01:00
continue_on_timeout: false
- service: media_player.volume_set
data:
entity_id: "{{ entity_id }}"
volume_level: "{{ volume }}"
start_spotify:
alias: Start Spotify
description: Start a Spotify playlist on KEF speakers
fields:
source:
description: The name of the speaker as it appears in Spotify
example: Sonos One
playlist:
description: The playlist URI from Spotify
example: 6rPTm9dYftKcFAfwyRqmDZ
sequence:
- service: homeassistant.update_entity
entity_id: media_player.spotify
- wait_template: '{{ source in state_attr("media_player.spotify", "source_list") }}'
timeout: 00:01:00
continue_on_timeout: false
- service: media_player.select_source
entity_id: media_player.spotify
data:
source: "{{ source }}"
- service: media_player.shuffle_set
entity_id: media_player.spotify
data:
shuffle: true
- service: media_player.play_media
data:
entity_id: media_player.spotify
media_content_type: "playlist"
media_content_id: spotify:playlist:{{ playlist }}
- service: media_player.media_play
entity_id: media_player.spotify
start_spotify_playlist_of_nearest_person:
alias: Start Spotify
description: Start a Spotify playlist on KEF speakers
fields:
source:
description: The name of the speaker as it appears in Spotify
example: Sonos One
entity_id:
description: entity_id of the speaker
example: media_player.kef_ls50
sequence:
- service: script.start_speakers
data:
source: Wifi
volume: 0.25
entity_id: "{{ entity_id }}"
- service: script.start_spotify
data:
source: "{{ source }}"
playlist: >
{{ states("sensor.favorite_playlist_of_nearest_person") }}
volume: 0.25
cozy_lights_living_room:
alias: Set cozy lights in the living room
mode: parallel
sequence:
- data:
entity_id: light.sphere_1
hs_color:
- 336.293
- 80.392
service: light.turn_on
- data:
entity_id: light.sphere_2
hs_color:
- 299.147
- 82.745
service: light.turn_on
- data:
entity_id: light.corner_living_room
hs_color:
- 26.667
- 88.235
service: light.turn_on
- data:
entity_id: light.ceiling_living_room
hs_color:
- 268.267
- 88.235
service: light.turn_on
- data:
entity_id: light.tv_led
hs_color:
- 26.725
- 89.804
service: light.turn_on
- service: input_select.select_option
entity_id: input_select.last_script_living_room
data:
option: script.cozy_lights_living_room
cozy_lights_bedroom:
alias: Set cozy lights in the bedroom
mode: parallel
sequence:
- data:
entity_id: light.bamboo
hs_color:
- 299.72
- 83.922
service: light.turn_on
- data:
entity_id: light.philips_go
hs_color:
- 0
- 100
service: light.turn_on
- data:
entity_id: light.bed_reading_up
hs_color:
- 26.725
- 89.804
service: light.turn_on
- data:
entity_id: light.bed_reading_down
hs_color:
- 26.725
- 89.804
service: light.turn_on
- data:
entity_id: light.lampan
hs_color:
- 269.86
- 84.314
service: light.turn_on
- data:
entity_id: light.ceiling_bedroom
hs_color:
- 22
- 100
service: light.turn_on
- data:
entity_id: light.bed_led
hs_color:
- 10
- 100
service: light.turn_on
- service: input_select.select_option
entity_id: input_select.last_script_bedroom
data:
option: script.cozy_lights_bedroom
white_lights_living_room:
alias: Set white lights in the living room
mode: parallel
sequence:
- service: light.turn_on
data:
entity_id:
- light.living_room_lights
color_temp: 366
- service: input_select.select_option
entity_id: input_select.last_script_living_room
data:
option: script.white_lights_living_room
white_lights_bedroom:
alias: Set white lights in the bedroom
mode: parallel
sequence:
- data:
color_temp: 366
entity_id:
- light.bedroom_lights
service: light.turn_on
- service: input_select.select_option
entity_id: input_select.last_script_bedroom
data:
option: script.white_lights_bedroom
increase_brightness:
alias: Increase the brightness of a group of lights
mode: parallel
fields:
group:
description: The group to apply the light increase to.
example: light.living_room_lights
sequence:
- service: light.turn_on
data:
entity_id: "{{ group }}"
brightness: >
{% set b = state_attr(group, 'brightness') %}
{% if b == None %}
10
{% elif b < 20 %}
128
{% elif b < 140 %}
255
{% else %}
10
{% endif %}
turn_off_everything_non_automatic:
alias: Turn off everything
mode: parallel
sequence:
- service: light.turn_off
data:
transition: 4
entity_id:
- light.living_room_lights
- light.bedroom_lights
- service: media_player.turn_off
entity_id: media_player.kef_ls50
- service: media_player.turn_off
entity_id: media_player.kef_lsx
- service: media_player.turn_off
entity_id: media_player.tv
turn_off_everything:
alias: Turn off everything
mode: parallel
sequence:
- service: script.turn_off_everything_non_automatic
- service: light.turn_off
entity_id: all
going_to_sleep:
alias: Going to sleep
mode: parallel
sequence:
- entity_id: input_select.sleep_mode
service: input_select.select_option
data:
option: "total"
- service: script.turn_off_everything_non_automatic
next_colors:
alias: Change the colors of lights
mode: parallel
fields:
input_select:
description: The input select that lists script names.
example: input_select.last_script_living_room
sequence:
- service: input_select.select_next
data:
entity_id: "{{ input_select }}"
- service: "{{ states(input_select) }}"
start_netflix:
alias: Start Netflix
sequence:
- entity_id: media_player.tv
service: media_player.turn_on
- data:
source: Netflix
entity_id: media_player.tv
service: media_player.select_source
set_low_temperature:
alias: Set low temperature
sequence:
- service: climate.set_temperature
entity_id: climate.thermostat
data:
temperature: >
{{ states("input_number.temperature_low") }}
set_high_temperature:
alias: Set high temperature
sequence:
- service: climate.set_temperature
entity_id: climate.thermostat
data:
temperature: >
{{ states("input_number.temperature_high") }}
leaving:
alias: Leaving the house
sequence:
- service: script.set_low_temperature
- service: script.turn_off_everything
arriving:
alias: Arriving home
sequence:
- service: script.set_high_temperature
- service: script.cozy_lights_living_room
update_dns:
alias: Update DNS record
sequence:
- service: shell_command.update_dns
data:
api: !secret gandi_api_key
domain: !secret domain
subdomain: !secret subdomain
fix_sound:
alias: Fix Opt LG Sound Sync bug
sequence:
- service: webostv.button
entity_id: media_player.tv
data:
button: MENU # Open "Menu"
- delay:
milliseconds: 1000
- service: webostv.button
entity_id: media_player.tv
data:
button: UP # Navigate to "All settings"
- delay:
milliseconds: 500
- service: webostv.button
entity_id: media_player.tv
data:
button: ENTER # enter into "All settings"
- delay:
milliseconds: 1500
- service: webostv.button
entity_id: media_player.tv
data:
button: DOWN # Navigate to "Sound"
- delay:
milliseconds: 1500
- service: webostv.button
entity_id: media_player.tv
data:
button: RIGHT # Move into "Sound" menu
- delay:
milliseconds: 500
- service: webostv.button
entity_id: media_player.tv
data:
button: ENTER # Enter "Sound Out" menu
- delay:
milliseconds: 1500
- service: webostv.button
entity_id: media_player.tv
data:
button: DOWN # Move to "Optical"
- delay:
milliseconds: 500
- service: webostv.button
entity_id: media_player.tv
data:
button: DOWN # Move to "Optical - LG Sound Sync"
- delay:
milliseconds: 500
- service: webostv.button
entity_id: media_player.tv
data:
button: ENTER # Disable "LG Sound Sync"
- delay:
milliseconds: 500
- service: webostv.button
entity_id: media_player.tv
data:
button: ENTER # Enable "LG Sound Sync"
- delay:
milliseconds: 500
- service: webostv.button
entity_id: media_player.tv
data:
button: BACK # Go up one menu in "All settings"
- delay:
milliseconds: 500
- service: webostv.button
entity_id: media_player.tv
data:
button: BACK # Close the "All settings" window
sync_kef_dsp:
alias: Sync KEF DSP setting with input_number, input_select, or input_boolean
mode: parallel
max: 20
fields:
trigger_entity_id:
description: trigger_entity_id
attribute:
description: attribute
domain:
description: domain
example: select
name:
description: name
example: kef_ls50
variables:
media_player: "{{ 'media_player.{}'.format(name) }}"
input_helper: "{{ 'input_{}.{}_{}'.format(domain, name, attribute) }}"
attribute_value: "{{ state_attr(media_player, attribute) }}"
trigger_to_state: >
{% if trigger_entity_id == media_player %}
{{ state_attr(media_player, attribute) }}
{% else %}
{{ states(input_helper) }}
{% endif %}
sequence:
- condition: template
value_template: "{{ is_state(media_player, 'on') }}"
- choose:
# input_number
- conditions: "{{ domain == 'number' }}"
sequence:
choose:
# KEF has changed
- conditions: "{{ trigger_entity_id == media_player }}"
sequence:
service: input_number.set_value
data:
entity_id: "{{ input_helper }}"
value: "{{ attribute_value | float }}"
# input_number changed
- conditions: "{{ trigger_entity_id == input_helper }}"
sequence:
service: kef_custom.set_{{ attribute }}
data:
entity_id: "{{ media_player }}"
"{{ attribute[-2:] }}_value": "{{ trigger_to_state }}"
# input_select or input_boolean
- conditions: "{{ domain in ('select', 'boolean') }}"
sequence:
choose:
# KEF has changed, select
- conditions: "{{ trigger_entity_id == media_player and domain == 'select' }}"
sequence:
service: input_select.select_option
data:
entity_id: "{{ input_helper }}"
option: "{{ attribute_value }}"
# KEF has changed, boolean
- conditions: "{{ trigger_entity_id == media_player and domain == 'boolean' }}"
sequence:
service: "input_boolean.turn_{{ 'on' if attribute_value == 'True' else 'off' }}"
data:
entity_id: "{{ input_helper }}"
# input_select or input_boolean changed
- conditions: "{{ trigger_entity_id == input_helper }}"
sequence:
service: kef_custom.set_mode
data:
entity_id: "{{ media_player }}"
"{{ attribute }}": "{{ trigger_to_state }}"
utility_notification:
mode: parallel
max: 20
fields:
name:
description: name
example: washing_machine
emojis:
description: emojis
example: "👚👕"
variables:
switch: "{{ 'switch.{}'.format(name) }}"
binary_sensor: "{{ 'binary_sensor.{}'.format(name) }}"
friendly_name: "{{ name.capitalize().replace('_', ' ') }}"
energy_sensor: "{{ 'sensor.{}_energy'.format(name) }}"
sequence:
- variables:
start_time: "{{ as_timestamp(now()) }}"
start_kwh: "{{ states(energy_sensor) }}"
- wait_for_trigger:
platform: template
value_template: "{{ is_state(binary_sensor, 'off') }}"
timeout: "03:00:00"
continue_on_timeout: false
- variables:
end_time: "{{ as_timestamp(now()) }}"
end_kwh: "{{ states(energy_sensor) }}"
- variables:
total_time: "{{ (end_time - start_time) }}"
total_kwh: "{{ end_kwh - start_kwh }}"
- variables:
minutes: "{{ (total_time / 60) | round(0) }}"
total_kwh_rounded: "{{ (total_kwh) | round(2) }}"
price: "{{ (states('sensor.electricity_price_peak')|float * total_kwh) | round(2) }}"
- service: "{{ states('sensor.nearest_iphone_notify') }}"
data:
title: "Utilities"
message: "{{ friendly_name }} is done after {{ minutes }} minutes and it used {{ total_kwh_rounded }} kWh (€{{ price }}) {{ emojis }}"
vacuum_command:
alias: Vacuum living room
icon: mdi:robot-vacuum
fields:
option:
description: living_room, bedroom, office, hall, kitchen, all, or stop
example: living_room
sequence:
choose:
# living_room
- conditions: "{{ option == 'living_room' }}"
sequence:
service: vacuum.send_command
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
command: app_zoned_clean
params: [[29706, 27237, 34806, 31137, 1]]
# bedroom
- conditions: "{{ option == 'bedroom' }}"
sequence:
service: vacuum.send_command
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
command: app_zoned_clean
params: [[22799, 27340, 27649, 31240, 1]]
# office
- conditions: "{{ option == 'office' }}"
sequence:
service: vacuum.send_command
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
command: app_zoned_clean
params: [[22803, 25150, 26353, 27250, 1]]
# hall
- conditions: "{{ option == 'hall' }}"
sequence:
service: vacuum.send_command
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
command: app_zoned_clean
params: [[26379, 26239, 31929, 27189, 1]]
# kitchen
- conditions: "{{ option == 'kitchen' }}"
sequence:
service: vacuum.send_command
data:
entity_id: vacuum.xiaomi_vacuum_cleaner
command: app_zoned_clean
params: [[31941, 25364, 34791, 27164, 1]]
# all
- conditions: "{{ option == 'all' }}"
sequence:
service: vacuum.start
entity_id: vacuum.xiaomi_vacuum_cleaner
# stop
- conditions: "{{ option == 'stop' }}"
sequence:
service: vacuum.return_to_base
entity_id: vacuum.xiaomi_vacuum_cleaner
turn_on_lights:
alias: Turn on lights with Adaptive Lighting
icon: mdi:lamp
fields:
entity_id:
description: entity_id of light
example: light.bedroom_lights
sequence:
service: adaptive_lighting.apply
data:
entity_id: switch.adaptive_lighting_living_room
lights: "{{ entity_id }}"
turn_on_lights: true
reset_adaptive_lighting:
alias: Reset 'manual control'
sequence:
- service: adaptive_lighting.set_manual_control
data:
entity_id: switch.adaptive_lighting_default
manual_control: false
- service: adaptive_lighting.set_manual_control
data:
entity_id: switch.adaptive_lighting_default_bed
manual_control: false
- service: adaptive_lighting.set_manual_control
data:
entity_id: switch.adaptive_lighting_half_and_dim
manual_control: false
- service: adaptive_lighting.set_manual_control
data:
entity_id: switch.adaptive_lighting_half_and_dim_bed
manual_control: false
- service: adaptive_lighting.set_manual_control
data:
entity_id: switch.adaptive_lighting_half_and_full
manual_control: false
- service: adaptive_lighting.set_manual_control
data:
entity_id: switch.adaptive_lighting_living_room
manual_control: false