All Projects → caiosweet → Home-Assistant-custom-components-DPC-Alert

caiosweet / Home-Assistant-custom-components-DPC-Alert

Licence: MIT license
Italy Meteo-hydro alert and hydrogeological phenomena Civil Protection (Protezione Civile). In this custom component you can find the vigilance Bulletin and the Bulletin of national hydrogeological and hydraulic criticalities. They allow to check whether in your current location there will be criticalities/warnings related to weather-hydrogeolog…

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Home-Assistant-custom-components-DPC-Alert

uptime-card
Minimalistic uptime card for Home Assistant Lovelace UI
Stars: ✭ 152 (+390.32%)
Mutual labels:  sensor, home-assistant, hacs, hassio
ha-zoom-automation
Custom Home Assistant component for Zoom. Tracks when you are connected to a Zoom call by default but may allow you to track more.
Stars: ✭ 47 (+51.61%)
Mutual labels:  home-assistant, homeassistant, hacs, hassio
sensor.avanza stock
Custom component to get stock data from Avanza for Home Assistant
Stars: ✭ 30 (-3.23%)
Mutual labels:  home-assistant, homeassistant, hacs
lovelace-valetudo-map-card
Draws the map available from a Xiaomi Vacuum cleaner flashed with Valetudo in a Home Assistant Lovelace card
Stars: ✭ 149 (+380.65%)
Mutual labels:  home-assistant, homeassistant, hacs
homeassistant-aemet-sensor
AEMET integration for Home Assistant
Stars: ✭ 21 (-32.26%)
Mutual labels:  homeassistant, hacs, hassio
ha-iaquk
Indoor Air Quality Sensor Component for Home Assistant
Stars: ✭ 57 (+83.87%)
Mutual labels:  sensor, home-assistant, hacs
ocpp
Home Assistant integration for electric vehicle chargers that support the Open Charge Point Protocol (OCPP).
Stars: ✭ 82 (+164.52%)
Mutual labels:  home-assistant, homeassistant, hacs
pymusiccast
Group MusicCast Speakers with Home Assistant
Stars: ✭ 34 (+9.68%)
Mutual labels:  home-assistant, homeassistant, hassio
read your meter
Home Assistant sensor to read water meter
Stars: ✭ 27 (-12.9%)
Mutual labels:  sensor, home-assistant, hacs
hifiberry
This is a custom component to allow control of HifiberryOS devices in Home Assistant using the audiocontrol2 REST API.
Stars: ✭ 26 (-16.13%)
Mutual labels:  home-assistant, hacs, hassio
ad-alexatalkingclock
Alexa (or other Smart Speakers) tell you the time without asking every hour. Please ⭐️if you like my app :)
Stars: ✭ 30 (-3.23%)
Mutual labels:  home-assistant, homeassistant, hacs
addon-tailscale
Tailscale - Home Assistant Community Add-ons
Stars: ✭ 47 (+51.61%)
Mutual labels:  home-assistant, homeassistant, hassio
homeassistant-afvalwijzer
Provides sensors for some Dutch waste collectors
Stars: ✭ 119 (+283.87%)
Mutual labels:  sensor, homeassistant, hacs
ha-gismeteo
Gismeteo Weather Provider for Home Assistant
Stars: ✭ 84 (+170.97%)
Mutual labels:  sensor, home-assistant, hacs
ical-sensor-homeassistant
an iCal Sensor for Home Assistant
Stars: ✭ 42 (+35.48%)
Mutual labels:  sensor, home-assistant, hacs
purifier-card
Air Purifier card for Home Assistant Lovelace UI
Stars: ✭ 155 (+400%)
Mutual labels:  home-assistant, homeassistant, hacs
hass-hue-icons
Additional vector icons for home assistant to model Philips Hue bulbs and fixtures.
Stars: ✭ 161 (+419.35%)
Mutual labels:  home-assistant, homeassistant, hacs
Awesome Home Assistant
A curated list of amazingly awesome Home Assistant resources.
Stars: ✭ 3,487 (+11148.39%)
Mutual labels:  home-assistant, homeassistant, hassio
HADailySensor
Sensor for Home Assistant that gets reset at midnight
Stars: ✭ 20 (-35.48%)
Mutual labels:  sensor, home-assistant, homeassistant
Home-Assistant-Sensor-Afvalbeheer
Provides Home Assistant sensors for multiple Dutch and Belgium waste collectors
Stars: ✭ 157 (+406.45%)
Mutual labels:  home-assistant, hacs, hassio

