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
// 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