How can I pass an additional argument

How can I pass an additional argument besides the on / off command when calling a javascript file in writeTransform. I need to pass the address there

.thing file

Bridge modbus:serial:localSerial [port="/dev/ttyUSB0", id=127, baud=57600,stopBits="1.0", parity="none", dataBits=8, encoding="rtu"]
        Thing data 11 [writeTransform="JS(lampONoff.js)", writeMultipleEvenWithSingleRegisterOrCoil=true]
        Thing data 12 [writeTransform="JS(lampONoff.js)", writeMultipleEvenWithSingleRegisterOrCoil=true]
        Thing data 13 [writeTransform="JS(lampONoff.js)", writeMultipleEvenWithSingleRegisterOrCoil=true]
        Thing data 14 [writeTransform="JS(lampONoff.js)", writeMultipleEvenWithSingleRegisterOrCoil=true]
        Thing data 15 [writeTransform="JS(lampONoff.js)", writeMultipleEvenWithSingleRegisterOrCoil=true]


and change the first element in the array


(function(inputData) {
    var obj = new Object();
    if (inputData== "ON"){
      obj.functionCode = 16;
      obj.address = 130;
      obj.value = [ 11, 7, 255];
      obj.maxTries = 3;
    }else if(inputData== "OFF") {
      obj.functionCode = 16;
      obj.address = 130;
      obj.value = [ 11, 7, 0 ];
      obj.maxTries = 3;
    return "[" + JSON.stringify(obj)+ "]";

.items file

Switch rele11 "Relay11" {channel="modbus:data:localSerial:11:switch" }
Switch rele12 "Relay12" {channel="modbus:data:localSerial:12:switch" }
Switch rele13 "Relay13" {channel="modbus:data:localSerial:13:switch" }
Switch rele14 "Relay14" {channel="modbus:data:localSerial:14:switch" }
Switch rele15 "Relay15" {channel="modbus:data:localSerial:15:switch" }

You can’t.

One approach could be to create a write only data thing with JS transform, and link the string channel to a String type Item. Send the Item string commands like “1234,ON” (or even JSON) and have your transform javascript parse that and convert it into the Modbus JSON

An alternative might be two data things, one for ON and one for OFF, linked to separate Number Items that you command with 1234.

You’d probably want a rule to decode openHAB commands sent to the original switches into whichever form you wanted to send to the intermediate Item(s)

The least complicated way would be to have a slightly different JS script for each switch data thing.

Does that work, out of interest? I’d always assumed thing uid’s should begin with an alpha, never tried just digits.

Yes it works.
How can I write Item string command “1234, ON”? So far, no matter how I tried to pass the value along with the command, an error came out. In the documentation did not find a similar

11:36:15.054 [WARN ] [arthome.model.script.actions.BusEvent] - Cannot convert '111,ON' to a command type which item 'rele11' accepts: [OnOffType, RefreshType].

rele11 is a Switch type Item, you cannot command it with strings.

You missed this part. If you want to send a string, you must create a String type Item.

What I’m suggesting is that you have an additional Item , “myModbusCommand” or whatever.
Link that to your write-only modbus channel with the JS transform. Do not link your Switch Items.
Have a rule that listens for commands to each of your switch Items and makes up a string to send to the string item, to be passed along to the string channel of your data thing.