Home Assistant - Custom Components DPC Alert

ITALY METEO-HYDRO ALERT - To get more detailed information about parameters of warnings visit Civil Protection Department. Dipartimento Protezione Civile

hacs Validate

GitHub latest release GitHub Release Date Maintenancebadge GitHub issuesbadge

Websitebadge Forum telegrambadge facebookbadge

Don't buy me a coffee


Information

The state of the sensor will be the highest alert level.

The Vigilance sensor will also report in attributes the values of all other meteo alerts and/or forecasts from next 12-48 hours, if there are any.

The Criticality sensor (DPC Alert) will also report in attributes the values of all other warning and/or forecasts from next 12-24 hours, if there are any.

Installation

Using Home Assistant Community Store (recommended)

  1. Click on HACS in the Home Assistant menu
  2. Click on Integrations
  3. Click the EXPLORE & ADD REPOSITORIES button
  4. Search for Dpc
  5. Click the INSTALL THIS REPOSITORY IN HACS button
  6. Restart Home Assistant

Configuration

Config flow

To configure this integration go to: Configurations -> Integrations -> ADD INTEGRATIONS button, search for Dpc and configure the component.

You can also use following My Home Assistant link

Open your Home Assistant instance and start setting up a new integration.

Setup

Now the integration is added to HACS and available in the normal HA integration installation

  1. In the HomeAssistant left menu, click Configuration

  2. Click Integrations

  3. Click ADD INTEGRATION

  4. Type Dpc and select it

  5. Enter the details:

    1. Name: Your location name or name of sensor
    2. Latitude: Latitude of monitored point
    3. Longitude: Longitude of monitored point
  6. Optional:

    1. Binary sensor enable/disable
    2. Sensor enabled/disable
    3. Municipality
    4. Update interval (minutes, default 30)
    5. Minimum level of warning. (int, default 2)

    N.B Some municipalities border on multiple alert areas. With the option (3) "municipality" the search is done by name of the municipality, and the area with the highest alert will be considered.

⚠️ Multiple instance are possible, but... for the moment the updates are independent, it is advisable not to exceed more than two / three locations.

Preview From my Natural Events project.



Cards: card-mod, auto-entities



Cards: card-mod, markdown



Cards: card-mod, auto-entities, config-template-card

Representation of the attributes present in the sensor

DPC Alert attributes

attribution: Data provided by Civil Protection Department
integration: dpc
id: "20210805_1513"
publication_date: "2021-08-05T15:13:00"
last_update: "2021-08-05T19:48:05.000855"
max_level: 3
total_alerts: 2
today:
  info: Moderata per rischio temporali
  alert: ALLERTA ARANCIONE
  level: 3
  image_url: >-
    https://raw.githubusercontent.com/pcm-dpc/DPC-Bollettini-Criticita-Idrogeologica-Idraulica/master/files/preview/20210805_1513_oggi.png
  expires: "2021-08-05T00:00:00"
events_today:
  - risk: Temporali
    info: Moderata
    alert: ALLERTA ARANCIONE
    level: 3
    icon: mdi:weather-lightning
  - risk: Idrogeologico
    info: Moderata
    alert: ALLERTA ARANCIONE
    level: 3
    icon: mdi:waves
tomorrow:
  info: Assenza di fenomeni significativi prevedibili
  alert: NESSUNA ALLERTA
  level: 1
  image_url: >-
    https://raw.githubusercontent.com/pcm-dpc/DPC-Bollettini-Criticita-Idrogeologica-Idraulica/master/files/preview/20210805_1513_domani.png
  expires: "2021-08-06T00:00:00"
zone_name: Lario e Prealpi occidentali
friendly_name: DPC Alert
icon: mdi:hazard-lights

DPC Vigilance attributes

attribution: Data provided by Civil Protection Department
integration: dpc
tomorrow:
  phenomena: []
  icon: mdi:numeric-1-circle
  image_url: >-
    https://raw.githubusercontent.com/pcm-dpc/DPC-Bollettini-Vigilanza-Meteorologica/master/files/preview/20220201_domani.png
  level: 1
  precipitation: Assenti o non rilevanti
