Number Item: JavaScript transformation in Profile

I’m trying to modify a numeric value received e.g. by the darksky binding by a simple multiplication.
My assumption was that this should be easy by using a profile using the JavaScript transform as shown below.

My item definition is:

Number:Speed localDailyForecastTodayRainIntensity "Rain intensity for today [%.2f mm/h]" <rain> { channel="darksky:weather-and-forecast:api:local:forecastToday#rain"  [profile="transform:JS", function="multiply24.js"]}

The JavaScript Transformation is installed and active.

The “multiply24.js” (Don’t be confused by the name, I’ve stripped the script down during debugging…)

(function(i) {
    var logger = Java.type("org.slf4j.LoggerFactory").getLogger("multiply24.js");
    logger.warn(typeof i);
    logger.warn(i);
/*    return i * 24; */
    return "0.7";
})(input)

The relevant log output is:

2020-06-06 19:13:04.580 [WARN ] [multiply24.js                       ] - string
2020-06-06 19:13:04.582 [WARN ] [multiply24.js                       ] - 0.2864 µ(km/h)

so it looks like the transform is called and running.

Anyhow I did not find a solution in returning the correct format.
Neither string (return “0.7”) nor a numeric value (return 0.7) is accepted. In either case the item is not updated.

When changing the item type from “Number:Speed” to “String” everything is working as expected - but I need a numeric item…

Does anyone have a clue on how to achieve this?

Regards
Dirk

Maybe keep the item as a string and use a short rule?

rule "number"
when
    Item yourStringItem changed
then
    var Number rain = yourItem.state
    YourNumberItem.postUpdate(rain)
end

@rossko57

What a shame - I added my support for your request…

@H102

Thanks for your proposal.
But then I could also leave out the transformation and just do the manipulation in a rule where both items are numeric types - maybe a bit easier.