Serial Binding with KMTronic USB Relay Controller

Hi guys,
I really need your help configuring a KMTronic USB Relay Controller (USB Relay Controller - Eight Channel with clips for DIN mount rail) with OpenHAB Serial Binding.

My platform is:

  • Ubuntu 22.04.2 LTS
  • openHAB 3.4.2

The controller is connected via the /dev/ttyKMT port and running the commands from Bash:

echo -e "\xff\x01\x01" > /dev/ttyKMT

or

echo -e "\xff\x01\x00" > /dev/ttyKMT

I’m able to turn on or turn off the first switch on the relay controller, even without “sudo”.

The linux user used for launching the Bash commands is member of “tty” and “dialout” group, like the “openhab” user.

I configured the openHAB Serial Bridge and Serial Device in a serial.thing file:

Bridge serial:serialBridge:sensors [serialPort="/dev/ttyKMT", baudRate=9600] {
        Thing serialDevice usbrelay [patternMatch=".*"] {
                Channels:
                        Type switch : r1 [onValue="\\xff\\x01\\x01", offValue="\\xff\\x01\\x00"]
        }
}

But… firing the switch linked to r1 doesn’t work! :frowning_with_open_mouth:

The led on the serial controller flashes but nothing happens, so I guess I’m sending a wrong command.

I’ve also tried with (for ON command):

  • “ff 01 01”
  • “255 1 1”

Do you have any suggestions?

Any help is appreciated!

I managed to take a significant step forward.

I recreated the Serial Bridge from the GUI as follows:

As you see i put ISO-8859-1 in the charset.

I then assigned a string item to channel “String Data” (AAA_Serial_Bridge_String_Data)

I then created a simple script in the openHAB GUI to send the command to the string item:

AAA_Serial_Bridge_String_Data.sendCommand('\u00FF\u0001\u0001')

In this way I’m able to send the FF 01 01 command to turn on the first relay.

If, on the other hand, I want to turn off the first relay, I send the command:

AAA_Serial_Bridge_String_Data.sendCommand('\u00FF\u0001\u0000')

In this way it works fine! :smiley:

Since the communication from openHAB works, I want to control the relays using an item switch.

I’ve created a Serial Device from GUI as follows:

In the Channel tab I’ve linked a Switch:

I’ve configured the Channal as follows:

But nothing happens when I turn the switch On or Off…

Any suggestions?

Thanks!