Conversion from m/s to km/h, what am I doing wrong?

Just wondering what I am doing wrong with this rule…

rule “Wind speed conversion m/s to km/h”


Item Weather_WindSpeed_External changed


postUpdate(kmh, Weather_WindSpeed_External *3.6)


In general, you are not giving enough info in your post. Here some thoughts:

  • I think you need to look into transformations ( rather than doing this in your rule.
  • You did not post any errors, but I am not aware that you can do math in postUpdate statements.
  • Please remember all items are objects, if you want to access the state of them, you need to specifically do so, e.g., Weather_WindSpeed_External.state. Depending how you defined `Weather_WindSpeed_External’, you may also need to cast it into the type Number.
  • And, is kmh an item? Or something else?
  • As a follow-up you may want to post all relevant item definitions.
1 Like

@lipp_markus did a good job providing all the info needed. :+1:

I’ll throw in an example of converting Celcius to Fahrenheit in a rule.

rule "temp"
	Item Basement_HT_Temperature received update
	var celsius = Basement_HT_Temperature.state as Number
    var Number fahrenheit = (celsius * 1.8) + 32



Hope this helps understand some of the bullet points above e.g. the 3rd one. :wink:


Thank you for the info, will read up on your suggestions.


This worked !

So here is my working rule however there is one problem, Weather_Windspeed_External1 does not seem to be able to be found in Grafana ?. When I mean found it does not come up in the selection as per below…

I did add Weather_Windspeed_External1 to my persist file.

rule “Convert m/s to km/h”


Item Weather_WindSpeed_External received update 


var kmh = Weather_WindSpeed_External.state as Number

var Number metric = (kmh * 3.6)



Update: Disregard it came up, had to wait for the strategy to update :frowning: