Divide10.js - Openhab4 - not getting it

Hi community,

after reading the new transform how to, I’m not getting it…

I’ve such things:

Thing data AUSSENTEMPERATUR [ readStart="506", readValueType="int16", readTransform="JS(divide10.js)" ]

this is the divide10.js

// 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;
})(input)

and getting this error in the openhab.log

your code goes here2023-07-27 08:10:12.918 [WARN ] [s.internal.SingleValueTransformation] - couldn't transform response because transformationService of type 'JS' is unavailable
2023-07-27 08:10:12.922 [WARN ] [s.internal.SingleValueTransformation] - couldn't transform response because transformationService of type 'JS' is unavailable

What do I need to enter in the things file to get the value provided by modbus divided by 10 to show the correct value?

sorry for this maybe stupid question, I’m just a user and now looking thru what to change to getting things done

thanks in advance
kind regards
Christian

The error log tells you, what to do.
Install JS transformation

There is no JS transformation anymore, as far as I understood?

Correct. In OH4, to run any of the script language-based transforms you have to install the script language add-on instead. You need to install the JSScripting add-on to enable JS transforms.

In OH4 transforms can now be managed by the UI, so you can also see what transforms are currently available to you by opening the transforms settings pages and clicking on the new button to open the transform creation wizard which will have the list.

Maybe it is because you use JS scripting for a thing.
In documentation, I only see scripting for items.

thanks got it
JavaScript Scripting installed, works again

1 Like

Note, isn’t the Modbus gain offset profile intended to handle this case?

This is also potentially something that can be solved with units as well, assuming the modbus Channel were configured to return units, depending on what units are in use.