Just wanted to share my setup which uses socat on both sides. I have a RPi with a Aeotec Z-Stick 5, and I’m running Home Assistant in a VM.
The Aeotec z-stick device was exposed as a serial device, so I felt doing usbip to be overkill, so I found the solution where someone used socat on server side and ser2net on the client to be more appropriate. While poking around, I found out that socat can be used on the client side as well, symmetry ftw!
Server Side
I’m running raspbian on a RPi. I use a dedicated user named hass
which is added to group dialout
to allow access to the device (or you can use root).
[Unit]
Description=Z-Wave Remote Server
After=network-online.target
[Service]
Type=simple
User=hass
ExecStart=/usr/bin/socat tcp-l:59595,reuseaddr,keepalive,nodelay file:/dev/ttyACM0,nonblock,raw
Restart=always
StartLimitIntervalSec=0
StartLimitBurst=0
[Install]
WantedBy=multi-user.target
Client Side
I have this running on the VM with home assistant. I’m also running it as hass
, because my home assistant also runs under user hass
, otherwise you will have a permission issue on the device.
[Unit]
Description=Z-Wave Remote Client
After=network-online.target
[Service]
Type=simple
User=hass
ExecStart=/usr/bin/socat pty,link=/var/lib/zwave/remotezwave,ignoreof,echo=0 tcp:RIPHOSTNAME:59595,forever
Restart=always
StartLimitIntervalSec=0
StartLimitBurst=0
[Install]
WantedBy=multi-user.target
Cheers.
EDIT: Okay, so the forever option was just for the initial connection, it wasn’t actually reconnecting. Anyways, relying on the systemd restart mechanism was a lot more reliable, plus I was able to use the journald logs to figure out when things go wrong (ie. client/server disconnected).