Passing multiple arguments to JS Item state transformation

  • Platform information:
  • Hardware: CPUArchitecture/RAM/storage
  • OS: Windows 7 64bit
  • Java Runtime Environment: Zulu8 / Zulu17
  • openHAB version: 2.5 / 4.0

I’ve got a very general question: does a URL like syntax: JS(<scriptname>.js?arg=value) work for an Item state transformation?

Yes, use URL like syntax. But it only works on OH 4.0+, not 3.x (I think, it may work there in some circumstances) nor 2.5.

JS(<scriptname>.js>arg1=value1&arg2=value2)

Also note that if the transform is a one liner you can use an inline script. For example

JS(| Math.round(parseFloat(input)))
1 Like