OpenHAB 3 TCP binding

I’m also interested in a TCP binding for OH3. I use it for my door bell which is connected to a mobotix front door camera. Here my real world example.

The config file

# all parameters can be applied to both the TCP and UDP binding unless
# specified otherwise

# Port to listen for incoming connections
port=5100

# Cron-like string to reconnect remote ends, e.g for unstable connection or remote ends
#reconnectcron=0 0 0 * * ?

# Interval between reconnection attempts when recovering from a communication error,
# in seconds
#retryinterval=5

# Queue data whilst recovering from a connection problem (TCP only)
#queue=true

# Maximum buffer size whilst reading incoming data
#buffersize=1024

# Share connections within the Item binding configurations
itemsharedconnections=true

# Share connections between Item binding configurations
bindingsharedconnections=true

# Share connections between inbound and outbound connections
directionssharedconnections=false

# Allow masks in ip:port addressing, e.g. 192.168.0.1:* etc
addressmask=true

# Pre-amble that will be put in front of data being sent
#preamble=

# Post-amble that will be appended to data being sent
#postamble=\r\n

# Perform all write/read (send/receive) operations in a blocking mode, e.g. the binding
# will wait for a reply from the remote end after data has been sent
blocking=false

# timeout, in milliseconds, to wait for a reply when initiating a blocking write/read
#  operation
#timeout=3000

# Update the status of Items using the response received from the remote end (if the
# remote end sends replies to commands)
updatewithresponse=false

# Timeout - or 'refresh interval', in milliseconds, of the worker thread
refreshinterval=250

# Timeout, in milliseconds, to wait when "Selecting" IO channels ready for communication
#selecttimeout=1000

# Used character set
charset=ASCII

The items file

   Switch Klingel {tcp="<[ON:192.168.0.10:5100:'REGEX((ON))']", autoupdate="false" }

In addition I have a rule that send a push notification to the iOS App, a TTS on the echo dots and a message to the TV, so everyone will realize it in the house. :slight_smile:

I would really appreciate a new TCP binding for OH3 in order to get rid of the second OH2 installation.

Best Regards,
Marcel

As an interim measure until the TCP binding is updated for OH3 (if ever), you might consider using Node-Red. By using a TCP node which I connected to my TCP listener item in OH3 I was able to replicate the functionality of the TCP binding. I’ve only been testing it for a couple of hours but it seems pretty solid so far.

I achieved this using 2 flows. Flow 1 was a TCP In node connected to a OH-Out node which is mapped to my Elk_Bridge item. This flow receives the TCP stream and passes it to OH. Flow 2 is the OpenHAB-In node, also mapped to the Elk_Bridge item and is connected to a TCP Out node. To assist with testing, I used a debug node in place of the OH node to make sure I wasn’t going to trigger anything.

I have very little experience with Node-Red but I surprised myself with how easy this was to set up. I use openHABian so all I needed to do was install the Node-Red package using the built in config.

Of course my preference is to have less dependence on systems outside of OH, and I definitely didn’t want to run an instance of OH2 just for this alone, so I think this is a good workaround until such time (thinking optimistically here) that the TCP binding is updated. I’ll have to check, but this was the last thing holding me back from going fully OH3, so I’ll be able to progress my migration now.

1 Like

@Lukie , that is brilliant. I am now receiving data from my solar inverter into a string item and processing it with rules. I still need to do a bit of fiddling about to extract the particular fields from the data but I would have needed to do that whatever the means of ingesting the data.

I haven’t cracked how to do sending and receiving data from my EVSE charger yet. I need to look again at how you did the two way comms with the Elk_bridge.

Great as an interim but I’d still rather keep things simple and be able to communicate using a tcp binding.

I had a go using your method, which looks as though it should work for my situation. In Node-Red I see the item change when I change the string and the TCP node says it is connected but the string never appears to reach the charger. I get no response in the other flow and the status of the charger doesn’t change.

@barneyd I’m not very familiar with Node-Red but maybe this can help you. Below are my flows as well as a screenshot of how they look in the GUI. The darker green nodes with “msg.debug” in them are the debug nodes and they populate the debug window on the right hand panel. I didn’t connect the OH node until I could see things happening over there. They are currently deactivated, as symbolised by the half-hidden rectangle to the right of each node. If you’re having trouble you probably don’t want to hear this but I actually did very little configuration and it pretty much worked correctly for me on the first attempt, so there was no real troubleshooting or having to wrestle with settings to get this to work.

Hopefully the info below helps…

[
    {
        "id": "a198c74b.08af98",
        "type": "tab",
        "label": "TCP",
        "disabled": false,
        "info": ""
    },
    {
        "id": "e557f99a.4d646",
        "type": "tcp in",
        "z": "a198c74b.08af98",
        "name": "",
        "server": "client",
        "host": "192.168.1.4",
        "port": "2101",
        "datamode": "stream",
        "datatype": "utf8",
        "newline": "",
        "topic": "",
        "base64": false,
        "x": 300,
        "y": 160,
        "wires": [
            [
                "4e31965b.aae1",
                "6f67c0b2.62582"
            ]
        ]
    },
    {
        "id": "4e31965b.aae1",
        "type": "debug",
        "z": "a198c74b.08af98",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 570,
        "y": 200,
        "wires": []
    },
    {
        "id": "6f67c0b2.62582",
        "type": "openhab2-out",
        "z": "a198c74b.08af98",
        "name": "",
        "controller": "cab40e46.548e5",
        "itemname": "Elk_Bridge",
        "topic": "ItemUpdate",
        "payload": "",
        "x": 570,
        "y": 120,
        "wires": [
            []
        ]
    },
    {
        "id": "4108b948.b90148",
        "type": "openhab2-in",
        "z": "a198c74b.08af98",
        "name": "",
        "controller": "cab40e46.548e5",
        "itemname": "Elk_Bridge",
        "x": 340,
        "y": 360,
        "wires": [
            [
                "fb896b5d.ff7438",
                "688700d6.44531"
            ],
            []
        ]
    },
    {
        "id": "fb896b5d.ff7438",
        "type": "debug",
        "z": "a198c74b.08af98",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 570,
        "y": 400,
        "wires": []
    },
    {
        "id": "688700d6.44531",
        "type": "tcp out",
        "z": "a198c74b.08af98",
        "host": "192.168.1.4",
        "port": "2101",
        "beserver": "client",
        "base64": false,
        "end": false,
        "name": "",
        "x": 600,
        "y": 320,
        "wires": []
    },
    {
        "id": "cab40e46.548e5",
        "type": "openhab2-controller",
        "name": "OH3",
        "protocol": "http",
        "host": "localhost",
        "port": "8080",
        "path": "",
        "username": "",
        "password": ""
    }
]

Hello all.
I just want to join the group of persons being interested in a TCP binding for openHAB 3.

The openHAB integration of my beamer in my home theater (as I recently posted here: BenQ Beamer via RS232, Serial-to-Ethernet converter and TCP/UDP Binding) just stopped working after upgrading to OH3 yesterday.

So in case there’s anybody out there being able to create a TCP binding for OH3 he/she would be my openHAB hero of the month :wink:
(I’d do it myself if I’d knew how to)

Kind regards,
Ralph…

Hello all,
I’m also interested in the TCP/UDP binding.
As I see in this community thread some users use it in OH3.

From where do you got the executable .jar file? Have you copied it to the “addons” folder of the OH3 installation?

Thanks in advance!

Hi, I do not think there is a binding available for OH3, Lucas uses Node Red as a workaround

I’ve got a Mobotix T24 as door station.
In OH2, I’ve configure it to send a TCP command to launch a DingDong playsound command in openHAB.Today, I don’t know how to integrate it with OH3 … So I also requesting the TCP binding :slight_smile:

1 Like

I also used TCP and since the update to OH3 nothing works anymore …
I go back to OH2 forced and forced

Thanks for sharing. I’ve checked my configuration against yours and it looks the same but it’s not working for me.

The inbound is fine; if I trigger a command from a PuTTY connection, NodeRed and OpenHAB are getting the response but for the life of me, I can’t get a change in the outbound item to send the string to the device, even though the debug message shows what the TCP node should have received.

I noticed that using your method, NodeRed creates two connections to the device, one for the Tx and one for the Rx. as I’ve limited my device to two connections (for OpenHAB and PuTTY), it was a problem so I’m using the 2-way TCP node. I also tried separating the inbound and outbound items but still no luck.

Thanks again for the NodeRed solution; I’m guessing it’s something about my device.

Roll on an integrated TCP Binding!

Hi,

I’ve interest in the tcp binding for this:

Best Regards,

Hi.
I’ve opened an issue on github on posted a 50 USD bounty for developing a TCP-binding for OH3, see:
OH3 TCP-Binding 50 USD bounty

In case there are more users “really” interested in such binding please feel free to join me and add an additional bounty on Bountysource.com OH3 TCP-Binding 50 USD bounty.

Hopefully with that incentive we’ll find a friendly developer who’s knowledgeable enough and willing to help with such binding (I’d do it myself if I know how unfortunately I don’t know how).

As it appears to me: help is on its way.
As far as I understand there’s a chance it might be included as of Rel 3.1.1 milestone - see:
TCP Binding for OH3
for detail.

2 Likes

That would be great.
I also need the TCP binding!!

It seems the binding is already coded. Any hints on when it will be available?

Update:
it seems that the TCP binding (at least the one syntacrsc was referring to) is not going to be included in OH3:

Too bad. Does anyone know why?

As others this is the remaining functionality stopping progress to OH3
Ive added the jar files, created a thing with the binding but cannot get a udp rely to work. This was a simple task with OH2 and so useful.
Is it possible some further guidance could be provided.
OH2

Switch Relayt "wall plug" (All) { channel=">[ON:192.168.1.101:6723:12] >[OFF:192.168.1.101:6723:22]" }

I have not read the binding documentation, but at first sight your item is missing any binding info after the channel keyword.

You want to use the binding with OH3 ?
Where did you get the jar file from ? I am not aware of that there is a TCP binding for OH3 at least it is not available in the documentation.

actually that was the wrong item.
The switch item in OH2 is

Switch Solar_switch "wall plug" (All) { udp=">[ON:192.168.1.100:6723:12] >[OFF:192.168.1.100:6723:22]" }

I changed it to channel to try to link to the thing and channel but the thing and channel remain unitialised
this is OH3

UID: tcpudp:client:91607768db
label: TCP/UDP Client
thingTypeUID: tcpudp:client
configuration:
  protocol: UDP
  delay: 0
  port: 6723
  host: 192.168.1.100
  refresh: 30
  timeout: 3000
  bufferSize: 2048
channels:
  - id: thisrelay
    channelTypeUID: tcpudp:switch
    label: thisrelay
    description: ""
    configuration:
      onValue: "12"
      offValue: "22"