-
Notifications
You must be signed in to change notification settings - Fork 0
TCP Binding
Documentation of the TCP & UDP binding Bundle
The TCP part of the binding has a built-in mechanism to keep connections to remote hosts alive, and will reset connections at regular intervals to overcome the limitation of "stalled" connections or remote hosts.
The TCP & UDP binding bundle acts as a network client or as a network server.
For installation of the binding, please see Wiki page Bindings.
In order to bind an item to a remote host:port, you need to provide configuration settings. The easiest way to do so is to add some binding information in your item file (in the folder configurations/items`). The syntax for the TCP & UDP binding configuration string is explained here:
Note: The examples here below are for the TCP protocol. UDP binding configuration are exactly the same, one only has to substitute "tcp="
with "udp="
The format of the binding configuration is simple and looks like this:
tcp="<direction>[<command>:<ip address>:<port>:<transformationrule>], <direction>[<command>:<ip address>:<port>:<transformationrule>], ..."
where <direction>
is one of the following values:
- < - for inbound-triggered communication, whereby the openHAB runtime will act as a server and listen for incoming connections from the specified
<ip address>:<port>
-
- for outbound-triggered communication, whereby the openHAB runtime will act as a client and establish an outbound connection to the specified
<ip address>:<port>
- for outbound-triggered communication, whereby the openHAB runtime will act as a client and establish an outbound connection to the specified
where <command>
is the openHAB command. For String Items <command>
: can be omitted
where <ip address>
is the hostname or ip address in dotted notation of the remote host
and where <transformationrule>
that will be applied to the <command>
received, before the resulting string is to be sent to the remote host. For String Items the received value of the Item will be passed on to the <transformationrule>
. When data is received from the remote host, then the Item will be updated with the <command>
in so far that the result of the <transformationrule>
applied on the incoming data is valid for the given Item. String items will be updated "as is" using the result of the <transformationrule>
.
##Configuration Parameters
The TCP and UDP bindings are highly configurable through the openhab.cfg . The following parameters can be set (substitute "tcp="
with "udp="
for the UDP binding):
The indicated values are the default values used by either binding
tcp:refreshinterval=250
- This is a mandatory field in order to start up the binding - Refresh interval for the polling thread, can be used to manage oh Host CPU Load
tcp:port=25001
- This is a mandatory field when inbound communication (<direction>
equals <) are used - Port to listen on for incoming connections.
tcp:addressmask=true
- Allow masks in ip:port addressing, e.g. 192.168.0.1:**
etc
tcp:reconnectron='0 0 0 ** * ?'
- Cron-like string to reconnect remote ends, e.g for unstable connection or remote ends
tcp:retryinterval=5
- Interval between reconnection attempts when recovering from a communication error, in seconds
tcp:queue=true
- Queue data whilst recovering from a connection problem (TCP only)
tcp:buffersize=1024
- Maximum buffer size whilst reading incoming data
tcp:preamble=''
- Pre-amble that will be put in front of data being sent
tcp:postamble='\r\n'
- Post-amble that will be appended to data being sent
tcp:blocking=false
- 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
tcp:timeout=3000
- Timeout, in milliseconds, to wait for a reply when initiating a blocking write/read operation
tcp:updatewithresponse=true
- Update the status of Items using the response received from the remote end (if the remote end sends replies to commands)
The parameters here below influence the way the binding will multiplex data over TCP and UDP connections
tcp:itemsharedconnections=true
- Share connections within the Item binding configurations
tcp:bindingsharedconnections=true
- Share connections between Item binding configurations
tcp:directionssharedconnections=false
- Share connections between inbound and outbound connections
##Examples
Here are some examples of valid binding configuration strings:
tcp=">[ON:192.168.0.1:3000:'MAP(my.device.map)')], >[OFF:192.168.0.1:3000:'MAP(my.device.map)']" // for a Switch Item where values are converted using the my.device.map
tcp="<[192.168.0.2:3000:'REGEX((.*))']" // for a String Item that captures some state of a remote device that connects to openHAB
###Linux / OS X
###Windows
- Cosm Persistence
- db4o Persistence
- Exec Persistence
- InfluxDB Persistence
- JDBC Persistence
- JPA Persistence
- Logging Persistence
- mapdb Persistence
- MongoDB Persistence
- MQTT Persistence
- my.openHAB Persistence
- MySQL Persistence
- rrd4j Persistence
- Sen.Se Persistence
- SiteWhere Persistence
- AlarmDecoder Binding
- Anel Binding
- Arduino SmartHome Souliss Binding
- Asterisk Binding
- Astro Binding
- Autelis Pool Control Binding
- BenQ Projector Binding
- Bluetooth Binding
- Bticino Binding
- CalDAV Binding
- Comfo Air Binding
- Config Admin Binding
- CUL Binding
- CUL Intertechno Binding
- CUPS Binding
- DAIKIN Binding
- Davis Binding
- Denon Binding
- digitalSTROM Binding
- DMX512 Binding
- DSC Alarm Binding
- DSMR Binding
- eBUS Binding
- Ecobee Binding
- EDS OWSever Binding
- eKey Binding
- Energenie Binding
- EnOcean Binding
- Enphase Energy Binding
- Epson Projector Binding
- Exec Binding
- Freebox Binding
- Freeswitch Binding
- Frontier Silicon Radio Binding
- Fritz AHA Binding
- Fritz!Box Binding
- FS20 Binding
- Global Cache IR Binding
- GPIO Binding
- HAI/Leviton OmniLink Binding
- HDAnywhere Binding
- Heatmiser Binding
- Homematic / Homegear Binding
- HTTP Binding
- IEC 62056-21 Binding
- IHC / ELKO Binding
- ImperiHome Binding
- Insteon Hub Binding
- Insteon PLM Binding
- IPX800 Binding
- IRtrans Binding
- jointSPACE-Binding
- KNX Binding
- Koubachi Binding
- LCN Binding
- LightwaveRF Binding
- Leviton/HAI Omnilink Binding
- Lg TV Binding
- Logitech Harmony Hub
- MailControl Binding
- MAX!Cube-Binding
- MAX! CUL Binding
- MiLight Binding
- MiOS Binding
- Modbus TCP Binding
- MPD Binding
- MQTT Binding
- MQTTitude binding
- Neohub Binding
- Nest Binding
- Netatmo Binding
- Network Health Binding
- Network UPS Tools Binding
- Nibe Heatpump Binding
- Nikobus Binding
- Novelan/Luxtronic Heatpump Binding
- NTP Binding
- One-Wire Binding
- Onkyo AV Receiver Binding
- Open Energy Monitor Binding
- OpenPaths presence detection binding
- OpenSprinkler Binding
- OSGi Configuration Admin Binding
- Panasonic TV Bindung
- panStamp Binding
- Philips Hue Binding
- Piface Binding
- pilight Binding
- Pioneer-AVR-Binding
- Plex Binding
- Plugwise Binding
- PLCBus Binding
- Primare Binding
- Pulseaudio Binding
- RFXCOM Binding
- RWE Smarthome Binding
- Sager WeatherCaster Binding
- Samsung AC Binding
- Samsung TV Binding
- Serial Binding
- Sallegra Binding
- Satel Alarm Binding
- Sinthesi Sapp Binding
- Snmp Binding
- Somfy URTSI II Binding
- Sonos Binding
- Squeezebox Binding
- Swegon ventilation Binding
- System Info Binding
- TA CMI Binding
- TCP/UDP Binding
- Tellstick Binding
- TinkerForge Binding
- Tivo Binding
- VDR Binding
- Velleman-K8055-Binding
- Wago Binding
- Wake-on-LAN Binding
- Waterkotte EcoTouch Heatpump Binding
- Weather Binding
- Wemo Binding
- Withings Binding
- XBMC Binding
- xPL Binding
- Yamahareceiver Binding
- Zibase Binding
- Z-Wave Binding
- Asterisk
- Google Calendar
- Linux Media Players
- ROS Robot Operating System
- Telldus Tellstick
- Zoneminder
- Wink Hub (rooted)
- Wink Monitoring
- Transformations
- XSLT
- JSON
- REST-API
- Security
- Service Discovery
- Voice Control
- BritishGasHive-Using-Ruby
- Dropbox Bundle
A good source of inspiration and tips from users gathered over the years. Be aware that things may have changed since they were written and some examples might not work correctly.
Please update the wiki if you do come across any out of date information.
- Comfo Air Binding
- Ecobee Examples
- Nest Examples
- Rollershutter Bindings
- Squeezebox
- WAC Binding
- WebSolarLog
- Alarm Clock
- Convert Farenheit to Celcius
- The mother of all lighting rules
- Reusable Rules via Functions
- Combining different Items
- Items, Rules and more Examples of a SmartHome
- Google Map
- Controlling openHAB with Android
- Usecase examples
- B-Control Manager
- Spell checking for foreign languages
- Flic via Tasker
- Chromecast via castnow