TCP connect with custom HW device

Hi people, i pretty much new arround here, so i would i appriciate some beginners tips. As i said i have custom hardware that runs on tcp and sending some information. So, my question is , what all i should set up (items,openhab.cfg…), to get info from device to openhub server. My idea is to print recieved massage or save it. Can someone explain me through example whole process?
Thank you!

Please see the TCP binding wiki page.

First I would recommend spending some time on the wiki and playing around with the Demo.

OH is a very complicated home automation hub that allows one to connect to and orchestrate over 100 different technologies. If all you want to do is “print received message or save it” you would be better served to write a Python (or your language of choice) script.

However, if your device is a sensor whose value can be used to drive some automated processes (e.g. a thermometer whose value can be used to turn on or off the heater, a motion sensor to turn on some lights, etc) OH is a good place to be.

But, like I said, OH is big and complex. There really isn’t such a thing as an end to end explanation for the whole process because everyone’s setup is different. But a very high level outline could be:

  1. Install openHAB (see the wiki for Linux apt-get instructions)
  2. Download, install and get the Demo working.
  3. Experiment with the Demo along with reading the wiki to figure out Items, Rules, Sitemap, and Persistence. These four things are the core of how OH works. Without understanding of how these interact with each other you will not get far.
  4. Install and configure the TCP Binding for your device
  5. Create Items and Rules to read in and process the data from your device

Please see the TCP binding wiki page.

First I would recommend spending some time on the wiki and playing around with the Demo.

OH is a very complicated home automation hub that allows one to connect to and orchestrate over 100 different technologies. If all you want to do is “print received message or save it” you would be better served to write a Python (or your language of choice) script.

However, if your device is a sensor whose value can be used to drive some automated processes (e.g. a thermometer whose value can be used to turn on or off the heater, a motion sensor to turn on some lights, etc) OH is a good place to be.

But, like I said, OH is big and complex. There really isn’t such a thing as an end to end explanation for the whole process because everyone’s setup is different. But a very high level outline could be:

  1. Install openHAB (see the wiki for Linux apt-get instructions)
  2. Download, install and get the Demo working.
  3. Experiment with the Demo along with reading the wiki to figure out Items, Rules, Sitemap, and Persistence. These four things are the core of how OH works. Without understanding of how these interact with each other you will not get far.
  4. Install and configure the TCP Binding for your device
  5. Create Items and Rules to read in and process the data from your device

Thank you for replay. I managed to recieve data from my device. But have problems with ports, more precise:
when i set
tcp:port=50000
and
{ tcp="<[192.168.1.107:*:‘REGEX(.*))’]" }
it connects but ends up with
java.lang.NullPointerException: null
at org.openhab.binding.tcp.AbstractSocketChannelBinding$Channel.(AbstractSocketChannelBinding.java:139) ~ [na:na]
at org.openhab.binding.tcp.AbstractSocketChannelBinding.execute(AbstractSocketChannelBinding.java:1193) ~ [na:na]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) ~ [na:na]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) ~ [na:na]

But when i do this
{ tcp="<[192.168.1.107:50001:‘REGEX(.*))’]" }
and try to connect on port 50 000 it says unallowed remote end 192.168.1.107:54453(and every connect attempt, it changes port), so if i specify port (50001) i cant connect coz every connect it changes port?
Te be clear, tcp:port, is is just for establishing conn? and they latter use another port(50001 or other) for communication or im wrong? I have simple software that reacts like client, and when i try connect on 50000, it connects but then soft says connection closed.
So my only idea is that tcp:port usses only for establishing connection,and after that they use another port. Who to fix this? Star * works, but what with exeptions…
Thank you anyway!

Please read theTCP/UDP Binding Wiki page Particularly the Configuration Parameters section where it states:

tcp:port=25001 - This is a mandatory field when inbound communication ( equals <) are used - Port to listen on for incoming connections.

The tl;dr version is that for incoming TCP connections you have configuration paramters you have to put into openhab.cfg in addition to your Item binding configuration.

In your case the port will be 50001 instead of 25001.

I found the solution. It was my stuped mistake, in openhab.cfg i did just
tcp:addressmask=true // i removed only #
instead
192.168.1.0:255.255.255.0=true
I though that those are constants :smiley:
Keep in touch for future advices :smiley:
Thank you!