I didn’t manage to send hex data directly to RFXCom using the RFXCom binding (configured with serialPort). After reading this post Share Z-wave dongle over IP (USB over IP using ser2net / socat ) guide and this page https://www.openhab.org/addons/bindings/rfxcom/ I decided to share my usb device over the network with a TCP connexion.
What I have done
- For connecting RFXCom with openhab :
RFXCom (/dev/ttyUSB0) <-> ser2net (TCP server) <-> socat (TCP client) <-> /dev/VirtualRfxCom (virtual serial port) <-> OpenHab2
- For sending hex data to RFXCom (for example replay undecoded data)
RFXCom (/dev/ttyUSB0) <-> ser2net (TCP server) <-> Script which send TCP data using netcat
- For managing RFXCom, test purposes…
RFXCom (/dev/ttyUSB0) <-> ser2net (TCP server) <-> RFXManager on Windows
The problems I encountered
>> Openhabian and ser2net
The apt repository in openhabian do not get the latest version of ser2net which allow multiple connexions (the parameter max-connexions). I had to install Raspbian and Openhab with the package repository procedure https://www.openhab.org/docs/installation/linux.html#package-repository-installation. Another solution (simpler) would be to update the repo definition in openhabian.
10001:raw:0:/dev/USBrfxcom:38400 8DATABITS NONE 1STOPBIT max-connections=3
This link is useful for the configuring the serial port : https://www.openhab.org/docs/administration/serial.html
>> RFXCom and TCP/IP binding
The TCP connexion is not stable (systematically released after some time), the serial connexion works better, that’s why I use of socat which map a virtual serial port with a TCP client.
forever and interval parameters are important because on reboot if ser2net is not ready ( = the port is not opened), socat will fail to establish the connexion
Openhab thing configuration
Bridge rfxcom:bridge:rfxcom433 [ serialPort="/dev/VirtualRfxCom", ignoreConfig=false, enableUndecoded=false, enableARC=true, enableAC=true]
>> The format of the data to send
I start with the undecoded messages I can observe with RFXManager, I re-send it with netcat and printf using the \x commutator. I also have to use sleep between commands because they are sent to quickly.
The shell commands I use (in a script) :
printf "\x54\x7F [ … some hex data separated with \x … ] \x00\x00" | nc -N 127.0.0.1 10001
And the code in the rules
Overall I must admit it is not a simple solution but It works like a charm.
I hope it can help, I am listening to all the good ideas / advices on this configuration.