Share Z-wave dongle over IP (USB over IP using ser2net / socat ) guide

Djeezz… you could have just said so in your first message :wink:

Sorry, I thought it would be clear (I had quoted the line…)

Hi Roel,
your solution works great for me with zwave.
Now I would like to put my enocean stick together with the zwave-stick in the Pi.
What is the correct syntax to put 2 OPTIONS in the socat.conf?
As I understand I could provide the zwave over 3333 and the enocean over 3334 - correct?

Michael

Excellent tutorial! Thanks for contributing it to the community.

1 Like

Exactly… add a new line to ser2net.conf with an incremental port number and new USB_port you would like to share and you’re golden!

1 Like

I have Rpi in ma living room with Z-wave stick and forwarding with USBIP package to virtualmachine in my basement where OpenHAB is installed.
Works very well, just need to prepare some automation once i reboot rpi.
http://usbip.sourceforge.net/

usbip in recent linux distros comes with kernel and not as external package like in my raspbian on Rpi.

Hi Michael,

you may use systemd (which is part of current Raspian) to start multiple instances of socat. Just create a file “/etc/systemd/system/socat@.service” with this content:

[Unit]
Description=Multipurpose relay (SOcket CAT)
After=network.target

[Service]
EnvironmentFile=/etc/default/socat-%i.conf
Type=simple
PIDFile=/var/run/socat-%i.pid
ExecStart=/usr/bin/socat -L/var/run/socat-%i.pid $SOCAT_DEFAULTS $SOCAT_CONNECTION
ExecStop=/bin/kill -SIGKILL $MAINPID

[Install]
WantedBy=multi-user.target   

and reload systemd configuration with:

systemctl daemon-reload

The configuration of a port goes into a file called “/etc/default/socat-<name of Device>.conf” - for example “/etc/default/socat-ttyUSB37.conf”, if you want to create a device /dev/ttyUSB37. The contents of the file are like this:

SOCAT_DEFAULTS=-d -d -s -lf /var/log/socat.log

SOCAT_CONNECTION=pty,link=/dev/ttyUSB37,raw,user=openhab,group=dialout,mode=777 tcp:<ip-address>:<port>

Just replace <ip-address> and <port> with the ip address and port of the ser2net server. The command:

systemctl enable socat@ttyUSB37

will enable the service at system startup and:

systemctl start socat@ttyUSB37

will start it directly. If you want to add another socat daemon for device /dev/ttyUSB38 which is mapped to another ip address/port combination, just copy the file /etc/defaults/socat-ttyUSB37.conf to /etc/defaults/socat-ttyUSB38.conf and edit it to match the new configuration. After this enable the service at system startup with:

systemctl enable socat@ttyUSB38

kind regards,

Christoph

6 Likes

Just want to say, +1 for this guide.

Using it to forward the usb to serial device for my DSC alarm and works 100%. Now I can move the adapter to a Pi Zero and let it work over wifi instead of a cable hanging through the roof!

1 Like

Does anyone have any experience with a Windows frontend for this? I’d like to be able to shutdown my OpenHAB Ubuntu VM and then connect to my USB Zwave stick on Windows in order to do a backup of the stick.

There are 2 windows alternatives available to my knowledge:

I have personally tried virtualhere and it worked perfectly fine

Excellent guide. Worked like a charm!

Thanks

Hi I am trying to set this up, I am not familiar with “VM”. Do you create the VM on the Raspberry PI running openhab or do you need another PI?

Thanks

The Virtual Machine (VM) part is not the main point of this tutorial. It just happens to be the specific environment OP is working with.

He is running OH on a Virtual Machine running on some server he has in a location that is not ideal for the Zwave controller.

The whole point of this tutorial is to show how you can place your Zwave controller (or any other USB device) in an ideal location and make it available to your OH server which might be in some other location. See the drawing.

1 Like

Thank you for the detailed guide.
I’ll try this with zwave- and enocean-stick

Michael

I found a piece of hardware for this instead. IO Gear 4 port wireless usb hub. I can move that device around and make it to connect to to lan or wifi since I prefere lan connections instead of wifi. I haven’t mkae it work for anything else than windows7.

I have tried setting this up with my EnOcean USB300.
I have a connection and I am receiving data on the client but for some reason the data looks different.

When I debug the EnOcean library I can see that the first integer of the message is now 102.
When I have the USB300 directly attached to the development machine, I get an 85 as the first value.

This leads the binding to not detect the EnOcean message.

How come the input data is changed?

edit:

I found the answer: I had to reduce the baud rate to half and the messages came through correctly.

I have connected a zwave and an enoceanstick.
Both are established.
Wich baudrate do you have set?

I get these errors in OH:

2017-11-26 15:53:42.843 [ERROR] [org.openhab.binding.enocean         ] - [org.openhab.binding.enocean.binding(229)] The deactivate method has thrown an exception

	at org.opencean.core.EnoceanSerialConnector.disconnect(EnoceanSerialConnector.java:71) [211:org.openhab.binding.enocean:1.11.0.201711190210]

	at org.openhab.binding.enocean.internal.bus.EnoceanBinding.deactivate(EnoceanBinding.java:95) [211:org.openhab.binding.enocean:1.11.0.201711190210]

2017-11-26 15:55:42.206 [INFO ] [.enocean.internal.bus.EnoceanBinding] - Connecting to Enocean [serialPort='/dev/ttyUSB4' ].

This is great.

I am using udev in addition to socat and ser2net on the usb server to have static serialports for my devices.
/etc/udev/rules.d/50-usb-serial.rules

# ZWave
SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", SYMLINK+="zwave", GROUP="dialout", MODE="0666"
# Enocean
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", SYMLINK+="enocean", GROUP="dialout", MODE="0666"

hi,

first a big thanks t @snoekieboe for this guide.
i got it that far up and running that my openhab2 server got connected to the zwave.me on my remote rpi3 and i also could include my first node.

but then the problems started. i added the items for my qubino flush 2 relay and tried to switch them from habmin. nothing happend.

the log is showing a lot of the below errors iw im trying to switch the items from habmin.

2017-12-28 20:09:31.876 [ERROR] [ing.zwave.handler.ZWaveSerialHandler] - Got I/O exception Input/output error in writeArray during sending. exiting thread

Could you first check to see if you still have a working connection between Openhab and your remote pi3?

“Netstat -antp” on the Openhab machine should show an active TCP connection on port 3333 to the IP address of your remote RPI3.

Is your virtual serial device still available? Check using " cd /dev" "ls"
this should show your TTYUSB0 or whatever you have configured as your virtual interface.

Also check de socat log in var/log