AD2USB not sending messages to OpenHab

I’ve got AD2USB setup connected to my Vista 20p and to a Raspberry Pi 2 and OpenHab. The issue is that when I restart OpenHab, messages from the AD2USB unit do not flow to OpenHab. I’ve turned on logging for AlarmDecoder and I see that everything is started up:

2015-11-09 22:12:51 DEBUG o.o.b.a.i.AlarmDecoderActivator[:31]- AlarmDecoder binding has been started.
2015-11-09 22:12:51 DEBUG o.o.b.a.i.AlarmDecoderBinding[:276]- marking all items as unknown
2015-11-09 22:12:51 DEBUG o.o.b.a.i.AlarmDecoderBinding[:279]- unupdated items found: 0
2015-11-09 22:12:51 INFO o.o.b.a.i.AlarmDecoderBinding[:234]- connected to serial port: /dev/USBalarm
2015-11-09 22:12:51 DEBUG o.o.b.a.i.AlarmDecoderBinding[:311]- msg reader thread started

But nothing shows up afterwards until I use screen to see what is going on on the serial connection. I looked through the code in GitHub and the only thing that jumped out at me is that the connection speed is not the recommended speed of 1152000. I also have updated my AD2USB to the latest firmware, so maybe there was some slight change in the protocol (though I could not find anything on the AlarmDecoder website). Anyone have any ideas? If not, I’ll start poking around in the code and see if I can figure anything out.

I’ll make the serial speed configurable and drop you a link to a jar file for testing.

1 Like

This pull request changes the default speed, and makes it configurable:

Link to jar file is in the pull request. Please let me know if that fixes the issue.

So I am messing around with your new jar now. Thanks for turning it around so quickly. I think the change is working as expected for AlarmDecoder, but I’m seeing some other weird behavior.

I’ve basically got two bindings configured in OpenHab.cfg, the zwave binding and the alarmdecoder binding. I’m not entirely sure what is going on, but my ZWave binding is sometimes failing because it says it cannot find /dev/USBzwave. The link is definitely there and it does work sometimes, just not always. Also, the start up of the server seems to get stuck trying to connect to my zwave device (Aeontec Gen5).

2015-11-10 22:42:02.416 [INFO ] [.z.internal.ZWaveActiveBinding] - Update config, port = /dev/USBzwave
2015-11-10 22:42:02.419 [INFO ] [.service.AbstractActiveService] - ZWave Refresh Service has been started
2015-11-10 22:42:02.480 [INFO ] [b.z.i.protocol.ZWaveController] - Starting Z-Wave controller
2015-11-10 22:42:02.483 [INFO ] [b.z.i.protocol.ZWaveController] - Z-Wave timeout is set to 5000ms. Soft reset is false.
2015-11-10 22:42:02.485 [INFO ] [b.z.i.protocol.ZWaveController] - Connecting to serial port /dev/USBzwave
2015-11-10 22:42:02.490 [ERROR] [b.z.i.protocol.ZWaveController] - Serial Error: Port /dev/USBzwave does not exist
2015-11-10 22:42:07.423 [INFO ] [.service.AbstractActiveService] - ZWave Refresh Service has been shut down

AlarmDecoder seems to be working just fine. :smile: I tried putting the old AlarmDecoder.jar back and it appears the old behavior of not getting messages has gone away. The only problem is that the zwave binding failure is causing the AlarmDecoder binding to take a long time to start. If you’ve got any suggestions I’m open to them. I’m going to poke around some more. Oh, when I started the server in debug mode everything seems ok… No extra logs to help figure out what happened either.

This is a known issue where different bindings that use the serial port conflict with each other.

I updated the pull request and built a new jar file. Please see the pull request for the new link (I edited the link in the original post).
Thanks for testing!

1 Like

Thanks for providing more fixes! I put one comment in your commit. I am new to reading this code, so I apologize if the comment is irrelevant. I’ll give the updated binding another try tomorrow (kind of late now) and let you know how it goes. BTW, code was super easy to read, nicely commented. I have a feeling I’ll be looking at more code as I get to using OpenHab more.

I’ve given the latest jar a try and it is working. I will give a few more restarts to see if the issue where my zwave binding stops working comes back. Another thing I’ve noticed is that it take 7-8 minutes from openhab start to the time that either of my two bindings start working. I guess it’s time to take a look at what’s going on there. Thanks again for the fix and the explanation in the code review.

Bernd,

I’m seeing related issues as Ken. I’m running OpenHab 1.7 on windows 7. I too have the Aeon Gen5 zwave usb stick. To help troubleshoot I’ve removed the zwave stick and configuration items to narrow it down to just the alarmdecoder. The alarmdecoder works fine using the keypad app that comes with it, and I’ve updated it to the latest firmware (2.2a8). Here are relevant log entries:

