Hi,
I use the DWD integration for my city to issue severe weather warnings as notifications on our smartphones and via Alexa, among other things.
The problem I have now is that my automation is repeatedly executed throughout the day, even though there is no new information. The severe weather warnings are in the sensor’s attribute. Therefore, I trigger my automation when the attribute changes. This means that I receive new notifications when more warnings have been added or an existing one has been adjusted (e.g. the time period has been changed).
The problem now is that the integration apparently inserts the current date into the “last_update” attribute every time it checks for changes in the sensor, even though NOTHING has changed. This of course means that the automation is executed again and I keep getting the same messages. It would be better if last_update only changed when something in the warnings had changed.
How can I ensure that I only receive messages for Warning1, Warning2 and Warning3 when they are NEW or when something has actually CHANGED within the warning and not with every update poll of the DWD integration? Or do you have to fix this in the integration so that last_update is only changed when something has changed in terms of content?
My automation:
alias: Unwetterwarnung senden
description: ""
mode: queued
max: 10
triggers:
- entity_id:
- sensor.stadt_entenhausen_aktuelle_warnstufe
attribute: warning_1
id: warning1
trigger: state
- entity_id:
- sensor.stadt_entenhausen_aktuelle_warnstufe
attribute: warning_2
id: warning2
trigger: state
- entity_id:
- sensor.stadt_entenhausen_aktuelle_warnstufe
attribute: warning_3
id: warning3
trigger: state
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id:
- warning1
sequence:
- action: script.benachrichtigung_senden
data:
header: Unwetterwarnung
body: >-
{% set description =
state_attr("sensor.stadt_entenhausen_aktuelle_warnstufe",
"warning_1_description") %} {{ description }}
message: >-
{% set headline =
state_attr("sensor.stadt_entenhausen_aktuelle_warnstufe",
"warning_1_headline") %} {% set time_start =
state_attr("sensor.stadt_entenhausen_aktuelle_warnstufe",
"warning_1_start") %} {% set time_end =
state_attr("sensor.stadt_entenhausen_aktuelle_warnstufe",
"warning_1_end") %} {{ headline }} von {{
(time_start|as_local).time().strftime("%H:%M") }} bis {{
(time_end|as_local).time().strftime("%H:%M") }} Uhr
- conditions:
- condition: trigger
id:
- warning2
sequence:
- action: script.benachrichtigung_senden
data:
header: Unwetterwarnung
body: >-
{% set description =
state_attr("sensor.stadt_entenhausen_aktuelle_warnstufe",
"warning_2_description") %} {{ description }}
message: >-
{% set headline =
state_attr("sensor.stadt_entenhausen_aktuelle_warnstufe",
"warning_2_headline") %} {% set time_start =
state_attr("sensor.stadt_entenhausen_aktuelle_warnstufe",
"warning_2_start") %} {% set time_end =
state_attr("sensor.stadt_entenhausen_aktuelle_warnstufe",
"warning_2_end") %} {{ headline }} von {{
(time_start|as_local).time().strftime("%H:%M") }} bis {{
(time_end|as_local).time().strftime("%H:%M") }} Uhr
- conditions:
- condition: trigger
id:
- warning3
sequence:
- action: script.benachrichtigung_senden
data:
header: Unwetterwarnung
body: >-
{% set description =
state_attr("sensor.stadt_entenhausen_aktuelle_warnstufe",
"warning_3_description") %} {{ description }}
message: >-
{% set headline =
state_attr("sensor.stadt_entenhausen_aktuelle_warnstufe",
"warning_3_headline") %} {% set time_start =
state_attr("sensor.stadt_entenhausen_aktuelle_warnstufe",
"warning_3_start") %} {% set time_end =
state_attr("sensor.stadt_entenhausen_aktuelle_warnstufe",
"warning_3_end") %} {{ headline }} von {{
(time_start|as_local).time().strftime("%H:%M") }} bis {{
(time_end|as_local).time().strftime("%H:%M") }} Uhr
Sensor from DWD integration:
region_name: Stadt entenhausen
region_id: 123456
last_update: "2024-11-22T15:05:26.070000+00:00"
warning_count: 3
warning_1_name: GLÄTTE
warning_1_type: 84
warning_1_level: 1
warning_1_headline: Amtliche WARNUNG vor GLÄTTE
warning_1_description: Es besteht Glättegefahr.
warning_1_instruction: |-
Hinweis auf Rutschgefahr.
Handlungsempfehlungen:
Verhalten im Straßenverkehr anpassen
warning_1_start: "2024-11-22T20:00:00+00:00"
warning_1_end: "2024-11-23T08:00:00+00:00"
warning_1_parameters: null
warning_1_color: "#ffeb3b"
warning_1:
start_time: "2024-11-22T20:00:00+00:00"
end_time: "2024-11-23T08:00:00+00:00"
event: GLÄTTE
event_code: 84
headline: Amtliche WARNUNG vor GLÄTTE
description: Es besteht Glättegefahr.
instruction: |-
Hinweis auf Rutschgefahr.
Handlungsempfehlungen:
Verhalten im Straßenverkehr anpassen
urgency: immediate
level: 1
parameters: null
color: "#ffeb3b"
warning_2_name: WINDBÖEN
warning_2_type: 51
warning_2_level: 1
warning_2_headline: Amtliche WARNUNG vor WINDBÖEN
warning_2_description: >-
Es treten Windböen mit Geschwindigkeiten bis 60 km/h (17 m/s, 33 kn, Bft 7)
anfangs aus südwestlicher, später aus westlicher Richtung auf.
warning_2_instruction: |-
Hinweis auf umherfliegende leichte Gegenstände.
Handlungsempfehlungen:
lose Gegenstände sichern; z.B. Zelte und Abdeckungen befestigen
warning_2_start: "2024-11-22T09:00:00+00:00"
warning_2_end: "2024-11-22T19:00:00+00:00"
warning_2_parameters:
wind direction: south-west
subsequent wind direction: west
gusts: <60 [km/h]
warning_2_color: "#ffeb3b"
warning_2:
start_time: "2024-11-22T09:00:00+00:00"
end_time: "2024-11-22T19:00:00+00:00"
event: WINDBÖEN
event_code: 51
headline: Amtliche WARNUNG vor WINDBÖEN
description: >-
Es treten Windböen mit Geschwindigkeiten bis 60 km/h (17 m/s, 33 kn, Bft 7)
anfangs aus südwestlicher, später aus westlicher Richtung auf.
instruction: |-
Hinweis auf umherfliegende leichte Gegenstände.
Handlungsempfehlungen:
lose Gegenstände sichern; z.B. Zelte und Abdeckungen befestigen
urgency: immediate
level: 1
parameters:
wind direction: south-west
subsequent wind direction: west
gusts: <60 [km/h]
color: "#ffeb3b"
warning_3_name: FROST
warning_3_type: 22
warning_3_level: 1
warning_3_headline: Amtliche WARNUNG vor FROST
warning_3_description: Es tritt leichter Frost bis -1 °C auf.
warning_3_instruction: |-
Hinweis auf mögliche Frostschäden.
Handlungsempfehlungen:
ggf. Frostschutzmaßnahmen ergreifen
warning_3_start: "2024-11-22T20:00:00+00:00"
warning_3_end: "2024-11-23T08:00:00+00:00"
warning_3_parameters:
minimum temperature: ">-1 [°C]"
warning_3_color: "#ffeb3b"
warning_3:
start_time: "2024-11-22T20:00:00+00:00"
end_time: "2024-11-23T08:00:00+00:00"
event: FROST
event_code: 22
headline: Amtliche WARNUNG vor FROST
description: Es tritt leichter Frost bis -1 °C auf.
instruction: |-
Hinweis auf mögliche Frostschäden.
Handlungsempfehlungen:
ggf. Frostschutzmaßnahmen ergreifen
urgency: immediate
level: 1
parameters:
minimum temperature: ">-1 [°C]"
color: "#ffeb3b"
attribution: Data provided by DWD
friendly_name: Stadt entenhausen Aktuelle Warnstufe
EDIT:
I also found out that the order of Warning1, Warning2 and Warning3 changes randomly during the next update poll of the DWD integration, even though NOTHING has changed within the warnings. This probably also leads to the automation being constantly triggered because the attribute has of course changed, even though it doesn’t make sense.