Using JS to MQTT return value

I have an item configured:

UID: mqtt:topic:8b07ced21b:fc1c2de3e2
label: Efergy E2
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:8b07ced21b
channels:
  - id: energy_kWh
    channelTypeUID: mqtt:number
    label: Energiankulutus
    description: ""
    configuration:
      stateTopic: rtl_433/602024/energy_kWh
      transformationPattern: JS(divByTwo.js):%f
      unit: kWh

And a js script is in the folder (and transformation enabled):

(function(f){
        return f / 2;
})(input)

But openhab gives me an error:

2021-08-28 00:28:13.509 [WARN ] [t.generic.ChannelStateTransformation] - Transformation service JS(DIVBYTWO.JS) for pattern %f not found!

Can anybody tell me what is wrong with my config?

Syntax error

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.