forked from matt8707/hass-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautomations.yaml
executable file
·695 lines (643 loc) · 21.2 KB
/
automations.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
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
####################################################
# #
# AUTOMATIONS #
# #
####################################################
- alias: homeassistant_start
initial_state: true
trigger:
- platform: homeassistant
event: start
action:
- service: frontend.set_theme
data:
name: slate
- delay: 00:00:30
- service: homekit.start
- condition: state
entity_id: light.hall
state: 'off'
- service: switch.turn_on
entity_id: switch.fullykiosk_screensaver
- alias: restart_homekit
initial_state: true
trigger:
platform: time
at: '04:00:00'
action:
- service: homekit.start
- alias: clear_log_filesize
initial_state: true
trigger:
- platform: numeric_state
entity_id: sensor.home_assistant_log
above: 50
action:
- service: shell_command.clear_logs
- alias: dator_on_update
initial_state: true
trigger:
- platform: state
entity_id: switch.dator_template
from: 'off'
to: 'on'
action:
- service: light.turn_on
entity_id:
['light.datorlampa', 'light.taklampor']
- delay: 00:00:05
- service: homeassistant.update_entity
entity_id:
['sensor.imac_cpu_per', 'sensor.imac_mem_per', 'sensor.imac_system_ssd',
'sensor.imac_macintosh_hd', 'sensor.imac_time_machine', 'sensor.getvolume',
'sensor.macos_uptime']
- alias: krisinformation_visibility
initial_state: true
trigger:
- platform: state
entity_id: sensor.krisinformation_time_trigger
action:
- service_template: >
{% if is_state(trigger.entity_id, 'true') %}
input_boolean.turn_on {% else %}
input_boolean.turn_off {% endif %}
data:
entity_id: input_boolean.krisinformation_visibility
####################################################
# #
# NOTIFICATIONS #
# #
####################################################
- alias: toast
initial_state: true
trigger:
- platform: state
entity_id:
['input_boolean.motion_garderob', 'input_boolean.motion_badrum',
'binary_sensor.wemo_motion']
from: 'off'
to: 'on'
action:
- service: browser_mod.toast
data_template:
duration: 8000
message: Rörelse detekterat i {{ trigger.to_state.name }}
- service: input_boolean.turn_off
data_template:
entity_id: "{{ trigger.entity_id }}"
- alias: notification_motion_hall
initial_state: 'false'
trigger:
- platform: state
entity_id: input_boolean.motion_hall
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: switch.dator_template
state: 'on'
action:
- service: shell_command.notify_motion_hall
####################################################
# #
# LIGHTS #
# #
####################################################
# - alias: light_studio_auto
# initial_state: true
# trigger:
# - platform: state
# entity_id: switch.switchbot
# condition:
# - condition: state
# entity_id: switch.dator_template
# state: 'off'
# action:
# - service: light.turn_on
# entity_id:
# ['light.datorlampa', 'light.taklampor']
- alias: light_studio_manual
initial_state: true
trigger:
- platform: state
entity_id: switch.dator_template
from: 'off'
to: 'on'
action:
- service: light.turn_on
entity_id:
['light.datorlampa', 'light.taklampor']
####################################################
# #
# MONITORS #
# #
####################################################
- alias: monitorer_volume_slider
initial_state: true
trigger:
platform: state
entity_id: input_number.monitorer_volume
condition:
- condition: state
entity_id: switch.dator_template
state: 'on'
action:
- service: shell_command.monitorer_volume_slider
- service: homeassistant.update_entity
entity_id: sensor.monitorer_mute_check
- alias: monitorer_volume_update
initial_state: true
trigger:
- platform: state
entity_id: sensor.getvolume
condition:
- condition: state
entity_id: switch.dator_template
state: 'on'
action:
- service: homeassistant.update_entity
entity_id: sensor.monitorer_mute_check
- service: input_number.set_value
data_template:
entity_id: input_number.monitorer_volume
value: "{{ states('sensor.getvolume') }}"
- alias: eq_calibration
initial_state: true
trigger:
- platform: state
entity_id: switch.wemo_monitorer
condition:
- condition: state
entity_id: switch.dator_template
state: 'on'
action:
- service_template: >
{% if trigger.from_state.state == 'unavailable' %}
script.dummy
{% elif trigger.to_state.state == 'on' %}
script.reference_monitors {% else %}
script.reference_headphones {% endif %}
- alias: turn_off_monitorer
initial_state: true
trigger:
- platform: state
entity_id: switch.dator_template
from: 'on'
to: 'off'
for:
minutes: 15
action:
- service: switch.turn_off
entity_id: switch.wemo_monitorer
####################################################
# #
# FAN #
# #
####################################################
- alias: turn_off_fläkt
initial_state: true
trigger:
platform: state
entity_id: switch.wemo_flakt
from: 'off'
to: 'on'
for:
hours: "{{ states('input_number.fan_timer') | int }}"
action:
- service: switch.turn_off
entity_id: switch.wemo_flakt
- alias: turn_on_fläkt_temp
initial_state: true
trigger:
platform: numeric_state
entity_id: sensor.hall_temperature
above: 26
condition:
condition: or
conditions:
- condition: state
entity_id: person.mattias
state: 'home'
- condition: state
entity_id: person.sanja
state: 'home'
action:
- service: switch.turn_on
entity_id: switch.wemo_flakt
####################################################
# #
# TABLET #
# #
####################################################
- alias: tablet_brightness_slider
initial_state: true
trigger:
platform: state
entity_id: input_number.fullykiosk_brightness_slider
action:
service: shell_command.fullykiosk_brightness_slider
- alias: close_popups_on_tablet
initial_state: true
trigger:
- platform: state
entity_id: switch.fullykiosk_screensaver
from: 'off'
to: 'on'
for:
minutes: 15
action:
- service: browser_mod.close_popup
data:
deviceID: tablet
- alias: turn_on_fullykiosk_screen
initial_state: true
trigger:
- platform: state
entity_id: input_boolean.motion_hall
from: 'off'
to: 'on'
action:
- service: switch.turn_off
entity_id: switch.fullykiosk_screensaver
- service_template: input_number.set_value
data_template:
entity_id: input_number.fullykiosk_brightness_slider
value: >
{% if is_state('sun.sun', 'above_horizon') %}
90 {% else %}
50 {% endif %}
- service: input_boolean.turn_off
data_template:
entity_id: "{{ trigger.entity_id }}"
- alias: turn_off_fullykiosk_screen
initial_state: true
trigger:
- platform: state
entity_id: light.hall
from: 'on'
to: 'off'
action:
- service: switch.turn_on
entity_id: switch.fullykiosk_screensaver
####################################################
# #
# LOADING #
# #
####################################################
- alias: turn_off_loading_wheel
initial_state: true
trigger:
- platform: state
entity_id:
['media_player.sony_bravia_tv', 'switch.samsung_6_series_50',
'switch.dator_template', 'switch.playstation_template']
action:
- service: input_boolean.turn_off
data_template:
entity_id: >-
{{ trigger.entity_id |
replace('media_player', 'input_boolean') |
replace('switch', 'input_boolean') }}
- alias: turn_off_loading_wheel_fail_safe
initial_state: true
trigger:
- platform: state
entity_id:
['input_boolean.sony_bravia_tv', 'input_boolean.samsung_6_series_50',
'input_boolean.dator_template', 'input_boolean.playstation_template']
to: 'on'
for:
minutes: 1
action:
- service: input_boolean.turn_off
data_template:
entity_id: "{{ trigger.entity_id }}"
####################################################
# #
# HDMI #
# #
####################################################
- alias: hdmi_input_select
initial_state: true
trigger:
- platform: state
entity_id: input_select.hdmi
action:
- service: media_player.select_source
data_template:
entity_id: media_player.sony_bravia_tv
source: "{{ states('input_select.hdmi') }}"
- alias: hdmi_input_select_update
initial_state: true
trigger:
- platform: state
entity_id: media_player.sony_bravia_tv
action:
- service: input_select.select_option
data_template:
entity_id: input_select.hdmi
option: >-
{% if state_attr('media_player.sony_bravia_tv', 'None') %}
HDMI 1 {% else %}
{{ state_attr('media_player.sony_bravia_tv', 'media_title') }}
{% endif %}
- alias: hdmi2_input_select
initial_state: true
trigger:
- platform: state
entity_id: input_select.hdmi2
action:
- service: media_player.select_source
data_template:
entity_id: media_player.samsung_tv_remote
source: "{{ states('input_select.hdmi2') }}"
- alias: hdmi2_input_select_update
initial_state: true
trigger:
- platform: state
entity_id: media_player.samsung_tv_remote
action:
- service: input_select.select_option
data_template:
entity_id: input_select.hdmi2
option: >-
{% if is_state('sensor.samsung_6_series_50_media_input_source', 'HDMI3') %}
HDMI {% else %}
TV {% endif %}
####################################################
# #
# LAUNDRY TIMER #
# #
####################################################
- alias: reveal_laundry_timer
initial_state: true
trigger:
- platform: state
entity_id: sensor.tvatta_countdown_timer_trigger
to: 'true'
action:
- service: input_boolean.turn_on
entity_id: input_boolean.laundry_timer_visibility
- delay: 04:00:00
- service: input_boolean.turn_off
entity_id: input_boolean.laundry_timer_visibility
- alias: alert_laundry_timer_finished
initial_state: true
trigger:
platform: event
event_type: timer.finished
event_data:
entity_id: timer.laundry
action:
- service: homeassistant.turn_off
entity_id: group.ui_sound
- service: media_player.play_media
data:
entity_id: media_player.tablet
media_content_id: /local/timer.mp3
media_content_type: music
- delay: 00:00:02
- service: media_player.play_media
data_template:
entity_id: media_player.tablet
media_content_id: >
{{ ['/local/tts_custom/timer_tvatten_ar_fardig.mp3',
'/local/tts_custom/timer_tvatten_ar_klar.mp3',
'/local/tts_custom/timer_dags_att_ga_ner.mp3'] | random }}
media_content_type: music
- service: shell_command.notify_laundry
- delay: '00:00:03'
- service: homeassistant.turn_on
entity_id: group.ui_sound
####################################################
# #
# VACUUM #
# #
####################################################
- alias: roborock_fan_speed_input_select
initial_state: true
trigger:
- platform: state
entity_id: input_select.roborock_fan_speed
action:
- service: vacuum.set_fan_speed
data_template:
entity_id: vacuum.xiaomi_vacuum_cleaner
fan_speed: >-
{% if is_state('input_select.roborock_fan_speed', 'Tyst') %} Quiet
{% elif is_state('input_select.roborock_fan_speed', 'Standard') %} Balanced
{% elif is_state('input_select.roborock_fan_speed', 'Medium') %} 75
{% elif is_state('input_select.roborock_fan_speed', 'Turbo') %} 100
{% else %} Balanced
{% endif %}
- alias: roborock_fan_speed_input_select_update
initial_state: true
trigger:
platform: state
entity_id: sensor.roborock_fan_speed
action:
- service: input_select.select_option
data_template:
entity_id: input_select.roborock_fan_speed
option: >-
{% if is_state('sensor.roborock_fan_speed', 'Quiet') %} Tyst
{% elif is_state('sensor.roborock_fan_speed', 'Balanced') %} Standard
{% elif is_state('sensor.roborock_fan_speed', '75') %} Medium
{% elif is_state('sensor.roborock_fan_speed', '100') %} Turbo
{% else %} Standard
{% endif %}
####################################################
# #
# UI SOUND #
# #
####################################################
- alias: ui_sound_on
initial_state: true
trigger:
- platform: state
entity_id:
['light.belysning', 'light.fonsterlampa', 'light.datorlampa', 'light.taklampor',
'light.mattias', 'light.sanja', 'light.badrum', 'light.taklampa', 'light.kladkammare_2',
'light.hall', 'switch.wemo_flakt', 'switch.wemo_monitorer', 'input_boolean.dator_template',
'input_boolean.playstation_template', 'input_boolean.sony_bravia_tv',
'input_boolean.samsung_6_series_50']
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: switch.fullykiosk_screensaver
state: 'off'
action:
- service: media_player.play_media
data:
entity_id: media_player.tablet
media_content_id: /local/on.m4a
media_content_type: music
- alias: ui_sound_off
initial_state: true
trigger:
- platform: state
entity_id:
['light.belysning', 'light.fonsterlampa', 'light.datorlampa', 'light.taklampor',
'light.mattias', 'light.sanja', 'light.badrum', 'light.taklampa', 'light.kladkammare_2',
'light.hall', 'switch.wemo_flakt', 'switch.wemo_monitorer', 'switch.dator_template',
'switch.playstation_template', 'switch.tv_template', 'switch.tv2_template']
from: 'on'
to: 'off'
condition:
- condition: state
entity_id: switch.fullykiosk_screensaver
state: 'off'
action:
- service: media_player.play_media
data:
entity_id: media_player.tablet
media_content_id: /local/off.m4a
media_content_type: music
- alias: ui_sound_popup
initial_state: true
trigger:
platform: event
event_type: call_service
event_data:
domain: browser_mod
service: popup
condition:
- condition: state
entity_id: switch.fullykiosk_screensaver
state: 'off'
action:
- service: media_player.play_media
data:
entity_id: media_player.tablet
media_content_id: /local/popup.m4a
media_content_type: music
####################################################
# #
# CONDITIONAL MEDIA #
# #
####################################################
- alias: conditional_media_playing
initial_state: true
trigger:
- platform: state
entity_id:
['media_player.vardagsrum', 'media_player.sovrum',
'media_player.playstation_4', 'media_player.google_nest_mini']
to: playing
action:
- service: input_select.select_option
data_template:
entity_id: input_select.conditional_media
option: "{{ trigger.to_state.name }}"
- alias: conditional_media_paused
initial_state: true
trigger:
- platform: state
entity_id:
['media_player.vardagsrum', 'media_player.sovrum',
'media_player.google_nest_mini']
to: paused
for:
minutes: 10
action:
- service: input_select.select_option
data_template:
entity_id: input_select.conditional_media
option: >-
{% set media_players =
[states.media_player.vardagsrum, states.media_player.sovrum,
states.media_player.playstation_4, states.media_player.google_nest_mini] %}
{% if media_players | selectattr('state','eq','playing') | list | count == 0 %}
{% if media_players | selectattr('state','eq','paused') | list | count == 0 %}
Senast nedladdat
{% else %}
{{ media_players | selectattr('state','eq','paused') | map(attribute='name') | max }}
{% endif %}
{% else %}
{{ media_players | selectattr('state','eq','playing') | map(attribute='name') | max }}
{% endif %}
- alias: conditional_media_idle
initial_state: true
trigger:
- platform: template
value_template: >
{{ is_state('media_player.vardagsrum', 'idle') and
is_state('media_player.sovrum', 'idle') and
is_state('media_player.playstation_4', 'standby') and
is_state('media_player.google_nest_mini', 'off') }}
action:
- service: input_select.select_option
data_template:
entity_id: input_select.conditional_media
option: Senast nedladdat
####################################################
- alias: turn_on_tv_fail_safe
initial_state: true
trigger:
platform: event
event_type: call_service
event_data:
domain: media_player
service: turn_on
service_data:
entity_id: media_player.sony_bravia_tv
action:
- service: remote.send_command
data:
entity_id: remote.vardagsrum
command: menu
- alias: turn_on_tv2_fail_safe
initial_state: true
trigger:
platform: event
event_type: call_service
event_data:
domain: media_player
service: turn_on
service_data:
entity_id: media_player.samsung_tv_remote
action:
- service: remote.send_command
data:
entity_id: remote.sovrum
command: menu
### Apple Tv - No title temp fix ###
- alias: conditional_media_fall_back_1
initial_state: true
trigger:
- platform: template
value_template: >
{{ is_state_attr('media_player.vardagsrum', 'media_title', 'No title') }}
for:
seconds: 5
action:
- service: input_select.select_option
data_template:
entity_id: input_select.conditional_media
option: >-
{% set media_players = [states.media_player.sovrum, states.media_player.playstation_4,
states.media_player.google_nest_mini] %} {% if media_players | selectattr('state','eq','playing')
| list | count == 0 %} {% if media_players | selectattr('state','eq','paused') | list | count == 0 %}
Senast nedladdat {% else %} {{ media_players | selectattr('state','eq','paused') | map(attribute='name')
| max }} {% endif %} {% else %} {{ media_players | selectattr('state','eq','playing')
| map(attribute='name') | max }}{% endif %}
- alias: conditional_media_fall_back_2
initial_state: true
trigger:
- platform: template
value_template: >
{{ is_state_attr('media_player.sovrum', 'media_title', 'No title') }}
for:
seconds: 5
action:
- service: input_select.select_option
data_template:
entity_id: input_select.conditional_media
option: >-
{% set media_players = [states.media_player.vardagsrum, states.media_player.playstation_4,
states.media_player.google_nest_mini] %} {% if media_players | selectattr('state','eq','playing')
| list | count == 0 %} {% if media_players | selectattr('state','eq','paused') | list | count == 0 %}
Senast nedladdat {% else %} {{ media_players | selectattr('state','eq','paused') | map(attribute='name')
| max }} {% endif %} {% else %} {{ media_players | selectattr('state','eq','playing')
| map(attribute='name') | max }}{% endif %}