Modbus binding for hex value

i have a relay board that i comunicate via Modbus TCP protocol. All the tests from Modbus Poll works as expexted though in OH i am not able to send correct value for the particular register. For retrieving register value seems to be ok because i get 0 or 1 from the register but for sending i need to transform value to Hex. if i need to switch on I have to send 0x0100, to switch off 0x0200.
I tried writing my own transform script, but that does not seem to do the trick.

My configuration:
Thing data thermorelay1 [ readStart=“0”, readValueType=“int16”, writeStart=“0”, writeValueType=“uint16”, writeType=“holding”, writeTransform=“JS(hexvalue.js)”]

(function(inputData) {
if(inputData==1) return 256;
else return 512;


Setpoint item=thermoRelay1 label=“Termo galbva (miegamasis)” icon=“heating” step=1

Openhab transformation receives a string representation of the command.

If you have Switch items, the command will be “OFF” or “ON”, not 0/1.

This is probably your issue there although I cannot be certain as you did not share your item configuration and

this is my item:
Number thermoRelay1 “Termo pavara (miegamasis)” (gHeating) { channel=“modbus:data:thermorelaymainbridge:localbridge:thermorelay1:number” }

still no luck…

if i change my item in sitemap from setpoint to switch, i get this error:

[WARN ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at ‘items/thermoRelay1’ with an invalid status value ‘OFF’.

Well, yes. You’d have to change the Item type as well, which would also mean changing the Modbus channel used to switch type.