forked from bieniu/home-assistant-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautomations.yaml
2828 lines (2712 loc) · 85.8 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
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
## POWIADOMIENIA SYSTEMOWE ##
# powiadomienie o aktualizacji HA
- id: notification_home_assistant_update_available
alias: "Notification Home Assistant Update Available"
trigger:
platform: state
entity_id: sensor.ha_version_current
condition:
- condition: template
value_template: "{{ trigger.to_state.state != 'unknown' }}"
- condition: template
value_template: "{{ trigger.to_state.state != 'unavailable' }}"
- condition: template
value_template: "{{ trigger.from_state.state != 'unknown' }}"
- condition: template
value_template: "{{ trigger.from_state.state != 'unavailable' }}"
- condition: template
value_template: "{{ trigger.from_state.state != trigger.to_state.state }}"
action:
- service: hassio.addon_start
data:
addon: core_check_config
- delay: "00:05:00"
- service: python_script.notify
data:
title: "Aktualizacja Home Assistanta"
message: "Dostępna jest aktualizacja do wersji {{ trigger.to_state.state }} dla Home Assistanta."
tag: "notification-ha-update"
group: "aktualizacje"
url: "/hassio/dashboard"
actions:
- title: "Zmiany"
action: "URI"
uri: "https://github.com/home-assistant/home-assistant/releases"
- title: "Konfiguracja"
action: "URI"
uri: "/hassio/addon/core_check_config/logs"
services:
- service: !secret maciek_notify_service
type: "android"
# powiadomienie o aktualizacji Supervisora
- id: notification_supervisor_update_available
alias: "Notification Supervisor Update Available"
trigger:
platform: template
value_template: "{{ state_attr('sensor.supervisor_updates', 'current_version') != state_attr('sensor.supervisor_updates', 'newest_version') }}"
action:
- service: python_script.notify
data:
title: "Aktualizacja Supervisora"
message: "Dostępna jest aktualizacja do wersji {{ state_attr('sensor.supervisor_updates', 'newest_version') }} dla Supervisora."
tag: "notification-supervisor-update"
group: "aktualizacje"
url: "/hassio/dashboard"
services:
- service: !secret maciek_notify_service
type: "android"
actions:
- title: "Zmiany"
action: "URI"
uri: "https://github.com/home-assistant/supervisor/releases"
# powiadomienie o aktualizacji addonów
- id: notification_addons_update_available
alias: "Notification Addons Update Available"
trigger:
platform: numeric_state
entity_id: sensor.supervisor_updates
above: 0
action:
- service: python_script.notify
data:
title: >-
{% if (trigger.to_state.state | int) == 1 %}
Aktualizacja dodatku Supervisora
{% else %}
Aktualizacje dodatków Supervisora
{% endif %}
message: >-
{% if trigger.to_state.state | int == 1 %}
{%- for repo in state_attr(trigger.entity_id, 'addons') %}
Dostępna jest aktualizacja dodatku {{ repo.name }} do wersji {{ repo.version }}.
{%- endfor %}
{%- else %}
Dostępne są aktualizacje dodatków:
{%- for repo in state_attr(trigger.entity_id, 'addons') %}
- {{ repo.name }} do wersji {{ repo.version }}
{%- endfor %}
{%- endif %}
tag: "notification-addons-update"
group: "aktualizacje"
url: "/hassio/dashboard"
services:
- service: !secret maciek_notify_service
type: "android"
# powiadomienie o aktualizacji w HACS
- id: notification_update_available_in_hacs
alias: "Notification Update Available In HACS"
trigger:
platform: state
entity_id: sensor.hacs
condition:
- condition: template
value_template: "{{ trigger.from_state.state != 'unknown'}}"
- condition: template
value_template: "{{ trigger.from_state.state != 'unavailable'}}"
- condition: template
value_template: "{{ trigger.to_state.state != 'unknown'}}"
- condition: template
value_template: "{{ trigger.to_state.state != 'unavailable'}}"
- condition: template
value_template: "{{ trigger.from_state.state | int < trigger.to_state.state | int }}"
action:
service: python_script.notify
data:
title: >-
{% if (trigger.to_state.state | int) == 1 %}
Aktualizacja dodatku z HACS
{% else %}
Aktualizacje dodatków z HACS
{% endif %}
message: >-
{% if trigger.to_state.state | int == 1 %}
{%- for repo in state_attr(trigger.entity_id, 'repositories') %}
Dostępna jest aktualizacja dodatku {{ repo.display_name }} do wersji {{ repo.available_version }}.
{%- endfor %}
{%- else %}
Dostępne są aktualizacje dodatków:
{%- for repo in state_attr(trigger.entity_id, 'repositories') %}
- {{ repo.display_name }} do wersji {{ repo.available_version }}
{%- endfor %}
{%- endif %}
tag: "notification-hacs"
group: "aktualizacje"
url: "/hacs/entry"
services:
- service: !secret maciek_notify_service
type: "android"
# powiadomienie o wysokim użyciu pamięci RAM
- id: notification_high_ram_usage
alias: "Notification High RAM Usage"
trigger:
platform: numeric_state
entity_id: sensor.memory_use_percent
above: 50
for:
minutes: 5
action:
service: python_script.notify
data:
title: "Wysokie użycie pamięci RAM"
message: "Serwer Home Assistant używa obecnie {{ states('sensor.memory_use_percent') }}% pamięci RAM."
tag: "notification-high-ram-usage"
group: "inne"
priority: "high"
services:
- service: !secret maciek_notify_service
type: "android"
# powiadomienie o wygasającym certyfikacie SSL
- id: notification_ssl_cert_expiry
alias: "Notification SSL Cert Expiry"
trigger:
platform: template
value_template: "{{ states('sensor.ssl_certificate_expiry') | int < 11 }}"
condition:
- condition: not
conditions:
condition: state
entity_id: sensor.ssl_certificate_expiry
state: "unavailable"
action:
- service: python_script.notify
data:
title: "Wygasa certyfikat SSL"
message: "Za {{ states('sensor.ssl_certificate_expiry') }} dni wygaśnie certyfikat SSL serwera WWW."
tag: "notification-ssl"
group: "inne"
services:
- service: !secret maciek_notify_service
type: "android"
# powiadomienie o aktualizacji oprogramowania Shelly
- id: notification_shelly_update_available
alias: "Notification Shelly Update Available"
trigger:
- platform: state
entity_id:
- binary_sensor.shelly_1_328900_firmware_update
- binary_sensor.shelly_2_5b2604_firmware_update
- binary_sensor.shelly_flood_f2ad1d_firmware_update
- binary_sensor.shelly_ht_e00abd_firmware_update
- binary_sensor.shelly_plug_s_7aecf4_firmware_update
from: "off"
to: "on"
action:
- service: python_script.notify
data:
title: "Aktualizacja oprogramowania Shelly"
message: "Dostępna jest aktualizacja oprogramowania dla {{ trigger.to_state.attributes.friendly_name | replace(' Firmware Update', '')}}."
tag: "notification-{{ trigger.entity_id }}"
group: "aktualizacje"
services:
- service: !secret maciek_notify_service
type: "android"
# powiadomienie o aktualizacji ESPHome
- id: notification_esphome_update_available
alias: "Notification ESPHome Update Available"
trigger:
platform: state
entity_id: sensor.esphome_version_current
condition:
- condition: template
value_template: "{{ trigger.to_state.state != 'unknown' }}"
- condition: template
value_template: "{{ trigger.to_state.state != 'unavailable' }}"
- condition: template
value_template: "{{ trigger.from_state.state != 'unknown' }}"
- condition: template
value_template: "{{ trigger.from_state.state != 'unavailable' }}"
action:
- service: python_script.notify
data:
title: "Aktualizacja ESPHome"
message: "Dostępna jest aktualizacja do wersji {{ trigger.to_state.state }} dla ESPHome."
tag: "notification-esphome-update"
group: "aktualizacje"
url: "/hassio/dashboard"
services:
- service: !secret maciek_notify_service
type: "android"
actions:
- title: "Zmiany"
action: "URI"
uri: "https://github.com/esphome/esphome/releases"
# powiadomienie o aktualizacji Caddy
- id: notification_caddy_update_available
alias: "Notification Caddy Update Available"
trigger:
platform: state
entity_id: sensor.caddy_version_current
condition:
- condition: template
value_template: "{{ trigger.to_state.state != 'unknown' }}"
- condition: template
value_template: "{{ trigger.to_state.state != 'unavailable' }}"
- condition: template
value_template: "{{ trigger.from_state.state != 'unknown' }}"
- condition: template
value_template: "{{ trigger.from_state.state != 'unavailable' }}"
action:
- service: python_script.notify
data:
title: "Aktualizacja Caddy"
message: "Dostępna jest aktualizacja do wersji {{ trigger.to_state.state }} dla Caddy."
tag: "notification-caddy-update"
group: "aktualizacje"
services:
- service: !secret maciek_notify_service
type: "android"
actions:
- title: "Zmiany"
action: "URI"
uri: "https://github.com/caddyserver/caddy/releases"
###################################################################################################
# włączenie drzewek jak jest zachód słońca i domownicy w domu
- id: light_turn_on_trees
alias: "Light Turn On Trees"
trigger:
platform: sun
event: sunset
condition:
condition: state
entity_id: binary_sensor.people_at_home
state: "on"
action:
- service: switch.turn_on
entity_id:
- switch.tree_sypialnia
- switch.tree_antek
# wyłączenie drzewek o 23
- id: light_turn_off_trees
alias: "Light Turn Off Trees"
trigger:
platform: time
at: "23:00:00"
action:
service: switch.turn_off
entity_id:
- switch.tree_sypialnia
- switch.tree_antek
# włączenie drzewek jak po zachodzie słońca wracają domownicy
- id: light_turn_on_trees_when_peoples_back
alias: "Light Turn On Trees When Peoples Back"
trigger:
platform: state
entity_id: binary_sensor.people_at_home
to: "on"
condition:
- condition: sun
after: sunset
- condition: time
before: "23:00:00"
action:
service: switch.turn_on
entity_id:
- switch.tree_sypialnia
- switch.tree_antek
# powiadomienie o zbliżającej się burzy
- id: notification_storm_comming
alias: "Notification Storm Comming"
trigger:
platform: numeric_state
entity_id: sensor.lightning_distance
below: 10
variables:
notification_title: "Burza w pobliżu domu"
notification_message: "Wyładowania atmosferyczne występują {{ states('sensor.lightning_distance') }} km od domu."
notification_tag: "notification-storm-comming"
action:
- choose:
conditions:
condition: state
entity_id: person.maciek
state: "home"
sequence:
service: python_script.notify
data:
title: "{{ notification_title }}"
message: "{{ notification_message }}"
tag: "{{ notification_tag }}"
services:
- service: !secret maciek_notify_service
type: "android"
- choose:
conditions:
condition: state
entity_id: person.edyta
state: "home"
sequence:
service: python_script.notify
data:
title: "{{ notification_title }}"
message: "{{ notification_message }}"
tag: "{{ notification_tag }}"
services:
- service: !secret edyta_notify_service
type: "ios"
- choose:
conditions:
condition: state
entity_id: media_player.bravia_salon
state: "on"
sequence:
service: notify.bravia
data:
title: "{{ notification_title }}"
message: "{{ notification_message }}"
data:
file:
url: !secret favicon_url
duration: 10
- choose:
conditions:
condition: state
entity_id: media_player.mibox_goscinny
state: "on"
sequence:
service: notify.mibox
data:
title: "{{ notification_title }}"
message: "{{ notification_message }}"
data:
file:
url: !secret favicon_url
duration: 10
- delay: "00:15:00"
# powiadomienie o końcu zmywania
- id: notification_dishwasher_end
alias: "Notification Dishwasher End"
trigger:
platform: state
entity_id: sensor.dishwasher_kuchnia
from: "zmywanie"
to: "wyłączona"
for:
minutes: 1
action:
service: python_script.notify
data:
title: "Koniec zmywania"
message: "Zmywarka zakończyła zmywanie naczyń."
tag: "notification-dishwasher"
group: "inne"
services:
- service: !secret maciek_notify_service
type: "android"
- service: !secret edyta_notify_service
type: "ios"
# powiadomienie o włączonym komputerze
- id: notification_desktop_computer_turned_on
alias: "Notification Desktop Computer Turned On"
trigger:
- platform: time
at: "22:45:00"
- platform: state
entity_id: person.maciek
to: not_home
for:
minutes: 5
condition:
condition: state
entity_id: switch.stacjonarny
state: "on"
action:
service: python_script.notify
data:
title: "Komputer stacjonarny włączony"
message: "Komputer stacjonarny jest włączony. Czy chcesz go wyłączyć?"
tag: "notification-desktop-computer"
group: "inne"
actions:
- title: "Wyłącz"
action: "TURN_OFF_DESKTOP_COMPUTER"
services:
- service: !secret maciek_notify_service
type: "android"
# wyłączenie komputera z powiadomienia
- id: notification_turn_off_desktop_computer
alias: "Notification Turn Off Desktop Computer"
trigger:
platform: event
event_type: mobile_app_notification_action
event_data:
action: "TURN_OFF_DESKTOP_COMPUTER"
action:
- service: switch.turn_off
entity_id: switch.stacjonarny
- service: python_script.notify
data:
title: "{{ trigger.event.data.title }}"
message: "clear_notification"
tag: "{{ trigger.event.data.tag }}"
services:
- service: !secret maciek_notify_service
type: "android"
# powiadomienie o encji ze stanem dead lub unavailable
- id: notification_dead_or_unavailable
alias: "Notification dead or unavailable"
trigger:
platform: time_pattern
minutes: "/10"
seconds: 0
condition:
condition: template
value_template: >
{% macro dead_unavailable_entities() %}
{%- set domains = ['light', 'switch', 'sensor', 'zwave', 'fan', 'binary_sensor', 'media_player'] -%}
{%- set rooms = ['przedpokoj', 'goscinny', 'pracownia', 'kuchnia', 'salon', 'schody', 'antresola', 'gabinet', 'pralnia', 'antek', 'sypialnia', 'lazienka', 'balkon', 'indoor', 'outdoor'] -%}
{%- set ignored = ['media_player.dune_salon'] -%}
{% for domain in domains -%}
{% for item in states[domain] if (item.entity_id.split('.')[-1].split('_')[-1] in rooms or item.entity_id.split('.')[-1].split('_')[-2] in rooms) and not (item.entity_id in ignored or 'battery' in item.entity_id or 'status' in item.entity_id) and item.state is defined and (item.state == 'dead' or item.state == 'unavailable') %}
- {{ item.name }} ({{ item.entity_id }})
{%- endfor %}
{%- endfor %}
{% endmacro %}
{{ dead_unavailable_entities() | trim != '' }}
action:
- service: python_script.notify
data:
title: "Encja z nieprawidłowym stanem"
message: >
{% macro dead_unavailable_entities() %}
{%- set domains = ['light', 'switch', 'sensor', 'zwave', 'fan', 'binary_sensor', 'media_player'] -%}
{%- set rooms = ['przedpokoj', 'goscinny', 'pracownia', 'kuchnia', 'salon', 'schody', 'antresola', 'gabinet', 'pralnia', 'antek', 'sypialnia', 'lazienka', 'balkon', 'indoor', 'outdoor'] -%}
{%- set ignored = ['media_player.dune_salon'] -%}
{% for domain in domains -%}
{% for item in states[domain] if (item.entity_id.split('.')[-1].split('_')[-1] in rooms or item.entity_id.split('.')[-1].split('_')[-2] in rooms) and not (item.entity_id in ignored or 'battery' in item.entity_id or 'status' in item.entity_id) and item.state is defined and (item.state == 'dead' or item.state == 'unavailable') %}
- {{ item.name }} ({{ item.entity_id }})
{%- endfor %}
{%- endfor %}
{% endmacro %}
Następujące encje mają nieprawidłowe stany: {{ dead_unavailable_entities() }}
tag: "notification-dead-unavailable"
group: "inne"
services:
- service: !secret maciek_notify_service
type: "android"
# powiadomienie o małej ilości wody w nawilżaczu
- id: notification_humidifier_low_water
alias: "Notification Humidifier Low Water"
trigger:
- platform: numeric_state
entity_id: sensor.humidifier_water_level
below: 10
- platform: numeric_state
entity_id: sensor.humidifier_water_level
below: 20
- platform: numeric_state
entity_id: sensor.humidifier_water_level
below: 40
condition:
condition: and
conditions:
- condition: or
conditions:
- condition: state
entity_id: person.maciek
state: "home"
- condition: state
entity_id: person.edyta
state: "home"
- condition: state
entity_id: input_boolean.heating_season
state: "on"
- condition: template
value_template: "{{ states('sensor.humidifier_water_level') | int != 0 }}"
variables:
notification_title: "Uzupełnij wodę w nawilżaczu"
notification_message: "W zbiorniku nawilżacza pozostało {{ states('sensor.humidifier_water_level') }}% wody."
notification_tag: "notification-humidifier"
action:
- choose:
conditions:
condition: state
entity_id: person.maciek
state: "home"
sequence:
service: python_script.notify
data:
title: "{{ notification_title }}"
message: "{{ notification_message }}"
tag: "{{ notification_tag }}"
services:
- service: !secret maciek_notify_service
type: "android"
- choose:
conditions:
condition: state
entity_id: person.edyta
state: "home"
sequence:
service: python_script.notify
data:
title: "{{ notification_title }}"
message: "{{ notification_message }}"
tag: "{{ notification_tag }}"
services:
- service: !secret edyta_notify_service
type: "ios"
- choose:
conditions:
condition: state
entity_id: media_player.bravia_salon
state: "on"
sequence:
service: notify.bravia
data:
title: "{{ notification_title }}"
message: "{{ notification_message }}"
data:
file:
url: !secret favicon_url
duration: 10
- choose:
conditions:
condition: state
entity_id: media_player.mibox_goscinny
state: "on"
sequence:
service: notify.mibox
data:
title: "{{ notification_title }}"
message: "{{ notification_message }}"
data:
file:
url: !secret favicon_url
duration: 10
# powiadomienie o wysokim stężeniu CO2 w salonie
- id: notification_salon_co2
alias: "Notification Salon CO2"
trigger:
platform: numeric_state
entity_id: sensor.co2_salon
above: 1000
for:
minutes: 5
condition:
condition: and
conditions:
- condition: or
conditions:
- condition: state
entity_id: person.maciek
state: "home"
- condition: state
entity_id: person.edyta
state: "home"
- condition: state
entity_id: input_boolean.away_mode
state: "off"
variables:
notification_title: "Wysokie stężenie dwutlenku węgla"
notification_message: "W salonie stężenie dwutlenku węgla wynosi {{ trigger.to_state.state }} ppm. Należy przewietrzyć pomieszczenie."
notification_tag: "notification-high-co2"
action:
- choose:
conditions:
condition: state
entity_id: person.maciek
state: "home"
sequence:
service: python_script.notify
data:
title: "{{ notification_title }}"
message: "{{ notification_message }}"
tag: "{{ notification_tag }}"
services:
- service: !secret maciek_notify_service
type: "android"
- choose:
conditions:
condition: state
entity_id: person.edyta
state: "home"
sequence:
service: python_script.notify
data:
title: "{{ notification_title }}"
message: "{{ notification_message }}"
tag: "{{ notification_tag }}"
services:
- service: !secret edyta_notify_service
type: "ios"
- choose:
conditions:
condition: state
entity_id: media_player.bravia_salon
state: "on"
sequence:
service: notify.bravia
data:
title: "{{ notification_title }}"
message: "{{ notification_message }}"
data:
file:
url: !secret favicon_url
duration: 10
- choose:
conditions:
condition: state
entity_id: media_player.mibox_goscinny
state: "on"
sequence:
service: notify.mibox
data:
title: "{{ notification_title }}"
message: "{{ notification_message }}"
data:
file:
url: !secret favicon_url
duration: 10
# powiadomienie jak pojawi się woda na podłodze w kuchni
- id: notification_water_leak_kuchnia
alias: "Notification Water Leak Kuchnia"
trigger:
- platform: state
entity_id:
- binary_sensor.water_leak_kuchnia
from: "off"
to: "on"
variables:
notification_title: "Wykryto wyciek wody"
notification_message: "W kuchni wykryto wodę na podłodze."
action:
- service: python_script.notify
data:
title: "{{ notification_title }}"
message: "{{ notification_message }}"
tag: "notification-water-leak"
priority: "high"
services:
- service: !secret maciek_notify_service
type: "android"
- service: !secret edyta_notify_service
type: "ios"
- choose:
conditions:
condition: state
entity_id: media_player.bravia_salon
state: "on"
sequence:
service: notify.bravia
data:
title: "{{ notification_title }}"
message: "{{ notification_message }}"
data:
file:
url: !secret favicon_url
duration: 10
- choose:
conditions:
condition: state
entity_id: media_player.mibox_goscinny
state: "on"
sequence:
service: notify.mibox
data:
title: "{{ notification_title }}"
message: "{{ notification_message }}"
data:
file:
url: !secret favicon_url
duration: 10
# powiadomienie jak zbyt duże obciążenie przekaźnika
- id: notification_relay_overpower
alias: "Notification Relay Overpower"
trigger:
- platform: state
entity_id:
- binary_sensor.shelly_plug_s_7aecf4_overpower_0
- binary_sensor.shelly_2_5b2604_overpower_0
- binary_sensor.shelly_2_5b2604_overpower_1
from: "off"
to: "on"
for:
minutes: 1
variables:
notification_title: "Zbyt duże obciążenie przekaźnika"
notification_message: "Przekaźnik {{ state_attr(trigger.to_state.attributes.relay, 'friendly_name') }} ma zbyt duże obciążenie i zostanie wyłączony."
action:
- service: python_script.notify
data:
title: "{{ notification_title }}"
message: "{{ notification_message }}"
tag: "notification-relay-overpower-{{ trigger.entity_id }}"
priority: "high"
services:
- service: !secret maciek_notify_service
type: "android"
- service: !secret edyta_notify_service
type: "ios"
- choose:
conditions:
condition: state
entity_id: media_player.bravia_salon
state: "on"
sequence:
service: notify.bravia
data:
title: "{{ notification_title }}"
message: "{{ notification_message }}"
data:
file:
url: !secret favicon_url
duration: 10
- choose:
conditions:
condition: state
entity_id: media_player.mibox_goscinny
state: "on"
sequence:
service: notify.mibox
data:
title: "{{ notification_title }}"
message: "{{ notification_message }}"
data:
file:
url: !secret favicon_url
duration: 10
- service: homeassistant.turn_off
data:
entity_id: "{{ trigger.to_state.attributes.relay }}"
# powiadomienie jak jest ruch i nikogo w domu
- id: notification_motion_when_away_mode
alias: "Notification Motion When Away Mode"
trigger:
- platform: state
entity_id:
- binary_sensor.motion_antresola
- binary_sensor.motion_salon
- binary_sensor.motion_sypialnia
- binary_sensor.motion_antek
- binary_sensor.motion_przedpokoj
- binary_sensor.motion_pracownia
- binary_sensor.motion_goscinny
- binary_sensor.motion_gabinet
from: "off"
to: "on"
condition:
condition: state
entity_id: input_boolean.away_mode
state: "on"
for:
minutes: 10
action:
service: script.notify_motion
data:
title: "Wykryto ruch w pustym mieszkaniu"
message: "Pomieszczenie: {{ trigger.to_state.attributes.location }}, godzina {{ now().strftime('%H:%M') }}."
tag: "notification-motion-{{ trigger.to_state.attributes.location }}"
datetime: "{{ now().strftime('%Y%m%d%H%M%S') }}"
snapshot_url: !secret snapshot_url
location: "{{ trigger.to_state.attributes.location }}"
# powiadomienie jak otworzy się okno i nikogo w domu
- id: notification_window_opened_when_away_mode
alias: "Notification Window Opened When Away Mode"
trigger:
- platform: state
entity_id:
- binary_sensor.balcony_door_sypialnia
- binary_sensor.window_sypialnia
- binary_sensor.window_kuchnia
- binary_sensor.balcony_door_pracownia
- binary_sensor.window_antresola
- binary_sensor.window_antek
- binary_sensor.window_sypialnia
from: "off"
to: "on"
condition:
condition: state
entity_id: input_boolean.away_mode
state: "on"
for:
minutes: 10
action:
service: python_script.notify
data:
title: "Wykryto otwarcie okna w pustym mieszkaniu"
message: "Pomieszczenie: {{ trigger.to_state.attributes.location }}, godzina {{ now().strftime('%H:%M') }}."
tag: "notification-window-opened-{{ trigger.to_state.attributes.location }}"
group: "okna"
priority: "high"
services:
- service: !secret maciek_notify_service
type: "android"
- service: !secret edyta_notify_service
type: "ios"
# powiadomienie o otwartych drzwiach balkonowych w pracowni po wyjściu z domu
- id: notification_balcony_door_pracownia_opened
alias: "Notification Balcony Door Pracownia Opened"
trigger:
platform: state
entity_id: binary_sensor.people_at_home
to: "off"
condition:
condition: state
entity_id: binary_sensor.balcony_door_pracownia
state: "on"
action:
service: python_script.notify
data:
title: "Otwarte drzwi balkonowe"
message: "Domownicy opuścili mieszkanie, a drzwi balkonowe w pracowni nie są zamknięte."
tag: "notification-balcony-door-pracownia"
priority: "high"
group: "okna"
services:
- service: !secret maciek_notify_service
type: "android"
- service: !secret edyta_notify_service
type: "ios"
# powiadomienia o małej ilości miejsca na Synology
- id: notification_low_disk_space_on_synology
alias: "Notification Low Disk Space On Synology"
trigger:
platform: numeric_state
entity_id: sensor.synology_disk_used
above: 70
action:
- service: python_script.notify
data:
title: "Mało miejsca na dysku Synology"
message: "Dysk Synology jest zapełniony w {{ trigger.to_state.state }}%."
tag: "notification-synology-low-space"
group: "inne"
services:
- service: !secret maciek_notify_service
type: "android"
# powiadomienie o wykryciu nowego urządzenia
- id: notification_new_device
alias: "Notification New Device"
trigger:
platform: event
event_type: device_tracker_new_device
action:
- service: python_script.notify
data:
title: "Nowe urządzenie"
message: "Wykryto nowe urządzenie o nazwie {{trigger.event.data.host_name}} ({{trigger.event.data.entity_id}})."
tag: "notification-new-device"
group: "inne"
services:
- service: !secret maciek_notify_service
type: "android"
# powiadomienie o niskim poziomie naładowania baterii
- id: notification_low_battery
alias: "Notification Low Battery"
trigger:
platform: time
at: "18:00:00"
condition:
condition: template
value_template: >
{% macro battery_level() %}
{%- set threshold = 10 -%}
{%- set domains = ['light', 'switch', 'sensor', 'zwave', 'lock', 'binary_sensor'] -%}
{% for domain in domains -%}
{% for item in states[domain] if (((item.attributes.battery_level is defined and item.attributes['battery_level'] | int < threshold) or ('battery' in item.name | lower and ((item.state | int < threshold and item.state|int != 0) or item.state | lower == 'low' or item.state | lower == 'unknown')))) and not (( 'humidity' in item.entity_id) or ('illumination' in item.entity_id)) -%}
{% if (item.attributes.battery_level is defined and item.attributes['battery_level'] | int < threshold) %}
- {{ item.entity_id }} [{{ item.attributes['battery_level'] | round(0) }}%]{% endif -%}
{% if 'battery' in item.name | lower and ((item.state | int < threshold and item.state|int != 0) or item.state | lower == 'low' or item.state | lower == 'unknown') %}
- {{ item.entity_id }} [{{ item.state | round(0) }}%]{% endif -%}
{% endfor %}
{%- endfor %}
{% endmacro %}
{{ battery_level() | trim != '' }}
action:
- service: python_script.notify
data:
title: "Niski poziom naładowania baterii"
message: >
{% macro battery_level() %}
{%- set threshold = 10 -%}
{%- set domains = ['light', 'switch', 'sensor', 'zwave', 'lock', 'binary_sensor'] -%}
{% for domain in domains -%}
{% for item in states[domain] if (((item.attributes.battery_level is defined and item.attributes['battery_level'] | int < threshold) or ('battery' in item.name | lower and ((item.state | int < threshold and item.state|int != 0) or item.state | lower == 'low' or item.state | lower == 'unknown')))) and not (( 'humidity' in item.entity_id) or ('illumination' in item.entity_id)) -%}
{% if (item.attributes.battery_level is defined and item.attributes['battery_level'] | int < threshold) %}
- {{ item.entity_id }} [{{ item.attributes['battery_level'] | round(0) }}%]{% endif -%}
{% if 'battery' in item.name | lower and ((item.state | int < threshold and item.state|int != 0) or item.state | lower == 'low' or item.state | lower == 'unknown') %}
- {{ item.entity_id }} [{{ item.state | round(0) }}%]{% endif -%}
{% endfor %}
{%- endfor %}
{% endmacro %}
W następujących urządzeniach jest niski poziom naładowania baterii: {{ battery_level() }}
tag: "notification-low-battery"
group: "inne"
services:
- service: !secret maciek_notify_service
type: "android"
##################################################################################################
#### OBECNOŚĆ ####################################################################################
# Edyta daleko od domu
- id: presence_edyta_far_from_home
alias: "Presence Edyta Far From Home"
trigger:
platform: state
entity_id: person.edyta
condition:
- condition: template
value_template: "{{ state_attr(trigger.entity_id, 'latitude') != None }}"
- condition: template
value_template: "{{ state_attr(trigger.entity_id, 'longitude') != None }}"
- condition: state
entity_id: input_boolean.edyta_far_from_home
state: "off"
- condition: template
value_template: "{{ distance(trigger.entity_id, 'zone.home') > 40 }}"
action:
service: input_boolean.turn_on
entity_id: input_boolean.edyta_far_from_home
# Maciek daleko od domu
- id: presence_maciek_far_from_home
alias: "Presence Maciek Far From Home"
trigger:
platform: state
entity_id: person.maciek
condition:
- condition: template
value_template: "{{ state_attr(trigger.entity_id, 'latitude') != None }}"
- condition: template