openhab / openhab-addons

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

[dwdunwetter] Binding stops refreshing after error #6924

Closed 9037568 closed 4 years ago

9037568 commented 4 years ago

Based on the discussion found in the community forum thread "Frustrated with DWDUnwetter".

Expected Behavior

The binding should receive valid data.

Current Behavior

The binding appears to be getting none of the data it expects when requesting data.

The binding sends this query:

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

And receives this response:

<?xml version="1.0" encoding="UTF-8"?><wfs:FeatureCollection xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dwd="http://www.dwd.de" xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" numberMatched="0" numberReturned="0" timeStamp="2020-01-27T06:21:13.324Z" xsi:schemaLocation="http://www.dwd.de https://maps.dwd.de/geoserver/dwd/wfs?service=WFS&amp;version=2.0.0&amp;request=DescribeFeatureType&amp;typeName=dwd%3AWarnungen_Gemeinden http://www.opengis.net/wfs/2.0 https://maps.dwd.de/geoserver/schemas/wfs/2.0/wfs.xsd http://www.opengis.net/gml/3.2 https://maps.dwd.de/geoserver/schemas/gml/3.2.1/gml.xsd"/>

The interesting part of the response appears to be this:

numberMatched="0" numberReturned="0"

The binding then proceeds to do absolutely no validation of the response, provides the user with no useful feedback to indicate that the request has utterly failed, and remains "ONLINE".

Possible Solution

  1. We need a valid query for the binding to send

I have found that the URL below returns 10844 values, so it appears to be a matter of finding a CQL filter string that works...

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

  1. The binding needs to implement validation of the response / correct error handling
  2. The binding needs to implement better logging
J-Arnold commented 4 years ago

Additional is in the file org.openhab.binding.dwdunwetter\src\main\resources\ESH-INF\i18n\dwdunwetter_de.properties is an error

# binding
binding.dwdunwetter.name = DWD Unwetter Binding
**binding.tankerkoenig.description** = Das DWD Unwetter Binding ermöglicht es über die API des DWD aktuelle Unwetterwarnungen abzurufen
9037568 commented 4 years ago

Thanks, @J-Arnold. I've fixed that in my fork.

9037568 commented 4 years ago

We now have evidence that the binding is receiving warnings data, at least in some cases.

mbremer99 commented 4 years ago

It looks the binding only returns warnings data for a place if a warning is really in effect. Otherwise the file with no data is returned. You can check it quite easy:

  1. Query the big file mentioned above (which seems to contain all warnings in effect at the moment) https://maps.dwd.de/geoserver/dwd/ows?service=WFS&request=GetFeature&typeName=dwd:Warnungen_Gemeinden
  2. pick a a warncellID from that file
  3. Query the URL currently used by the binding with that warncell ID, e.g. https://maps.dwd.de/geoserver/dwd/ows?service=WFS&version=2.0.0&request=GetFeature&typeName=dwd:Warnungen_Gemeinden&CQL_FILTER=WARNCELLID+LIKE+%27816070052%27 make sure to keep the %27 before and after the warncellID at the end.
9037568 commented 4 years ago

@mbremer99:

It looks the binding only returns warnings data for a place if a warning is really in effect.

Seems like that should be fairly obvious. I guess I should have changed the title of this issue once I confirmed the binding was receiving data. I'll take care of that momentarily.

The second community thread I linked above hints at what the actual problem is. From what I can see so far, the binding works fine until it fails to retrieve data for some reason. e.g.:

15:45:48.964 [WARN ] [er.internal.data.DwdWarningDataAccess] - Communication error occurred while getting data
15:45:48.964 [DEBUG] [er.internal.data.DwdWarningDataAccess] - Communication error trace
java.io.IOException: java.util.concurrent.ExecutionException: java.net.UnknownHostException: maps.dwd.de

After that, the binding does not update that Thing any longer. I'm working on a fix for this now. I'd also like to add a couple channels for tracking the total number of warnings received and the cell id associated with each warning. I don't know if I should create a separate PR for that...