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.