[SOLVED]OH 3.0.1 UI Transformation Modbus

Hi All

OH 3 is really great. Thanks everybody.

I’m working with the Modbus binding trying to add a transformation to my Modbus Data Thing on read.
The data Thing returns the expected value 2420 which I want to divide.
I’m using the example from the Modbus binding page:

// Wrap everything in a function (no global variable pollution)
// variable “input” contains data passed by openHAB
(function(inputData) {
// on read: the polled number as string
// on write: openHAB command as string
var DIVIDE_BY = 10;
return parseFloat(inputData) / DIVIDE_BY;

having put “JS:divide100.js” in the “read transform” field in the Modbus Data Thing finds the transform fine but still is giving me the following error in the openhab.log:

2021-02-08 19:36:15.756 [WARN ] [ernal.handler.ModbusDataThingHandler] - Channel number will not be updated since transformation was unsuccessful. Channel is expecting the following data types [DecimalType, QuantityType, UnDefType]. Input data: number value 2420 (value type ‘int16’ taken into account) and bool value true. Transformation: Transformation@d98df6[tranformation=JS:divide100.js,transformationServiceName=,transformationServiceParam=]

The description text in the Modbus Data Thing by the read transform field says this:

Transformation to apply to polled data, after it has been converted to number using readValueType

Use “default” to communicate that no transformation is done and value should be passed as is.
Use SERVICENAME(ARG) to use transformation service.
Any other value than the above types will be interpreted as static text, in which case the actual content of the polled value is ignored.
But when trying to enter anything but what I have put in the field it gives me an error saying that it can not find the transform service.

Anybody have an idea what I’m doing wrong or have an idea to what I could try out to proceed?’’

Thanks in advance everybody


Did you install the add-on JS transformation service?

Hi Rossko57

Yes the Javascript Transformation 3.0.1 is installed


Hi Again

Solved it my self.
Aparently the way it has to be entered in the UI transform field is:

JS(divide100.js) and not JS:divide100.js

This made it work

Oh, yes! It’s in the hint as well :frowning:

Yes it indeed is. I just didn’t understand it. did not know that SERVICENAME meant Java Script Service ea. JS and didn’t know that ARG meant the script file from the transform folder.
I would add that to the hint text if I could and maybe add an example like JS(divide10.js) that I think would have helped me understand :slight_smile:

Thanks everyone for a fantastic product.
Regards Jesper

For posterity…in the future release both will be supported [modbus] Modbus transformations: cascaded/chained transformations and new-style transformation string by ssalonen · Pull Request #9945 · openhab/openhab-addons · GitHub


Hi friend,

I am trying exactly this. I have my function ready and tested in JavaScript Tester online and I know where call the function but I don’t know where save my function code.

Thanks a lot.

In your transform folder.

There should be an option in the UI, right? How?