Connect to tcp socket for request/response openhab 3

How can I talk to a tcp socket for a simple json request/response using openhab 3.

I have a homegrown internal IOT setup that I have put together over the years from devices like RS232 serial connected Microchip 1684 to ethernet arduino nano to wifi wemos boards. I have alway done straight request/response devices so all my devices are controlled by a simple C program but can be controlled via any programming language due to the simple json request/response interface. eg: via shell:

$ echo ‘{ “cmd” : “ON”, “channel” : 0, “time” : 30 }’ | nc -w 2 relay1 2000
{“result”: 0, “error” : “OK” }
$ echo ‘{ “cmd” : “STATUS”, “channel” : 0 }’ | nc -w 2 relay1 2000
{“result”: 0, “error” : “OK”, “state”: 1, “remain”: 25 }

I am on an expansion plan now so to try and make my life easier I have installed openhab 3 on a RPI3 B+. I have configured a basic setup using the UI with a dummy thing using the mqtt_binding that I can control with the mosquito_[sub|pub] CLI commands but now I am stuck on how to talk to all my existing devices. Is there a basic tcp request/response binding that I missed or some other binding that would be appropriate.
I know I can reflash some devices with more generic code like tasmota but this isnt a solution to all.

For a similar case that I have I am using the execututeCommandLine command to call a shell script.
You also may have a look at the exec binding.

After a whole bunch more research I did come across the Exec binding so if thats the only option then I will take a look.

Thanks.

The REST API uses http and JSON. If that helps. The UI uses the API.

Ok, I now have a simple script that does the following:

/usr/local/bin/sdevice ON
ON
/usr/local/bin/sdevice STAT
ON
/usr/local/bin/sdevice OFF
OFF

As I have no openhab2 experience so I am trying to use the UI to configure my exec bindings but have failed dismally. I created 2 things using the exec binding using the following:

Label Device On
Command /usr/local/bin/sdevice ON
Transform REGEX((.*))
Interval 0
Timeout 15
Autorun off

and another…

Label Device On
Command /usr/local/bin/sdevice OFF
Transform REGEX((.*))
Interval 0
Timeout 15
Autorun off

I have set up the misc/exec.whitelist as defined in doco. I dont think I need any channels…
I am now trying to work out what to do for the items to make my script work as a switch but nothing I try runs the script and no events in the log.

OOPS… Sorry for the shouting, I used a ‘#’ as a unix prompt…

I do not have the link handy but that should be in code fences. Without them the forum eats spaces and does other formatting.

You should be able to click the pencil icon and edit the post.