-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathscripts.yaml
1102 lines (1054 loc) · 36.1 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
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
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
broadcast_alert_in_the_house:
alias: important broadcast alert in the house
sequence:
- variables:
playing_chromecasts: '{{ integration_entities(''universal'') | select(''search'',
''chromecast'') | expand | selectattr(''state'', ''eq'', ''playing'')| map(attribute=''entity_id'')|
list }}
'
non_playing_chromecasts: '{{ integration_entities(''universal'') | select(''search'',
''chromecast'') | expand | rejectattr(''state'', ''eq'', ''playing'')| map(attribute=''entity_id'')|
list }}
'
alias: Store Chromecasts in variables
- parallel:
- alias: Lights
sequence:
- variables:
light_entity_ids: "{% set light_group = state_attr('light.group_notifications_light','entity_id')%}
\ {% set ns = namespace( rgb_dict= [] ) %} {% for entity_id in light_group
%}\n {% set light_state = states(entity_id) %}\n {% set light_rgb_color
= state_attr(entity_id, \"rgb_color\") %}\n {% if light_state != 'unavailable'
and light_rgb_color %}\n {%- set rgb_values = light_rgb_color |
replace('(','') | replace(')','')| replace(' ','')| string -%}\n {%
set rgb_dict = [(entity_id , rgb_values, states(entity_id))] %}\n {%
set ns.rgb_dict = ns.rgb_dict + rgb_dict %}\n {% elif light_state !=
'unavailable' %}\n {%- set rgb_values = \"0,0,0\" %}\n {%
set rgb_dict = [(entity_id , rgb_values, states(entity_id))] %}\n {%
set ns.rgb_dict = ns.rgb_dict + rgb_dict %}\n {% endif %} \n{% endfor
%} {{ ns.rgb_dict }}\n"
alias: 'Store Lights entity_id and current rgb values '
- if:
- condition: template
value_template: '{% if color %}
true
{% else %}
false
{% endif %}'
then:
- alias: Turn all lights to selected color
repeat:
sequence:
- target:
entity_id: '{{light_entity_ids[repeat.index].0}}'
data:
color_name: '{{color}}'
enabled: true
action: light.turn_on
count: '{{ light_entity_ids | length - 1 }}'
alias: Change lights conditionally
- delay:
hours: 0
minutes: 0
seconds: 2
milliseconds: 250
- alias: Restore lights to their initial state
repeat:
sequence:
- if:
- condition: template
value_template: '{{ not light_entity_ids[repeat.index].2 | bool }}'
then:
- target:
entity_id: '{{light_entity_ids[repeat.index].0}}'
enabled: true
alias: Turn back off lights to previous state
action: light.turn_{{ light_entity_ids[repeat.index].2 }}
alias: Turn off lights back to off
- if:
- condition: template
value_template: '{{ light_entity_ids[repeat.index].2 | bool }}'
then:
- target:
entity_id: '{{light_entity_ids[repeat.index].0}}'
data:
rgb_color: '{{light_entity_ids[repeat.index].1}}'
enabled: true
alias: Turn back on lights to previous state
action: light.turn_{{ light_entity_ids[repeat.index].2 }}
alias: Turn on lights back to their original colors
count: '{{ light_entity_ids | length - 1 }}'
- alias: 'Announcements '
if:
- condition: template
value_template: '{% if message %}
true
{% else %}
false
{% endif %}'
then:
- alias: Announcements
parallel:
- metadata: {}
data:
cache: true
media_player_entity_id: media_player.group_mass_home_airplay_speakers
message: '{{ message }}'
target:
entity_id: tts.piper
alias: TTS in the home group
action: tts.speak
- metadata: {}
data:
cache: true
media_player_entity_id: media_player.hotbox_down_display
message: '{{ message }}'
target:
entity_id: tts.piper
alias: TTS in the hotbox
action: tts.speak
continue_on_error: true
- metadata: {}
data:
cache: true
media_player_entity_id: media_player.mass_bedroom_airplay_wiim_speaker
message: '{{ message }}'
target:
entity_id: tts.piper
alias: TTS in the bedroom
action: tts.speak
- metadata: {}
data:
cache: true
media_player_entity_id: media_player.mass_closet_wiim_speaker
message: '{{ message }}'
target:
entity_id: tts.piper
alias: TTS in the closet
action: tts.speak
- alias: 'Notifications '
if:
- condition: template
value_template: '{% if phone_data %}
true
{% else %}
false
{% endif %}'
then:
- action: notify.mobile_app_phone_maxi
metadata: {}
data: '{{ phone_data }}
'
- action: notify.maxi_notification_group
metadata: {}
data: "{{ phone_data }}\ndata:\n ttl: 0\n priority: high\n"
enabled: true
- if:
- condition: and
conditions:
- condition: state
entity_id: input_boolean.party_mode
state: 'off'
- condition: state
entity_id: input_boolean.kink_party
state: 'off'
then:
- alias: TVs
parallel:
- alias: Broadcast image to paused TVs if image is present
if:
- condition: template
value_template: '{% if image %}
true
{% else %}
false
{% endif %}'
then:
- sequence:
- alias: Broadcast Image to paused chromecasts
repeat:
sequence:
- metadata: {}
data:
media_content_id: '{{image}}'
media_content_type: image
entity_id: '{{non_playing_chromecasts[repeat.index - 1]}}'
action: media_player.play_media
for_each: '{{ non_playing_chromecasts }}'
- wait_for_trigger:
- trigger: state
entity_id:
- lock.lock_front_door
to: locked
for:
hours: 0
minutes: 0
seconds: 15
timeout:
hours: 0
minutes: 2
seconds: 0
milliseconds: 0
- alias: Turn off precedent chromecats
repeat:
sequence:
- action: media_player.turn_off
metadata: {}
data: {}
target:
entity_id: '{{ non_playing_chromecasts }}'
for_each: '{{ non_playing_chromecasts }}'
- action: dash_cast.load_url
metadata: {}
data:
force: false
reload_seconds: 0
entity_id: media_player.hotbox_down_hub
url: '{{image}}'
enabled: true
continue_on_error: true
- alias: Broadcast image to paused TVs if url is present
if:
- condition: template
value_template: '{% if url %}
true
{% else %}
false
{% endif %}'
then:
- sequence:
- alias: Broadcast URL to paused chromecasts
repeat:
sequence:
- metadata: {}
data:
media_content_id: '{{url}}'
media_content_type: video
entity_id: '{{non_playing_chromecasts[repeat.index - 1]}}'
action: media_player.play_media
for_each: '{{ non_playing_chromecasts }}'
- wait_for_trigger:
- trigger: state
entity_id:
- lock.lock_front_door
to: locked
for:
hours: 0
minutes: 0
seconds: 15
timeout:
hours: 0
minutes: 2
seconds: 0
milliseconds: 0
- alias: Turn off precedent chromecats
repeat:
sequence:
- action: media_player.turn_off
metadata: {}
data: {}
target:
entity_id: '{{ non_playing_chromecasts }}'
for_each: '{{ non_playing_chromecasts }}'
- action: dash_cast.load_url
metadata: {}
data:
force: false
reload_seconds: 0
entity_id: media_player.hotbox_down_hub
url: '{{url}}'
enabled: true
continue_on_error: true
- if:
- condition: state
entity_id: input_boolean.party_mode
state: 'off'
- condition: state
entity_id: input_boolean.acid_time
state: 'off'
then:
- alias: Pause Playing Chromecasts
repeat:
sequence:
- metadata: {}
data: {}
target:
entity_id: '{{playing_chromecasts[repeat.index - 1]}}'
action: media_player.media_pause
for_each: '{{ playing_chromecasts }}'
enabled: true
continue_on_error: true
alias: 'TVs '
- delay:
hours: 0
minutes: 0
seconds: 10
mode: queued
icon: mdi:speaker-message
max: 10
change_received_lights_to_random_colors:
alias: Change received lights to random color
sequence:
- variables:
lights: "{%- set lights = states.light | selectattr('entity_id', 'in', state_attr(selected_group,
'entity_id')) | list -%}\n{%- set entity_ids = lights | map(attribute='entity_id')
| list -%} \n{{ entity_ids }}\n"
- repeat:
sequence:
- metadata: {}
data:
hs_color: '{{ range(1, 360) | random | string + '','' + saturation | string
}}'
target:
entity_id: '{{lights[repeat.index - 1]}}'
action: light.turn_on
for_each: '{{ lights }}'
mode: restart
icon: mdi:sale
fields: {}
start_visual_playlist_on_plex:
alias: Start requsted Playlist on plex for all unplaying chromecasts
sequence:
- variables:
chromecasts: '{{integration_entities(''cast'') | select(''search'', ''chromecast'')
| list}}
'
- repeat:
sequence:
- if:
- condition: template
value_template: '{{states(chromecasts[repeat.index - 1 ]) == "off"}}'
- condition: template
value_template: '{{ area_id(chromecasts[repeat.index - 1 ] | string) | replace(''_top'','''')
| replace(''_down'','''') not in states(''sensor.active_sleeper_rooms'')
| string }}'
then:
- variables:
playlist: 'plex://{"playlist_name":"{{requested_playlist}}","shuffle":"1"}
'
- data:
media_content_id: '{{playlist}}'
media_content_type: playlist
target:
entity_id: '{{chromecasts[repeat.index -1]}}'
action: media_player.play_media
- data:
is_volume_muted: true
target:
entity_id: '{{chromecasts[repeat.index -1]}}'
action: media_player.volume_mute
- delay:
hours: 0
minutes: 0
seconds: 15
milliseconds: 0
enabled: false
- wait_for_trigger:
- trigger: template
value_template: '{{states(chromecasts[repeat.index - 1 ]) == "playing"}}'
timeout:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
for_each: '{{ chromecasts }}'
mode: single
icon: mdi:led-strip-variant
non_important_broadcast_alert_in_the_house:
alias: non-important broadcast alert in the house
sequence:
- variables:
light_entity_ids: "{% set light_group = state_attr('light.group_notifications_light','entity_id')%}
\ {% set ns = namespace( rgb_dict= [] ) %} {% for entity_id in light_group
%}\n {% set light_state = states(entity_id) %}\n {% set light_rgb_color
= state_attr(entity_id, \"rgb_color\") %}\n {% if light_state == 'on' and
light_rgb_color %}\n {%- set rgb_values = light_rgb_color | replace('(','')
| replace(')','')| replace(' ','')| string -%}\n {% set rgb_dict =
[(entity_id , rgb_values, states(entity_id))] %}\n {% set ns.rgb_dict
= ns.rgb_dict + rgb_dict %}\n {% endif %} \n{% endfor %} {{ ns.rgb_dict
}}\n"
alias: 'Store ON Lights entity_id and current rgb values '
- parallel:
- alias: Lights
sequence:
- if:
- condition: template
value_template: '{% if color %}
true
{% else %}
false
{% endif %}'
then:
- alias: Turn all lights to selected color
repeat:
sequence:
- target:
entity_id: '{{light_entity_ids[repeat.index].0}}'
data:
color_name: '{{color}}'
enabled: true
action: light.turn_on
count: '{{ light_entity_ids | length - 1 }}'
alias: Change lights conditionally
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 250
- alias: Restore lights to their initial state
repeat:
sequence:
- if:
- condition: template
value_template: '{{ not light_entity_ids[repeat.index].2 | bool }}'
then:
- target:
entity_id: '{{light_entity_ids[repeat.index].0}}'
enabled: true
alias: Turn back off lights to previous state
action: light.turn_{{ light_entity_ids[repeat.index].2 }}
alias: Turn off lights back to off
- if:
- condition: template
value_template: '{{ light_entity_ids[repeat.index].2 | bool }}'
then:
- target:
entity_id: '{{light_entity_ids[repeat.index].0}}'
data:
rgb_color: '{{light_entity_ids[repeat.index].1}}'
enabled: true
alias: Turn back on lights to previous state
action: light.turn_{{ light_entity_ids[repeat.index].2 }}
alias: Turn on lights back to their original colors
count: '{{ light_entity_ids | length - 1 }}'
- alias: 'Announcements '
if:
- condition: template
value_template: '{% if message %}
true
{% else %}
false
{% endif %}'
then:
- alias: Announcements
parallel:
- metadata: {}
data:
media_player_entity_id: media_player.group_mass_home_airplay_speakers
message: '{{ message }}'
target:
entity_id: tts.piper
alias: TTS in the home group
action: tts.speak
- metadata: {}
data:
cache: true
media_player_entity_id: media_player.hotbox_down_display
message: '{{ message }}'
target:
entity_id: tts.piper
alias: TTS in the hotbox
action: tts.speak
continue_on_error: true
- metadata: {}
data:
media_player_entity_id: media_player.bedroom_speaker
message: '{{ message }}'
target:
entity_id: tts.piper
alias: TTS in the bedroom
action: tts.speak
- metadata: {}
data:
cache: true
media_player_entity_id: media_player.mass_closet_wiim_speaker
message: '{{ message }}'
target:
entity_id: tts.piper
alias: TTS in the closet
action: tts.speak
- alias: TVs
parallel:
- alias: Broadcast image to paused TVs if image is present
if:
- condition: template
value_template: '{% if image %}
true
{% else %}
false
{% endif %}'
then:
- alias: Broadcast Image to paused chromecasts
repeat:
sequence:
- metadata: {}
data:
media_content_id: '{{image}}'
media_content_type: video
entity_id: '{{non_playing_chromecasts[repeat.index - 1]}}'
action: media_player.play_media
for_each: '{{ non_playing_chromecasts }}'
- delay:
hours: 0
minutes: 0
seconds: 40
milliseconds: 0
- alias: Turn off precedent chromecats
repeat:
sequence:
- action: media_player.turn_off
metadata: {}
data: {}
target:
entity_id: '{{ non_playing_chromecasts }}'
for_each: '{{ non_playing_chromecasts }}'
enabled: true
continue_on_error: true
- alias: Broadcast image to paused TVs if URL is present
if:
- condition: template
value_template: '{% if url %}
true
{% else %}
false
{% endif %}'
then:
- alias: Broadcast Image to paused chromecasts
repeat:
sequence:
- action: dash_cast.load_url
data:
entity_id: '{{non_playing_chromecasts[repeat.index - 1]}}'
url: '{{url}}'
force: true
for_each: '{{ non_playing_chromecasts }}'
- delay:
hours: 0
minutes: 0
seconds: 40
milliseconds: 0
enabled: false
- wait_for_trigger:
- trigger: state
entity_id:
- lock.lock_front_door
to: unlocked
timeout:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
- alias: Turn off precedent chromecats
repeat:
sequence:
- action: media_player.turn_off
metadata: {}
data: {}
target:
entity_id: '{{ non_playing_chromecasts }}'
for_each: '{{ non_playing_chromecasts }}'
enabled: true
continue_on_error: true
- if:
- condition: state
entity_id: input_boolean.party_mode
state: 'off'
- condition: state
entity_id: input_boolean.acid_time
state: 'off'
then:
- alias: Pause Playing Chromecasts
repeat:
sequence:
- metadata: {}
data: {}
target:
entity_id: '{{playing_chromecasts[repeat.index - 1]}}'
action: media_player.media_pause
for_each: '{{ playing_chromecasts }}'
enabled: true
continue_on_error: true
- alias: Restore lights to their initial state
repeat:
sequence:
- if:
- condition: template
value_template: '{{ not on_light_entity_ids[repeat.index].2 | bool }}'
then:
- target:
entity_id: '{{on_light_entity_ids[repeat.index].0}}'
enabled: true
alias: Turn back off lights to previous state
action: light.turn_{{ light_entity_ids[repeat.index].2 }}
alias: Turn off lights back to off
- if:
- condition: template
value_template: '{{ on_light_entity_ids[repeat.index].2 | bool }}'
then:
- target:
entity_id: '{{on_light_entity_ids[repeat.index].0}}'
data:
rgb_color: '{{on_light_entity_ids[repeat.index].1}}'
enabled: true
alias: Turn back on lights to previous state
action: light.turn_{{ light_entity_ids[repeat.index].2 }}
alias: Turn on lights back to their original colors
count: '{{ on_light_entity_ids | length - 1 }}'
mode: queued
icon: mdi:speaker-message
max: 3
changes_all_on:
alias: Changes all on lights to random colors
sequence:
- variables:
all_on_lights: '{{ integration_entities(''group'')| select(''search'', ''light.group_all_lights'') |
expand | selectattr("attributes.rgb_color", "defined") | selectattr("state",
"eq", "on") | map(attribute=''entity_id'') | list }}
'
- repeat:
sequence:
- metadata: {}
data:
hs_color: '{{ range(1, 360) | random | string + '','' + 100 | string }}'
target:
entity_id: '{{all_on_lights[repeat.index - 1]}}'
action: light.turn_on
for_each: '{{ all_on_lights }}'
mode: restart
icon: mdi:sale
fields: {}
'1714667687332':
alias: Changes all on lights to random pastel colors
sequence:
- variables:
on_lights: '
{{ integration_entities(''group'')| select(''search'', ''light.group_all_inside_lights'') |
expand | selectattr("attributes.rgb_color", "defined") | selectattr("state",
"eq", "on") | map(attribute=''entity_id'') | list }}
'
- repeat:
sequence:
- metadata: {}
data:
hs_color: '{{ range(1, 360) | random | string + '','' + 30 | string }}'
target:
entity_id: '{{on_lights[repeat.index - 1]}}'
action: light.turn_on
for_each: '{{ on_lights }}'
mode: restart
icon: mdi:sale
fields: {}
generate_and_save_localai_image:
alias: Generate and save LocalAI image
sequence:
- service: rest_command.local_ai_generate_image
metadata: {}
data:
prompt: '{{prompt}}'
model: '{{model}}'
size: '{{size}}'
steps: '{{steps}}'
response_variable: return
- service: downloader.download_file
metadata: {}
data:
overwrite: true
url: '{{return.content.data[0].url}}'
filename: stable_diffusion.jpg
mode: single
icon: mdi:image-frame
generate_and_save_sd_image:
alias: Generate and save SD image
sequence:
- service: rest_command.stability_ai_get_session_id
metadata: {}
data: {}
response_variable: return
- service: downloader.download_file
metadata: {}
data:
overwrite: true
url: '{{return.content.data[0].url}}'
filename: stable_diffusion.jpg
mode: single
icon: mdi:image-frame
changes_all_on_lights_to_warm_colors:
alias: Changes all on lights to warm colors
sequence:
- variables:
on_lights: '{{ integration_entities(''group'')| select(''search'', ''light.group_all_inside_lights'') |
expand | selectattr("attributes.rgb_color", "defined") | selectattr("state",
"eq", "on") | map(attribute=''entity_id'') | list }}
'
- repeat:
sequence:
- metadata: {}
data:
hs_color: "{% set hue_under_20 = range(1, 20) | random | string + ',' +
100 | string %} {% set hue_over_260 = range(260, 360) | random | string
+ ',' + 100 | string %} {% set random = range(1, 3) | random %} {%
if random == 1 %}\n {{hue_under_20 }}\n{% elif random > 1 %} {{hue_over_260}}
{%endif%}\n"
target:
entity_id: '{{on_lights[repeat.index - 1]}}'
action: light.turn_on
for_each: '{{ on_lights }}'
mode: restart
icon: mdi:sale
fields: {}
'1716330781093':
alias: Changes all on lights to warm pale colors
sequence:
- variables:
on_lights: '{{ integration_entities(''group'')| select(''search'', ''light.group_all_inside_lights'') |
expand | selectattr("attributes.rgb_color", "defined") | selectattr("state",
"eq", "on") | map(attribute=''entity_id'') | list }}
'
- repeat:
sequence:
- metadata: {}
data:
hs_color: "{% set hue_under_20 = range(1, 20) | random | string + ',' +
30 | string %} {% set hue_over_260 = range(260, 360) | random | string
+ ',' + 30 | string %} {% set random = range(1, 3) | random %} {%
if random == 1 %}\n {{hue_under_20 }}\n{% elif random > 1 %} {{hue_over_260}}
{%endif%}\n"
target:
entity_id: '{{on_lights[repeat.index - 1]}}'
action: light.turn_on
for_each: '{{ on_lights }}'
mode: restart
icon: mdi:sale
fields: {}
generate_fake_white_colors:
alias: Generate fake white colors
sequence:
- variables:
on_lights: "{% set ns = namespace(lights=[]) %} {% set groups = integration_entities('group')|
\ select('search', '^light.') | list %} {% for group in groups %}\n {%
set individual_lights = state_attr(group,'entity_id')%}\n {% for individual_light
in individual_lights %}\n {% if \"group\" not in individual_light and
state_attr(individual_light, 'rgb_color') and states(individual_light) ==
'on' %}\n {% set ns.lights = ns.lights + [individual_light] %}\n {%
endif %}\n {% endfor %} \n{% endfor %} {{ ns.lights }}\n"
- repeat:
sequence:
- service: light.turn_on
metadata: {}
data:
hs_color: "{% set hue_under_20 = range(1, 20) | random | string + ',' +
30 | string %} {% set hue_over_260 = range(260, 360) | random | string
+ ',' + 30 | string %} {% set random = range(1, 3) | random %} {%
if random == 1 %}\n {{hue_under_20 }}\n{% elif random > 1 %} {{hue_over_260}}
{%endif%}\n"
target:
entity_id: '{{on_lights[repeat.index - 1]}}'
for_each: '{{ on_lights }}'
mode: restart
icon: mdi:sale
fields: {}
in_home_defense_script:
alias: All on defense script
sequence:
- metadata: {}
data:
stop_actions: true
action: automation.turn_off
target:
entity_id: automation.mute_speakers_when_the_room_is_empty
- metadata: {}
data:
stop_actions: true
target:
entity_id: automation.set_speakers_volume_on_initial_playback_v2
action: automation.turn_off
- data:
media_content_id: https://hass.purgatoire.ca/local/civil-defense-siren.wav
media_content_type: music
action: media_player.play_media
target:
entity_id:
- media_player.universal_bedroom_speakers
- media_player.universal_closet_speaker
- media_player.universal_hallway_speakers
- media_player.universal_kitchen_speakers
- media_player.universal_livingroom_speakers
- media_player.universal_hotbox_top_speakers
- media_player.universal_salon_speakers
- media_player.universal_office_speakers
- repeat:
count: 10
sequence:
- action: media_player.volume_up
metadata: {}
data: {}
target:
entity_id:
- media_player.universal_bedroom_speakers
- media_player.universal_closet_speaker
- media_player.universal_hallway_speakers
- media_player.universal_kitchen_speakers
- media_player.universal_livingroom_speakers
- media_player.universal_hotbox_top_speakers
- media_player.universal_salon_speakers
- media_player.universal_office_speakers
- metadata: {}
data: {}
target:
entity_id:
- switch.plug_back_door_horn
- switch.plug_front_door_horn
enabled: true
action: switch.turn_on
- wait_for_trigger:
- entity_id:
- binary_sensor.home_occupancy
to: 'off'
for:
hours: 0
minutes: 5
seconds: 0
trigger: state
timeout:
hours: 0
minutes: 40
seconds: 0
milliseconds: 0
continue_on_timeout: false
- action: media_player.media_stop
metadata: {}
data: {}
target:
entity_id:
- media_player.universal_bedroom_speakers
- media_player.universal_closet_speaker
- media_player.universal_hallway_speakers
- media_player.universal_kitchen_speakers
- media_player.universal_livingroom_speakers
- media_player.universal_hotbox_top_speakers
- media_player.universal_salon_speakers
- media_player.universal_office_speakers
- target:
entity_id:
- automation.set_speakers_volume_on_initial_playback_v2
data: {}
action: automation.turn_on
mode: restart
changes_all_on_lights_to_fake_white:
alias: Changes selected light group to ordered fake white
sequence:
- variables:
lights: "{%- set light_group = states.light | selectattr('entity_id', 'in',
state_attr(selected_group, 'entity_id')) | list -%} {%- set num_lights =
light_group | count -%} {%- set h_increment = 360 / num_lights -%} {% set
ns = namespace(output=[] ) %}\n{%- for i in range(num_lights) %}\n {%- set
light = light_group[i] -%}\n {%- set h = (h_increment * i) | int -%}\n {%-
set s = 100 -%}\n {%- set hs_color = [h, s] -%}\n {% set temp_output= {\n
\ \"entity_id\": light.entity_id ,\n \"hs_color\": hs_color \n } %}\n
\ {% set ns.output = [temp_output] + ns.output %}\n \n{%- endfor %} {% set
lights = ns.output %} {% set ns = namespace(x = lights) %} {% for i in range(ns.x
| length - 1, 0, -1) %}\n {% set j = range(0, i + 1) | random %}\n {%
if j != i %}\n {% set ns.x = ns.x[:j]+[ns.x[i]]+ns.x[j+1:i]+[ns.x[j]]+ns.x[i+1:]
%}\n {% endif %}\n{% endfor %} {{ ns.x }}\n"
- repeat:
sequence:
- data:
hs_color: '{{ repeat.item.hs_color }}'
transition: 0
target:
entity_id: '{{ repeat.item.entity_id }}'
action: light.turn_on
for_each: '{{ lights }}'
mode: restart
icon: mdi:sale
fields: {}
description: ''
inside_only_home_defense_script:
alias: Inside only home defense script
sequence:
- metadata: {}
data:
stop_actions: true
target:
entity_id: automation.set_speakers_volume_on_initial_playback_v2
action: automation.turn_off
- data:
media_content_id: https://hass.purgatoire.ca/local/civil-defense-siren.wav
media_content_type: music
action: media_player.play_media
target:
entity_id:
- media_player.universal_bedroom_speakers
- media_player.universal_closet_speaker
- media_player.universal_hallway_speakers
- media_player.universal_kitchen_speakers
- media_player.universal_livingroom_speakers
- media_player.universal_hotbox_top_speakers
- media_player.universal_salon_speakers
- media_player.universal_office_speakers
- repeat:
count: 10
sequence:
- action: media_player.volume_up
metadata: {}
data: {}
target:
entity_id:
- media_player.universal_bedroom_speakers
- media_player.universal_closet_speaker
- media_player.universal_hallway_speakers
- media_player.universal_kitchen_speakers
- media_player.universal_livingroom_speakers
- media_player.universal_hotbox_top_speakers
- media_player.universal_salon_speakers
- media_player.universal_office_speakers
- wait_for_trigger:
- entity_id:
- binary_sensor.home_occupancy
to: 'off'
from: 'on'
for:
hours: 0
minutes: 5
seconds: 0
trigger: state
timeout:
hours: 0
minutes: 30
seconds: 0
milliseconds: 0
continue_on_timeout: true
- action: media_player.media_stop
metadata: {}
data: {}
target:
entity_id:
- media_player.universal_bedroom_speakers
- media_player.universal_closet_speaker
- media_player.universal_hallway_speakers
- media_player.universal_kitchen_speakers
- media_player.universal_livingroom_speakers
- media_player.universal_hotbox_top_speakers
- media_player.universal_salon_speakers
- media_player.universal_office_speakers
mode: restart
start_plex_media_on_requested_player:
alias: Start plex media on requested player
sequence:
- variables:
chromecasts: '{{integration_entities(''cast'') | select(''search'', ''chromecast'')
| list}}
'
- repeat:
sequence:
- if:
- condition: template
value_template: '{{states(chromecasts[repeat.index ]) == "off"}}'
then:
- variables:
playlist: 'plex://{"playlist_name":"{{requested_playlist}}","shuffle":"1"}
'
- service: media_player.play_media
data: