From 2763ec3f46295e76e53fd93f33fe7f68cc9b1303 Mon Sep 17 00:00:00 2001
From: caiosweet <24454580+caiosweet@users.noreply.github.com>
Date: Tue, 18 May 2021 23:08:13 +0200
Subject: [PATCH 1/3] Ability to choose the notify service.
---
config/packages/natural_events.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/config/packages/natural_events.yaml b/config/packages/natural_events.yaml
index ef0365d..03611b5 100644
--- a/config/packages/natural_events.yaml
+++ b/config/packages/natural_events.yaml
@@ -1127,6 +1127,7 @@ script:
DEFAULT_MOBILE_APP_ICON: *DEFAULT_MOBILE_APP_ICON
INVALIDATE: [false, null, "", "none"]
notify_service: >-
+ {% set DEFAULT_NOTIFY = notify|default(DEFAULT_NOTIFY) %}
{{ (DEFAULT_NOTIFY|replace('notify.','')|regex_replace(find=" *, *", replace=",")|lower).rsplit(",")
if DEFAULT_NOTIFY is string else DEFAULT_NOTIFY }}
title: "{{title|default}}"
From d78ad5e0dc7e69f26086760f89941d9418a18d63 Mon Sep 17 00:00:00 2001
From: caiosweet <24454580+caiosweet@users.noreply.github.com>
Date: Tue, 13 Jul 2021 20:51:31 +0200
Subject: [PATCH 2/3] Suitable for the new installation of the dpc component.
- Fixed Italy country in meteoalarm.
- Added more notifications and features in the internal script.
- Added new DPC maps.
---
.gitignore | 3 +
.../cards/card_natural_events_light.yaml | 194 ++++--
.../cards/card_natural_events_picture.yaml | 0
.../card_natural_events_picture_menu.yaml | 158 +++--
config/packages/natural_events.yaml | 581 +++++++++++-------
5 files changed, 624 insertions(+), 312 deletions(-)
create mode 100644 .gitignore
mode change 100644 => 100755 config/lovelace/cards/card_natural_events_light.yaml
mode change 100644 => 100755 config/lovelace/cards/card_natural_events_picture.yaml
mode change 100644 => 100755 config/lovelace/cards/card_natural_events_picture_menu.yaml
mode change 100644 => 100755 config/packages/natural_events.yaml
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..70182bf
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+
+config/.DS_Store
+.DS_Store
diff --git a/config/lovelace/cards/card_natural_events_light.yaml b/config/lovelace/cards/card_natural_events_light.yaml
old mode 100644
new mode 100755
index 7ade2c7..320226c
--- a/config/lovelace/cards/card_natural_events_light.yaml
+++ b/config/lovelace/cards/card_natural_events_light.yaml
@@ -66,6 +66,8 @@ cards:
entities:
- type: custom:auto-entities # MENU Impostazioni fold
show_empty: false
+ sort:
+ method: domain
filter:
include:
- attributes:
@@ -111,17 +113,8 @@ cards:
card_mod:
style: |
:host {
- {% set color = {0:'var(--primary-text-color)', 1:'Green', 2:'Yellow', 3:'Orange', 4:'Red'} %}
- color: {% if 'dpc' in config.entity %} {{color[state_attr(config.entity, 'level')|int]}}
- {% elif 'binary_sensor.meteoalarm' in config.entity %}
- {{state_attr('binary_sensor.global_natural_alert','meteoalarm_level')}}
- {% elif 'burze' in config.entity and states(config.entity) == 'on'%}
- {% set d = state_attr(config.entity,'distance') %}
- {% if d %}
- {% if d <= 1 %}Red{% elif 1 < d <= 5 %}Orange{% elif 5 < d <= 10 %}Yellow{% else %}Green{% endif %}
- {% endif %}
- {% endif %};
- {% if 'meteoalarm_custom' in config.entity and states(config.entity) > '0' %}
+ {% if 'meteoalarm_custom' in config.entity
+ and states(config.entity) > '0' %}
--paper-item-icon-color: var(--paper-item-icon-active-color);
{% endif %}
}
@@ -142,11 +135,6 @@ cards:
card_mod:
style: |
:host {
- {% set color = {0:'var(--primary-text-color)', 1:'Green', 2:'Yellow', 3:'Orange', 4:'Red'} %}
- color: {% if 'dpc' in config.entity %} {{color[state_attr(config.entity, 'level')|int]}}
- {% elif 'meteoalarm' in config.entity %} {{state_attr('binary_sensor.global_natural_alert','meteoalarm_level')}}
- {% elif 'quake' in config.entity and states('binary_sensor.lastquake') == 'on' %} {{color[state_attr('binary_sensor.lastquake', 'level')|int]}}
- {% endif %};
{% if 'gdacs' in config.entity and states(config.entity) > '0' %} --paper-item-icon-color: var(--paper-item-icon-active-color);{% endif %}
}
#################################################################
@@ -164,7 +152,6 @@ cards:
card_mod:
style: |
ha-card { background: none; border-radius: 0px; box-shadow: none; }
- # .card-content {padding: 0px}
div#states.card-content {padding-block-end: 0; padding-block-start: 0;}
header:
type: custom:paper-buttons-row
@@ -195,6 +182,12 @@ cards:
service: input_select.select_next
service_data:
entity_id: input_select.geo_map
+ double_tap_action:
+ action: call-service
+ service: input_select.select_option
+ service_data:
+ option: Nessuna
+ entity_id: input_select.geo_map
style:
button:
color: var(--paper-item-icon-active-color)
@@ -202,7 +195,6 @@ cards:
nessuna:
button:
color: var(--paper-item-icon-color)
-
- entity: input_select.meteo_map
layout: icon|state
style:
@@ -233,7 +225,12 @@ cards:
service: input_select.select_next
service_data:
entity_id: input_select.meteo_map
-
+ double_tap_action:
+ action: call-service
+ service: input_select.select_option
+ service_data:
+ option: Nessuna
+ entity_id: input_select.meteo_map
- entity: input_select.meteo_iframe
layout: icon|state
name: I-Frame
@@ -242,7 +239,9 @@ cards:
state_text:
nessuna: I-Frame
windy alert: Alert
- protezione civile: DPC
+ dpc radar: DPC Radar
+ dpc bollettino criticità: Criticità
+ dpc vigilanza meteo: Vigilanza
blitzortung: Blitz
radareu: Radareu
volcanodiscovery: Vulcani
@@ -251,6 +250,12 @@ cards:
service: input_select.select_next
service_data:
entity_id: input_select.meteo_iframe
+ double_tap_action:
+ action: call-service
+ service: input_select.select_option
+ service_data:
+ option: Nessuna
+ entity_id: input_select.meteo_iframe
style:
button:
color: var(--paper-item-icon-active-color)
@@ -266,11 +271,31 @@ cards:
state: "on"
row:
type: divider
+ # sort:
+ # method: entity_id
filter:
exclude:
- entity_id: "binary_sensor.global_natural_alert"
# - entity_id: 'binary_sensor.shakemap'
include:
+ - entity_id: sensor.*
+ state: ">0"
+ attributes:
+ integration: dpc
+ options:
+ entity: this.entity_id
+ secondary_info: last-changed
+ card_mod:
+ style: |
+ :host {
+ --color:
+ {% set color = {0:'White', 1:'Green', 2:'Yellow', 3:'Orange', 4:'Red'} %}
+ {% if is_state_attr(config.entity, 'integration', 'dpc') %} {{color[state_attr(config.entity, 'max_level')|int]}}
+ {% endif %};
+ color: var(--color);
+ --paper-item-icon-color: var(--paper-item-icon-active-color); ##var(--color);
+ }
+
- entity_id: "binary_sensor.*"
state: "on"
attributes:
@@ -284,7 +309,7 @@ cards:
:host {
--color:
{% set color = {0:'White', 1:'Green', 2:'Yellow', 3:'Orange', 4:'Red'} %}
- {% if 'dpc' in config.entity %} {{color[state_attr(config.entity, 'level')|int]}}
+ {% if is_state_attr(config.entity, 'integration', 'dpc') %} {{color[state_attr(config.entity, 'level')|int]}}
{% elif 'meteoalarm' in config.entity %} {{state_attr('binary_sensor.global_natural_alert','meteoalarm_level')}}
{% elif 'quake' in config.entity %} {{color[state_attr('binary_sensor.lastquake', 'level')|int]}}
{% elif 'burze' in config.entity and states(config.entity) == 'on'%}
@@ -368,35 +393,31 @@ cards:
show_empty: false
filter:
include:
- - entity_id: binary_sensor.dpc_*
+ - entity_id: binary_sensor.*
state: "on"
- # attributes:
- # level: '> 0'
+ attributes:
+ integration: "dpc"
card:
type: markdown
- entity_id: this.entity_id
+ # entity_id: this.entity_id
card_mod:
style: |
ha-card {background: none; border-radius: 0px; box-shadow: none;}
- # .card-content {padding: 0}
content: >
___
#### PROTEZIONE CIVILE
- {% set color = {0:'White', 1:'Green', 2:'Yellow', 3:'Orange', 4:'Red'} %}
- {% for e in config.entities %}
-
-
-
-
-
- {{state_attr(e.entity, 'friendly_name')}} - {{state_attr(e.entity, 'allerta')}} {{state_attr(e.entity, 'info')}}
- {%- endfor %}
+ {% set color = {0:'White', 1:'Green', 2:'Yellow', 3:'Orange', 4:'Red'} %}
+ {% for state in states.binary_sensor %}
+ {%- if is_state_attr(state.entity_id, 'integration', 'dpc') and state.state == 'on' %}
+
+ {{state.name}} - {{state.attributes.alert}} {{state.attributes.info}}
+ {%- endif -%} {% endfor %}
- [Protezione Civile](http://www.protezionecivile.it/home) ~ [Vigilanza Meteo](http://www.protezionecivile.gov.it/dettaglio/-/journal_content/56/20182/1131180?refererPlid=42041&controlPanelCategory=current_site.content)
- ~ [Criticità Idro](http://www.protezionecivile.gov.it/attivita-rischi/meteo-idro/attivita/previsione-prevenzione/centro-funzionale-centrale-rischio-meteo-idrogeologico/previsionale/bollettini-criticita/bollettino-odierno) ~ [Radar](http://www.protezionecivile.gov.it/radar-dpc)
+ [Protezione Civile](https://www.protezionecivile.gov.it/it/) ~ [Vigilanza Meteo](https://mappe.protezionecivile.it/it/mappe-rischi/bollettino-di-vigilanza)
+ ~ [Criticità Idro](https://mappe.protezionecivile.gov.it/it/mappe-rischi/bollettino-di-criticita) ~ [Radar](https://mappe.protezionecivile.it/it/mappe-rischi/piattaforma-radar)
#################################################################
## METEOALARM
#################################################################
@@ -436,6 +457,9 @@ cards:
**Istruzioni**
{{state_attr('binary_sensor.meteoalarm', 'instruction')}}
[MeteoAlarm]({{state_attr('binary_sensor.meteoalarm', 'web')|replace('http://','https://')}})
+ #################################################################
+ ## METEOALARM CUSTOM
+ #################################################################
- type: conditional
conditions:
- entity: sensor.meteoalarm_custom
@@ -527,19 +551,22 @@ cards:
Un terremoto di magnitudo **{{magnitudo}}**
è avvenuto nella zona: [{{state_attr(entityid, 'region')}}](https://www.openstreetmap.org/?mlat={{lat}}&mlon={{long}}#map=12/{{lat}}/{{long}})
a **{{state_attr(entityid, 'distance')}}** km da casa,
- con coordinate geografiche (lat, long) {{lat}},{{long}}.
+ con coordinate epicentrali {{lat}}, {{long}}.
- {% set state_dict = {'home': 'casa', 'not_home': 'fuori casa'} %}
- {%- for person in expand(states.person) -%}
- {% set distanza = distance(lat, long, person.entity_id)
- if person.attributes.latitude is defined else state_attr(entityid, 'distance') %}
- {{"📍{} \[{}\] a circa {} km dall'epicentro.".format(person.name|upper, state_dict.get(person.state, person.state), distanza|round(1)) }}
+ {% set state_dict = {'home': 'casa', 'not_home': 'fuori casa', 'unknown': '❓'} %}
+ {% for person in expand(states.person) %}
+ {% if 'latitude' in person.attributes %}
+ {% set distanza = distance(lat|default(0), long|default(0), person.entity_id|default(0)) %}
+
{{"📍{} ({}) a circa {} km dall'epicentro.".format(person.name|upper, state_dict.get(person.state, person.state), distanza|round(1)) }}
+ {% else %}
+
{{"📍{} ({})".format(person.name|upper, state_dict.get(person.state, person.state)) }}
+ {% endif %}
{% endfor %}
-
+
{% if magnitudo >= 3 %}
[Intensity]({{url.format(id,'intensity')}}) ~
[PGA]({{url.format(id,'pga')}}) ~ [PGV]({{url.format(id,'pgv')}}) ~ [PSA0]({{url.format(id,'psa0p3')}}) ~ [PSA1]({{url.format(id,'psa1p0')}}) ~
- [HaiSentitoIlTerremoto](http://eventi.haisentitoilterremoto.it/{{id}}/{{id}}_mcs.jpg)
+ [HSIT](http://eventi.haisentitoilterremoto.it/{{id}}/{{id}}_mcs.jpg)