-
Notifications
You must be signed in to change notification settings - Fork 11
/
natural_events.yaml
executable file
·1756 lines (1693 loc) · 83.2 KB
/
natural_events.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
## How to use the Alexa Audio Library with Google.
## soundbank://soundlibrary/ >> REPLACE TO >> https://d3qhmae9zx9eb.cloudfront.net/
homeassistant:
customize:
package.natural_events:
version: &v "2023.08.0"
date: 📅 01/08/2019 - Updated 04/08/2023
info: https://github.com/caiosweet/Package-Natural-Events#readme
information provided by: Blitzortung, Burze, DPC, GDACS, INGV, MeteoAlarm and USGS
links:
notifier: https://github.com/jumping2000/notifier
centro_notifiche: https://github.com/caiosweet/Package-Notification-HUB-AppDaemon
web: https://hassiohelp.eu/
tools_radius: https://www.mapdevelopers.com/draw-circle-tool.php
extra_attributes: &extra_attributes
version: *v
package: "Natural_events"
attribution: "Caio & Gianpi - natural events - hassiohelp.eu"
##---------------------- IMPOSTAZIONI DEL PACKAGE ----------------------##
### Important! Make sure the editor doesn't change this formatting.
### ====> DESCRIPTION: &ALIAS !secret parameter_of_secret <====
## DEFAULT
SCRIPT NOTIFICHE: &DEFAULT_SCRIPT !secret pkg_natural_events_script
SERVIZIO NOTIFY: &DEFAULT_NOTIFY !secret pkg_natural_events_notify
MEDIA PLAYER ALEXA: &DEFAULT_MEDIA_PLAYER_ALEXA !secret pkg_natural_events_alexa
MEDIA PLAYER GOOGLE: &DEFAULT_MEDIA_PLAYER_GOOGLE !secret pkg_natural_events_google
SERIVICE TTS: &DEFAULT_SERVICE_TTS !secret pkg_natural_events_service_tts
## DND TTS (Orario Non Disturbare - Per lo script del package script.notify_hub presente in questo package)
TTS PRIMA CHE INIZIA DND: &DEFAULT_DND_START !secret pkg_natural_events_dnd_start
TTS DOPO CHE FINISCE DND: &DEFAULT_DND_STOP !secret pkg_natural_events_dnd_stop
## FOLDER DOWLOADS [Se la cambi, ricorda di farlo anche in lovelace!]
DOWNLOAD DIRECTORY: &DEFAULT_DOWNLOAD_DIR !secret pkg_natural_events_download_dir
## CONFIGURATION
LATITUDINE DI CASA: &CONF_LATITUDE !secret pkg_natural_events_latitude_home
LONGITUDINE DI CASA: &CONF_LONGITUDE !secret pkg_natural_events_longitude_home
RAGGIO ZONA GEOALERT (metri): &CONF_RADIUS_GEOALERT !secret pkg_natural_events_radius_geoalert
RAGGIO ZONA METEOALERT (metri): &CONF_RADIUS_METEOALERT !secret pkg_natural_events_radius_meteoalert
MAGNITUDO USGS minimo: &CONF_MAGNITUDE !secret pkg_natural_events_magnitude
RAGGIO USGS (km): &CONF_RADIUS_QUAKE !secret pkg_natural_events_radius_quake
REGIONE METEOALARM: &CONF_METEOALARM_REGION !secret pkg_natural_events_meteoalarm_region
##---------------------- FINE IMPOSTAZIONI PACKAGE ---------------------##
##----------------------- START OF HELP SETTINGS -----------------------##
IMAGE_PATH: &IMAGE_PATH /config/www/hassiohelp/pkg_natural_events
DEFAULT_MOBILE_APP_ICON_2: &DEFAULT_MOBILE_APP_ICON_2 "https://hassiohelp.eu/wp-content/uploads/2021/05/icon_forum-750x750-full.png"
DEFAULT_MOBILE_APP_ICON_1: &DEFAULT_MOBILE_APP_ICON_1 "https://hassiohelp.eu/wp-content/uploads/2021/05/icon_site-750x750-full.png"
# "https://hassiohelp.eu/wp-content/uploads/2019/03/hassiohelp-192.png"
CARDINAL:
&CARDINAL {
"N": "Nord",
"NNE": "Nord-Nord Est",
"NE": "Nord Est",
"ENE": "Este-Nord Est",
"E": "Est",
"ESE": "Est-Sud Est",
"SE": "Sud Est",
"SSE": "Sud-Sud Est",
"S": "Sud",
"SSW": "Sud-Sud Ovest",
"SW": "Sud Ovest",
"WSW": "Ovest-Sud Ovest",
"W": "Ovest",
"WNW": "Ovest-Nord Ovest",
"NW": "Nord Ovest",
"NNW": "Nord-Nord Ovest",
}
METEOALARM_SIGN: &METEOALARM_SIGN
0:
icon: "❌"
text: "Nessun Avviso"
alexa_sound: <audio src="soundbank://soundlibrary/musical/amzn_sfx_test_tone_01"/>
google_sound: "https://d3qhmae9zx9eb.cloudfront.net/musical/amzn_sfx_test_tone_01.mp3"
1:
icon: "🚩"
text: "Vento"
alexa_sound: <audio src="soundbank://soundlibrary/weather/wind/wind_10"/>
google_sound: "https://d3qhmae9zx9eb.cloudfront.net/weather/wind/wind_10.mp3"
2:
icon: "🧊"
text: "Neve-Ghiaccio"
alexa_sound: <audio src="soundbank://soundlibrary/footsteps/snow/snow_06"/>
google_sound: "https://d3qhmae9zx9eb.cloudfront.net/footsteps/snow/snow_06.mp3"
3:
icon: "⚡⛈"
text: "Temporali"
alexa_sound: <audio src="soundbank://soundlibrary/weather/thunder/thunder_01"/>
google_sound: "https://d3qhmae9zx9eb.cloudfront.net/weather/thunder/thunder_01.mp3"
4:
icon: "🌫"
text: "Nebbia"
alexa_sound: <audio src="soundbank://soundlibrary/alarms/air_horns/air_horns_01"/>
google_sound: "https://d3qhmae9zx9eb.cloudfront.net/alarms/air_horns/air_horns_01.mp3"
5:
icon: "🥵"
text: "Temperature massime estreme"
alexa_sound: <audio src="soundbank://soundlibrary/human/amzn_sfx_drinking_slurp_01"/>
google_sound: "https://d3qhmae9zx9eb.cloudfront.net/human/amzn_sfx_drinking_slurp_01.mp3"
6:
icon: "🥶"
text: "Temperature minime estreme"
alexa_sound: <audio src="soundbank://soundlibrary/human/amzn_sfx_sneeze_01"/>
google_sound: "https://d3qhmae9zx9eb.cloudfront.net/human/amzn_sfx_sneeze_01.mp3"
7:
icon: "⚓🏖"
text: "Eventi Costieri"
alexa_sound: <audio src="soundbank://soundlibrary/boats_ships/anchors/anchor_01"/>
google_sound: "https://d3qhmae9zx9eb.cloudfront.net/boats_ships/anchors/anchor_01.mp3"
8:
icon: "🔥🌲"
text: "Incendi bischivi"
alexa_sound: <audio src="soundbank://soundlibrary/home/amzn_sfx_fireplace_crackle_03"/>
google_sound: "https://d3qhmae9zx9eb.cloudfront.net/home/amzn_sfx_fireplace_crackle_03.mp3"
9:
icon: "⛄"
text: "Valanghe"
alexa_sound: <audio src="soundbank://soundlibrary/ice_snow/ski/ski_01"/>
google_sound: "https://d3qhmae9zx9eb.cloudfront.net/ice_snow/ski/ski_01.mp3"
10:
icon: "☔🌧"
text: "Pioggia"
alexa_sound: <audio src="soundbank://soundlibrary/nature/amzn_sfx_rain_01"/>
google_sound: "https://d3qhmae9zx9eb.cloudfront.net/nature/amzn_sfx_rain_01.mp3"
11:
icon: "❌"
text: "Non disponibile"
alexa_sound: <audio src="soundbank://soundlibrary/alarms/beeps_and_bloops/tone_02"/>
google_sound: "https://d3qhmae9zx9eb.cloudfront.net/alarms/beeps_and_bloops/tone_02.mp3"
12:
icon: "🌊"
text: "Alluvione"
alexa_sound: <audio src="soundbank://soundlibrary/nature/amzn_sfx_oars_splashing_rowboat_01"/>
google_sound: "https://d3qhmae9zx9eb.cloudfront.net/nature/amzn_sfx_oars_splashing_rowboat_01.mp3"
13:
icon: "💧🌊"
text: "Pioggia-Alluvione"
alexa_sound: <audio src="soundbank://soundlibrary/weather/rain/rain_08"/>
google_sound: "https://d3qhmae9zx9eb.cloudfront.net/weather/rain/rain_08.mp3"
NUMBER_ICONS:
&NUMBER_ICONS {
"0": "0️⃣",
"1": "1️⃣",
"2": "2️⃣",
"3": "3️⃣",
"4": "4️⃣",
"5": "5️⃣",
"6": "6️⃣",
"7": "7️⃣",
"8": "8️⃣",
"9": "9️⃣",
}
WARNING_SIGN: &WARNING_SIGN
0:
icon_color: "⚪"
text: "Valutazione non trasmessa"
decimal_color: 16777215
hex_color: "#FFFFFF"
1:
icon_color: "🟢"
text: "Verde"
decimal_color: 3381555
hex_color: "#339933"
2:
icon_color: "🟡"
text: "Gialla"
decimal_color: 16776960
hex_color: "#FFFF00"
3:
icon_color: "🟠"
text: "Arancione"
decimal_color: 16753920
hex_color: "#FFA500"
4:
icon_color: "🔴"
text: "Rossa"
decimal_color: 16711680
hex_color: "#FF0000"
5:
icon_color: "🟣🏴☠️"
text: "Massima"
decimal_color: 10502399
hex_color: "#A040FF"
WEEKDAYS: &WEEKDAYS
- Domenica
- Lunedì
- Martedì
- Mercoledì
- Giovedì
- Venerdì
- Sabato
##------------------------ END OF HELP SETTINGS ------------------------##
## Automation
automation.natural_events_blitzortung_lightning_notifications:
<<: *extra_attributes
friendly_name: "Blitzortung Notifiche"
automation.natural_events_burze_notifications:
<<: *extra_attributes
friendly_name: "Burze Notifiche"
automation.natural_events_gdacs_notifications:
<<: *extra_attributes
friendly_name: "Gdacs Notifiche"
automation.natural_events_meteoalarm_notifications:
<<: *extra_attributes
friendly_name: "MeteoAlarm Notifiche"
automation.natural_events_protezione_civile_notifications:
<<: *extra_attributes
friendly_name: "DPC Notifiche BinarySensor"
automation.natural_events_protezione_civile_notifications_criticita_sensor:
<<: *extra_attributes
friendly_name: "DPC Notifiche Criticità"
automation.natural_events_protezione_civile_notifications_vigilance_sensor:
<<: *extra_attributes
friendly_name: "DPC Notifiche Vigilanza"
automation.natural_events_quake_ingv_notifications:
<<: *extra_attributes
friendly_name: "INGV Notifiche"
automation.natural_events_quake_usgs_notifications:
<<: *extra_attributes
friendly_name: "USGS Notifiche"
## Binary Sensor
binary_sensor.burze_storms_nearby:
<<: *extra_attributes
friendly_name: "Temporale nelle vicinanze"
device_class: vibration
binary_sensor.download_file:
<<: *extra_attributes
friendly_name: Download File
icon: mdi:link
binary_sensor.global_natural_alert:
<<: *extra_attributes
binary_sensor.lastquake:
<<: *extra_attributes
friendly_name: Scossa Terremoto
icon: mdi:pulse
binary_sensor.meteoalarm:
<<: *extra_attributes
friendly_name: MeteoAlarm
binary_sensor.natural_events_meteoalert:
<<: *extra_attributes
## Group
group.geoalert:
<<: *extra_attributes
friendly_name: "Allerta Geologica"
icon: mdi:earth
group.meteoalert:
<<: *extra_attributes
friendly_name: "Allerta Meteo"
icon: mdi:weather-lightning-rainy
group.natural_events:
<<: *extra_attributes
friendly_name: "Eventi Naturali"
icon: mdi:location-enter
## Input
input_boolean.natural_events:
<<: *extra_attributes
friendly_name: "Info e Impostazioni"
icon: mdi:cogs
input_boolean.natural_events_send_image:
<<: *extra_attributes
friendly_name: "Invia Immagini"
icon: mdi:image
input_select.geo_map:
<<: *extra_attributes
friendly_name: Geo Map
icon: mdi:earth-box
input_select.meteo_iframe:
<<: *extra_attributes
friendly_name: Iframe Map
icon: mdi:image-frame
input_select.meteo_map:
<<: *extra_attributes
friendly_name: Meteo Map
icon: mdi:tooltip-image
input_text.ingv_path_image:
<<: *extra_attributes
friendly_name: Ingv path-image automatico (non toccare)
## Sensor
sensor.meteoalarm_level:
<<: *extra_attributes
friendly_name: "MeteoAlarm Level"
sensor.meteoalarm_type:
<<: *extra_attributes
friendly_name: "MeteoAlarm Type"
## Script
script.notify_hub:
<<: *extra_attributes
friendly_name: Mini Centro Notifiche
icon: mdi:account-tie
## Zone
zone.geoalert:
<<: *extra_attributes
friendly_name: Zona Allerta Geologica
icon: mdi:radiobox-marked
zone.meteoalert:
<<: *extra_attributes
friendly_name: Zona Allerta Meteo
icon: mdi:lightning-bolt-circle
#######################################-######################################
## CUSTOMIZE GLOB
#######################################-######################################
customize_glob:
automation.natural_events_*:
<<: *extra_attributes
icon: mdi:alpha-a-circle-outline
#######################################-########################################
## COMMAND LINE
#######################################-########################################
#-------------------------------------
# LAST QUAKE DOWNLOAD FILE
#-------------------------------------
## https://www.home-assistant.io/integrations/command_line
command_line:
- binary_sensor:
name: download_file # shakemap check URL and download
device_class: connectivity
command: >
local=$(echo "{{ states('input_text.ingv_path_image') }}" | cut -d" " -f1);
remote=$(echo "{{ states('input_text.ingv_path_image') }}" | cut -d" " -f2);
rm -f "$local";
curl -sSf -Lk -m 5 "$remote" --create-dirs -o "$local" &&
echo "ON" || echo "OFF"
scan_interval: 525600 # 1 year
value_template: "{{ value }}"
#######################################-########################################
## COMPONENT
#######################################-########################################
#-------------------------------------
# BLITZORTUNG Configuration in Integration UI
# info https://github.com/mrk-its/homeassistant-blitzortung
#-------------------------------------
#-------------------------------------
# BURZE Configuration in Integration UI
# info https://github.com/PiotrMachowski/Home-Assistant-custom-components-Burze.dzis.net
#-------------------------------------
## binary_sensor.burze_storms_nearby
## binary_sensor.burze_dzis_net_wyladowania_w_poblizu
## {{ integration_entities('Burze.dzis.net') }}
#-------------------------------------
# DPC Configuration in Integration UI
# Info https://github.com/caiosweet/Home-Assistant-custom-components-DPC-Alert
#-------------------------------------
#-------------------------------------
# GDACS Configuration in Integration UI
# Info https://www.home-assistant.io/integrations/gdacs/
#-------------------------------------
#-------------------------------------
# INGV Configuration in Integration UI
# info https://github.com/caiosweet/Home-Assistant-custom-components-INGV
#-------------------------------------
#-------------------------------------
# METEOALARM INTEGRATION Configuration yaml
# info https://www.home-assistant.io/components/meteoalarm/
#-------------------------------------
binary_sensor:
- platform: meteoalarm
name: meteoalarm
country: "italy"
province: *CONF_METEOALARM_REGION
language: "it"
#-------------------------------------
# USGS GEO LOCATION Configuration yaml
# info https://www.home-assistant.io/components/geo_location/
#-------------------------------------
geo_location:
- platform: usgs_earthquakes_feed
feed_type: "past_day_all_earthquakes"
radius: *CONF_RADIUS_QUAKE
minimum_magnitude: *CONF_MAGNITUDE
latitude: *CONF_LATITUDE
longitude: *CONF_LONGITUDE
#-------------------------------------
# ZONE
#-------------------------------------
zone:
- name: geoalert
latitude: *CONF_LATITUDE
longitude: *CONF_LONGITUDE
radius: *CONF_RADIUS_GEOALERT
passive: true
- name: meteoalert
latitude: *CONF_LATITUDE
longitude: *CONF_LONGITUDE
radius: *CONF_RADIUS_METEOALERT
passive: true
#######################################-########################################
## GROUP
#######################################-########################################
group:
natural_events:
entities:
- group.meteoalert
- group.geoalert
meteoalert:
entities:
- binary_sensor.meteoalarm
- binary_sensor.burze_storms_nearby
- binary_sensor.dpc_temporali_oggi
- binary_sensor.dpc_temporali_domani
- binary_sensor.natural_events_meteoalert
geoalert:
entities:
- binary_sensor.lastquake
- binary_sensor.dpc_idraulico_domani
- binary_sensor.dpc_idraulico_oggi
- binary_sensor.dpc_idrogeologico_domani
- binary_sensor.dpc_idrogeologico_oggi
#######################################-########################################
## INPUT
#######################################-########################################
input_select:
geo_map:
options:
- Posizione Geografica
- Nessuna
meteo_map:
options:
- Temperatura Nuvole Infrared
- Nuvole Infrared
- Nuvole e Sole
- Pioggia
- Neve
- Il Meteo
- Burze
- Burze Nord Ovest
- Burze Nord Est
- Burze Sud Ovest
- Burze Sud Est
- WWLLN
- Nessuna
meteo_iframe:
options:
- Windy Alert
- AM Ita
- DPC Radar
- DPC Bollettino Criticità
- DPC Vigilanza Meteo
- EUMET
- Blitzortung
- Radareu
- Volcanodiscovery
- Nessuna
input_boolean:
natural_events:
natural_events_send_image:
input_text:
ingv_path_image:
max: 255
#######################################-########################################
## TEMPLATE
#######################################-########################################
template:
- trigger:
- platform: geo_location
source: "ingv_centro_nazionale_terremoti"
zone: zone.geoalert
event: enter
- platform: geo_location
source: "ingv_centro_nazionale_terremoti"
zone: zone.geoalert
event: leave
- platform: state
entity_id: sensor.date
- platform: event
event_type: automation_reloaded
- platform: event
event_type: event_template_reloaded
binary_sensor:
#-------------------------------------
# LAST QUAKE TEST
#-------------------------------------
- name: "LastQuake"
unique_id: lastquake
device_class: vibration
availability: >-
{{expand(integration_entities("ingv_centro_nazionale_terremoti")) | length > 0}}
state: >-
{% set pub_date = states.geo_location
| selectattr('attributes.source','eq','ingv_centro_nazionale_terremoti')
| sort(reverse=true, attribute='attributes.publication_date')
| map(attribute='attributes.publication_date') | first | default %}
{{ False if not pub_date else (utcnow() < ((pub_date) + timedelta(hours = 12))) }}
attributes:
distance: >-
{{states.geo_location|selectattr('attributes.source','defined')|selectattr('attributes.source','match','ingv_')
|sort(attribute='attributes.publication_date')|map(attribute='state')|list|last|default('unknown') }}
lat: >-
{{states.geo_location|selectattr('attributes.source','defined')|selectattr('attributes.source','match','ingv_')
|sort(attribute='attributes.publication_date')|map(attribute='attributes.latitude')|list|last|default(0)}}
long: >-
{{states.geo_location|selectattr('attributes.source','defined')|selectattr('attributes.source','match','ingv_')
|sort(attribute='attributes.publication_date')|map(attribute='attributes.longitude')|list|last|default(0)}}
region: >-
{{states.geo_location|selectattr('attributes.source','defined')|selectattr('attributes.source','match','ingv_')
|sort(attribute='attributes.publication_date')|map(attribute='attributes.region')|list|last|default('unknown')}}
magnitude: >-
{{states.geo_location|selectattr('attributes.source','defined')|selectattr('attributes.source','match','ingv_')
|sort(attribute='attributes.publication_date')|map(attribute='attributes.magnitude')|list|last|default(0)}}
depth: >-
{{states.geo_location|selectattr('attributes.source','defined')|selectattr('attributes.source','match','ingv_')
|sort(attribute='attributes.publication_date')|map(attribute='attributes.depth')|list|last|default(0)}}
publication_date: >-
{{states.geo_location|selectattr('attributes.source','defined')|selectattr('attributes.source','match','ingv_')
|sort(attribute='attributes.publication_date')|map(attribute='attributes.publication_date')|list|last|default('unknown')}}
event_id: >-
{{states.geo_location|selectattr('attributes.source','defined')|selectattr('attributes.source','match','ingv_')
|sort(attribute='attributes.publication_date')|map(attribute='attributes.event_id')|list|last|default('unknown')}}
image_url: >-
{{states.geo_location|selectattr('attributes.source','defined')|selectattr('attributes.source','match','ingv_')
|sort(attribute='attributes.publication_date')|map(attribute='attributes.image_url')|list|last|default('')}}
level: >-
{% set m = states.geo_location|selectattr('attributes.source','defined')|selectattr('attributes.source','match','ingv_')
|sort(attribute='attributes.publication_date')|map(attribute='attributes.magnitude')|list|last|default(0) %}
{% if 0 <= m < 2 %}0{% elif 2 <= m < 3 %}1{% elif 3 <= m < 4 %}2{% elif 4 <= m < 6 %}3{% else %}4{% endif %}
- binary_sensor:
- name: Natural events meteoalert
unique_id: natural_events_meteoalert
device_class: safety
# availability_template: False
state: >
{% set phenomena = expand(integration_entities("dpc")) |select('search', 'phenomena')
|map(attribute='attributes.total_phenomena')|list | max | default(0) %}
{% set alert = expand(integration_entities("dpc")) |select('search', 'alerts')
|map(attribute='attributes.total_alerts')|list | max | default(0) %}
{% set binary = expand(integration_entities("dpc"))
|selectattr('entity_id', 'search', 'temporali')
|selectattr('state', '==', 'on')|list |length > 0 %}
{{ ((phenomena + alert) > 0) or binary }}
#-------------------------------------
# GLOBAL NATURAL ALERT PACKAGE
#-------------------------------------
- name: Global Natural Alert
unique_id: global_natural_alert
device_class: safety
# availability_template: False
state: >
{{ is_state('group.natural_events', 'on')
or this.attributes.my_sensors | default(false) }}
attributes:
my_sensors: >-
{% set phenomena = expand(integration_entities("dpc")) |select('search', 'total_phenomena')
|map(attribute='attributes.total_phenomena')|list | max | default(0) %}
{% set alert = expand(integration_entities("dpc")) |select('search', 'total_alerts')
|map(attribute='attributes.total_alerts')|list | max | default(0) %}
{{ (phenomena + alert) > 0 }}
burze_direction: >-
{% set direction = state_attr('binary_sensor.burze_storms_nearby', 'direction') %}
{% set cardinal = {
'N':'Nord',
'NE':'Nord Est',
'E':'Est',
'SE':'Sud Est',
'S':'Sud',
'SW':'Sud Ovest',
'W':'Ovest',
'NW':'Nord Ovest', } %}
{{ cardinal[direction] if direction in cardinal else direction }}
burze_direction_icon: >-
{% set direction = state_attr('binary_sensor.burze_storms_nearby', 'direction') %}
{% set cardinal = {
'N':'arrow-up',
'NE':'arrow-top-right',
'E':'arrow-left',
'SE':'arrow-bottom-right',
'S':'arrow-down',
'SW':'arrow-bottom-left',
'W':'arrow-left',
'NW':'arrow-top-left', } %}
mdi:{{ cardinal[direction] if direction in cardinal else 'arrow-left-right' }}-bold-outline
meteoalarm_type: >-
{% set type = state_attr('binary_sensor.meteoalarm', 'awareness_type') %}
{% set warning_texts = [
'Nessun Avviso',
'Vento','Neve-Ghiaccio',
'Temporali','Nebbia',
'Temperature massime estreme',
'Temperature minime estreme',
'Eventi Costieri',
'Incendi boschivi',
'Valanghe','Pioggia',
'Non disponibile',
'Alluvione',
'Pioggia-Alluvione'] %}
{{ 'Non disponibile' if type is none else warning_texts[type.split(';')[0]|int(0)] }}
meteoalarm_type_icon: >-
{% set type = state_attr('binary_sensor.meteoalarm', 'awareness_type') %}
{% set warning_icons = {
0 : "shield-outline",
1 : "weather-windy",
2 : "snowflake-alert",
3 : "weather-lightning",
4 : "weather-fog",
5 : "thermometer-plus",
6 : "thermometer-minus",
7 : "sailing",
8 : "fire",
9 : "shovel",
10 : "weather-pouring",
11 : "help-circle",
12 : "waves",
13 : "home-flood", } %}
{{ 'mdi:help-circle' if type is none else 'mdi:' ~ warning_icons[type.split(';')[0]|int(0)]}}
meteoalarm_level: >
{% set level = state_attr('binary_sensor.meteoalarm', 'awareness_level') %}
{{ 'White' if level is none else level.split(';')[1]|title |replace('Yellow', 'Gold')}}
meteoalarm_level_icon: >
{% set level = state_attr('binary_sensor.meteoalarm','awareness_level') %}
{{'mdi:numeric-0-box' if level is none else 'mdi:numeric-' ~ level.split(';')[0] ~ '-box'}}
code: >-
{# Numeric code for warning and color #}
{% set color_codes = {'White':'0','Green':'1','Yellow':'2','Orange':'3','Red':'4'} %}
{% set ma_level = state_attr('binary_sensor.meteoalarm','awareness_level') %}
{% set lev1 = '0' if not ma_level else ma_level.split(';')[0] %}
{% set lev2 = expand('group.natural_events')
| selectattr("attributes.level", 'defined')
| rejectattr("state", '!=', 'on')
| join(', ', attribute='attributes.level')|default('0', True)|max %}
{% set lev3 = expand(integration_entities("dpc"))
| selectattr("attributes.max_level", 'defined')
| join(', ', attribute='attributes.max_level')|default('0', True)|max %}
{% set lev_color = [lev1,lev2,lev3]|max %}
{{ lev_color|max }}
icon: >-
{# Icon to display the numerical code for the warning and color. #}
{% set lev_color = this.attributes.get('code', 0) %}
mdi:numeric-{{ lev_color }}-box
level: >-
{# Colored text based on the numerical code for warning and color. #}
{% set lev_color = this.attributes.get('code', 0) %}
{% set color_texts = {0:'White', 1:'Green', 2:'Gold', 3:'Orange', 4:'Red'} %}
{{ color_texts.get(lev_color) }}
- trigger:
- platform: state
entity_id: binary_sensor.global_natural_alert
sensor:
#-------------------------------------
# SENSOR FOR CARD PICTURE ELEMENTS
#-------------------------------------
- name: meteoalarm type
unique_id: meteoalarm_type
state: "{{ state_attr('binary_sensor.global_natural_alert', 'meteoalarm_type') }}"
icon: "{{ state_attr('binary_sensor.global_natural_alert', 'meteoalarm_type_icon') }}"
- name: meteoalarm level
unique_id: meteoalarm_level
state: "{{ state_attr('binary_sensor.global_natural_alert', 'meteoalarm_level') }}"
icon: "{{ state_attr('binary_sensor.global_natural_alert', 'meteoalarm_level_icon') }}"
#######################################-########################################
## AUTOMATION
#######################################-########################################
automation:
#----------------------------------------------------------------------------------------------------#
# BLITZORTUNG - Notifica caduti fulmini nel raggio impostato nell'integrazione
#----------------------------------------------------------------------------------------------------#
- alias: "natural_events_blitzortung_lightning_notifications"
# initial_state: true
mode: single
trigger:
- platform: state
entity_id: sensor.blitzortung_lightning_counter
condition:
- "{{ (as_timestamp(now()) - as_timestamp(this.attributes.last_triggered) ) > 60 }}"
- condition: numeric_state
entity_id: sensor.blitzortung_lightning_counter
above: 0
action:
- service: *DEFAULT_SCRIPT
data:
title: "Lightning Warning!"
message: &mess_lightning >
Un fulmine è stato rilevato entro
{{ states('sensor.blitzortung_lightning_distance') | default }} km da casa.
alexa:
# mode: false
message: *mess_lightning
#----------------------------------------------------------------------------------------------------#
# BURZE.NET Notifica caduti fulmini nel raggio impostato in radius_meteoalert
#----------------------------------------------------------------------------------------------------#
- alias: natural_events_burze_notifications
# initial_state: true
trigger:
platform: state
entity_id: binary_sensor.burze_storms_nearby
condition: >
{{ trigger.to_state.state == 'on' and (trigger.from_state.state == 'off'
or trigger.to_state.attributes.distance < trigger.from_state.attributes.distance) }}
action:
- variables:
NUMBER_ICONS: *NUMBER_ICONS
WARNING_SIGN: *WARNING_SIGN
IMAGE_PATH: *IMAGE_PATH
direction: "{{ state_attr('binary_sensor.global_natural_alert','burze_direction') | default('Nord',true) }}"
radius: "{{ (state_attr('zone.meteoalert','radius') //1000)|int(0) }}"
distance: "{{ trigger.to_state.attributes.distance | default(radius, true) }}"
number: "{{ trigger.to_state.attributes.number | default(0, true) }}"
period: "{{ trigger.to_state.attributes.period | default(0, true) }}"
burze_tts_msg: >-
{% if trigger.from_state is defined and trigger.from_state.state == 'off' %}
Probabile arrivo di un temporale da {{ direction }}.
{% else %} Aggiornamento Temporale. Il fulmine più vicino è stato rilevato a {{ distance }} km
a {{ direction }} da casa. {% endif %}
- service: *DEFAULT_SCRIPT
data:
call_no_annuncio: 1
title: >-
Burze ↯ {% if trigger.from_state is defined and trigger.from_state.state == 'off' %}
{{ trigger.to_state.attributes.friendly_name }}.
{% else %} AGGIORNAMENTO TEMPORALE. {% endif %}
message: >-
{% set n = number %}
{% set d = distance %}
{% macro range_distance() %} {% if d <= 0.5 %}5{% elif 0.5 < d <= 1 %}4{% elif 1 < d <= 5 %}3
{% elif 5 < d <= 10 %}2{% elif 10 < d <= 20 %}1{% else %}0{% endif %} {% endmacro %}
{{WARNING_SIGN.get(range_distance()|int(0)).icon_color}} Negli ultimi {{ period }} minuti
{% for x in n|string %} {{NUMBER_ICONS[x]|default(x)}}{% endfor %}⚡{% if n != 1 %}
scariche di fulmini {% else %} fulmine scaricato {% endif %} nel raggio di {{ radius }} km.
La scarica più vicina è avvenuta a {{ distance }} km a {{ direction }} da casa.
alexa:
# mode: false
message: "{{ burze_tts_msg }}"
google:
# mode: false
message: "{{ burze_tts_msg }}"
image: >-
{% if trigger.from_state is defined and trigger.from_state.state == 'off'
and is_state('input_boolean.natural_events_send_image', 'on') %}
{{ IMAGE_PATH }}/burze.png{% else %}{% endif %}
#----------------------------------------------------------------------------------------------------#
# DPC - PROTEZIONE CIVILE - Notifica criticità meteo-idro Sensor
#----------------------------------------------------------------------------------------------------#
- alias: natural_events_protezione_civile_notifications_criticita_sensor
mode: queued
max_exceeded: silent
# initial_state: true
trigger:
- platform: state
entity_id:
- sensor.dpc_alert
condition:
- "{{ trigger.from_state.state not in ['unavailable','unknown'] }}"
- or:
- "{{ trigger.from_state.attributes.total_alerts != trigger.to_state.attributes.total_alerts }}"
- and:
- "{{ trigger.to_state.attributes.id != trigger.from_state.attributes.id }}"
- "{{ trigger.to_state.attributes.total_alerts > 0 }}"
action:
- variables:
WARNING_SIGN: *WARNING_SIGN
BULLETIN: "https://mappe.protezionecivile.gov.it/it/mappe-rischi/bollettino-di-criticita"
WARN_DPC:
{
none: "❌",
"Temporali": "⚡",
"Idraulico": "💧",
"Idrogeologico": "🌊",
}
ENTITY: "{{ trigger.entity_id |default('sensor.dpc_alert', true) }}"
DAYS: { 1: "today", 2: "tomorrow" }
GIORNI: { 1: "oggi", 2: "domani" }
- repeat:
while:
- "{{ repeat.index <= DAYS|length }}"
sequence:
- variables:
giorno: "{{ GIORNI[repeat.index] }}"
day: "{{ DAYS[repeat.index] }}"
event: "{{ 'events_' + day }}"
- if: "{{ state_attr(ENTITY, event) is not none }}"
then:
- service: *DEFAULT_SCRIPT
data:
call_no_annuncio: 1
title: "DPC Criticità"
message: |
{% set attr = state_attr(ENTITY, event) %}
Criticità per {{giorno}}
{%- for d in attr %}
{{WARNING_SIGN[d['level']].icon_color}} {{ WARN_DPC[d['risk']] }} {{ d['info'] }} {{ d['alert'] }} per rischio {{ d['risk'] }}.
{%- endfor %}
Zona: {{ state_attr(ENTITY, 'zone_name') }}
alexa:
# mode: false
message: &dpc_criticita_tts_msg >-
{%- set attr = state_attr(ENTITY, event) %}
Protezione Civile, bollettino di criticità per {{giorno}},
{%- for d in attr %}
{{ d['info'] }} {{ d['alert'] }}, per rischio {{ d['risk'] }},
{%- endfor %}
audio: soundbank://soundlibrary/weather/thunder/thunder_11
google:
# mode: false
message: *dpc_criticita_tts_msg
audio: "https://d3qhmae9zx9eb.cloudfront.net/nature/amzn_sfx_rain_01.mp3"
image: >
{% if is_state('input_boolean.natural_events_send_image', 'on') %}
{{ state_attr(ENTITY, day).image_url |default("", true) }}
{% endif %}
link: >
[Bollettino di criticità]({{ BULLETIN }})
level: >
{{ state_attr(ENTITY, day)['level'] |int(0)}}
#----------------------------------------------------------------------------------------------------#
# DPC - PROTEZIONE CIVILE - Notifica Vigilanza Meteo Sensor
#----------------------------------------------------------------------------------------------------#
- alias: natural_events_protezione_civile_notifications_vigilance_sensor
mode: queued
max_exceeded: silent
# initial_state: true
trigger:
- platform: state
entity_id:
- sensor.dpc_vigilance
condition:
- "{{ trigger.from_state.state not in ['unavailable','unknown'] }}"
- or:
- "{{ trigger.from_state.attributes.total_alerts != trigger.to_state.attributes.total_alerts }}"
- and:
- "{{ trigger.to_state.attributes.id != trigger.from_state.attributes.id }}"
- or:
- "{{ trigger.to_state.attributes.total_phenomena > 0 }}"
- "{{ trigger.to_state.attributes.total_alerts > 0 }}"
action:
- variables:
BULLETIN: "https://mappe.protezionecivile.gov.it/it/mappe-rischi/bollettino-di-vigilanza"
CARDINAL: *CARDINAL
WARNING_SIGN: *WARNING_SIGN
ENTITY: "{{ trigger.entity_id |default('sensor.dpc_vigilance', true) }}"
DAYS: { 1: "today", 2: "tomorrow", 3: "aftertomorrow" }
GIORNI: { 1: "oggi", 2: "domani", 3: "dopodomani" }
- repeat:
while:
- "{{ repeat.index <= DAYS|length }}"
sequence:
- variables:
giorno: "{{ GIORNI[repeat.index] }}"
day: "{{ DAYS[repeat.index] }}"
- if: "{{ state_attr(ENTITY, day) is not none
and (state_attr(ENTITY, day)['level'] > 1
or state_attr(ENTITY, day)['phenomena']|length > 0) }}"
then:
- service: *DEFAULT_SCRIPT
data:
call_no_annuncio: 1
title: "DPC Vigilanza Meteo"
message: |
{% set attr = state_attr(ENTITY, day) %}
Vigilanza meteo per {{giorno}}
{{WARNING_SIGN[attr['level']].icon_color}} Quantitativi previsti {{attr['precipitation']}}
{% if attr.phenomena|length > 0 %}
Fenomeni nelle vicinanze:
{% for p in attr['phenomena'] %}
➡️ {{p.event}}: {{p.value}} in direzione {{CARDINAL[p.direction]}} alla distanza di {{p.distance}}km.
{% endfor %}
{% endif %}
Zona: {{ state_attr(ENTITY, 'zone_name') }}
alexa:
# mode: false
message: &dpc_vigilance_tts_msg >-
{% if repeat.index == DAYS|length %}
Vigilanza meteo,
{%- for day in DAYS.values() %}
{% set v = state_attr(ENTITY, day) %}
{%- if v and (v.level > 1 or v.phenomena|length > 0) %}
per {{ GIORNI[loop.index] }},
{% if v.level > 1 %}
Quantitativi previsti {{ v['precipitation'] }}.
{% endif %}
{% if v.phenomena|length > 0 %}
Fenomeni nelle vicinanze:
{% for p in v['phenomena'] %}
{{p.event}} {{p.value}} in direzione {{CARDINAL[p.direction]}} a circa {{p.distance}}km,
{% endfor %}
{% endif %}
{%- endif %}
{%- endfor %}
{% endif %}
audio: soundbank://soundlibrary/nature/amzn_sfx_rain_01
google:
# mode: false
message: *dpc_vigilance_tts_msg
audio: "https://d3qhmae9zx9eb.cloudfront.net/nature/amzn_sfx_rain_01.mp3"
image: >
{% if is_state('input_boolean.natural_events_send_image', 'on') %}
{{ state_attr(ENTITY, day).image_url |default("", true) }}
{% endif %}
link: >
[Bollettino di vigilanza]({{ BULLETIN }})
level: >
{{ state_attr(ENTITY, day)['level'] |int(0)}}
#----------------------------------------------------------------------------------------------------#
# DPC - PROTEZIONE CIVILE - Notifica criticità meteo-idro Binary Sensor
#----------------------------------------------------------------------------------------------------#
- alias: natural_events_protezione_civile_notifications
mode: queued
max_exceeded: silent
# initial_state: true
trigger:
- platform: state
entity_id:
- binary_sensor.dpc_idrogeologico_oggi
- binary_sensor.dpc_idraulico_oggi
- binary_sensor.dpc_temporali_oggi
- binary_sensor.dpc_idrogeologico_domani
- binary_sensor.dpc_idraulico_domani
- binary_sensor.dpc_temporali_domani
condition: >-
{{ trigger.to_state.state == 'on'
and not trigger.from_state.state in ["unavailable","unknown"]
and (trigger.from_state.state == 'off'
or (trigger.to_state.attributes.id != trigger.from_state.attributes.id)) }}
action:
- variables:
WARNING_SIGN: *WARNING_SIGN
BULLETIN: "https://mappe.protezionecivile.gov.it/it/mappe-rischi/bollettino-di-criticita"
PREVIEW: "https://raw.githubusercontent.com/pcm-dpc/DPC-Bollettini-Criticita-Idrogeologica-Idraulica/master/files/preview/{}_{}.png"
dpc_tts_msg: >-
{% set attr = trigger.to_state.attributes if trigger.to_state is defined else ({}) %}
Attenzione. {{attr.get('friendly_name', 'Test DPC')}}.
{{attr.get('info', 'Nessuna info')}}. {{attr.get('alert', 'Valutazione non trasmessa')}}
- service: *DEFAULT_SCRIPT
data:
call_no_annuncio: 1
title: >-
{% set attr = trigger.to_state.attributes if trigger.to_state is defined else ({}) %}
Protezione Civile - {{attr.get('risk', 'Test DPC')}}
{% if trigger.from_state is defined and trigger.from_state.state == 'on' %} - Revisione {% endif %}
message: |
{% set attr = trigger.to_state.attributes if trigger.to_state is defined else ({}) %}
{% set warn = {none: '❌', 'Temporali':'⚡', 'Idraulico':'💧', 'Idrogeologico':'🌊'} %}
{{warn[attr.get('risk')]}} {{attr.get('friendly_name', 'Test DPC')}}.
{{WARNING_SIGN[attr.get('level', 0)].icon_color}} {{attr.get('info', 'Nessuna info')}}
{{attr.get('alert' ,'Valutazione non trasmessa')}}
alexa:
# mode: false
message: "{{dpc_tts_msg}}"
audio: soundbank://soundlibrary/weather/thunder/thunder_11
google:
# mode: false
message: "{{dpc_tts_msg}}"
audio: "https://d3qhmae9zx9eb.cloudfront.net/weather/thunder/thunder_11.mp3"
link: >
{% set attr = trigger.to_state.attributes if trigger.to_state is defined else ({}) %}
[Bollettino di criticità]({{attr.get('link', BULLETIN)}})
level: >
{% set attr = trigger.to_state.attributes if trigger.to_state is defined else ({}) %}
{{attr.get('level', 0)}}
image: >
{% if is_state('input_boolean.natural_events_send_image', 'on') %}
{% set attr = trigger.to_state.attributes if trigger.to_state is defined else ({}) %}
{{attr.get('image_url', PREVIEW.format('20210702_1500', 'domani'))}}
{% endif %}
#----------------------------------------------------------------------------------------------------#
# METEOALARM - Notifica criticità meteo nella regione impostata - Vedi tabella a fine package
#----------------------------------------------------------------------------------------------------#
- alias: natural_events_meteoalarm_notifications
mode: queued
# initial_state: true
trigger:
platform: state
entity_id: binary_sensor.meteoalarm
condition: >-
{{ trigger.to_state.state == 'on' and (trigger.from_state.state == 'off'
or trigger.to_state.attributes != trigger.from_state.attributes) }}
action: