XCP-NG with Zigbee, but network instead of USB

tl;dr - Options to share RPi3 with USB SONOFF Zigbee stick to HA over network.

I got a Home Assistant VM running on XCP-ng to use my SONOFF Zigbee USB stick via pass-through. It all worked fine from the HA point of view, but snapshots didn’t work on XCP-NG, and besides that if I migrated the VM to another host then it will lose access to the USB stick plugged into the original physical host.

So, I want to be able to use my SONOFF Zigbee stick from any XCG-NG host, which I guess means sharing it over the network somehow.

I’ve seen MQTT, Mosquitto, ser2net, etc., being mentioned but I’m lost a bit in what to actually use for my purposes.

I have a bunch of spare Raspberry Pi 3 devices that I’d like to repurpose for this - one for production and one for hot swap as a backup with a cloned SD card.

I’ve also seen a pre-made network enabled Zigbee sticks like SLZB-06 for example, but I would rather not have to purchase more stuff.

Hello,

I was in a similar situation as you, with HA running on a remote server and a SONOFF zigbee stick at home.
I’ve been using usbip on a Raspberry Pi with the dongle connected. Then the host with HA would connect to the Rapsberry Pi to get Zigbee connectivity.
Another solution is virtualhere, but it is a paid option.

That worked fine for a time with the caveat that every time the VPN connection to the host was off, I had to restart the usbip service or reboot the Pi.

I ended up buying a SLZB-MR01, which makes the setup way more easier and reliable.
I also add the benefit that you could easily move the stick on the best location in your house, especially if you have PoE capable switches.

EDIT:
I didn’t consider that at that time, but if you confortable with Docker, you could also install it on the Pi.
Then run 2 containers: zigbee2mqtt and MQTT.
HA would just need to connect to MQTT and you would have all your Zigbee devices available.

Hi mlantin,

Never knew about the usbip project, looks interesting. I was looking into VirtualHere and other similar paid projects before for sharing USB stuff from home machine to my work machine for a work from home thing I needed, but never thought about it from this point of view. I don’t think I will go down that route for this need though.

The SLZB-MR01 I also saw, seems like a good device and as you say it’s PoE so can go anywhere really. But my RPis can go anywhere too as I have many PoE to USB splitters that can power the RPis. My switch is a UniFi USW Pro HD 24 PoE which is super good and would have no trouble running this kind of thing.

Ya, I’m used of Docker. This is kind of along the lines of what I was thinking - zigbee2mqtt / MQTT on the RPi to share out the SONOFF Zigbree stick and a backup RPi with clone SDCard just in case the production one breaks.

I’m just not sure where to start with this, do you know any good guides on hooking it all up. I know on HA instead of using the main Zigbee integration you use the MQTT based one instead, but that’s all I know.

If this doesn’t work out or I find managing the RPis serving the SONOFF stick too troublesome, then I’ll just buy the SLZB-MR01 or similar. But until then I want to force myself to learn it from the ground up, even though it’s very nice to have a plug and play option.

I don’t have any guide for that, but I’ll try to summarize briefly what a quick search gave me.
Assuming you’ve got Docker and Docker-compose up and running on a Raspberry.

Create 2 containers using docker-compose.yml files.
You obviously need to adapt ports and path to your liking.

MQTT

mosquitto:
    container_name: mosquitto
    image: eclipse-mosquitto:2
    restart: unless-stopped
    ports:
      - "1883:1883/tcp"
    volumes:
      - ./data/mosquitto/config:/mosquitto/config
      - ./data/mosquitto/data:/mosquitto/data
      - ./data/mosquitto/log:/mosquitto/log
    environment:
      - TZ=Europe/Berlin # Match your timezone   
    healthcheck:
      test: ["CMD", "mosquitto_sub", "-u", "test", "-P", "test_user_password", "-h", "localhost", "-t", "$$SYS/broker/uptime", "-i", "docker_health_check", "-C", "1"]
      interval: 1m
      timeout: 10s
      retries: 3

Then in /data/mosquitto/config you’ll want to create a config file. Mine for instance looks like:

persistence true
persistence_location /mosquitto/data/

password_file /mosquitto/config/pwfile
allow_anonymous false

log_dest file /mosquitto/log/mosquitto.log

listener 1883

And once you start the container you can create a user in mosquitto with a command like this:

docker compose exec mosquitto mosquitto_passwd -b /mosquitto/config/pwfile test test_user_password

Once you’ve created a user you need to restart mosquitto (restart the container).
You’d need to also create a user for zigbee2mqtt and another one for Home Assistant.

Then, we can create the Z2M container.

Zigbee2MQTT

services:
    zigbee2mqtt:
        container_name: zigbee2mqtt
        image: ghcr.io/koenkk/zigbee2mqtt
        restart: unless-stopped
        volumes:
            - ./data/z2m:/app/data  # a folder on your Pi to store the config files
            - /run/udev:/run/udev:ro
        ports:
            # WebUI port
            - 8080:8080
        environment:
            - TZ=Europe/Berlin # Match your timezone
        devices:
            # Make sure this matched your adapter location
            - /dev/serial/by-id/usb-Texas_Instruments_TI_CC2531_USB_CDC___0X00124B0018ED3DDF-if00:/dev/ttyACM0

Once the container is running, go to the WebUI (port 8080 in the example below) to continue the configuration, it’s pretty straightforward.

Lastly, in Home Assistant, add the MQTT integration and add an entry for the MQTT broker installed on the RPi.

All Zigbee devices added through Z2M will be published to MQTT and Home Assistant will see them if properly connected to MQTT.

Hope that could help you,

Sources:

MQTT - Home Assistant

Hi mlantin,

Thanks! This is exactly what I needed.

Looking at this and getting it done and working is fine but I think I might go down the dedicated POE SLZB adapter path when all tried and tested. It seems like there’s going to be extra maintenance using the RPi way that I wasn’t thinking of, whereas the SLZB stick just has firmware updates which can be done either via its own web interface or even directly through home assistant.

Thanks for all the guidance, much appreciated.

Not sure if a typo, so did you mean

this (slzb-mr1)

or this (slzb-mrw10)

SLZB-MR1, the first link.

Cool, was thinking so.

I was reading this article on which radio/chipset to use for Zigbee and which for Thread. He goes into great detail about all of it, so linking it here for a reference.

I got my RPi working but like I said earlier I’d rather not have to deal with the far more upgrade/management points, and this has an extra radio to boot! I’m going to get one of these before I start pairing up because otherwise I’ve to do it all over again later.

Just not sure to get the SLZB -MR1, -MR2, or -MR3

Edit: Just ordered the SLZB-MR1 as the -MR3 was out of stock and didn’t like the -MR2