Connecting to a remote Zigbee coordinator with ZHA using ser2net

This is a quick guide on how to connect ZHA to a Zigbee coordinator on different hardware than the hardware HomeAssistant is running on.

Reasons for wanting to do this could include:

  • HomeAssistant running on hardware in a bad location in your house
  • Needing to use ZHA over Z2M
  • Long USB cords causing instability in Zigbee network

You will need another computer running Linux. A Raspberry Pi would work fine. I am using some really old Optiplex SFF running Debian.

  1. On the linux computer, run apt install ser2net.
  2. Get the USB path by-id. This prevents issues when plugging in other devices to USB ports or moving the device to a different port. ls /dev/serial/by-id
    My output: usb-dresden_elektronik_ingenieurtechnik_GmbH_ConBee_II_DE2420347-if00
  3. Edit the yaml config for ser2net with sudo nano /etc/ser2net.yaml
    3.a The file will have a bunch of default config in it - comment all of that out and add the new config to the bottom:
connection: &con01
    accepter: tcp,20108
    enable: on
    options:
      kickolduser: true
      chardelay-min: 0
      chardelay-max: 0
    connector: serialdev,
              /dev/serial/by-id/usb-dresden_elektronik_ingenieurtechnik_GmbH_ConBee_II_DE2420347-if00,
              115200n81,nobreak,local

Check: [Connect to a remote adapter | Zigbee2MQTT](Connect to a Remote Adapter) for examples of other adapter configs. Note I changed the Conbee II config slightly from the example in that article to match the default configs I noticed in the yaml file and added some options I think provide more stability. I am not sure if this was necessary.

  1. Save with ctrl+x and execute:
    sudo systemctl restart ser2net
    
  2. In HomeAssistant navigate to Settings > Devices & Services > Integrations > ZHA (Configure button).
  3. Click Migrate Radio
  4. Select reconfigure the current radio
  5. On serial device path click “enter manually”
  6. Type in:
    tcp://192.168.X.X:20108
    
    9.a Substitute 192.168.X.X with the IP or hostname of the workstation that the coordinator is plugged into.

I have HomeAssistant running on a rack server in the basement. Previously I was using a very long USB cable and a lot of commands would fail, especially scenes involving a lot of Zigbee devices. Since making this change the stability has been rock solid.

Edit:

  • Changed the USB path to device by-id - Thanks SwerveShot

  • Added chardeley-min and chardelay-max options in ser2net.yaml - not sure if this actually does anything, but larger commans, like turn off all the lights at once, seem to be more consistent.

  • Added “or hostname” in option 9, as that is what I am using now

11 Likes

What an excellent idea. I was just wondering if this would be possible only to find a complete guide available to me. Thanks a lot for posting your setup.

At the moment I have a POPP ZB Stick connected directly to my home assistant server, but having it located elsewhere will be much better in terms of signal strength. So I will definitely give this a try.

I’m already using an old Raspberry Pi with ser2net to connect to my smart utility meter which is nowhere near my home assistant server. Adding a couple of new lines to my ser2net config is something I think I can probably handle. :grinning_face_with_smiling_eyes:

1 Like

Aside from the fact that I’m running a bit older version of ser2net which does not support a YAML style config the migration went fine. I don’t have a kickolduser setting and reloading the zha integration did not close the TCP connection right away. So I had to allow more than 1 connection.

Finally, as suggested on the ZHA integration page I switched to using the device path /dev/serial/by-id instead of using /dev/ttyUSB1. This will cause the configuration to still work when sticking USB devices in other ports than they were inserted originally. And maybe got another ttyUSB reference assigned. Devices in the /dev/serial/by-id path are simply symbolic links so it does not affect the way the devices work.

3001:raw:600:/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0:115200 8DATABITS NONE 1STOPBIT max-connections=3

Cannot access /dev/serial/by-id: No such file or directory

So far, no good!:unamused:

That’s strange. What distro are you using. This is after you plugged your coordinator into the remote computer?

Unplug and replug your coordinator into the USB port then run dmesg. What is your output?

Perhaps this is why:

serial:
  port: tcp://192.168.1.115:8888
  adapter: ezsp

is it possible to do a backup of the zigbee stick if it is attached via ser2net?

I don’t get errors when performing backups. I did recently switch to a Sonoff 3.0 and backing up from Conbee to Sonoff failed, but I think that’s to be expected.

Hello, first, thanks for this guide! I am also looking for such a solution so that I want to move my device running home assistant to basement, and I still need to put the Z-Wave and ZHA stick in the middle of living room.
I just have question, because in the home assistant ZHA documentation, it says Ser2Net remote adapter is not recommended, “Serial protocols used by the Zigbee Coordinator do not have enough robustness, resilience, or fault tolerance to handle packet loss and latency delays that can occur over unstable connections.”
I know this is somehow has to be comprised. I only want to ask, what is the real experience you have with this setup. Is there realizable behavior? Or it doesn’t have big impact?
Thanks! I currently only connected on IKEA remote button in the ZHA, and want to add a Aqara relay module later.

I haven’t had any issues.

I think the key part in the caution in the ZHA documentaion is:

Be aware that using a Zigbee Coordinator via a Serial-Proxy-Server (also known as Serial-to-IP bridge or Ser2Net remote adapter) over a Wi-Fi, WAN, or VPN connection is not recommended.

I would recommend connecting over ethernet. I haven’t, nor would I, try to connect over WIFI, WAN, or VPN.