I am rather new to openHAB, so please bear with me if I have overlooked something obvious.
At any rate, I am having trouble setting up an incoming tcp connection. I have an OpenHAB 2 Openhabian Raspberry pi connected by hardwire ethernet. The openhab logs seem to indicate that the incoming data is being heard by the pi, but for some reason, the data is being dumped or otherwise not passed. Here is a copy of my relevant files:
Sitemap:
sitemap default label="My home automation" {
Frame label="Default" {
Switch item=Lights icon="light"
Switch item=Lights2 icon="light" label="Lights2" mappings=[0="P/R", 1="P/H", 2="Rel"]
Switch item=test_switch_1 icon="light"
Text item=LT_receive label="LT_Receive [%s]"
}
}
Rules:
rule "LT Send Rule"
when
// only process on a switch on state
Item test_switch_1 changed to ON
then
{
var String mymessage
mymessage = "R,CTGSW,0122\r"
logInfo("openhab", "test message sent:" + mymessage)
LT_send.sendCommand(mymessage)
logInfo("openhab", "test message received:[{}]", LT_receive)
}
end
rule "LT Receive Rule"
when
// only process on a switch on state
Item LT_receive received update
then
{
logInfo("openhab", "test message received:[{}]" + LT_receive)
}
end
Items:
//Switch Lights "Test Light" { tcp=">[ON:10.1.0.251:10001:'MAP(test1.map)'], >[OFF:10.1.0.251:10001:'MAP(test1.map)']" }
//Number Lights2 "Test Light2 [%d]" { tcp=">[10.1.0.251:10001:'MAP(test2.map)']" }
Switch test_switch_1 "Test Switch 1"
String LT_send "[%s]" { tcp=">[10.1.0.251:10001:'REGEX((.*))']" }
String LT_receive "[%s]" { tcp="<[10.1.0.251:*:'REGEX((.*))']" }
tcp.cfg
# all parameters can be applied to both the TCP and UDP binding unless
# specified otherwise
# Port to listen for incoming connections
#port=25001
# 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
postamble=\r
# 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=true
# 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
Relevant openhab.log
2017-10-26 22:32:54.577 [INFO ] [lipse.smarthome.model.script.openhab] - test message sent:R,CTGSW,0122
2017-10-26 22:32:54.587 [INFO ] [lipse.smarthome.model.script.openhab] - test message received:[LT_receive (Type=StringItem, State=NULL, Label=, Category=null)]
2017-10-26 22:32:54.979 [ERROR] [b.core.service.AbstractActiveService] - Error while executing background thread TCP Refresh Service
java.lang.NullPointerException
at org.openhab.binding.tcp.protocol.internal.TCPBinding.parseBuffer(TCPBinding.java:156)[182:org.openhab.binding.tcp:1.10.0]
at org.openhab.binding.tcp.AbstractSocketChannelBinding.parseChanneledBuffer(AbstractSocketChannelBinding.java:1030)[182:org.openhab.binding.tcp:1.10.0]
at org.openhab.binding.tcp.AbstractSocketChannelBinding.execute(AbstractSocketChannelBinding.java:1766)[182:org.openhab.binding.tcp:1.10.0]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:157)[183:org.openhab.core.compat1x:2.1.0]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:169)[183:org.openhab.core.compat1x:2.1.0]
I am not sure why the data is not being passed to the script variable. Interestingly, when I comment out the first 2 items in the .items file and use .map files, tcp seems to update the incoming string variable, but due to limitations of my system, I cannot pass data using map files.