brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Guide: Zigbee2MQTT and Home Assistant on Unraid: USB stick, Mosquitto and your first sensor

Zigbee2MQTT and Home Assistant on Unraid: USB stick, Mosquitto and your first sensor

Guide unraid

12 steps 10 min read

I run Home Assistant as a container on my Unraid server, and the first thing I would add to it is Zigbee. Cheap battery sensors, no vendor cloud. The route I would take is Zigbee2MQTT: a USB coordinator stick, a Mosquitto broker with a password, and Zigbee2MQTT in between, talking to Home Assistant through its MQTT integration. Most of the pain sits in three spots: the stick’s USB path, an open broker, and a network key you cannot change later without re-pairing everything. I checked every setting below against the official Zigbee2MQTT, Mosquitto, Home Assistant and Docker docs, and where I could not confirm something I say so.

Time
10 min
Steps
12
Updated
19 Nov 2026

You will learn

  • How the data travels
  • Pick the stick and plug it in with a…
  • Mosquitto with a username and password
  • Find the stick's stable path
  • The Zigbee2MQTT container and the US…
Zigbee2MQTT onboarding page with the Found Devices dropdown for picking the coordinator

What you get and what you need

You end up with a Zigbee network you own, a web page for pairing devices, and sensors that show up in Home Assistant as normal entities. You need Unraid with Docker running, a working Home Assistant and a Zigbee coordinator stick. Zigbee2MQTT’s docs call the Texas Instruments (zStack) and Silicon Labs (EmberZNet) families the recommended ones and list every supported adapter on their adapters page, so pick your exact model there. The reference here is the current Zigbee2MQTT image from ghcr.io/koenkk/zigbee2mqtt and the official eclipse-mosquitto image; the Mosquitto docs I read describe 2.0 and newer, so check the version you actually pull.

The easy route in the Home Assistant docs is the Mosquitto app, which needs an install that supports apps. I run Home Assistant as a plain container, so Mosquitto gets its own container here.

Step 1 of 12: How the data travels

A sensor talks Zigbee on 2.4 GHz to the stick. Zigbee2MQTT owns the stick through a serial port and publishes every reading as an MQTT message to Mosquitto. Home Assistant is a client of the same broker: it subscribes, and through MQTT discovery it creates the entities by itself. When something breaks, the problem lives on exactly one of those arrows.

Animation: a sensor reading travels from the sensor over Zigbee to the USB stick, through Zigbee2MQTT and Mosquitto into Home Assistant
Animation: one reading from sensor to Home Assistant

Step 2 of 12: Pick the stick and plug it in with a cable

The adapter needs coordinator firmware; the docs say some come pre-flashed and some do not, so read the page for your model first. The part people skip is the cable. The Zigbee2MQTT docs say a USB extension cable of 50 cm is already enough to reduce interference, preferably a shielded one, and that it may help to use a USB 2 port instead of USB 3. They also warn that placing the adapter close to a USB or HDMI port can kill the radio signal entirely.

On a server this matters: the back of a NAS is a crowd of USB ports. I would use a USB 2 port, a short extension cable and put the stick on a shelf, not behind the case. After pairing you can watch linkquality while you move it around.

Step 3 of 12: Mosquitto with a username and password

Mosquitto 2.0 and up makes you choose authentication explicitly before remote clients can connect, so an empty config is not enough. Create the folders and the config, then the password file, then start the broker.

mkdir -p /mnt/user/appdata/mosquitto/{config,data,log}

cat > /mnt/user/appdata/mosquitto/config/mosquitto.conf <<'EOF'
listener 1883
allow_anonymous false
password_file /mosquitto/config/passwd
persistence true
persistence_location /mosquitto/data/
EOF

# first user (-c creates the file, it overwrites an existing one)
docker run --rm -it -v /mnt/user/appdata/mosquitto/config:/mosquitto/config \
  eclipse-mosquitto mosquitto_passwd -c /mosquitto/config/passwd z2m
