[SOLVED] JS after JSON transformation in stateTransformation (and commandTransformation)


I am struggling with transformation of a channel, it is probably a small syntax thing.
So I hope someone is able to help my out here.

I have a sitemap with the following line:
Text item=ToonThermostaatCurrentTemp label="Current Temperature [JS(div100.js):%.1f °C]"
Works fine: content of item is divided by 100, and I used it as proof that my JS transformation is working.

Now I would like to add that transformation to a channel (after json transformation), and I tried this:
stateTransformation: JSONPATH:$.currentSetpoint ∩ JS:div100.js

But then I get an error:
2021-04-05 10:41:16.643 [WARN ] [.transform.SingleValueTransformation] - Transformation service JS for pattern div100.js not found!

What I am trying to achieve:
I use a Thing from the http binding to get json from my thermostat. The thermostat setpoint is provided as 2000. I would like to transform that to 20,00 and put it as a setpoint on a sitemap. And yes, It indeed means I need to multiply the number with 100 again when sending the setpoint to the thermostat :slight_smile:

What binding are we talking about here?

This means that openHAB thinks that the JS Transformation Service isn’t installed. If you think it is, uninstall it, then re-install it.

1 Like

I did un-install and re-install the JS transformation just to be sure but that unfortunately does not solve the problem

Where did you put that, how did you put that? I’m thinking about possibly quotemarks, brackets, and encoding here (there is the funny bridge character for example).

I placed it in the YAML in the web interface:

UID: http:url:Toon_Thermostaat
label: Toon Thermostaat
thingTypeUID: http:url
  authMode: BASIC
  ignoreSSLErrors: false
  baseURL: http://toon.familie-dokter.lan/happ_thermstat
  refresh: 60
  commandMethod: GET
  timeout: 3000
  bufferSize: 2048
  - id: currentTemp
    channelTypeUID: http:number
    label: Toon Current Temperatuur
    description: ""
      stateExtension: ?action=getThermostatInfo
      stateTransformation: JSONPATH:$.currentTemp
  - id: currentSetpoint
    channelTypeUID: http:number
    label: Toon Current Setpoint
    description: null
      stateExtension: ?action=getThermostatInfo
      stateTransformation: JSONPATH:$.currentSetpoint ∩ JS:div100.js

(there is more channels after these)

I “copied/pasted” the union symbol from the documentation :slight_smile:

Try it without the spaces? It may not be obvious if it is searching for a " JS" service.

1 Like

That’s it!
That did the trick…

      stateTransformation: JSONPATH:$.currentSetpoint∩JS:div100.js