Z-Wave Serial-over-TCP Controller
See original GitHub issue- OH2 Version: 2.2.0
- Binding Version: 2.2.0
While moving the whole home IT to stateless, dockerized systems I noticed, that there is no way to connect to a TCP socket instead of a serial device. I found those functionalities in the MySensors and RFXCOM Binding and found that using them is very easy and reliable.
The hardware device that has the Z-Wave Serial Controller connected can forward that serial port to a listening TCP socket using socat or ser2net and connecting to that socket from another device yields the same exact data like talking to the serial port directliy, minus the serial settings (baud rate, stop bits, …).
I am very aware of alternatives like using socat to create a pty. All of this is not possible when the Serial Controller is not running on the same host as the openHAB docker container. So this is a feature request by design.
While I really hope that this would be relatively easy to implement, I can’t take a shot at it right now and ask for help while continuing to get my development environment up and running.
Creating a test environment on Raspbian
Prerequisites for the device host:
- Z-Wave Serial Controller
- root access
I am using a raspberry pi as a realistic and common example.
Installation
- Log in to the Host
- Become root, if not already:
sudo -i
- Install ser2net:
apt-get update && apt-get install ser2net
Configuration
- Open the config file of ser2net:
vi /etc/ser2net.conf
- Replace the content of the file with this:
2002:raw:0:/dev/zwave:115200 8DATABITS NONE 1STOPBIT HANGUP_WHEN_DONE
where /dev/zwave
is the device or a symlink to the device.
where 2002
is the TCP port you want to expose the device on the network.
- Save and quit
- Restart ser2net (after every change):
systemctl restart set2net
netstat -lntp
should show a tcp LISTEN on socket 0.0.0.0:2002 by programser2net
Usage
- Connect to the port and talk to Z-Wave Controller over TCP
Linux netcat example
nc openhab 2002
where openhab
is the host name of the host device that has the serial controller connected.
Links
Please, let me know if I can do more to help and thank you very much!
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (3 by maintainers)
Top GitHub Comments
I would suggest to comment on the ESH issue as well - at least so that people know this work is being looked at as I think it’s likely to be of interest to other bindings.
Hi @gersilex!
I like that you have written this message, because that is what I am currently doing and its working great. To start with, I’m using this python program/script in the Raspberry Pi that acts as a gateway (I call them seriatl2tcp gateways): https://github.com/Tknika/serial2tcp-gateway
Both common Z-Wave controllers are supported (Z-Wave Gen2 and new Z-Wave+ usb devices) but it is really easy to add more just editing this file: https://github.com/Tknika/serial2tcp-gateway/blob/master/serial2tcp-gateway/device_definitions.py The TCP ports are anounced using multicast DNS (mDNS) and I have edited the binding to support this new bridge type and its discovery. I will try to push the code to my own repo tomorrow and will compile a .jar file so that you can test it and give me your opinion.
Anyway, my idea was to wait until @cdjackson merges the development branch into master and then have a conversation about how he would like to address it. But, yeah, first I should show my code and then discuss it, so tomorrow I will come back here and we can talk about it using my code as the starting point.
As always, thanks to Chris for all the time he spends for the openHAB community and best regards,
AItor