KNX wind speed transformation does not work after moving to OH 3.1.0

I tried to activate js transformation to calculate km/h out of ms wind speed from KNX wind sensor.

Here my javascript
return kmh.toString();

I enabled javascript transformation

I defined in the channel the following

and in the sitemap I changed the 2.5.6 entry like this

159 showing the old value 158 the new one

As a result I receive the bare ms value, not calculated and not formatted as written in the State formatter

I can’t highlight it because you used screenshots instead of code fences, but you’ve given the profile a formatter %.2f km/h I think?
That is going to format the plain number coming from your channel into “nn.nn km/h” before it gets to JS.
The JS will fail, because it can’t do maths on the string “nn.nn km/h”.

Don’t do that, just use %s format

Ok, so formatter is on the input side and before any script.
I changed and ist works now, thanks
Problem solved

1 Like