eclipse-archived / smarthome

Eclipse SmartHome™ project
https://www.eclipse.org/smarthome/
Eclipse Public License 2.0
865 stars 782 forks source link

[owm] Wind direction is UNDEF if direction is North #6734

Open MHerbst opened 5 years ago

MHerbst commented 5 years ago

If the wind direction is north the angle is 0 and the return JSON file does not contain a value for direction. In this case the binding sets the value to UNDEF:

20:47:38.352 [DEBUG] [enWeatherMapWeatherAndForecastHandler] - Update channel 'wind-direction' of group 'current' with new state 'UNDEF'.

It would be more user-friendly if the binding would set the channel state to 0°.

This is the JSON buffer returned by owm of :

 OpenWeatherMap response: status = 200, content = '{"coord":{"lon":8.57,"lat":51.39},"weather":[{"id":741,"main":"Fog","description":"Nebel","icon":"50n"}],"base":"stations","main":{"temp":1.99,"pressure":1030,"humidity":100,"temp_min":1,"temp_max":3},"visibility":550,"wind":{"speed":1},"clouds":{"all":90},"dt":1545852000,"sys":{"type":1,"id":1304,"message":0.0051,"country":"DE","sunrise":1545809428,"sunset":1545837775},"id":2944079,"name":"Brilon","cod":200}'

There is a value for wind:speed but no value for direction.

If you request the data in XML format, it looks like this:

...
    <wind>
        <speed value="1" name="Calm"></speed>
        <gusts></gusts>
        <direction value="0" code="N" name="North"></direction>
    </wind>
...

Here you can see that the value is "0" because the wind direction is "North".

Maybe there are other entries that are missing in the return JSON file if they are "0". In this case the binding should use appropriate default values and not "UNDEF".

cweitkamp commented 5 years ago

Makes sense. But it would be nice to have a confirmation from OWM support for such a behavior. Most answers in the FAQ sounds different. Let's open a ticket over there and hand over your results/data to them.

MHerbst commented 5 years ago

Maybe they try to keep the amount of data in JSON as small as possible. But you are right, an "official" statement would be good.

cweitkamp commented 5 years ago

I posted a message at OWM Support Center: https://openweathermap.desk.com/customer/en/portal/questions/17476619-wind-not-degre-

cweitkamp commented 5 years ago

@MHerbst I got an answer for my question from the OpenWeatherMap Agent. It looks like our assumption was wrong and the JSON is correct. Thus we do not need any changes / workarounds in the binding.

Pavel Zuykov Jan 09, 2019 08:49AM GMT OpenWeatherMap Agent

Hello Christoph,

Thank you for report.

I checked this, and seems like XML output gives zero then there is no data about direction.

We will add this fix to our list of improvements.