How to send a HEX command on the serial port

I need to send a HEX command on the external device connected on the serial port
command is : 10H 01H FFH FFH 10H 30H F8H 02H E3H 61H FFH
I prepared this :

ind linked item is switch, but isn’t working

Do you know how to correctly configurate ?

To get any binding to transmit anything, you need to send a command to a linked Item.
There are no HEX Item types, so you’ll have to use a String type Item.

Channel and Thing settings control exactly what is done with an Item command. You might just send the command Or, you might add it to some fixed data e.g. “some fixed string” + “command content” Or you might have a transformation configured, that converts “ON” to “on” or suchlike.

You’ll need to work out what you mean by “HEX”.

Some devices work with encoded hex e.g you send four characters “A”, “6”, “B”, “7” and the target devices reads it as the sixteen bit value hex A6B7

I think most likely you are trying to send binary data though, raw bytes? Where your “xF0” represents a one-byte serial character bit pattern 11110000 on the actual wire.

As we said, there is no hex or binary Item type, and you’ll have to hide the binary in a String type. That’s about encoding, and in openHAB you’ll generally use unicode.


Doing this binary stuff is really fiddly, don’t expect an instant solution. Give clear examples of exactly what you want to send - always the same string, different strings, some blend of fixed and variable parts, etc.

external unit is expecting HEX command. Code 10H 01H FFH FFH 10H 30H F8H 02H E3H 61H FFH

I think to send this HEX code I must do it via rules and .sendcommand ?
I tested a lot of setups and try send to serial port via switch, but it’s not working. Command is alway exactly string and external unit doesn’t except it.

I readed your post many times, but it isn’t clear for me. Also in tutorial I can’t find.

Change On Value to

10H 01H FFH FFH 10H 30H F8H 02H E3H 61H FFH

Get your device to work with command line first and post results in text format.

That’s no answer, there’s more than one way to do that. We can send characters “1” “0” “H” “space” easily enough.

But you are probably looking to send binary. Binary is the keyword. Then it’s all about how to encode binary in openHAB, which is unicode.

There’s some detail about handling bytes as unicode in this post

which in your case would be something like

var testoutput = '\u0010\u0001\u00FF\u00FF ...'