Just wondering what I am doing wrong with this rule…
rule “Wind speed conversion m/s to km/h”
when
Item Weather_WindSpeed_External changed
then
postUpdate(kmh, Weather_WindSpeed_External *3.6)
end
Just wondering what I am doing wrong with this rule…
rule “Wind speed conversion m/s to km/h”
when
Item Weather_WindSpeed_External changed
then
postUpdate(kmh, Weather_WindSpeed_External *3.6)
end
In general, you are not giving enough info in your post. Here some thoughts:
postUpdate
statements.Weather_WindSpeed_External.state
. Depending how you defined `Weather_WindSpeed_External’, you may also need to cast it into the type Number.@lipp_markus did a good job providing all the info needed.
I’ll throw in an example of converting Celcius to Fahrenheit in a rule.
rule "temp"
when
Item Basement_HT_Temperature received update
then
var celsius = Basement_HT_Temperature.state as Number
var Number fahrenheit = (celsius * 1.8) + 32
Basement_HT_Temperature1.postUpdate(fahrenheit)
end
Hope this helps understand some of the bullet points above e.g. the 3rd one.
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”
when
Item Weather_WindSpeed_External received update
then
var kmh = Weather_WindSpeed_External.state as Number
var Number metric = (kmh * 3.6)
Weather_WindSpeed_External1.postUpdate(metric)
end
Update: Disregard it came up, had to wait for the strategy to update