13:08:39.311 [DEBUG] [.o.b.a.i.AlarmDecoderActivator:31 ] - AlarmDecoder binding has been started.
13:08:39.358 [DEBUG] [a.internal.AlarmDecoderBinding:212 ] - config updated!
13:08:39.358 [DEBUG] [a.internal.AlarmDecoderBinding:150 ] - serial port configuration: speed: 115200 device: COM8
13:08:39.358 [DEBUG] [xecPersistenceServiceActivator:33 ] - Exec persistence bundle has been started.
13:08:39.358 [INFO ] [a.internal.AlarmDecoderBinding:236 ] - accepting commands!
13:08:39.358 [INFO ] [.service.AbstractActiveService:169 ] - AlarmDecoder binding has been started
13:08:39.358 [DEBUG] [a.internal.AlarmDecoderBinding:354 ] - marking all items as unknown
13:08:39.374 [DEBUG] [a.internal.AlarmDecoderBinding:357 ] - unupdated items found: 0
13:08:55.754 [INFO ] [a.internal.AlarmDecoderBinding:312 ] - connected to serial port: COM8
13:08:55.770 [DEBUG] [a.internal.AlarmDecoderBinding:389 ] - msg reader thread started
13:08:56.082 [ERROR] [a.internal.AlarmDecoderBinding:419 ] - I/O error while reading from stream: Underlying input stream returned zero bytes
13:08:56.082 [DEBUG] [a.internal.AlarmDecoderBinding:424 ] - msg reader thread exited
13:09:05.785 [DEBUG] [a.internal.AlarmDecoderBinding:354 ] - marking all items as unknown
13:09:05.785 [DEBUG] [a.internal.AlarmDecoderBinding:357 ] - unupdated items found: 0
13:09:15.801 [ERROR] [a.internal.AlarmDecoderBinding:318 ] - cannot open serial port: COM8, it is in use!

Last message will repeat continuously every 20 seconds.
When I run with the zwave stick installed and configured I get “Node DEAD message dropped” entries repeatedly.

Appreciate any help,
John

John,
Please use the latest OH 1.8 version of the binding. You can actually just pick up the compiled alarmdecoder jar file from cloudbees and drop it into the addons folder. It should work with OH 1.7 as well.

Bernd,

Sorry I didn’t mention before, those logs are from using your 1.8 jar file.
Anything else I can do to help debug?

Thanks,
John

The log says “it’s in use”. Any other application running that might be accessing it? Maybe that keypad app that you mentioned?

That was my thought as well, so I tried it after a clean boot. The strange
thing is it says it opened the port, then later it can’t access it.

The first problem is this:

13:08:56.082 [ERROR] [a.internal.AlarmDecoderBinding:419 ] - I/O error while reading from stream: Underlying input stream returned zero bytes

I think the port stays open, then the binding tries to reconnect, but fails since the port has not been closed properly. That’s probably a bug (I don’t have the USB version of the device, so I cannot easily debug the corner cases).

I noticed that the line numbers given in the error messages you posted are off with respect to the official current repository. What binding are you exactly running?

I’m not a windoze guy, but could it be a permissions issue? Can you start a plain serial terminal program and dump the ascii stream? There used to be HyperTerminal on windows but they removed it…

I use putty on windows for my serial connection needs. Works well.

I am having the same exact problem. I just received and installed the AD2USB device and can confirm the hardware is working. I can get to it with serial terminal software and it does spew information once I connect. Also, as the other poster mentioned, I have full operation of my alarm system using the AlarmDecoder Keypad app from the nu tech folks.

OH is working fine;however, once I install the binding, I start having problems. It looks like OH is fighting over the com ports as if it can only communicate with one comm port. During startup, sometimes my zWave device will get COM4 and work, but my AD2USB device then can’t communicate with COM5. Or, the other way around. But, it seems that even when the alarmdecoder binding wins out (I get a short verification during boot that it can read correctly) the zwave binding will always manage to take control.

I’m combing through the logs because it seems to spit out all kind of zwave errors when I have the alarmdecoder binding installed, but I’m trying to narrow down the messages.

I am using the latest jar file from cloudbees, any advice?

Here’s the pertinent entry from the alarmdecoder.log:

