Door contact over TCP/Binding don’t work!

Hi all,

I installed openHAB2 on my windows laptop and I have some problems with the TCP Binding.
For interested people I have a (AVR-NET-IO-Fertigmodul ) which I want to control.
And for a Digital Output everything works very well.
I connected it to a switch with the following Item definition:

Switch Garage_Andreas   "Garage-Andreas"   <garagedoor>  {tcp=">[ON:'SETPORT 1.1'], >[OFF:'SETPORT 1.0']"}

Now I want to read a Digital Input. I connected a sensor for a door on it.
The command which I have to send is “GETPORT 1” and the answer is “0” or “1”
My question is how can I add the sensor for my door?
I think I have 2 possibilities, a String Item or a Contact Item.

What I tried is:


String  Fensterkontakt "Garage Kontakt %s" {tcp=">['GETPORT 1']"}


Text item=Fensterkontakt label="test [%s]"

But it doesn’t work.
I tried some other things with a contact or rules but nothing worked
My Rule Idea was:

rule "Garagenkontakt_Andreas"
	Time cron "* * * ? * *" 
	sendCommand(Fensterkontakt,'GETPORT 1')

Did anyone have an Idea what I do wrong?

And if I have luck maybe someone can explain me some other things:
How does the reading for sensors like a door contact work, is there a cycle that it will be read every second or do I need a rule for these kind of function?
How can I update my sitemap? I have a switch with a Rule that switch it of after 1 second ON state, but in my Sitemap (I am using google Chrome) the switch is still on until I press F5 (update). Is that a Openhub2 thing or a Chrome thing?

I’m pretty sure you have to use an inbound configuration for getting values. My guess is, to set up the item to something like this:

String  Fensterkontakt "Garage Kontakt %s" {tcp=">['GETPORT 1'], <['REGEX(().*)']"}

At least you have to configure tcp.cfg with updatewithresponse=true

Unfortunately it doesn’t work. I get back the command ‘GETPORT 1’ not the response as you can see in the picture. . And the fascinating thing is that I get the same result with to different item definitions.

My actual Items are:

Switch Garage_Andreas   "Garage-Andreas"   <garagedoor>  {tcp=">[ON:'SETPORT 1.1'], >[OFF:'SETPORT 1.0']"} 
Switch Garage_Mona   "Garage-Mona"   <garagedoor>  {tcp=">[ON:'SETPORT 2.1'], >[OFF:'SETPORT 2.0']"}
String  Fensterkontakt "Garage Kontakt %s" {tcp=">['GETPORT 1']"}
String  Fensterkontakt3 "Garage3 Kontakt %s" {tcp=">['GETPORT 2'], <['REGEX(().*)']"}

My actual Sitemap is:

 Frame label="Garage" {
   Switch item=Garage_Andreas 
   Text item=Fensterkontakt label="Sensor Andreas [%s]"	 	
   Switch item=Garage_Mona
   Text item=Fensterkontakt3 label="Sensor Mona [%s]"

And the tcp.cfg is:

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

# Port to listen for incoming connections

# 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

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

# Maximum buffer size whilst reading incoming data

# Share connections within the Item binding configurations

# Share connections between Item binding configurations

# Share connections between inbound and outbound connections

# Allow masks in ip:port addressing, e.g.* etc

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

# Post-amble that will be appended to data being sent

# 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

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

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

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

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

# Used character set

Maybe I need more time between the command and the reading?
Is the any possibility to wait maybe 500ms or do you think the problem is an other?

Sorry, typo, (displaced bracket)…


you could try to add an autoupdate="false" to the binding definition, to ensure, the sent command is not stored as state:

String  Fensterkontakt "Garage Kontakt %s" {tcp=">['GETPORT 1'], <['REGEX((.*))']", autoupdate="false"}

Thank you for the answer but nothing has changed, I have still the same behavior as in my post before.