Add network protocol support to Zigbee and Zwave Integrations

I am currently trying to utilize a HUSBZB-1 connected remotely on another device in my HASSIO deployment.

It involves using ser2net to make the serial device available over the network.

3333:raw:0:/dev/ttyUSB0:115200 8DATABITS NONE 1STOPBIT
3334:raw:0:/dev/ttyUSB1:57600 8DATABITS NONE 1STOPBIT

Typically using socat you can make a “virtual” serial device to utilize this connection

pty,link=/dev/ttyUSB1,raw,user=0,group=0,mode=777 tcp:IP_address:3334

However currently there is no way to get socat running in HASSIO.

I saw that network support was added to RFXtrx (Danielhiversen/pyRFXtrx#85)

Could the same thing be added to this library and the zwave libraries?

For reference I am using the HUSBZB-1 with

Which has the potential to be a wifi/ethernet usb or POE powered zwave/zigbee hub. ( a wink replacement for me)

Just found by using portainer and gaining access to the homeassistant container I can run

socat pty,link=/dev/ttyUSB0,raw,user=0,group=0,mode=777 tcp: &
socat pty,link=/dev/ttyUSB1,raw,user=0,group=0,mode=777 tcp: &

from the console and successfully configure zwave and zigbee integrations on the mapped serial interfaces.

I am thinking I can run these commands from a script but I need them to run prior to Zwave and Zigbee start.

Used a custom component to spawn the socat commands needed. However custom components do not start prior to the zigbee or zwave integrations starting so the comm ports are not ready in time.

My latest attempt at a fix/workaround.

Since socat seems to be included in the hassio image I now have the zwave and zigbee componenlty calling the subprocess commands to launce socat.

I think this might be the right way to do this moving forward.

I unfortunately lack what is required to make this an option for others. Any takers? Im willing to money in for it.

I suspect something like this would work.

  usb_path: /dev/ttyUSB0
  device_config: !include zwave_device_config.yaml

then during setup this gets called.

import subprocess
subprocess.Popen(['socat pty,link=usb_path,raw,user=0,group=0,mode=777 tcp:net_path'])