# second user, no -c this time
docker run --rm -it -v /mnt/user/appdata/mosquitto/config:/mosquitto/config \
  eclipse-mosquitto mosquitto_passwd /mosquitto/config/passwd homeassistant

docker run -d --name mosquitto --restart unless-stopped -p 1883:1883 \
  -v /mnt/user/appdata/mosquitto/config:/mosquitto/config \
  -v /mnt/user/appdata/mosquitto/data:/mosquitto/data \
  -v /mnt/user/appdata/mosquitto/log:/mosquitto/log \
  eclipse-mosquitto

The mounts and the port come from the image’s own page; the same values go into an Unraid template. Two users on purpose, so you can cut one off without touching the other. I leave the password off the command line, because it would end up in the shell history.

To verify, subscribe with the right user and keep that window open. Then try without a user and see it refused.

docker exec -it mosquitto mosquitto_sub -h localhost -u z2m -P '<password>' -t 'zigbee2mqtt/#' -v
docker logs mosquitto

Newer Mosquitto versions can complain in the log about the owner or permissions of the password file. I found no official page with exact values for the container case, so follow what the message says.

Step 4 of 12: Find the stick’s stable path

Never point a container at /dev/ttyUSB0 or /dev/ttyACM0. Those names are handed out in plug-in order and can change after a reboot or when another USB device shows up. The Zigbee2MQTT docs say to always use the /dev/serial/by-id/ path on the host. Open the Unraid terminal with the stick plugged in:

ls -l /dev/serial/by-id/

You get one line per serial device: a long name like usb-<vendor>_<model>_<serial>-if00-port0 pointing at a ttyUSB or ttyACM node. Copy that name. No folder means the stick is not seen as a serial device yet.

Step 5 of 12: The Zigbee2MQTT container and the USB device

Docker’s --device option exposes a host device to an otherwise unprivileged container, in the form host-path:container-path. No privileged container needed. The Zigbee2MQTT install docs give this layout; I changed the container path to /dev/zigbee, the same name the Unraid Community Apps template for Zigbee2MQTT suggests in its notes.

docker run -d --name zigbee2mqtt --restart unless-stopped \
  --device=/dev/serial/by-id/usb-<vendor>_<model>_<serial>-if00-port0:/dev/zigbee \
  -p 8080:8080 \
  -v /mnt/user/appdata/zigbee2mqtt:/app/data \
  -v /run/udev:/run/udev:ro \
  -e TZ=Europe/Amsterdam \
  ghcr.io/koenkk/zigbee2mqtt

The pieces: /app/data holds your configuration and database, port 8080 is the web frontend, and /run/udev read-only is, per the docs, needed for adapter auto-detection. On the Unraid Docker tab the same thing is a template with a path for /app/data, a port for 8080 and the device passed as an extra parameter (--device=... in the Advanced view). I cannot give you the exact labels of your Unraid version, so check them. The Community Apps template from digiblur also tells you to edit configuration.yaml in the appdata folder.

Recent Zigbee2MQTT versions start an onboarding page when no configuration.yaml exists: open the frontend port, pick your stick under Found Devices and fill in the MQTT details. I would write the file myself and put it in the data folder before the first start.

Step 6 of 12: Configuration.yaml

This is the file with the four blocks you were promised: serial, mqtt, frontend and homeassistant, plus the network settings. It follows the minimal example from the docs. Use the IP of your Unraid server for the broker; the container name only resolves on a custom Docker network, and a LAN IP always works.

version: 5
mqtt:
  base_topic: zigbee2mqtt
  server: mqtt://192.168.1.x:1883
  user: z2m
  password: '!secret.yaml password'
serial:
  port: /dev/zigbee
  adapter: zstack
frontend:
  enabled: true
  port: 8080
homeassistant:
  enabled: true
advanced:
  channel: 20
  network_key: GENERATE
  pan_id: GENERATE
  ext_pan_id: GENERATE

Next to it, in the same folder, a secret.yaml with password: <the z2m password>. The quotes around the !secret.yaml reference are required, per the docs. The adapter line depends on your stick: the docs allow zstack, ember, deconz, zigate and zboss. I put zstack in the example, so match it to your stick’s page. The file must stay writable, because Zigbee2MQTT updates it. If you read my secrets and env guide, this is the same idea: keep the password out of the main file.

The frontend has an auth_token option, off by default and stored in clear text. If you put the frontend behind a reverse proxy with basic auth, note the docs warning that basic auth does not work with WebSockets in WebKit browsers, which includes every iOS browser; use auth_token instead.

Cheat sheet with the configuration.yaml blocks, the Unraid container settings and the usual failure points

Step 7 of 12: Network key and channel, decided once

The docs list default values for network_key, pan_id and ext_pan_id, and those are published on the docs page, so everyone who takes the defaults shares them. GENERATE makes Zigbee2MQTT create new values on the next startup. After the first start I would open configuration.yaml and confirm it holds real values rather than the word GENERATE; the docs do not spell out what the file looks like afterwards, so look, and then copy the whole data folder somewhere safe.

Changing the network_key requires re-pairing all devices, and changing the channel might require re-pairing some. The docs say to use one of 11, 15, 20 or 25, chosen against the closest Wi-Fi 2.4 GHz network, because both share the band. I would fix my router’s 2.4 GHz channel first, pick the Zigbee channel away from it and never touch it again. The 20 above is only an example.

Step 8 of 12: Pair a first sensor

Start the container and read the log; you want to see it connect to the stick and the broker. Then open the frontend, port 8080 on your server, and click the join button at the top right. That opens the network for 254 seconds. Put the sensor in pairing mode; the Supported Devices list has the steps per model, and without any a factory reset usually does it. The log says the device has successfully been paired.

Rename it in the frontend, because the friendly name becomes the MQTT topic: readings go to zigbee2mqtt/<friendly_name> as JSON. Your open mosquitto_sub window should now print something that looks like {"temperature": 21.5, "humidity": 48.3, "battery": 95, "linkquality": 120}; the fields depend on the sensor and this sample is illustrative.

Step 9 of 12: Home Assistant finds it

In Home Assistant open Settings, Devices and services, Add integration, and choose MQTT. Enter the broker’s address, the port and the homeassistant user with its password. MQTT discovery is on by default with the prefix homeassistant, and because homeassistant: enabled: true is set in Zigbee2MQTT, your sensor appears as a device with its entities. Per the docs, renaming in the Zigbee2MQTT frontend needs no Home Assistant restart.

Step 10 of 12: Troubleshooting

The container does not start or says it cannot find the adapter: check that the by-id link exists on the host and that you copied it exactly. If the first start fails, the docs say onboarding runs again. An SRSP timeout talking to the stick is, per the FAQ, normally fixed by replugging the adapter and restarting Zigbee2MQTT.

Not authorised on MQTT: wrong user or password. Check docker logs mosquitto, and restart the container after you edit the password file.

A device will not pair or the interview fails: make sure joining is enabled, pair closer to the coordinator, fit a fresh battery, use the extension cable, and try pairing near a mains-powered bulb that acts as a router. The docs say almost all mains-powered devices act as routers. A device that keeps dropping wants a mains-powered router nearby.

Entities do not appear in Home Assistant: the MQTT integration is missing or points at the wrong host, homeassistant: enabled is false, or the discovery prefix was changed in one place only. After changing the channel, a device that stays unresponsive for several minutes after waking may need to be re-paired by hand.

For the long run, a healthcheck and log rotation are worth the five minutes.

Step 11 of 12: My advice

Buy a stick from the supported list, plug it in on a USB 2 port with an extension cable, use the by-id path, give the broker a password and write the network settings down before you pair the first sensor. The network key and channel are the two decisions you cannot cheaply undo, so make them early and back up the data folder. The rest can be restarted and fixed in a minute.

Step 12 of 12: Where to go next

For reaching Home Assistant when you are away, my Tailscale ACLs and tags guide covers limiting who can reach what, and the key expiry guide covers keeping a container node from dropping off the tailnet.

Further reading

Link