Problem with graaljs script transformation in .things file

Hi there,

i migrated to 4.0.0.M1 an hour ago.
Did all the “before installation” steps mentioned here and its working so far.
But i cannot get my js transformations to work again with the modbus binding.

My .items file looks like this at the moment:

Thing data LWZ_RaumIstTemperaturHK1             "LWZ404SOL Raum IstTemperatur HK1"          [ readStart="0",  readValueType="int16", readTransform="SCRIPT(graaljs:divide10.script)" ]

I’ll tried different approaches in the readTransform but i still get the following error:

2023-03-12 18:14:59.585 [ERROR] [s.internal.SingleValueTransformation] - transformation throws exception [transformation=SCRIPT(graaljs:divide10.script), response=230]
org.openhab.core.transform.TransformationException: Could not get script for UID 'divide10.script'.

The divide10.script file is there. It looks like this:

(function(data) {
	var DIVIDE_BY = 10;
	return parseFloat(data) / DIVIDE_BY;
    })(input)

What am i missing?
Thanks for your help.

where did you store the script file? Should be in the transform/ folder.

Hi Udo,

yes the file is in the transform/ folder. I renamed it from .js to .script. the folder stays the same.

In a Thing shouldn’t it be the following?

SCRIPT:graals:divide10.script

i already tried this. the error is the same:

[ERROR] [s.internal.SingleValueTransformation] - transformation throws exception [transformation=SCRIPT:graaljs:divide10.script, response=188]
org.openhab.core.transform.TransformationException: Could not get script for UID 'divide10.script'.

and to confirm … the file seems to me in the right spot:

Assuming openHAB-conf is the config folder OH is working off of that looks correct. I know others have managed to get the transformation to work. Maybe there is something unique about that binding? Or maybe the file permissions are off and OH can’t read the file?

I use the official modbus binding https://home.myopenhab.org/settings/addons/binding-modbus

The path didn’t changed for years.

Ok my fault. a simple restart did the trick.

The correct syntax is

Thing data LWZ_RaumIstTemperaturHK1             "LWZ404SOL Raum IstTemperatur HK1"          [ readStart="0",  readValueType="int16", readTransform="SCRIPT:graaljs:divide10.script" ]

Thanks for your help. And sorry for bothering :wink:

Regards
Gunnar

I opened an issue for this a few days ago. It will be fixed in OH 4. For now, when adding a new transformation file of any type, not just SCRIPT, a restart of OH is required to recognize it.