2015-12-20 20:53:03 DEBUG o.o.b.a.i.AlarmDecoderActivator[:31]- AlarmDecoder binding has been started.
2015-12-20 20:53:03 DEBUG o.o.b.a.i.AlarmDecoderBinding[:209]- config updated!
2015-12-20 20:53:03 DEBUG o.o.b.a.i.AlarmDecoderBinding[:150]- serial port configuration: speed: 115200 device: COM5
2015-12-20 20:53:03 INFO o.o.b.a.i.AlarmDecoderBinding[:233]- accepting commands!
2015-12-20 20:53:03 DEBUG o.o.b.a.i.AlarmDecoderBinding[:351]- marking all items as unknown
2015-12-20 20:53:03 DEBUG o.o.b.a.i.AlarmDecoderBinding[:354]- unupdated items found: 46
2015-12-20 20:53:05 INFO o.o.b.a.i.AlarmDecoderBinding[:309]- connected to serial port: COM5
2015-12-20 20:53:05 DEBUG o.o.b.a.i.AlarmDecoderBinding[:386]- msg reader thread started
2015-12-20 20:53:05 ERROR o.o.b.a.i.AlarmDecoderBinding[:416]- I/O error while reading from stream: Underlying input stream returned zero bytes
2015-12-20 20:53:05 DEBUG o.o.b.a.i.AlarmDecoderBinding[:421]- msg reader thread exited
2015-12-20 20:53:15 DEBUG o.o.b.a.i.AlarmDecoderBinding[:351]- marking all items as unknown
2015-12-20 20:53:15 DEBUG o.o.b.a.i.AlarmDecoderBinding[:354]- unupdated items found: 46
2015-12-20 20:53:15 ERROR o.o.b.a.i.AlarmDecoderBinding[:319]- got no such port for COM5
2015-12-20 20:53:25 DEBUG o.o.b.a.i.AlarmDecoderBinding[:351]- marking all items as unknown
2015-12-20 20:53:25 DEBUG o.o.b.a.i.AlarmDecoderBinding[:354]- unupdated items found: 46
2015-12-20 20:53:25 ERROR o.o.b.a.i.AlarmDecoderBinding[:319]- got no such port for COM5
2015-12-20 20:53:35 DEBUG o.o.b.a.i.AlarmDecoderBinding[:351]- marking all items as unknown
2015-12-20 20:53:35 DEBUG o.o.b.a.i.AlarmDecoderBinding[:354]- unupdated items found: 46
2015-12-20 20:53:35 ERROR o.o.b.a.i.AlarmDecoderBinding[:319]- got no such port for COM5
2015-12-20 20:53:45 DEBUG o.o.b.a.i.AlarmDecoderBinding[:351]- marking all items as unknown

I removed my zwave binding and commented out all of the zwave material in the openhab.cfg and I’m still getting the same results from the alarmdecoder binding. I guess the primary cause of my problems aren’t a conflict of the zwave port. I did notice that while openhab is running, I cannot get into the ad2usb device through my serial terminal software. It gives me an error saying the com port is in use. So, this shows that OH does in fact have the port open. OH just isn’t playing well with my COM5, unfortunately.

I wish I could be of any help here, but I can’t. I don’t have the USB device, and I don’t run on Windows (and never will). From what I understand Ken got the USB device to work on Linux, so it’s not strictly a TCP vs USB problem.

All I can offer is shots in the dark: maybe the serial port parameters are not set correctly? What serial port parameters are you using when you successfully connect to COM5? I think I made the port speed configurable through openhab.cfg, but none of the other parameters.

Next step up would be to get the IDE running, and run the binding within the IDE. There you can change all serial port parameters. Maybe don’t make the binding exit when it reads null bytes, but just keep on reading and printing out whatever garbage comes from the serial port.

I’ve got this working on Linux as Bernd mentioned. My suggestion is to make sure you can connect using the ad2usb software. I would turn off OH and make sure that it does in fact connect. Perhaps you’ve got something else that is conflicting. I would also try to use putty and connect using the serial options.

Strange, I’m not receiving updates to the topic any more. At any rate, I’m running 1.7.1 of the alarmdecoder.jar. I think you are right, that the binding receives invalid bytes and then tries to reconnect without closing the port. No idea why that should have any affect at all on Zwave or any other com port connected binding. My guess is there is an issue further down the java stack in the port handling code.

I’m thinking about switching over to linux anyway, so I’m probably putting this one to rest. That said, has anyone tried replacing their alarm panel completely? I’d like to just use the Pi or similar sbc to do the same job.

Thanks,
John

Hello @JohnChiasson and @Corey_Elliott! Reving an old thread here I know, but have either of you successfully gotten AD2USB to work with OH? I am experiencing the same error that you guys had described, “underlying input stream returned zero bytes” despite the Alarm Decoder Windows keypad software and Putty being able to communicate with the device over COM3 without any issues. A bit discouraging as I have all the other components I need to make my alarm system work with OH! Surely in the 5 years since the last post someone has figured this out…