Add network protocol support to Zigbee and Zwave Integrations

Update:

This is now possible with the built in zigbee integration.

Choosing the EZSP radio and using socket://ipaddress:3334 allows me to use the ser2net server hosting my husbzb-1

Old Post:

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:

See the first post. This now works with the built-in zigbee integration.

Is there any way to setup this for zwave just the way you can with zigbee? (socket://ipaddress:3334)

Sadly No. zwave only accepts /usbpath

Also the zwave mqtt path they are headed towards completely kills my setup.

If any developers are paying attention I would be willing to buy the hardware if you think this is doable.

Adding an update here. Zwave- JS adds promise to my goal.

Underlying Zwave-JS and zwave-js-server supports serial over tcp.

In addition to serial ports, serial-over-tcp connections (e.g. by using ser2net ) are now supported. You can connect to such a host using a connection string of the form tcp://hostname:port . Use these ser2net settings to host a serial port: `:raw:0::115200 8DATABITS NONE 1STOPBIT

The Official HASS zwave-js add on does work with tcp://IP:port but the configuration screen and yaml editor does not allow you to save that configuration.

Pull request to undo the breaking change for device tty validation was rejected. Only option now is custom add on or community ZwaveJS - MQTT integration.

It’s a shame, really. The developers are willingly alienating a lot of users with this decision. One should not be required to have a degree in current technologies used in software development to be able to use zwave in a central home position. Of course, this only seem to apply to Home Assistant…

This is from a while ago, but wouldn’t it be better to run socat on the docker host and map the ttyUSB devices to the docker container? This way you can upgrade your container without having to run these commands inside the container.