I am using OpenHab 2.5.5
Do transform:JS profiles on items only work if the receiving item is a string and the incoming Channel delivers a string? I have been fiddling for the past hour and this seems to be the only combination that works.
The examples are all with String items, but I never saw it documented that it would not work with Number items. It would be quite convenient
Transformation services of any type only handle strings in and strings out.
When you call a transform, the service automatically converts the input parameter to a string.
Maybe it’s a channel state update, maybe it’s raw device data, maybe it’s a display state, depending on the context you are using the transform in.
Doesn’t matter, it gets delivered to the transform as a string.
(So you might have to parse it to a number inside the transform etc.)
When the transform returns a result, it is always converted to a string.
What happens next again depends on context. When used in a binding for example, the binding may want to use the return to feed a number channel update. The binding has to take care of parsing the returned string into the desired new number form.
The transform profile does not currently do anything with the return string. So it is only suitable as a state update for a String type Item.