Having difficulty getting a simple UDP output binding to work on openHAB2.
Had this working on openHAB1, but want to switch to the latest code base (Downloaded the 2.0.0 snapshot yesterday. May 14, 2016).
Have a sitemap file with my group in and am able to see this item in the basic web UI.
However, when I click on the switch icon, I don’t see any UDP messages sent out (checking via wireshark, and also on my remote device). But I do see this error in the logfile:
2016-05-14 21:37:42.841 [ERROR] [g.tcp.AbstractDatagramChannelBinding] - there is no channel that services [itemName=MySwitch1, command=ON]
Note1: I see a similar error for the OFF command.
Note2: I’ve added a tcp.cfg file to my /conf/services directory with:
Note3: I see the following log, so I assume the udp binding is active.
2016-05-14 21:37:08.103 [INFO ] [g.tcp.AbstractDatagramChannelBinding] - Listening for incoming data on /0:0:0:0:0:0:0:0:13000
Note4: I’ve also tried to drop (and remove) the 1.8.2 tcp binding jar into the addons directory - doesn’t seem to change the behavour. I still get the above error & info logs.
Note5: Also looked at the newer openHAB2 syntax for items, things & channels but cannot figure out how to configure the channel string in the item file. Not even sure this makes sense, because how would the generic tcp/udp binding define or know what channels are available on my device?
Appreciate any advice/help with the “no channel” error and how to this up properly on openHAB2.
I have just adjusted some things and can confirm, xbmc and tcp/udp won’t load ( stats then stops) and won’t create items until you rename/save/modify either a openhab.cfg file or a specific “tcp.cfg” file in the service folder. Change the file name to tcp1.cfg after I have started OH2 and all the items/channels load and work. !!???
What is going on???
PS actually xbmc is still causing me some troubles as it won’t handle the “POST” Updates. Any thoughts on this.
i have the same issue with tcp right now, maybe we can get this fixed for both of us. i too have noticed it working after a change is made to the config file only after the system starts…my thread is at
Thank you @Branden_Smale for the trail that you left here.
I was able to follow your post and install the tcp 1.9.0 binding.
This seems to work much better on 2 fronts:
I was also getting those NPEs from the “deactivate method” - they’re gone now.
Now my UDP packets are being sent out when I toggle the switch on the basic ui. This is great!
However, still one puzzle to solve. I now see the following warnings as my mapping is not working:
2016-05-17 22:49:30.368 [WARN ] [.core.transform.TransformationHelper] - Cannot get service reference for transformation service of type MAP
2016-05-17 22:49:30.368 [WARN ] [ing.tcp.protocol.internal.UDPBinding] - couldn’t transform response because transformationService of type ‘MAP’ is unavailable
I get these warnings for both ON & OFF switch transitions.
Any ideas on this?
I can see that my UDP input packet is received and displayed properly in the basic web UI, however I noticed the following in the log file:
2016-05-19 20:48:34.063 [INFO ] [marthome.event.ItemStateChangedEvent] - TestSensor changed from NULL to SwitchState=ON < followed by many Null characters >
Looks like the code that prints this log is printing the entire UDP packet buffer (1024 bytes) and not just the length of the actual data rec’d in the packet. (ie: 14 bytes in my example).
It seems like a small bug, yes?
Thank you @watou. That sure looks like what I see in the logfile.
If I may… what do you think of this solution:
Assuming that result.array() is a byte array returned from the socket (or DatagramPacket object), then the result string could be built like so:
String receivedDataString = new String(byteArray, 0, actualNumberOfBytesReceived);
In this way, the receivedDataString contains the actual UDP payload.
Splitting or trimming may not get the right string.
(Although you could argue that trimming nulls or trailing white-space may be a good thing anyway).