Combining JS and JSON in MQTT incoming transformation

Tags: #<Tag:0x00007f617db4ec78> #<Tag:0x00007f617db4ea98> #<Tag:0x00007f617db4e9a8>

Hello!

I am trying to get a JSON and Javascript incoming transformation to run.
If I get the mqtt message 1 on the topic i expect to get 0.2 in the item.
The result now is that I get 1 on the item after receiving the message and the error message:

2020-07-05 20:25:20.257 [WARN ] [t.generic.ChannelStateTransformation] - Transformation service  JS for pattern counter_precipitation.js not found!

I have both transformations installed.
It was working before but I did some modifications and I can’t figure out how to get it to run again.

  • Platform information:
    • Hardware: _CPUArchitecture/RAM/storage_RPi4 4GB
    • openHAB version:2.5.6.2

example mqtt message

{"Time":"2020-07-05T20:06:20","Switch1":"ON","COUNTER":{"C1":1},"BME280":{"Temperature":23.4,"Humidity":60.1,"DewPoint":15.2,"Pressure":994.6},"BH1750":{"Illuminance":0},"PressureUnit":"hPa","TempUnit":"C"}

thing

		Type number : raingauge                     "Niederschlagmesser"		 		  [stateTopic="C-BoilerRoom/tele/SENSOR", transformationPattern="JSONPATH:$.COUNTER.C1∩JS:counter_precipitation.js"]

item

Number:Length          		  OU_Garden_Rain_Gauge            		 "Niederschlag total [%.1f mm]"	           								   <rain>                           (OU_Garden, Weather)                                                                         {channel="mqtt:topic:mosquitto:cboilerroom:raingauge"}

counter_precipitation.js

(function(i) {
	if (isNaN(i)) {
		return (i);
	}
	return(i * 0.2);
}) (input)

JS javascript transformation service needs to be installed

You mean this one?
Already had this installed

I got it solved!
There was something wrong with the transformation service. It was showing that it was installed but not working.
I uninstalled it. Did a reboot and reinstalled it. Now its working. Thanks!