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
lampONoff.js
(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)+ "]";
})(input)
.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" }