I am using a transformation to remove the unit from an item before sending it to the thing.
I am 99% certain that everything was working fine until, maybe, when I upgraded to 4.3.
Thing relevant code
- id: Set-Point
channelTypeUID: mqtt:number
label: Set Point Heating
description: Temperature set point
configuration:
unit: °F
min: 50
formatBeforePublish: '{"value":%d}'
transformationPatternOut:
- config:js:21024793d7
max: 80
commandTopic: zwave/Living_Room/Thermostat/67/0/setpoint/1/set
stateTopic: zwave/Living_Room/Thermostat/67/0/setpoint/1
transformationPattern:
- JSONPATH:$.value
The function (transformation) I am using is
(function(data) {
var returnValue = data.split(" ");
return returnValue[0]
})(input)
And the error is
20:37:17.144 WARN org.openhab.core.thing.binding.generic.ChannelTransformation$TransformationStep Failed to use TransformationStep{serviceName='CONFIG', function='js:21024793d7'}, service not found
Please change your transformationPatternOut from config:js:21024793d7 to JS(config:js:21024793d7) - but JS:config:js:21024793d7 would also work. Both JS(xxx) and JS:xxx are supported syntaxes.
That fixed it. I am sure this was working when I set it up, because this was the first time writing a function other than additions or subtractions and I needed to make sure it was working. But maybe I followed the correct syntax then and later I made some edits and used the copy UID link and pasted the value in the thing channel configuration
I need to take a look at my other transformations.
I tested your original config in 4.2.3 - it didn’t work either. It too issued the exact same warning in the log.
The only difference is that in 4.2.3 when the transformation failed, it would pass through the original data, untransformed. In 4.3, the untransformed data is discarded and not sent out.
Since your transformation is subtle, you might not have noticed the issue.
This configuration is correct. You’ve selected the profile transformation type as “ECMAScript”, so inside “Thing to Item Transformation” you just need to enter the transformation function (in this case the transformation uid)
In file-based config, you’d have written the profile as something like this:
Also another tip: you can, and probably should, name your transforms with a descriptive id. So instead of 21024793d7, you could call it extract_first_word. This would make for a much more readable config
I was under the impression that most zwave thermostats understand units (maybe yours is different). It is part of Silab spec. I don’t use a transform and they work fine.
I am starting to think that you are right and that I overthought the issue from the beginning.
If my transformation was always ignored and the string was sent without removing the units, then I have to conclude that the thermostat understood the command. The problem arose when Openhab 4.3 started discarding the command when it could not process the transformation.