From 8b29daee168e2cf67c81bef56a4c3b2f1f6cf333 Mon Sep 17 00:00:00 2001 From: Thomas Hollstegge Date: Sat, 26 Sep 2020 20:59:38 +0200 Subject: [PATCH] Determine current and advance warnings based on urgency attribute (#1) According to their documentation [1], DWD sets the urgency to "Immediate" for current warnings and to "Future" for advance warnings. We should use this attribute to distinguish between current and advance warnings. [1] https://www.dwd.de/DE/leistungen/gds/help/warnungen/cap_dwd_profile_de_pdf.pdf?__blob=publicationFile&v=1 --- dwdwfsapi/weatherwarnings.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dwdwfsapi/weatherwarnings.py b/dwdwfsapi/weatherwarnings.py index 7002939..35bf6ca 100644 --- a/dwdwfsapi/weatherwarnings.py +++ b/dwdwfsapi/weatherwarnings.py @@ -61,6 +61,8 @@ def convert_warning_data(data_in): data_out["description"] = data_in["description"] if "instruction" in data_in: data_out["instruction"] = data_in["instruction"] + if "urgency" in data_in: + data_out["urgency"] = data_in["urgency"] if "severity" in data_in: try: if data_in["severity"].lower() in weather_severity_mapping: @@ -292,8 +294,7 @@ def __parse_result(self, json_obj): continue if ( - warning["start_time"] is not None - and warning["start_time"] < current_time + warning["urgency"] == "Immediate" ): current_warnings.append(warning) current_maxlevel = max(