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.

##Zwave
3333:raw:0:/dev/ttyUSB0:115200 8DATABITS NONE 1STOPBIT
##Zigbee
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 https://www.gl-inet.com/products/gl-ar150/

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:192.168.47.168:3333 &
socat pty,link=/dev/ttyUSB1,raw,user=0,group=0,mode=777 tcp:192.168.47.168:3334 &

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.

zwave:
  usb_path: /dev/ttyUSB0
  net_path: 192.168.0.10:3333
  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.

https://github.com/rbflurry/Home-Assistant-Config/blob/174b62069231e54bb7790c15400bca7f836c2517/custom_components/zha/init.py#L6

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: