[openweathermap] How to get windspeed in km/h

Hi dear openhabers,

I have configured the openweathermap add-on to get the current wind speed. As a result I get a value which seems to be in m/s. I’d prefer to get in km/h but I cannot find any way of doing that.

Question 1:
Is there a configuration to retrieve the speed as km/h?

Question 2:
I found a very similar issue in OH1 :

Should the default value not be in km/h also in OH2 openweathermap add-on?

Here is my configuration:


Bridge openweathermap:weather-api:api "OpenWeatherMap Account" [
  language="fr"] {
    Thing weather-and-forecast lyon "Lyon Weather" [location="45.77,4.82", forecastHours=0, forecastDays=0]


Number:Speed    WindSpeed_LYO       "Vitesse vent"      <wind> (WeatherGroup) { channel="openweathermap:weather-and-forecast:api:lyon:current#wind-speed" }

As I want to reuse the existing “WindSpeed_LYO” item (previously used with the Weather binding) I’m not interested in any solution that only change the displayed value.

Any advice?

You are already using a Unit of Measure by defining the Item as Number:Speed. So you just need to put the units in your label to display it properly. In your Rule you need to just supply the units you want.

val kmh = WindSpeed_LYO.state|km/h

You might need to cast it to a QuantityType first.

val kmh = (WindSpeed_LYO.state as QuantityType<Speed>)|km/h

If you need to actually have the Item state be km/h without using Units of Measure to convert between units, you need to create a proxy Item and a Rule to post the km/h value to the Proxy Item.

Thank you @rlkoshak, the syntax for the rules was not fully correct but you put me on the right way.
Here is what I did:

val kmh = (WindSpeed_LYO.state as QuantityType<Speed>).toUnit("km/h").doubleValue

Seems to work well now. Thanks for your help!

1 Like