๐ Zigbee2MQTT
![]()
Zigbee2MQTT allows you to use your Zigbee devices without the vendorโs bridge or gateway. It bridges events and allows you to control your Zigbee devices via MQTT.
Works great with Home Assistant, OpenHAB, and any MQTT-compatible home automation platform.
๐ท๏ธ Category: Network, Smarthome
๐ณ Image: koenkk/zigbee2mqtt:latest
โ ๏ธ Requires: Zigbee USB coordinator (CC2531, ConBee II, Sonoff ZBDongle, etc.)
๐ Links
| ย | ย |
|---|---|
| ๐ Website | zigbee2mqtt.io |
| ๐ Documentation | zigbee2mqtt.io/guide |
| ๐ Support | GitHub Issues |
| ๐ฆ Supported Devices | zigbee2mqtt.io/supported-devices |
๐ Ports
| Port | Protocol | Description |
|---|---|---|
8080 | TCP | Zigbee2MQTT web frontend |
๐พ Volumes
| Host Path | Container Path | Mode | Description |
|---|---|---|---|
/mnt/cache/appdata/zigbee2mqtt | /app/data | RW | Configuration, device database, and state |
โ๏ธ Environment Variables
๐ค Permissions
| Variable | Default | Masked | Description |
|---|---|---|---|
PUID | 500 | โ | User ID for file permissions |
PGID | 500 | โ | Group ID for file permissions |
TZ | Europe/Vienna | โ | Timezone for the container |
๐ MQTT Connection
| Variable | Default | Masked | Description |
|---|---|---|---|
ZIGBEE2MQTT_CONFIG_MQTT_SERVER | mqtt://mosquitto:1883 | โ | MQTT broker URL. Use container name or IP. |
ZIGBEE2MQTT_CONFIG_MQTT_USER | `` | โ | MQTT username (if authentication enabled) |
ZIGBEE2MQTT_CONFIG_MQTT_PASSWORD | `` | โ | MQTT password (if authentication enabled) |
๐ Zigbee Adapter
| Variable | Default | Masked | Description |
|---|---|---|---|
ZIGBEE2MQTT_CONFIG_SERIAL_PORT | /dev/ttyUSB0 | โ | USB port of your Zigbee coordinator |
ZIGBEE2MQTT_CONFIG_SERIAL_ADAPTER | auto | โ | Adapter type: zstack, deconz, zigate, ezsp |
ZIGBEE2MQTT_CONFIG_PERMIT_JOIN | false | โ | Allow new devices to join (true/false) |
๐ Quick Start
Prerequisites
You need a Zigbee USB coordinator:
- CC2531 (cheapest, needs flashing)
- ConBee II / RaspBee (popular, good range)
- Sonoff ZBDongle-P/E (popular, pre-flashed)
- Electrolama zig-a-zig-ah! (zzh)
- Slaeshโs CC2652RB stick
And an MQTT broker (like the Mosquitto template).
Step 1: Find Your USB Device
Before installing, identify your Zigbee adapter:
# List USB devices
ls -la /dev/serial/by-id/
ls -la /dev/ttyUSB*
ls -la /dev/ttyACM*
Note the device path (e.g., /dev/ttyUSB0 or /dev/ttyACM0).
Step 2: Update Container Device
Edit the container and update the Device in extra_parameters:
--device=/dev/ttyUSB0
Use the path you identified in Step 1.
Step 3: Install via MOS Hub
- Open the MOS Hub and search for Zigbee2MQTT
- Configure MQTT:
- If using Mosquitto template: keep default
mqtt://mosquitto:1883 - Otherwise set your MQTT broker IP:
mqtt://192.168.1.10:1883
- If using Mosquitto template: keep default
- Set MQTT credentials if your broker requires authentication
- Verify
ZIGBEE2MQTT_CONFIG_SERIAL_PORTmatches your USB device - Click Install
Step 4: Access Frontend
- Open Zigbee2MQTT at
http://YOUR_SERVER_IP:8080 - The frontend shows network map, devices, and logs
Step 5: Pair Your First Device
- In the web frontend, click Permit join (All)
- Put your Zigbee device in pairing mode (usually hold button for 5-10 seconds)
- Device should appear in the device list
- Click on device to configure friendly name
๐ง Configuration
MQTT Broker Setup
If using the Mosquitto template:
ZIGBEE2MQTT_CONFIG_MQTT_SERVER=mqtt://mosquitto:1883
If Mosquitto requires auth, set the same credentials you configured in Mosquitto.
For external MQTT broker:
ZIGBEE2MQTT_CONFIG_MQTT_SERVER=mqtt://192.168.1.10:1883
ZIGBEE2MQTT_CONFIG_MQTT_USER=zigbee2mqtt
ZIGBEE2MQTT_CONFIG_MQTT_PASSWORD=yourpassword
Serial Port Troubleshooting
Common device paths:
/dev/ttyUSB0- Most USB sticks (CC2531, Sonoff)/dev/ttyACM0- ConBee II, some other adapters/dev/ttyAMA0- RaspBee on Raspberry Pi GPIO
Persistent naming (recommended):
ls -la /dev/serial/by-id/
# Use the full path like:
# /dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_12345-if00-port0
Update the device in container settings with the persistent path.
Adapter Types
Auto-detect works for most adapters, but you can specify:
zstack- Texas Instruments CC2531, CC2652P (most common)deconz- Dresden ConBee/RaspBeezigate- ZiGate USB-TTLezsp- Silicon Labs EZSP (HubZ, HUSBZB-1)zboss- ZBOSS NCP
Pairing Devices
Enable pairing:
ZIGBEE2MQTT_CONFIG_PERMIT_JOIN=true
Security best practice: Only enable when adding devices, then disable:
ZIGBEE2MQTT_CONFIG_PERMIT_JOIN=false
๐ Home Assistant Integration
Zigbee2MQTT integrates seamlessly with Home Assistant via MQTT Discovery.
MQTT Discovery (Automatic)
- Ensure Home Assistant MQTT integration is configured
- Zigbee2MQTT auto-discovers devices - they appear automatically in HA
- Devices show as entities you can control and monitor
Manual MQTT Topics
Base topic: zigbee2mqtt
| Topic | Purpose |
|---|---|
zigbee2mqtt/FRIENDLY_NAME | Device state |
zigbee2mqtt/FRIENDLY_NAME/set | Send commands |
zigbee2mqtt/FRIENDLY_NAME/get | Request state |
Example: Control a Light
# Home Assistant configuration.yaml
light:
- platform: mqtt
name: "Bedroom Light"
state_topic: "zigbee2mqtt/bedroom_light"
command_topic: "zigbee2mqtt/bedroom_light/set"
brightness_state_topic: "zigbee2mqtt/bedroom_light"
brightness_command_topic: "zigbee2mqtt/bedroom_light/set"
brightness_scale: 254
๐ ๏ธ Troubleshooting
โError: Failed to connect to MQTTโ
- Verify MQTT broker is running:
docker ps | grep mosquitto - Check MQTT URL is correct
- Verify credentials if auth is enabled
- Test with MQTT client:
mosquitto_pub -h IP -t test -m "hello"
โError: SRSP - AF data requestโ
USB device not found or permissions issue:
- Check device path is correct:
ls -la /dev/ttyUSB* - Verify PUID/PGID can access the device
- Fix permissions:
sudo usermod -aG dialout $USER
Devices Not Pairing
- Enable permit join:
ZIGBEE2MQTT_CONFIG_PERMIT_JOIN=true - Check device is Zigbee (not Z-Wave or WiFi)
- Ensure device is in pairing mode (check device manual)
- Move device closer to coordinator
- Check supported devices list: zigbee2mqtt.io/supported-devices
Weak Signal / Dropped Connections
- Use USB extension cable (2-3m) to move coordinator away from USB3/WiFi
- Add Zigbee routers (smart plugs, bulbs) to extend mesh
- Check channel conflicts (WiFi vs Zigbee)
- Consider coordinator with external antenna
High CPU Usage
- Reduce log level in configuration
- Disable device reporting if not needed
- Check for devices flooding the network
๐ก Best Practices
Zigbee Network Range
- Zigbee creates a mesh network - powered devices (routers) extend range
- Battery devices (end devices) donโt route traffic
- Add smart plugs or powered bulbs to extend network
Security
- Always disable
PERMIT_JOINafter pairing devices - Change default MQTT passwords
- Use separate MQTT user for Zigbee2MQTT
- Keep coordinator firmware updated
USB Port Selection
- Avoid USB 3.0 ports (causes interference)
- Use USB 2.0 port or extension cable
- Keep away from WiFi router/Bluetooth devices
Backup
Backup the data volume:
cp -r /mnt/cache/appdata/zigbee2mqtt /backup/zigbee2mqtt-$(date +%Y%m%d)
This preserves your device network (pairing info).
๐ Related Templates
| Template | Purpose | Integration |
|---|---|---|
| Mosquitto | MQTT broker | Required for Zigbee2MQTT |
| Home Assistant | Home automation | Consumes MQTT data |
| Node-RED | Automation flows | Can process MQTT events |
๐ก Tip: Keep your coordinator firmware updated for bug fixes and new device support.
๐ก Tip: A USB 2.0 extension cable (2-3 meters) significantly improves Zigbee range by moving the coordinator away from interference sources.
๐ก Tip: After initial setup, disable PERMIT_JOIN to prevent unauthorized devices from joining your network.
๐ For more information: Visit the Zigbee2MQTT Documentation for device-specific instructions, network optimization, and troubleshooting.