aftertomorrow:
  phenomena: []
  icon: mdi:numeric-1-circle
  image_url: null
  level: 1
  precipitation: Assenti o non rilevanti
today:
  phenomena:
    - id: 202202011
      date: 2022-01-31Z
      id_event: 11
      event: Venti
      value: burrasca
      latitude: 43.15908136602766
      longitude: 12.860448349161915
      distance: 46
      direction: WSW
      degrees: 256
      icon: mdi:weather-windy
  icon: mdi:numeric-2-circle
  image_url: >-
    https://raw.githubusercontent.com/pcm-dpc/DPC-Bollettini-Vigilanza-Meteorologica/master/files/preview/20220201_oggi.png
  level: 2
  precipitation: Deboli
id: '20220201'
publication_date: '2022-02-01T00:00:00'
zone_name: Coste marchigiana meridionale e abruzzese centro-settentrionale
last_update: '2022-02-01T17:27:04.002291'
max_level: 2
total_phenomena: 1
total_alerts: 1
icon: mdi:hazard-lights
friendly_name: DPC Vigilance

Representation of the attributes present in the binary sensor

attribution: Data provided by Civil Protection Department
integration: dpc
id: '20220322_1401'
publication_date: '2022-03-22T14:01:00'
expires: '2022-03-23T00:00:00'
last_update: '2022-03-22T20:30:16.170457'
risk: Idrogeologico
info: Assenza di fenomeni significativi prevedibili
alert: NESSUNA ALLERTA
level: 1
zone_name: Bacini di Roma
image_url: >-
  https://raw.githubusercontent.com/pcm-dpc/DPC-Bollettini-Criticita-Idrogeologica-Idraulica/master/files/preview/20220322_1401_domani.png
link: https://mappe.protezionecivile.gov.it/it/mappe-rischi/bollettino-di-criticita/
device_class: safety
icon: mdi:waves
friendly_name: Rischio Idrogeologico Domani

Here are some advanced examples of using the entities created with this component

Lovelace markdown card example sensor

