Dear fellow openHABers,
Here in Sweden we don’t use km/h or even mph for measuring wind speed. We simply use meters per second. Weather Underground only supports km/h alternatively miles/h.
Can this be solved easy?
This is my things file
Number Wu_WindSpeed "Wind Speed [JS(kmh2mps.js):%.1f]" <wind> (G_CurCond, G_Wind) {channel="weatherunderground:weather:local:current#windSpeed"}
Number Wu_WindGust "Wind Gust [JS(kmh2mps.js):%.1f]" <wind> (G_CurCond, G_Wind) {channel="weatherunderground:weather:local:current#windGust"}
And here is my transform script kmh2mps.js
(function(kmh){
function round(value, precision) {
var multiplier = Math.pow(10, precision || 0);
return Math.round(value * multiplier) / multiplier;
}
return round(kmh/3.6, 1);
})(input)
Now, in the label, I would like to add “m/s” after the float but then “m/s” will be sent to the function as well so it returns “NaN”. I don’t know how to do that.
This is what I tried:
Number Wu_WindSpeed "Wind Speed [JS(kmh2mps.js):%.1f m/s]" <wind> (G_CurCond, G_Wind) {channel="weatherunderground:weather:local:current#windSpeed"}
Number Wu_WindGust "Wind Gust [JS(kmh2mps.js):%.1f m/s]" <wind> (G_CurCond, G_Wind) {channel="weatherunderground:weather:local:current#windGust"}
Actually, most of all I would like to store the wind speed in Wu_WindSpeed expressed as meters per second so I can do calculations later in my rules. That would be better than just recalculate for display purposes.
If someone could help me a bit I’d be really happy. Cheers!