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

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

ok this is what i have on the openhab server

[22:38:23] openhab@openhab:/dev$ sudo netstat -antp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:9001            0.0.0.0:*               LISTEN      7763/node
tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN      28427/smbd
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1124/sshd
tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN      28427/smbd
tcp        0     64 192.168.1.163:22        192.168.1.113:53267     ESTABLISHED 5788/sshd: openhab
tcp        0      0 192.168.1.163:51442     192.168.1.174:3333      ESTABLISHED 9030/socat
tcp        0      0 192.168.1.163:445       192.168.1.113:53346     ESTABLISHED 6960/smbd
tcp        0      0 192.168.1.163:9001      192.168.1.113:53674     ESTABLISHED 7763/node
tcp6       0      0 :::139                  :::*                    LISTEN      28427/smbd
tcp6       0      0 :::5007                 :::*                    LISTEN      7158/java
tcp6       0      0 :::8080                 :::*                    LISTEN      7158/java
tcp6       0      0 127.0.0.1:36080         :::*                    LISTEN      7158/java
tcp6       0      0 :::22                   :::*                    LISTEN      1124/sshd
tcp6       0      0 :::8443                 :::*                    LISTEN      7158/java
tcp6       0      0 :::445                  :::*                    LISTEN      28427/smbd
tcp6       0      0 127.0.0.1:8101          :::*                    LISTEN      7158/java
tcp6       0      0 192.168.1.163:8080      192.168.1.113:54542     ESTABLISHED 7158/java
tcp6       0      0 192.168.1.163:8080      192.168.1.113:53680     ESTABLISHED 7158/java
tcp6       0      0 192.168.1.163:8080      192.168.1.113:53640     ESTABLISHED 7158/java

and here the log from socat

[22:38:26] openhab@openhab:/dev$ tail -f /var/log/socat.log
2017/12/28 22:38:23 socat[9030] I setting option "group" to 20
2017/12/28 22:38:23 socat[9030] I setting option "perm" to 511
2017/12/28 22:38:23 socat[9030] I openpty({6}, {7}, {"/dev/pts/2"},,) -> 0
2017/12/28 22:38:23 socat[9030] N PTY is /dev/pts/2
2017/12/28 22:38:23 socat[9030] N opening connection to AF=2 192.168.1.174:3333
2017/12/28 22:38:23 socat[9030] I starting connect loop
2017/12/28 22:38:23 socat[9030] I socket(2, 1, 6) -> 8
2017/12/28 22:38:23 socat[9030] N successfully connected from local address AF=2 192.168.1.163:51442
2017/12/28 22:38:23 socat[9030] I resolved and opened all sock addresses
2017/12/28 22:38:23 socat[9030] N starting data transfer loop with FDs [6,6] and [8,8]

an this is on my PI

pi@raspberrypi:/etc/udev/rules.d $ netstat -antp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp        0     64 192.168.1.174:22        192.168.1.113:52991     ESTABLISHED -
tcp6       0      0 :::22                   :::*                    LISTEN      -
tcp6       0      0 :::3333                 :::*                    LISTEN      -
tcp6       0      0 192.168.1.174:3333      192.168.1.163:51442     ESTABLISHED -

looks all not that wrong to me.

the only difference to your guide is that i’m pointing the sert2net config to a symlink.

udev rule:

ACTION=="add", ATTRS{product}=="DWC OTG Controller", ATTRS{serial}=="3f980000.usb", SYMLINK+="zwave", GROUP="dialout", MODE="0666"

sert2net config

3333:raw:0:/dev/zwave:115200 8DATABITS NONE 1STOPBIT

looks good to me as well… strange… any packet loss between openhab and your RPI3?

no package lost, i removed the symbolic link and pointed it directly to the port but still the same.
the strange thing i noticed is that i could start the inclusion from hambin once and could see the reaction from the zwave.me stick. but when i tried it a second time, no reaction.

noticed on the openhab server this:

lrwxrwxrwx  1 root root          10 Dec 29 10:54 ttyUSB0 -> /dev/pts/2

does the group should not show “dialout” ?

socat config

OPTIONS="pty,link=/dev/ttyUSB0,raw,user=openhab,group=dialout,mode=777 tcp:192.168.1.174:3333"

Your socat.conf seems fine…for reference see the content of my own production socat.conf below:

OPTIONS=“pty,link=/dev/ttyUSB0,raw,user=openhab,group=dialout,mode=777 tcp:172.16.11.5:3333”

after some testing i figured out what the actual problem was, it seems that the PI got restarted and even i restarted the ser2net and the socat service the problem persists. after i restarted the OH2 everything came back to normal.

so the question is now how to ensure that this will not happened again, i guess i need a kind of script which will ensure that all services get restarted if the remote PI-Zwave was not reachable for a certain time.

For Windows users, this is the equivalent:

If you’re using the systemd service file above, add a “Restart=always” line to the Service section. When systemd sees socat exit, it will restart the service automatically.

This doesn’t seem to be happening. I disconnected the server (reboot), socat died on OH2 and didn’t start back even after z-wave controller server was back up.

I had to make these modifications to get it to work:

[Unit]
Description=Multipurpose relay (SOcket CAT)
After=network.target
**StartLimitIntervalSec=0**
**StartLimitBurst=3000**

[Service]
**Restart=always**
**RestartSec=3**
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

NOTE: Remove **

This is what the netstat looks like:

tcp        0      0 openHAB2-IP:35514      Z-WAVE-Controller-IP:3333     ESTABLISHED 2133/socat   
<reboot z-wave controller>   
tcp        0      1 openHAB2-IP:35521      Z-WAVE-Controller-IP:3333     SYN_SENT    2192/socat      
tcp        0      1 openHAB2-IP:35521      Z-WAVE-Controller-IP:3333     SYN_SENT    2192/socat      
tcp        0      1 openHAB2-IP:35521      Z-WAVE-Controller-IP:3333     SYN_SENT    2192/socat      
tcp        0      1 openHAB2-IP:35521      Z-WAVE-Controller-IP:3333     SYN_SENT    2192/socat      
tcp        0      1 openHAB2-IP:35521      Z-WAVE-Controller-IP:3333     SYN_SENT    2192/socat      
tcp        0      1 openHAB2-IP:35521      Z-WAVE-Controller-IP:3333     SYN_SENT    2192/socat      
tcp        0      1 openHAB2-IP:35521      Z-WAVE-Controller-IP:3333     SYN_SENT    2192/socat      
tcp        0      1 openHAB2-IP:35521      Z-WAVE-Controller-IP:3333     SYN_SENT    2192/socat      
tcp        0      1 openHAB2-IP:35521      Z-WAVE-Controller-IP:3333     SYN_SENT    2192/socat      
tcp        0      0 openHAB2-IP:35521      Z-WAVE-Controller-IP:3333     ESTABLISHED 2192/socat      
tcp        0      0 openHAB2-IP:35521      Z-WAVE-Controller-IP:3333     ESTABLISHED 2192/socat
1 Like

Short question.
I know. A RaspPi3 isnt expensive. But i have 2 RaspPi first generation lying around.
What you think. Worth a try? Or should i buy a RaspPi3 to be save?
I hate to have unused hardware lying around and buy new stuff…
[EDIT]
Btw. I plan to use a Aeon Labs USB Stick for that.

Regards
Capo