How to Set Up Zigbee2MQTT with Home Assistant (Complete Guide)


Zigbee2MQTT (Z2M) is the most flexible way to run Zigbee devices with Home Assistant. It gives you more control, better device support, and a powerful dashboard for managing your mesh. Here’s how to set it up from scratch.

Why Zigbee2MQTT Over ZHA?

Home Assistant has a built-in Zigbee integration called ZHA (Zigbee Home Automation). It works fine. So why use Z2M instead?

Zigbee2MQTTZHA
Device support2,800+ devices2,400+ devices
New device supportUsually firstSlightly behind
ConfigurationYAML + web UIHA UI only
MQTTRequired (adds flexibility)Not needed
Setup complexityMediumEasy
Mesh visualizationBuilt-in, excellentBasic
OTA updatesBuilt-in for many devicesLimited
External toolsWorks with any MQTT clientHA-only

My take: If you’re just starting out and want the simplest path, ZHA is fine. If you want the most device support, best mesh visualization, and plan to grow your network beyond 30-40 devices, go with Z2M.

What You Need

  1. A Zigbee coordinator — I recommend the SONOFF Zigbee 3.0 USB Dongle Plus (CC2652P). ~$28 on Amazon.
  2. MQTT broker — Mosquitto, which runs as a Home Assistant add-on.
  3. Zigbee2MQTT — runs as a Home Assistant add-on.
  4. At least one Zigbee device to test with.

Step 1: Plug In Your Coordinator

Plug the SONOFF dongle into your Home Assistant server. If you’re running HA on a VM, make sure USB passthrough is configured.

Important: Use a USB extension cable (even a short one). Having the coordinator right next to the computer creates radio interference. A 3-foot USB extension cable makes a real difference in range and stability.

Step 2: Find Your Device Path

SSH into Home Assistant or use the Terminal add-on:

ls -la /dev/serial/by-id/

You’ll see something like:

usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_XXXXXXXXXXXX-if00-port0

Copy this full path. You’ll need it in the Z2M configuration.

Step 3: Install Mosquitto MQTT Broker

  1. Go to Settings → Add-ons → Add-on Store
  2. Search for Mosquitto broker
  3. Click Install, then Start
  4. Go to Settings → Devices & Services → Integrations
  5. MQTT should auto-discover. Click Configure and accept the defaults.

That’s it — Mosquitto is running with Home Assistant auto-integration.

Step 4: Install Zigbee2MQTT

Z2M isn’t in the default add-on store. You need to add its repository first:

  1. Go to Settings → Add-ons → Add-on Store
  2. Click the 3-dot menu (top right) → Repositories
  3. Add this URL: https://github.com/zigbee2mqtt/hassio-zigbee2mqtt
  4. Click AddClose
  5. Refresh the page — you’ll see Zigbee2MQTT in the store
  6. Click Install

Step 5: Configure Zigbee2MQTT

Before starting, go to the Z2M add-on → Configuration tab. Set the serial port:

serial:
  port: /dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_XXXXXXXXXXXX-if00-port0

Replace with your actual device path from Step 2.

Other useful settings to add:

mqtt:
  base_topic: zigbee2mqtt
  server: mqtt://core-mosquitto
homeassistant:
  enabled: true
frontend:
  port: 8099
advanced:
  network_key: GENERATE
  log_level: info
  last_seen: ISO_8601

The network_key: GENERATE line creates a unique encryption key on first start. This secures your Zigbee network.

Step 6: Start Zigbee2MQTT

Click Start on the add-on. Check the logs — you should see:

Zigbee2MQTT:info  - Zigbee2MQTT started!
Zigbee2MQTT:info  - Coordinator firmware version: '...'

If you see errors about the serial port, double-check the device path. If you see “coordinator failed to start,” try unplugging and replugging the dongle.

Step 7: Access the Dashboard

Enable Show in sidebar on the Z2M add-on page. You’ll get a “Zigbee2MQTT” menu item in your HA sidebar. Click it to open the Z2M dashboard.

This dashboard is one of Z2M’s best features. You can:

  • See all paired devices
  • View and edit device settings
  • Visualize your Zigbee mesh (Map tab)
  • Monitor device connectivity
  • Update device firmware (OTA tab)

Step 8: Pair Your First Device

  1. In the Z2M dashboard, click Permit join (All) at the top
  2. Put your Zigbee device in pairing mode:
    • Aqara sensors: Hold the reset button for 5 seconds until the LED blinks
    • SONOFF devices: Hold the button for 5+ seconds
    • IKEA devices: Press the pairing button 4 times quickly
  3. Watch the Z2M logs — you’ll see the device appear within 30 seconds
  4. Click Permit join again to disable it (always disable when done)

The device will automatically appear in Home Assistant as new entities. No manual MQTT configuration needed.

Step 9: Rename and Organize

In the Z2M dashboard, click on your new device and give it a friendly name like kitchen_motion or front_door_contact. This name becomes the entity ID in Home Assistant.

Naming convention I use:

  • {room}_{device_type} — e.g., bedroom_temperature, garage_door, kitchen_motion

Consistent naming makes automations much easier to write and maintain.

Step 10: Check Your Mesh

Click the Map tab in the Z2M dashboard. You’ll see a visualization of your Zigbee mesh:

  • Green lines: Strong connections
  • Blue lines: Good connections
  • Red lines: Weak connections
  • Coordinator: Center of the mesh
  • Routers: Mains-powered devices (plugs, bulbs) that relay signals
  • End devices: Battery-powered sensors

If you see red lines or disconnected devices, add a router (smart plug or repeater) in between.

Troubleshooting Common Issues

Device won’t pair

  • Make sure permit join is enabled
  • Move the device closer to the coordinator or a router
  • Try resetting the device (hold reset 10+ seconds)
  • Some devices need to be factory reset before re-pairing

Device drops offline frequently

  • Your mesh is too thin — add more routers
  • The device is too far from any router
  • Check for Wi-Fi interference (Zigbee uses 2.4GHz, same as Wi-Fi)
  • Change the Zigbee channel in Z2M settings to avoid Wi-Fi overlap

Entities not appearing in Home Assistant

  • Check that homeassistant: enabled: true is in your Z2M config
  • Restart the Z2M add-on
  • Check Settings → Devices & Services → MQTT — devices should auto-discover

Coordinator shows as offline

  • USB passthrough issue (common with VMs)
  • Try a different USB port
  • Use a USB extension cable to reduce interference

My Z2M Network

For reference, I run 40+ Zigbee devices through Z2M:

  • 8 motion sensors
  • 12 contact sensors
  • 6 temperature sensors
  • 4 smart plugs (also serving as mesh routers)
  • 6 smart bulbs (also routers)
  • Assorted buttons and leak sensors

With enough routers distributed around the house, the mesh is rock solid. Devices report instantly and battery life is excellent (12-18 months on most sensors).

Next Steps

Once Z2M is running:

  1. Add devices room by room — start with the rooms where you want automation first
  2. Build your mesh — add at least one mains-powered device per room
  3. Create automations — motion lights, door alerts, temperature monitoring
  4. Check the map regularly — a healthy mesh means reliable automations