DPC alerts - Italian Civil Protection Department Weather Alerts
An awtrix light automation to display weather alerts provided by the Italian Civil Protection Department (Dipartimento Protezione Civile)
About this flow
| System | Home Assistant |
|---|---|
| AWTRIX version | AWTRIX 3 |
| Topic | Miscellaneous |
| Built by | Icchan |
| File | PegMAVG8ov3p.yaml · 3.0 KB |
| Icons | 1 |
| Published | 10 Feb 2024 · updated 3 Mar 2024 |
| Downloads | 50 |
Is this your flow?
If you created this flow, open your saved edit link to add it to your account. You can then manage it whenever you sign in. Adding it to your account replaces the edit link.
Flow description
Prerequisites:
Please make sure you have this integration installed and configured: Home Assistant - Custom Components DPC Alert.
Remember to change the topic in mqtt.publish service according to your topic on the flow.
Icons:
Idraulico: 63
Idrogeologico: 2661
Temporali: 11428
How it works:
The text color will change according to the alert color (yellow, orange, red).
It will display alerts for the current day and the day after as soon as they are available. Alerts are shown on Awtrix light only if there is an active alert.
More info:
To get more detailed information about parameters of warnings visit Civil Protection Department or Dipartimento Protezione Civile (in Italian)
Updates:
- 29/02/2024: Fixed events not being deleted after new event took place.
- 14/02/2024: Fixed loop not working as expected. It was hard, but I won. 😎
PegMAVG8ov3p.yaml
alias: Awtrix App - DPC Alert
description: ""
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:
- service: mqtt.publish
data:
qos: 0
retain: false
topic: awtrix_xxx/custom/dpc_alert
- variables:
payload_apps: >
{%- set entity = 'sensor.dpc_alert' -%} {%- set days_map =
{'today':'Oggi','tomorrow':'Domani'} -%} {%- set alert_color =
{0:"#FFFFFF", 1:'#00FF00', 2:'#ffff00', 3:'#ffa500', 4:'#ff0000'}
-%} {%- set risk_icon =
{'Temporali':'11428','Idraulico':'63','Idrogeologico':'2661'} -%}
{%- set ns = namespace(data=false) -%}{%- set events_today =
state_attr(entity, 'events_today') -%}
{%- if events_today -%}
{%- for ev in events_today if events_today is defined -%}
{%- set evloop = loop -%}
{%- if ev -%}
{%- set ns.data = true -%}
{
"icon": "{{ risk_icon.get(ev['risk']) }}",
"text":
[
{
"t": "Oggi {{ ev['alert']}} ({{ ev['risk'] }})",
"c": "{{ alert_color.get(ev['level']) }}"
}
]
}
{%- endif -%}
{%- if not evloop.last -%},{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- set events_tomorrow = state_attr(entity, 'events_tomorrow') -%}
{%- if events_tomorrow -%}
{%- for ev in events_tomorrow if events_tomorrow is defined -%}
{%- set evloop = loop -%}
{%- if ev -%}
{%- if ns.data == true -%},{%- endif %}
{%- set ns.data = true -%}
{
"icon": "{{ risk_icon.get(ev['risk']) }}",
"text":
[
{
"t": "Domani {{ ev['alert']}} ({{ ev['risk'] }})",
"c": "{{ alert_color.get(ev['level']) }}"
}
]
}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
payload: |
{%- if payload_apps -%}
[
{{ payload_apps }}
]
{%- else -%}
{}
{%- endif -%}
- service: mqtt.publish
data:
qos: 0
retain: false
topic: awtrix_xxx/custom/dpc_alert
payload: |
{{ payload | tojson }}
mode: queued
max_exceeded: silent
max: 10
This flow uses the following icons. Add them to your AWTRIX along with the flow.
32×8 px
Sign in to download these icons or send them to your AWTRIX.
Discussion 0
Ask a question, suggest a change or share how you use it.
No comments yet. Start the conversation.
More flows for Home Assistant or Miscellaneous
Something wrong with this flow? Report it.
Have an idea?
Sign in to ask questions and join the conversation.