Hi - I’m very new to OH and am trying to create a UDP item that will represent a sensor on a remote node. The sensor will send an update from a specific IP address and port; as there may be more than 1 sensor connected to the node I think the port is required to identify the actual sensor.
I modified the openhab.cfg file to have the following
# UDP parameters ™
net_addr(“127.0.0.1”)udp:updatewithresponse=false
pd:charset=ASCII
udp:port=9000
The item definition is
String Garage_Back_Door “Back Door [%s]” (Garage)
{
udp="<[192.168.0.100:7892:‘REGEX((.*))’]"
}
OH startup shows
2016-07-27 11:32:17.033 [INFO ] [.service.AbstractActiveService] - UDP Refresh Service has been started
2016-07-27 11:32:17.034 [INFO ] [t.protocol.internal.UDPBinding] - The maximum time out for blocking write operations will be set to the default vaulue of 3000
2016-07-27 11:32:17.036 [INFO ] [t.protocol.internal.UDPBinding] - The blocking nature of read/write operations will be set to the default vaulue of false
2016-07-27 11:32:17.042 [INFO ] [t.protocol.internal.UDPBinding] - The preamble for all write operations will be set to the default vaulue of
2016-07-27 11:32:17.043 [INFO ] [AbstractDatagramChannelBinding] - We will accept data coming from the remote end /192.168.0.100:7892
2016-07-27 11:32:17.044 [INFO ] [t.protocol.internal.UDPBinding] - The postamble for all write operations will be set to the default vaulue of
2016-07-27 11:32:17.052 [INFO ] [t.protocol.internal.UDPBinding] - The characterset will be set to the default vaulue of ASCII
When I send a test message from a client I get
2016-07-27 11:35:34.029 [WARN ] [AbstractDatagramChannelBinding] - Received data test
from an undefined remote end /192.168.0.100:7892. We will not process it
2016-07-27 11:35:34.032 [WARN ] [AbstractDatagramChannelBinding] - No channel is active or defined for the data we received from /192.168.0.100:7892. It will be discarded.
If I modify the item to use * for the port
String Garage_Back_Door “Back Door [%s]” (Garage)
{
udp="<[192.168.0.100::'REGEX((.))’]"
}
I get the following from the OH refresh
-27 11:37:10.227 [WARN ] [AbstractDatagramChannelBinding] - When using address masks we will not verify if we are already listening to similar incoming connections
2016-07-27 11:37:10.231 [INFO ] [AbstractDatagramChannelBinding] - We will accept data coming from the remote end 192.168.0.100:*
2016-07-27 11:37:10.234 [INFO ] [AbstractDatagramChannelBinding] - We will accept data coming from the remote end with mask 192.168.0.100:*
Running the test client now shows
2016-07-27 11:38:42.143 [INFO ] [runtime.busevents ] - Garage_Back_Door state updated to test
and the browser shows the item receiving the new “test” status
If I now change the item back to port 7892 the refresh shows
2016-07-27 11:42:04.075 [INFO ] [.service.AbstractActiveService] - UDP Refresh Service has been started
2016-07-27 11:42:04.079 [INFO ] [AbstractDatagramChannelBinding] - We will accept data coming from the remote end /192.168.0.100:7892
Running the test client produces
2016-07-27 11:43:01.995 [ERROR] [t.protocol.internal.UDPBinding] - transformation throws exception [transformation=null, response=test2
]
java.lang.NullPointerException: null
at java.util.regex.Matcher.getTextLength(Matcher.java:1283) ~[na:1.8.0_65]
at java.util.regex.Matcher.reset(Matcher.java:309) ~[na:1.8.0_65]
at java.util.regex.Matcher.(Matcher.java:229) ~[na:1.8.0_65]
at java.util.regex.Pattern.matcher(Pattern.java:1093) ~[na:1.8.0_65]
at org.openhab.binding.tcp.protocol.internal.UDPBinding.splitTransformationConfig(UDPBinding.java:236) [bundlefile:na]
at org.openhab.binding.tcp.protocol.internal.UDPBinding.transformResponse(UDPBinding.java:254) [bundlefile:na]
at org.openhab.binding.tcp.protocol.internal.UDPBinding.parseBuffer(UDPBinding.java:150) [bundlefile:na]
at org.openhab.binding.tcp.AbstractDatagramChannelBinding.parseChanneledBuffer(AbstractDatagramChannelBinding.java:998) [bundlefile:na]
at org.openhab.binding.tcp.AbstractDatagramChannelBinding.execute(AbstractDatagramChannelBinding.java:1505) [bundlefile:na]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) [org.openhab.core_1.8.3.jar:na]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) [org.openhab.core_1.8.3.jar:na]
2016-07-27 11:43:02.014 [INFO ] [runtime.busevents ] - Garage_Back_Door state updated to test2
However the status of the item is NOT updated; despite the statement in the OH output.
Am I doing something wrong in the configuration or transformation or ??
Any suggestions are much appreciated
Tom