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.

1 Like

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'])
1 Like

I’m wanting to move my HUSBZB-1 to remote location as well, and I was wondering how this would work on the HASSIO setup, so this is looking interesting.

So, current state:

  1. you’ve reached out via the RFC process, I read those comments… not much happening…?
  2. you can use portainer to manually setup socat on the HA container… but maybe this needs to happen on each upgrade?
  3. you’ve suggested here (but not in RFC?) a change to the zwave component which would allow specifying optional host/port to the remote network serial device.

This third item looks ideal. Have you seen anyone doing it this way or looking at it?

I have not much much more exploring since I made this work for me.

Currently I am using a zha custom component to call a scripts to mount the socat process.
See the two lines here.

the script it calls is here.

Its not clean as I have to manually update the custom components when things are changed. I unfortunately am not skilled enough in python to make any of the other options a reality.

That’s interesting.

This is the first thing that has me interested in doing a custom component. I think i could put together a rough attempt to read custom zwave/zha config to setup socat…

No promises :slight_smile: but I’m going to investigate.

@bsherman Did you have any luck?

Maybe this might be interesting for you

Sorry for slow reply.

I did start the process of setting up custom component dev, but had some other systems problems that prevented me from making progress. I’m still interested though :slight_smile: