Hi,
I am struggling to get a JS transformation on an mqtt channel to work although my setup seems similar to others who have managed to solve this.
I am using Openhab 2.5.
transformation-javascript - 2.5.0
binding-mqtt - 2.5.0
The mqtt channels are working correctly but incoming value is not transformed. There are no errors in the openhab logs.
I have a sensor which produces the distance to the surface of oil in a tank. I want to transform the incoming value to subtract this value from the height of the tank (900) to give me the depth of oil.
.things
Type number : oil [ stateTopic=“rtl_433/145279404/depth_cm”, transformationPattern=“JS:depth.js”]
.items
Number Oil "Oil Depth [%f cm]" { channel="mqtt:topic:Oban-MQTT:RTL_433:oil" }
depth.js
(function(i){
return 900 - i;
})(input)
Regards