Passing ZWave Controller Through socat to Docker Container

I’m trying to migrate my RPi3 Docker OH2.4 installation to a Docker container on my QNAP NAS drive. The problem I found is that QNAP doesn’t have the cdc-acm.ko drivers to support the Aeotek Gen5 ZStick (which I’m using). So, in order to work around that, I’m generally following this tutorial to continue using my RPi solely as a hub for the Zstick, and then forwarding the data via TCP, using ser2net and socat, to the NAS. From there, I figure I should be able to pass the virtual serial port created by socat along to the docker container by adding the docker command line argument “–device=/dev/ttyUSB0”.

So, after setting this all up, when I spin up the container and try to add the ZWave controller through PaperUI, it provides the error “Serial Error: Port {0} does not exist”. This is the problem I’m trying to solve.

So, let’s step back for a second; the first potential point of failure is obviously the Rpi broadcasting the USB data to the NAS drive. Running netstat -ant from both the Rpi and the NAS indicate that a connection is established between the two:
tcp6 0 0 192.168.0.12:3333 192.168.0.7:59552 ESTABLISHED -
(192.168.0.12 is the Rpi, and 192.168.0.7 is the NAS)
Additionally, when I check /var/log/socat.log on the NAS, I see log entries like this:

2019/07/04 22:37:37 socat[24295] I setting option "symbolic-link" to "/dev/ttyUSB0"
2019/07/04 22:37:37 socat[24295] I setting option "raw"
2019/07/04 22:37:37 socat[24295] I setting option "user" to 0
2019/07/04 22:37:37 socat[24295] I setting option "group" to 0
2019/07/04 22:37:37 socat[24295] I setting option "perm" to 511
2019/07/04 22:37:37 socat[24295] I openpty({6}, {7}, {"/dev/pts/1"},,) -> 0
2019/07/04 22:37:37 socat[24295] N PTY is /dev/pts/1
2019/07/04 22:37:37 socat[24295] N opening connection to AF=2 192.168.0.12:3333
2019/07/04 22:37:37 socat[24295] I starting connect loop
2019/07/04 22:37:37 socat[24295] I socket(2, 1, 6) -> 8
2019/07/04 22:37:37 socat[24295] N successfully connected from local address AF=2 192.168.0.7:59552
2019/07/04 22:37:37 socat[24295] I resolved and opened all sock addresses
2019/07/04 22:37:37 socat[24295] N starting data transfer loop with FDs [6,6] and [8,8]

Also, ll /dev/ttyUSB0 produces this result:
lrwxrwxrwx 1 admin administ 10 Jul 4 22:37 /dev/ttyUSB0 -> /dev/pts/1
So, the serial port (symlink) is there. I don’t really know what I’m doing with socat, but I’m assuming this step is working (huge assumption, I know).

Moving on, the next potential point of failure is passing the virtual serial device to the Docker container. I was doing this before, when I was running OH on a Docker container on my RPi, and it worked fine, so I expect to be able to do it again, here. My full container creation command evaluates to this:
docker run -d --restart always --env-file config.env --device=/dev/ttyUSB0 --net=host openhab/openhab:2.4.0. I’m able to access the site through the browser, install the zwave binding, and add the serial controller, but when I provide it with “/dev/ttyUSB0” as the serial port, that’s when I get the error message. Quickly checking the container’s filesystem with ll /dev/ttyUSB0, I get
crwxrwxrwx 1 root root 136, 1 Jul 5 02:52 /dev/ttyUSB0, so the container’s at least picking it up, but I don’t really know what it’s doing with it beyond that.

Can anyone provide any assistance with this issue, please? If I need to provide any more information, please let me know. Thanks!

  • Platform information:
    • Hardware: QNAP 231-P2 NAS
    • openHAB version: Docker image: openhab/openhab:2.4.0

While you likely don’t want to hear this, I’d advise not to migrate. It’s best practice to keep things simple and run OH on a dedicated device.

You know what? I just saw in another thread that the RPi 4 was recently released. On a whim, I decided to just buy one of those and migrate to that instead.

I was getting tired of how slow my RPi3 is, and I noticed that a vanilla install of OH2 was SO much faster on the NAS drive. Plus, my filesystem kept getting corrupted when trying to upgrade my Docker images to OH2.5 on the SD card, which is what prompted me to try to migrate it to the NAS drive. Also, I just found a spare SSD lying around that I can use as a proper storage drive, now. So…I guess what I’m saying is, thank you for knocking some sense into me.

It just sucks that I’ve wasted about 3 days of effort trying to get it working on the NAS drive…and now I have to wait for the new components to arrive in the mail. Oh well…there’s no shortage of projects to work on…

It’s way fast enough to run OH (and the RPi4 won’t be much faster).
The only 2 situations when it is annoyingly slow is 1) on startup and 2) if you manually edit config files or rules in-place.
Install openHABian on your old RPi3 (it likely won’t work on the 4 yet) and activate “delayed rules load” option to speed up startup.

That hasn’t been my experience. Like I said, it was MUCH faster, out of the box, on my NAS drive. Honestly, I think the memory card played a part in that. But the biggest problem was really the filesystem corruption issues. Switching to an SSD should fix that.

Thanks for the suggestions.

Totally unlikely. Activate the delayed rules. And go SSD or wait for this PR to be merged. And make sure you don’t compare apples to oranges (such as the second start with Karaf cache in place to the initial start).

Thanks, I’ll take a look at the delayed rules.

I am soooo unhappy that you brought him back to a native PI :frowning:
I wished he would have finished his idea, course I am stucking at the same point.

ser2net & socat vs. usbip

first might be faster (because did not handle all raw informations)
second might be easier with Docker?

RUDY seeams to be a solutione but I do not know (for now) how it works in details.

Any off-mainstream hardware, anything containers is only complicating things, for no relevant benefit. You, too, wouldn’t need this if you went with the standard so don’t blame me, please (after another 5 yrs BTW).