type: markdown
content: |-

  ___

  {% set entity = 'sensor.dpc_alert' %}

  #### PROTEZIONE CIVILE - [CRITICITA](https://mappe.protezionecivile.gov.it/it/mappe-rischi/bollettino-di-criticita)

  ##### ZONA {{state_attr(entity, 'zone_name')}}


  {% set color = {0:'White', 1:'Green', 2:'Gold', 3:'Orange', 4:'Red'} %}
  {% set days_map = {'today':'Oggi.', 'tomorrow':'Domani.', 'aftertomorrow': 'Dopodomani.'} %} 
  {%- for day in ['today', 'tomorrow'] %}
  {% set d = state_attr(entity, day) %}
  {%- set events = state_attr(entity, 'events_'+day) %}
  {%- if d %} 
  {%- if  d['level'] >= 1 %}

  |   |   |
  |:--|:--|
  | <font color="{{ color.get(d['level']) }}"/> <ha-icon icon="{{ 'mdi:numeric-' ~ d['level'] ~ '-box'}}"/></ha-icon> | {{ days_map[day] }} {{d['info']}} {{d['alert']}}</font> |
  {% endif %}
  {%- endif %}
  {%- if events %} 
  {%- for ev in events %}

  |   |   |   |
  |:--|:--|:--|
  | <font color="{{ color.get(ev['level']) }}"/> <ha-icon icon="{{ 'mdi:numeric-' ~ ev['level'] }}"/> | <font color="{{ color.get(ev['level']) }}"/> <ha-icon icon="{{ ev['icon'] }}"/> | {{ ev['alert'] }} {{ ev['info'] }} criticità per rischio {{ ev['risk'] }} |

  {%- endfor %} 
  {%- endif %}
  {%- endfor %}

  ___

  {% set entity = 'sensor.dpc_vigilance' %}

  #### PROTEZIONE CIVILE - [VIGILANZA METEO](https://mappe.protezionecivile.it/it/mappe-rischi/bollettino-di-vigilanza)

  ##### ZONA {{state_attr(entity, 'zone_name')}}

  {% set color = {0:'White', 1:'Green', 2:'Gold', 3:'Orange', 4:'Red', 5: 'BlueViolet'} %}
  {# set color_vigilance = {0:'#FFFFFF', 1:'#008000', 2:'#C3FFFE', 3:'#50FFFF', 4:'#508BFF', 5: '#A040FF'} #}
  {% set color_v = {0:'White', 1:'Green', 2:'LightCyan', 3:'BabyBlue', 4:'CornflowerBlue', 5: 'BlueViolet'} %}
  {% set day = {'today':'Oggi.', 'tomorrow':'Domani.', 'aftertomorrow': 'Dopodomani.'} %} 
  {%- for status in ['today', 'tomorrow','aftertomorrow'] %}
  {% set v = state_attr(entity, status) %}
  {%- if v %} 
  {%- if v['level'] >= 1 %}
  <font color="{{ color_v.get(v['level']) }}"/> <ha-icon icon="{{ v['icon'] }}"/></ha-icon> {{ day[status] }} Quantitativi previsti {{ v['precipitation'] }} </font>
  {%- endif %}
  {%- if v.phenomena %} 
  {% for d in v.phenomena %}

  |   |   |
  |:--|:--|
  | <ha-icon icon="{{ d['icon'] }}"/> |{{ d['event'] }} {{ d['value'] }} [{{ d['distance'] }} Km {{ d['direction'] }}] |

  {%- endfor %}
  {%- endif %}
  {%- endif %}
  {%- endfor %}

  [Sito Web Protezione Civile](https://www.protezionecivile.gov.it/it/) ~ [Radar](https://mappe.protezionecivile.it/it/mappe-rischi/piattaforma-radar)

Lovelace markdown card example sensor (GUI)

type: markdown
content: >-

  ___


  {% set entity = 'sensor.dpc_alert' %}


  #### PROTEZIONE CIVILE -
  [CRITICITA](https://mappe.protezionecivile.gov.it/it/mappe-rischi/bollettino-di-criticita)


  ##### ZONA {{state_attr(entity, 'zone_name')}}



  {% set color = {0:'White', 1:'Green', 2:'Gold', 3:'Orange', 4:'Red'} %}

  {% set days_map = {'today':'Oggi.', 'tomorrow':'Domani.', 'aftertomorrow':
  'Dopodomani.'} %} 

  {%- for day in ['today', 'tomorrow'] %}

  {% set d = state_attr(entity, day) %}

  {%- set events = state_attr(entity, 'events_'+day) %}

  {%- if d %} 

  {%- if  d['level'] >= 1 %}

  <font color="{{ color.get(d['level']) }}"/> <ha-icon icon="{{ 'mdi:numeric-' ~
  d['level'] ~ '-box'}}"/></ha-icon> {{ days_map[day] }} {{d['info']}}
  {{d['alert']}}</font>

  {% endif %}

  {%- endif %}

  {%- if events %} 

  {%- for ev in events %}


  |   |   |   |

  |:--|:--|:--|

  | <font color="{{ color.get(ev['level']) }}"/> <ha-icon icon="{{
  'mdi:numeric-' ~ ev['level'] }}"/> | <font color="{{ color.get(ev['level'])
  }}"/> <ha-icon icon="{{ ev['icon'] }}"/> | {{ ev['alert'] }} {{ ev['info'] }}
  criticità per rischio {{ ev['risk'] }} |


  {%- endfor %} 

  {%- endif %}

  {%- endfor %}


  ___


  {% set entity = 'sensor.dpc_vigilance' %}


  #### PROTEZIONE CIVILE - [VIGILANZA
  METEO](https://mappe.protezionecivile.it/it/mappe-rischi/bollettino-di-vigilanza)


  ##### ZONA {{state_attr(entity, 'zone_name')}}


  {% set color = {0:'White', 1:'Green', 2:'Gold', 3:'Orange', 4:'Red', 5:
  'BlueViolet'} %}

  {% set color_v = {0:'White', 1:'Green', 2:'#C3FFFE', 3:'#50FFFF', 4:'#508BFF',
  5: '#A040FF'} %}

  {% set day = {'today':'Oggi.', 'tomorrow':'Domani.', 'aftertomorrow':
  'Dopodomani.'} %} 

  {%- for status in ['today', 'tomorrow','aftertomorrow'] %}

  {% set v = state_attr(entity, status) %}

  {%- if v %} 

  {%- if v['level'] >= 1 %}

  <font color="{{ color_v.get(v['level']) }}"/> <ha-icon icon="{{ v['icon']
  }}"/></ha-icon> {{ day[status] }} Quantitativi previsti {{ v['precipitation']
  }} </font>

  {% if "zone_name" in v %} {{v['zone_name']  if state_attr(entity, 'zone_name')
  != v['zone_name']  else ''}}{%- endif %}

  {%- endif %}

  {%- if "phenomena" in v%} 

  {% for d in v.phenomena %}


  |   |   |

  |:--|:--|

  | <ha-icon icon="{{ d['icon'] }}"/> |{{ d['event'] }} {{ d['value'] }} [{{
  d['distance'] }} Km {{ d['direction'] }}] |


  {%- endfor %}

  {%- endif %}

  {%- endif %}

  {%- endfor %}


  [Sito Web Protezione Civile](https://www.protezionecivile.gov.it/it/) ~
  [Radar](https://mappe.protezionecivile.it/it/mappe-rischi/piattaforma-radar)
title: Markdown Alert and Vigilance

Lovelace markdown card example Binary Sensor

type: markdown
card_mod:
  style: |
    ha-card {background: none; border-radius: 0px; box-shadow: none;}
content: >
  ___

  #### PROTEZIONE CIVILE

  {% 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' %} 

  <font color= {{color[state.attributes.level|int]}}> <ha-icon icon="{{ 'mdi:numeric-' ~ state.attributes.level|int ~ '-box'}}" style="width: 36px; height: 36px;"></ha-icon>  
  {{state.name}} - {{state.attributes.alert}} {{state.attributes.info}}</font> 
  {%- endif -%} {% endfor %}

  [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)

Lovelace custom config-template-card example to display maps (autoupdate fase)

type: custom:config-template-card
entities:
  - sensor.dpc_alert
card:
  type: iframe
  card_mod:
    style: |
      ha-card {
        border-radius: var(--ha-card-border-radius);
        margin-top: 8px;
      }
  aspect_ratio: 100%
  url: >-
    ${const d = new Date(); 
    const dpc_d = new Date(String(states['sensor.dpc_alert'].attributes.publication_date));
    var fase = (dpc_d.getDate() === d.getDate()) ? 'today' : 'tomorrow';
    'https://servizio-mappe.protezionecivile.it/#/view/dashboard?x=11.756&y=41.495&
    zoom=5.8&basemap=BING_AERIAL&appname=BollettinodiCriticità&file=
    https://raw.githubusercontent.com/pcm-dpc/DPC-Bollettini-Criticita-Idrogeologica-Idraulica/master/files/'
    +states['sensor.dpc_alert'].attributes.id+'.json&hidden=info,minimap&fase=' + fase}
type: custom:config-template-card
entities:
  - sensor.dpc_vigilance
card:
  type: iframe
  card_mod:
    style: |
      ha-card {
        border-radius: var(--ha-card-border-radius);
        margin-top: 8px;
      }
  aspect_ratio: 100%
  url: >-
    ${const d = new Date(); 
    const dpc_d = new Date(String(states['sensor.dpc_vigilance'].attributes.publication_date));
    var fase = (dpc_d.getDate() === d.getDate()) ? 'today' : 'tomorrow';
    'https://servizio-mappe.protezionecivile.it/#/view/dashboard?x=11.756&y=41.495&
    zoom=5.8&basemap=OPEN_STREET_MAP&appname=Bollettino di Vigilanza&file=
    https://raw.githubusercontent.com/pcm-dpc/DPC-Bollettini-Vigilanza-Meteorologica/master/files/'
    +states['sensor.dpc_vigilance'].attributes.id+'.json&hidden=minimap,info&fase=' + fase}
  # #hidden=minimap,info,switch <<--- 

Lovelace custom lovelace-card-templater example to display maps (autoupdate fase)

type: custom:card-templater
card:
  type: iframe
  aspect_ratio: 100%
  url_template: >-
    {% set day = 'today' if now().day == state_attr('sensor.dpc_vigilance',
    'publication_date').day else 'tomorrow' %}
    {{'https://servizio-mappe.protezionecivile.it/#/view/dashboard?x=11.756&y=41.495&
    zoom=5.8&basemap=OPEN_STREET_MAP&appname=Bollettino di Vigilanza&file=
    https://raw.githubusercontent.com/pcm-dpc/DPC-Bollettini-Vigilanza-Meteorologica/master/files/'
    + state_attr('sensor.dpc_vigilance', 'id') +
    '.json&hidden=minimap,info,&fase=' + day}}
type: custom:card-templater
card:
  type: iframe
  aspect_ratio: 100%
  url_template: >-
    {% set day = 'today' if now().day == state_attr('sensor.dpc_alert',
    'publication_date').day else 'tomorrow' %}
    {{'https://servizio-mappe.protezionecivile.it/#/view/dashboard?x=11.756&y=41.495&zoom=5.8&basemap=GOOGLE_SATELLITE&appname=Bollettino
    di
    Criticità&file=https://raw.githubusercontent.com/pcm-dpc/DPC-Bollettini-Criticita-Idrogeologica-Idraulica/master/files/'
    + state_attr('sensor.dpc_alert', 'id') + '.json&hidden=info,minimap,&fase='
    + day }}

Automation example using the sensors (Compatible with UI Automation Editor)

alias: protezione_civile_notifications_criticita_sensor
trigger:
  - platform: state
    entity_id:
      - sensor.dpc_alert
condition:
  - condition: template
    value_template: >-
      {{ not trigger.from_state.state in ["unavailable","unknown"]  and (
      trigger.from_state.attributes.total_alerts !=
      trigger.to_state.attributes.total_alerts or
          ( trigger.to_state.attributes.id != trigger.from_state.attributes.id and trigger.to_state.attributes.total_alerts > 0 )) }}
action:
  - variables:
      BULLETIN: >-
        https://mappe.protezionecivile.gov.it/it/mappe-rischi/bollettino-di-criticita
      WARNING_SIGN:
        "0": 
        "1": 🟢
        "2": 🟡
        "3": 🟠
        "4": 🔴
      WARN_DPC:
        none: 
        Temporali: 
        Idraulico: 💧
        Idrogeologico: 🌊
      ENTITY: "{{ trigger.entity_id |default('sensor.dpc', true) }}"
      DAYS:
        "1": today
        "2": tomorrow
      GIORNI:
        "1": oggi
        "2": domani
  - repeat:
      while:
        - condition: template
          value_template: "{{ repeat.index <= DAYS|length }}"
      sequence:
        - variables:
            giorno: "{{ GIORNI[repeat.index|string] }}"
            day: "{{ DAYS[repeat.index|string] }}"
            event: "{{ 'events_' + day }}"
        - choose:
            - conditions:
                - condition: template
                  value_template: "{{ state_attr(ENTITY, event) is not none }}"
              sequence:
                - service: notify.discord
                  data:
                    title: DPC Criticità
                    message: >
                      {% set attr = state_attr(ENTITY, event) %}

                      Criticità per {{giorno}}

                      {%- for d in attr %}

                      {{WARNING_SIGN[d['level']|string]}} {{ WARN_DPC[d['risk']]
                      }} {{ d['info'] }} {{ d['alert'] }} per rischio {{
                      d['risk'] }}.

                      {%- endfor %}

                      Zona: {{ state_attr(ENTITY, 'zone_name') }}
mode: queued
max_exceeded: silent
max: 10
alias: protezione_civile_notifications_vigilance_sensor
trigger:
  - platform: state
    entity_id:
      - sensor.dpc_vigilance
condition:
  - condition: template
    value_template: >-
      {{ trigger.from_state.state not in ["unavailable","unknown"]  and (
      trigger.from_state.attributes.total_alerts !=
      trigger.to_state.attributes.total_alerts or
          ( trigger.to_state.attributes.id != trigger.from_state.attributes.id and
          ( trigger.to_state.attributes.total_phenomena > 0 or trigger.to_state.attributes.total_alerts > 0 ))) }}
action:
  - variables:
      BULLETIN: >-
        https://mappe.protezionecivile.gov.it/it/mappe-rischi/bollettino-di-vigilanza
      ENTITY: "{{ trigger.entity_id |default('sensor.dpc_vigilance', true) }}"
      DAYS:
        "1": today
        "2": tomorrow
        "3": aftertomorrow
      GIORNI:
        "1": oggi
        "2": domani
        "3": dopodomani
      WARNING_SIGN:
        "0": 
        "1": 🟢
        "2": 🟡
        "3": 🟠
        "4": 🔴
  - repeat:
      while:
        - condition: template
          value_template: "{{ repeat.index <= DAYS|length }}"
      sequence:
        - variables:
            giorno: "{{ GIORNI[repeat.index|string] }}"
            day: "{{ DAYS[repeat.index|string] }}"
        - choose:
            - conditions:
                - condition: template
                  value_template: "{{ state_attr(ENTITY, day) is not none }}"
                - condition: template
                  value_template: "{{ state_attr(ENTITY, day).level|default|int > 1 }}"
              sequence:
                - service: notify.pushover
                  data:
                    title: DPC Vigilanza Meteo
                    message: >
                      {% set attr = state_attr(ENTITY, day) %}

                      Vigilanza meteo per {{giorno}}

                      {{WARNING_SIGN[attr['level']|string]}} Quantitativi
                      previsti {{attr['precipitation']}}

                      {% if 'phenomena' in attr %}

                      Fenomeni nelle vicinanze:

                      {% for f in attr['phenomena'] %}

                      ➡️ {{f.event}}: {{f.value}} in direzione {{f.direction}}
                      alla distanza di {{f.distance}}km.

                      {% endfor %}

                      {% endif %}


                      Zona: {{ state_attr(ENTITY, 'zone_name') }}
mode: queued
max_exceeded: silent
max: 10

Automation example using the binary sensor (Compatible with UI Automation Editor)

automation:
  - alias: Protezione Civile Notifications
    mode: queued
    max_exceeded: silent
    max: 10
    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:
      - condition: template
        value_template: >-
          {{ trigger.to_state.state == 'on' and (trigger.from_state.state == 'off'
          or (trigger.to_state.attributes != trigger.from_state.attributes))}}
    action:
      - variables:
          BULLETIN: "https://mappe.protezionecivile.gov.it/it/mappe-rischi/bollettino-di-criticita"
          dpc_tts_msg: >-
            {% set attr = trigger.to_state.attributes if trigger.to_state is defined else ({}) %}
            Attenzione. {{ attr.get('friendly_name','Test DPC') }}.
            Allerta {{ attr.get('allerta','Bianca') }} {{ attr.get('info','Nessuna info') }}.
      - service: notify.pushover
        data:
          title: >-
            {% set attr = trigger.to_state.attributes if trigger.to_state is defined else ({}) %}
            Protezione Civile - {{ attr.get(''rischio'') }}
          message: |
            {% set attr = trigger.to_state.attributes if trigger.to_state is defined else ({}) %}
            {% set alert = {'0': '⚪', '1':'🟢', '2':'🟡', '3':'🟠', '4': '🔴'} %}
            {% set risk = {none: '❌', 'Temporali':'⚡', 'Idraulico':'💧', 'Idrogeologico':'🌊'} %}
            {{ risk[attr.get('rischio')] }} {{ attr.get('friendly_name','Test DPC') }}.
            {{ alert[attr.get('level', 0)|string] }} Allerta {{ attr.get('allerta','Bianca') }}
            {{ attr.get('info','No info') }}.

            Bollettino di criticità {{ attr.get('link', BULLETIN) }}
      - service: tts.google_translate_say
        data:
          message: "{{ dpc_tts_msg }}"
          entity_id: media_player.red
      - service: notify.alexa_media
          data:
            message: "{{ dpc_tts_msg }}"
            data:
              type: tts
            target: "media_player.studio"

Other Lovelace Examples HA Card weather conditions @r-renato

License

Information provided by Department of Civil Protection - Presidency of the Council of Ministers Creative Commons Licenses CC-BY-SA 4.0.

Dati forniti dal servizio Dipartimento della Protezione Civile-Presidenza del Consiglio dei Ministri Licenza Creative Commons CC-BY-SA 4.0.

Contributions are welcome


Trademark Legal Notices

All product names, trademarks and registered trademarks in the images in this repository, are property of their respective owners. All images in this repository are used by the author for identification purposes only. The use of these names, trademarks and brands appearing in these image files, do not imply endorsement.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].