-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathscripts.yaml
2185 lines (2122 loc) · 66.4 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
restart_home_assistant:
alias: Restart Home Assistant
sequence:
- service: script.notify_web
data:
type: warning
message: Restarting Home Assistant
duration: 60
- service: homeassistant.restart
data: {}
mode: single
icon: mdi:restart-alert
reboot_server:
alias: Reboot Server
sequence:
- service: script.notify_web
data:
type: error
message: Rebooting the server!
duration: 120
- service: hassio.host_reboot
data: {}
mode: single
icon: mdi:power-cycle
refresh_count_sensors:
alias: Refresh entity count sensors
mode: single
icon: mdi:cog-refresh
sequence:
- service: homeassistant.update_entity
target:
entity_id: "{%- set storage = namespace(entities=\"\") %}\n{%- set entities
= states.sensor | map(attribute=\"entity_id\") | list %}\n{%- for entity in
entities if entity[(entity|length-6):] == \"_count\" %}\n {%- set storage.entities
= storage.entities ~ entity %}\n {%- if not loop.last %}\n {%- set storage.entities
= storage.entities ~ ',' %}\n {%- endif %}\n{%- endfor %}\n{{ storage.entities.split(\",\")
}}\n"
alias: Update templated entities
- service: script.notify_web
data:
type: success
message: Sensor counts are refreshed.
duration: 10
refresh_update_sensors:
alias: Refresh version sensors
sequence:
- service: homeassistant.update_entity
target:
entity_id:
- sensor.addon_updates
- sensor.unifi_gateway_firmware_upgradable
- sensor.updates
data: {}
- delay:
seconds: 2
- service: homeassistant.update_entity
target:
entity_id:
- sensor.updates
data: {}
- service: script.notify_web
data:
type: success
message: Update sensors are refreshed.
duration: 10
mode: single
icon: mdi:cog-refresh
generate_readme:
alias: Generate readme
sequence:
- service: homeassistant.update_entity
data: {}
target:
entity_id: sensor.code_line_count
- delay:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
- service: readme.generate
data: {}
- service: script.notify_web
data:
message: README + ui-lovelace generation process complete.
mode: single
icon: mdi:github
generate_fake_secrets:
alias: Generate fake secrets
sequence:
- service: shell_command.rebuild_test_secrets
data: {}
- service: script.notify_web
data:
message: Fake_secrets.yaml regenerated.
mode: single
icon: mdi:thought-bubble
goodbye_routine:
alias: Goodbye routine
sequence:
- service: script.turn_on
entity_id: script.shutdown_routine
- service: homeassistant.turn_off
entity_id: group.bedroom_lights
- service: script.say
data:
media_player: media_player.google_downstairs
say_goodbye: 'true'
- delay:
seconds: 10
- wait_for_trigger:
- platform: state
entity_id:
- binary_sensor.front_door
from: 'on'
to: 'off'
timeout:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
alias: Wait for front door to close.
- service: lock.lock
entity_id: lock.front_door
mode: single
icon: mdi:exit-run
goodnight_routine:
alias: Goodnight routine
sequence:
- alias: Make sure the garage door is closed.
service: cover.close_cover
entity_id: cover.garage_door
- alias: Lock the front door right away as well.
service: lock.lock
entity_id: lock.front_door
- alias: Shutdown routine
service: script.shutdown_routine
data: {}
- alias: Say goodnight.
service: script.say
data:
media_player: media_player.google_family_room
say_goodnight: 'true'
mode: single
icon: mdi:lightbulb-night-outline
shutdown_routine:
alias: Shutdown routine
sequence:
- alias: Turn off everything except for the play room.
service: homeassistant.turn_off
entity_id:
- fan.family_room
- media_player.family_room_tv
- group.kitchen_lights
- group.dining_room_fixture
- light.home_entry
- light.family_room_floor_lamp
- light.family_room_table_lamp
- switch.hot_water_pump
- delay:
seconds: 2
- alias: Turn off family room light last after a brief delay.
service: light.turn_off
entity_id: light.family_room
mode: single
icon: mdi:close-circle
store_mqtt_sensor:
alias: Store MQTT sensor
sequence:
- service: mqtt.publish
data:
topic: custom/sensor/{{ name }}/state
payload: '{{ state }}'
retain: true
- alias: Only add attributes if they are present.
if:
- condition: template
value_template: '{{ attributes is defined }}'
then:
- service: mqtt.publish
data:
topic: custom/sensor/{{ name }}/attributes
payload: '{{ attributes }}
'
retain: true
mode: queued
icon: mdi:motion-sensor
holiday_sensors_update:
alias: Holiday sensors update
sequence:
- alias: Update upcoming dynamic holiday - easter.
service: script.update_next_holiday
data:
holiday: easter
- alias: Update upcoming dynamic holiday - election day.
service: script.update_next_holiday
data:
holiday: election_day
- alias: Update the holiday sensor.
service: homeassistant.update_entity
entity_id: sensor.holiday
- delay:
seconds: 10
- service: script.holiday_color_change
data: {}
mode: single
icon: mdi:calendar-sync
update_next_holiday:
alias: Update next holiday
sequence:
- variables:
today: '{{ states("sensor.date") }}'
holiday_sensor: '{{ "sensor.date_" ~ holiday }}'
next_holiday_sensor: '{{ "sensor.date_next_" ~ holiday }}'
event_date: '{{ states(holiday_sensor) }}'
day_after_event: "{%- if event_date != \"unknown\" %}\n {%- set split_date
= event_date.split(\"-\") %}\n {{ \"{:04}-{:02}-{:02}\".format(split_date[0]|int(default=0),
split_date[1]|int(default=0), (split_date[2]|int(default=0)+1)) }}\n{% endif
%}\n"
- alias: Only update the day after the event (or the event date is unknown).
condition: template
value_template: '{{ today == day_after_event or event_date == ''unknown'' }}
'
- service: persistent_notification.create
data:
title: update_next_holiday
message: Updating {{ next_holiday_sensor }}.
- service: homeassistant.update_entity
data:
entity_id: '{{ next_holiday_sensor }}'
mode: single
icon: mdi:calendar-sync
fields:
holiday:
description: Name of the holiday that needs updating. (ex. easter or election_day)
default: election_day
required: true
selector:
text:
lights_flash:
alias: Lights flash
sequence:
- variables:
is_hue: '{{ state_attr(entity_id,"effect_list") is sequence }}'
- service: script.notify_web
data:
message: 'entity_id: {{ entity_id }}
number_of_flashes: {{ number_of_flashes }}
delay_between_flashes: {{ delay_between_flashes }}
flash_transition_delay: {{ flash_transition_delay }}
is_hue: {{ is_hue }}'
enabled: false
alias: Debug output (notify_web)
- alias: Store the current state of the light.
service: scene.create
data:
scene_id: lights_flash_snapshot
snapshot_entities: '{{ entity_id }}'
- repeat:
count: '{{ number_of_flashes }}'
sequence:
- choose:
- alias: Use Hue built in flash when available.
conditions:
- '{{ is_hue }}'
sequence:
- service: light.turn_on
data:
entity_id: '{{ entity_id }}'
flash: short
default:
- service: light.turn_on
data:
entity_id: '{{ entity_id }}'
transition: 0
- alias: Transition time between flashes.
delay:
seconds: '{{ flash_transition_delay }}'
- service: light.turn_off
data:
entity_id: '{{ entity_id }}'
transition: 0
- alias: Delay between flashes.
delay:
seconds: '{{ delay_between_flashes }}'
- delay:
seconds: 2
- alias: Restore the previous state of the light.
service: scene.turn_on
data:
entity_id: scene.lights_flash_snapshot
transition: 5
mode: single
icon: mdi:lightbulb-on
fields:
entity_id:
description: Select the light to flash.
required: true
selector:
entity:
multiple: false
domain: light
number_of_flashes:
description: Number of flashes.
required: true
default: 3
selector:
number:
min: 1
max: 10
delay_between_flashes:
description: Seconds delay between flashes.
required: true
default: 1
selector:
number:
min: 1
max: 5
flash_transition_delay:
description: Transition duration.
required: true
default: 0.5
selector:
number:
min: 0.5
max: 5
step: 0.5
holiday_color_change:
alias: Holiday light color set
sequence:
- variables:
holiday_colors:
test: Green
birthday: Purple
christmas: Green
easter: Orchid
fathers: Orange
halloween: OrangeRed
marti_gras: Purple
new_years: Violet
pi: Blue
st_patty: DarkGreen
starwars: Red
thanksgiving: Orange
usa: Blue
valentine: Crimson
holiday: "{% set holiday = states('sensor.holiday') -%}\n{%- if holiday is not
none and holiday != \"\" -%}\n {%- set holiday = holiday|lower|trim|replace(\"'\",\"\")|replace(\"
\",\"_\")|replace(\",_eve\",\"\")|replace(\"_day\",\"\") -%}\n {%- if holiday
in [\"constitution\",\"flag\",\"independence\",\"memorial\",\"mlk\",\"presidents\",\"veterans\"]
-%}\n {{ \"usa\" }}\n {%- else -%}\n {%- if holiday == \"christmas\"
-%}\n {{ \"christmas\" }}\n {%- elif holiday.split('_')|last == \"birthday\"
-%}\n {{ \"birthday\" }}\n {%- else -%}\n {{ holiday|replace(\"mothers\",\"valentine\")|replace(\"earth\",\"st_patty\")
}}\n {%- endif -%}\n {%- endif %}\n{%- else -%}\n {{ \"standard\" }}\n{%-
endif %}\n"
- if:
- alias: When today is a holiday/birthday/anniversary.
condition: template
value_template: '''{{ holiday != "standard" }}'''
then:
- variables:
color: '{{ holiday_colors[holiday] }}'
alias: Retrieve the holiday color.
- if:
- alias: When the porch light is on.
condition: template
value_template: '{{ is_state("light.porch","on") }}'
then:
- alias: Set the porch light color.
service: light.turn_on
target:
entity_id: light.porch
data:
color_name: '{{ color }}'
- if:
- alias: When the family room table lamp is on.
condition: template
value_template: '{{ is_state("light.family_room_table_lamp","on") }}'
then:
- alias: Set the family room light color.
service: light.turn_on
target:
entity_id: light.family_room_table_lamp
data:
color_name: '{{ color }}'
else:
- if:
- alias: When the porch light is on.
condition: template
value_template: '{{ is_state("light.porch","on") }}'
then:
- alias: Set the porch light color temperature to the default.
service: light.turn_on
target:
entity_id: light.porch
data:
kelvin: 4000
- if:
- alias: When the family room table lamp is on.
condition: template
value_template: '{{ is_state("light.family_room_table_lamp","on") }}'
then:
- alias: Set the family room table lamp color temperature to the default.
service: light.turn_on
target:
entity_id: light.family_room_table_lamp
data:
kelvin: 4000
mode: single
icon: mdi:palette
light_sequence:
alias: Light sequence
sequence:
- variables:
color_count: '{{ colors|count }}'
- alias: Display debug info (notify_web).
enabled: false
service: script.notify_web
data:
message: 'delay: ''{{ delay }}''
transition: ''{{ transition }}''
colors: ''{{ colors }}''
color_count: ''{{ colors_count }}''
entity_id: ''{{ entity_id }}''
'
- alias: Turn on light group before we start.
repeat:
count: '{{ color_count|int(default=0) }}'
sequence:
- service: script.light_sequence_color
data:
entity_id: '{{ entity_id }}'
brightness: 255
color: white
delay: '0'
transition: '0'
- alias: Loop through the colors.
repeat:
count: '{{ color_count|int(default=0) }}'
sequence:
- alias: Change all bulbs to this color one at a time.
service: script.light_sequence_color
data:
entity_id: '{{ entity_id }}'
color: '{{ colors[repeat.index-1] }}'
delay: '{{ delay }}'
transition: '{{ transition }}'
- alias: Stop
choose:
- conditions:
- '{{ is_state(entity_id,"off") }}'
sequence:
- service: script.turn_off
entity_id:
- script.light_sequence
- script.light_sequence_color
- service: homeassistant.turn_off
data:
entity_id: '{{ entity_id }}'
mode: restart
max_exceeded: silent
icon: mdi:string-lights
fields:
entity_id:
description: Select the light sequence.
required: true
default: light.dining_room
example: light.dining_room
selector:
entity:
multiple: false
domain: light
delay:
description: Duration between flashes.
required: true
default: 0.5
selector:
number:
min: 0.5
max: 5
step: 0.5
transition:
description: Transition duration.
required: true
default: 2
selector:
number:
min: 0.5
max: 5
step: 0.5
colors:
description: Choose multiple colors to cycle through. https://www.w3.org/TR/css-color-3/#svg-color
required: true
selector:
select:
multiple: true
options:
- aquamarine
- blueviolet
- cadetblue
- coral
- cornflowerblue
- crimson
- cyan
- darkslateblue
- darkgoldenrod
- darkmagenta
- darkslategrey
- darkviolet
- darkturquoise
- deeppink
- deepskyblue
- firebrick
- dodgerblue
- forestgreen
- gold
- indigo
- lavenderblush
- lawngreen
- lemonchiffon
- lightblue
- darkturquoise
light_sequence_color:
alias: Light sequence color
sequence:
- variables:
light_groups:
light.bedroom_east: group.bedroom_east_fixture
light.dining_room: group.dining_room_fixture
light.play_room_floor_lamp: group.play_room_floor_lamp_fixture
entity: '{{ light_groups[entity_id]|default(entity_id) }}'
bulb_count: '{{ state_attr(entity,"entity_id")|count if entity.startswith("group")
else 1 }}'
color: '{{ color|default("cyan") }}
'
delay: '{{ delay|float(default=0.5) }}'
transition: '{{ transition|int(default=5) }}'
- alias: Show debug info (notify_web).
service: script.notify_web
enabled: false
data:
message: 'entity: {{ entity }}
bulb_count: {{ bulb_count }}
'
- choose:
- conditions:
- '{{ bulb_count|int(default=0) > 1 }}'
sequence:
- repeat:
count: '{{ bulb_count }}'
sequence:
- delay:
seconds: '{{ delay }}'
- service: light.turn_on
data:
brightness: 255
entity_id: '{{ state_attr(entity,"entity_id")[repeat.index-1] }}'
color_name: '{{ color }}'
transition: '{{ transition }}'
default:
- delay:
seconds: '{{ delay }}'
- service: light.turn_on
data:
brightness: 255
entity_id: '{{ entity }}'
color_name: '{{ color }}'
transition: '{{ transition }}'
- delay:
seconds: '{{ transition }}'
mode: queued
max: 10
icon: mdi:palette
fields:
entity_id:
description: Select the light sequence.
required: true
default: light.dining_room
example: light.dining_room
selector:
entity:
multiple: false
domain: light
delay:
description: Duration between flashes.
required: true
default: 0.5
selector:
number:
min: 0.5
max: 5
step: 0.5
transition:
description: Transition duration.
required: true
default: 2
selector:
number:
min: 0.5
max: 5
step: 0.5
colors:
description: Choose multiple colors to cycle through. https://www.w3.org/TR/css-color-3/#svg-color
required: true
selector:
select:
multiple: true
options:
- aquamarine
- blueviolet
- cadetblue
- coral
- cornflowerblue
- crimson
- cyan
- darkslateblue
- darkgoldenrod
- darkmagenta
- darkslategrey
- darkviolet
- darkturquoise
- deeppink
- deepskyblue
- firebrick
- dodgerblue
- forestgreen
- gold
- indigo
- lavenderblush
- lawngreen
- lemonchiffon
- lightblue
vacuum_room_clean:
alias: Vacuum room clean
sequence:
- variables:
rooms: "{%- if rooms is defined %}\n {{ rooms }}\n{%- endif %}\n"
vacuum: "{%- if vacuum is defined %}\n {{ vacuum }}\n{%- else %}\n [\"vacuum.downstairs\",\"vacuum.play_room\"]\n{%-
endif %}\n"
- if:
- condition: template
value_template: '{{ rooms|upper in ["","ALL"] }}'
then:
- service: vacuum.send_command
data:
command: sweep_auto
target:
entity_id: '{{ vacuum }}'
else:
- service: vacuum.send_command
data:
command: sweep_rooms
params:
rooms: ' {{ rooms }} '
target:
entity_id: '{{ vacuum }}'
icon: mdi:update
mode: parallel
fields:
rooms:
name: Room(s)
description: Room or rooms to clean
example: Family room
selector:
select:
multiple: true
options:
- ALL
- Family room
- Kitchen
vacuum:
name: Vacuum
description: Vacuum to clean.
example: vacuum.downstairs
selector:
entity:
multiple: true
domain:
- vacuum
max: 10
vacuum_update:
alias: Vacuum update
sequence:
- variables:
vacuum: "{%- if vacuum is defined %}\n {{ vacuum }}\n{%- else %}\n [\"vacuum.downstairs\",\"vacuum.play_room\"]\n{%-
endif %}\n"
- service: vacuum.send_command
data:
command: update
target:
entity_id: '{{ vacuum }}'
icon: mdi:update
mode: parallel
fields:
vacuum:
name: Vacuum
description: Vacuum to update.
example: vacuum.downstairs
selector:
entity:
multiple: true
domain:
- vacuum
max: 10
cast:
alias: Cast
sequence:
- if:
- condition: state
entity_id: automation.startup
state: 'on'
alias: When startup is on.
then:
- wait_for_trigger:
- platform: state
entity_id:
- automation.startup
from: 'on'
to: 'off'
alias: Should this try to run during startup... wait for startup to complete.
- variables:
entities: "{%- set data = namespace(displays=\"\") %}\n{%- if displays is defined
%}\n {%- if displays is not string %}\n {%- for display in displays %}\n
\ {%- set data.displays = data.displays ~ '\"' ~ device_entities(display)[0]
~ '\"' ~ iif(not loop.last, \",\", \"\") %}\n {%- endfor %}\n {%- else
%}\n {%- set data.displays = '\"' ~ device_entities(displays)[0] ~ '\"'
%}\n {%- endif %}\n{%- else %}\n {%- set data.displays = '\"media_player.google_kitchen\"'
%}\n{%- endif %}\n[{{ data.displays }}]\n"
- service: script.debug
enabled: false
data:
message: 'displays is not string: ''{{ displays is not string }}''
dismiss_after is defined: ''{{ dismiss_after is defined }}''
displays: ''{{ displays }}''
entities: ''{{ entities }}''
count: {{ entities|count }}
dashboard_path: "{{ dashboard_path }}"
view_path: "{{ view_path }}"
dismiss_after: ''{{ dismiss_after }}''
'
- alias: Turn off the media players before we cast a new page for it to display.
service: media_player.turn_off
target:
entity_id: '{{ entities }}'
- alias: Cast a page to the specified displays.
repeat:
count: '{{ entities|count }}'
sequence:
- alias: Cast a dashboard to a display.
service: cast.show_lovelace_view
data:
entity_id: '{{ entities[repeat.index-1] }}'
dashboard_path: '{{ dashboard_path }}'
view_path: '{{ view_path }}'
- alias: If `dismiss_after` is set, then turn off the displays after the specified
delay.
if:
- condition: template
value_template: '{{ dismiss_after is defined }}'
alias: When dismiss_after is set.
then:
- delay:
seconds: '{{ dismiss_after }}'
alias: Delay for the specified number of seconds.
- alias: Stop the displays.
service: media_player.turn_off
target:
entity_id: '{{ entities }}'
mode: parallel
icon: mdi:cast
fields:
displays:
description: Select the Google cast display(s).
selector:
device:
multiple: true
integration: cast
entity:
domain: media_player
dashboard_path:
description: Path to the desired dashboard.
default: dashboard-cast
example: lovelace
required: false
selector:
text:
view_path:
description: Path to the page within the dashboard
default: cameras
example: home
required: false
selector:
text:
dismiss_after:
description: 'Reset the display after # seconds.'
required: false
selector:
number:
min: 60
max: 300
max: 10
debug:
alias: Debug
sequence:
- service: persistent_notification.create
data:
title: '{{ title|default(''Debug Message'') }}'
message: '{{ message }}'
notification_id: '{{ id|default(''debug_'' ~ as_timestamp(now())) }}'
variables:
title: '{{ title|default("Debug Message") }}'
fields:
title:
description: Bold first line of the message.
example: Debug Message
selector:
text:
message:
description: Useful information to share.
selector:
text:
mode: queued
icon: mdi:bug
max: 10
notify_mobile_clear:
alias: Notify mobile clear
sequence:
- variables:
notification_service: "{%- set who = who|default(\"brian\") %}\n{%- if who.startswith(\"notify.\")
%}\n {{ who }}\n{%- else %}\n notify.{{ who|default(\"brian\") }}\n{% endif
%}\n"
tag: '{{ tag }}'
- alias: Only continue it mobile notifications are enabled.
condition: state
entity_id: input_boolean.mobile_notifications
state: 'on'
- alias: Clear the notification.
service: '{{ notification_service }}'
data:
message: clear_notification
data:
tag: '{{ tag }}'
mode: queued
icon: mdi:cellphone-message-off
notify_mobile:
alias: Notify mobile
sequence:
- condition: state
entity_id: input_boolean.mobile_notifications
state: 'on'
- variables:
notification_service: "{%- set who = who|default(\"brian\") %}\n{%- if who.startswith(\"notify.\")
%}\n {{ who }}\n{%- else %}\n notify.{{ who|default(\"brian\") }}\n{% endif
%}\n"
camera: '{{ camera|default("none") }}'
image: '{{ iif(who.endswith("pc"), camera, "") }}'
critical: '{{ critical|default(false) }}'
title: '{{ title|default("") }}'
subtitle: '{{ subtitle|default("") }}'
url: "{%- if camera != \"none\" %}\n homeassistant://navigate/lovelace/outdoor\n{%-
elif url is string %}\n {%- if url.startswith(\"/\") %}\n homeassistant://navigate{{
url }}\n {%- else %}\n {{ url }}\n {% endif %}\n{%- else %}\n {{ default
}}\n{% endif %}\n"
group: "{%- set group = group|default(\"\") %}\n{%- if camera|default(\"\")
!= \"\" %}\n {%- set group = \"camera\" %}\n{%- elif image|default(\"\")
!= \"\" %}\n {%- set group = \"image\" %}\n{% endif %}\n{{ group }}\n"
tag: '{{ tag }}'
push:
category: "{%- if camera|default(\"\") != \"\" %}\n camera\n{%- else %}\n
\ {{ default }}\n{%- endif %}\n"
sound:
name: "{%- if sound is string %}\n {%- if sound.startswith(\"/\") %}\n
\ media-source://media_source{{ sound }}\n {%- else %}\n {{ sound
}}\n {%- endif %}\n{%- elif critical %}\n Update.caf\n{%- elif tag ==
\"doorbell\" or category == \"doorbell\" %}\n media-source://media_source/local/audio/jetsons-doorbell.mp3\n{%-
elif tag == \"person_detected\" %}\n US-EN-Alexa-Motion-At-Front-Door.wav\n{%
else %}\n default\n{%- endif %}\n"
'{{ iif(critical, "critical", "disabled_critical") }}': 1
'{{ iif(critical, "volume", "disabled_volume") }}': 1
actions: '{{ actions|default([]) }}'
- service: '{{ notification_service }}'
data:
title: '{{ title }}'
message: '{{ message }}'
data:
subtitle: '{{ subtitle }}'
url: '{{ url }}'
entity_id: '{{ camera }}'
push: '{{ push }}'
actions: '{{ actions }}'
'{{ iif(image == "", "disabled_", "") }}image': '{{ image }}'
'{{ iif(group == "", "disabled_", "") }}group': '{{ group }}'
'{{ iif(tag == "", "disabled_", "") }}tag': '{{ tag }}'
fields:
who:
description: Who are we sending this message to?
example: brian
default: brian
selector:
text:
title:
description: Bold first line of the message.
example: Safety Alert!
default: Home Assistant
selector:
text:
subtitle:
description: Bold second line of the message.
example: Notification
selector:
text:
message:
description: Include details here.
example: Test message
default: Test message
selector:
text:
multiline: true
camera:
description: Camera entity.
example: camera.front_door
selector:
text:
critical:
description: Sound a critical alert sound!
example: false
selector:
boolean:
group:
description: Combine notifications together visually. (iOS does not support
grouping critical notifications.)
example: person-detected
selector:
text:
tag:
description: Replace an existing notification by using a tag for the notification.
All subsequent notifications will take the place of a notification with the
same tag. (iOS does not support grouping critical notifications.)
example: front-door-person-detected
selector:
text:
url:
description: Link to open.
example: /lovelace/outdoor
selector:
text:
sound:
description: Audio to play with notification.
example: /local/audio/jetsons-doorbell.mp3
selector:
text:
mode: single
icon: mdi:cellphone-message
notify_audio:
alias: Notify audio
icon: mdi:cast-audio
sequence:
- variables:
entities: "{%- if speakers is defined %}\n {%- set entities = speakers %}\n{%-
else %}\n {%- set entities = '[\"media_player.google_family_room\"]' %}\n{%-
endif %}\n{{ entities }}\n"
audio_file: '{{ audio_file|default("media-source://media_source/local/audio/sfx-pop4.mp3")
}}'
content_type: '{{ content_type|default("audio") }}'
new_volume: "{%- if volume is number %}\n {%- if volume > 1.0 %}\n {%- set
volume = volume / 100 %}\n {%- else %}\n {%- set volume = volume %}\n
\ {%- endif %}\n{%- else %}\n {%- set volume = states(\"input_number.default_audio_volume\")|float(default=0)
/ 100 %}\n{%- endif %}\n{{ volume }}\n"
audio_notifications: '{{ is_state("input_boolean.audio_notifications", "on")
}}'
quiet_time: '{{ is_state("binary_sensor.noncritical_alert_quiet_time", "on")
}}'
family_home: '{{ states("sensor.family_present")|int(default=0) > 0 }}'
guest_mode: '{{ is_state("input_boolean.guest_mode", "on") }}'
- alias: Debug output. (Disable to turn off.)