openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.86k stars 3.57k forks source link

[dwdunwetter] Cell IDs are not a reliable way to query for an area #7856

Open euphi opened 4 years ago

euphi commented 4 years ago

The dwdunwetter binding queries the DWD API by using a CQL query to match a cell id.

This is not reliable, because even if a warning is active within a cell, the query may return 0 results.

Details (see https://community.openhab.org/t/dwd-unwetter-warnungen-no-values/93847/13)

Steps to reproduce:


items:

Group gUnwetter "Unwetterwarnungen"

Switch Unwetter1                "Weather warning"               { channel="dwdunwetter:dwdwarnings:fuerth:warning1" }
String Unwetter1Serverity       "Severity[%s]"                  { channel="dwdunwetter:dwdwarnings:fuerth:severity1" }
String Unwetter1Beschreibung    "[%s]"                          { channel="dwdunwetter:dwdwarnings:fuerth:description1" }
String Unwetter1Ausgabedatum    "Issued at [%s]"                { channel="dwdunwetter:dwdwarnings:fuerth:effective1" }
String Unwetter1GueltigAb       "Valid from [%s]"               { channel="dwdunwetter:dwdwarnings:fuerth:onset1" }
String Unwetter1GueltigBis      "Valid to [%s]"                 { channel="dwdunwetter:dwdwarnings:fuerth:expires1" }
String Unwetter1Typ             "Type [%s]"                     { channel="dwdunwetter:dwdwarnings:fuerth:event1" }
String Unwetter1Titel           "[%s]"                          { channel="dwdunwetter:dwdwarnings:fuerth:headline1" }
String Unwetter1Urgency         "[%s]"                          { channel="dwdunwetter:dwdwarnings:fuerth:urgency1" }
String Unwetter1Instruction     "Additional information: [%s]"  { channel="dwdunwetter:dwdwarnings:fuerth:instruction1" }

Analysis:

Conclusion: The cell id is not reliable to be used to query for warnings. There shall be another way, e.g. query for region.

DerOetzi commented 3 years ago

Had same issues like this at the beginning. @euphi can you please check the query result without filter next time you have an active warning for Fürth in your app, by querying following URL:

https://maps.dwd.de/geoserver/dwd/ows?service=WFS&version=2.0.0&request=GetFeature&typeName=dwd:Warnungen_Gemeinden

Then please do a fulltext search for Fürth on the xml-result to compare CellIDs to the ones of warning,json.

In my case "Nürnberger Land->Leinburg" there always is no warning for Nürnberger Land but only for Leinburg and concret neighbor towns, which makes sence for querying Warnungen_Gemeinden in my opinion.

DerOetzi commented 3 years ago

The XML-results should exactly contains the same content as displayed on this side: https://www.dwd.de/DE/wetter/warnungen_gemeinden/warntabellen/warntab_bay_node.html which although differs from the information inside the warnings.json.

As a concret example at the moment in warning.json there is a active "DAUERREGEN"-Warning for the "Kreis Nürnberger Land (109574000)" but not in binding results. But when you look at the map of DWD you can see only the north of the Landkreis has active warning.

Which can be although seen on the page mentioned above. For example "Lauf a.d. Pegnitz (809574138)" and Leinburg(809574139) has neither results on this page nor for the binding request, but "Hersbruck (809574132)" which is more north gives results on the page as well as in binding query.

Conclusion: It is a bit tricky to find really the "smallest" cell, which is the only one reported by the binding request and not the huger areas around. But it is the one with most concret information about your local warning situation.

DerOetzi commented 3 years ago

Maybe the binding can be changed to accept "Kreis"-CellIDs as well by requesting another filter:

https://maps.dwd.de/geoserver/dwd/ows?service=WFS&version=2.0.0&request=GetFeature&typeName=dwd:Warnungen_Landkreise&CQL_FILTER=GC_WARNCELLID+LIKE+%27109574000%27

Unfortunately for changing my system to OH3 at the moment I don't have the time at the moment to dive deeper into bindings code, but maybe someone else can give it a try with this information.

lsiepel commented 2 months ago

Last comment is allmost 3,5 years old. Would be nice if anyone can verify if this is still relevant in current 4.2 snapshot / last milestone.