Skip to content

Zigbee2MQTT Advanced Guide

Zigbee Z2M Advanced

This guide covers advanced Zigbee2MQTT techniques - from network optimization and groups to firmware updates and troubleshooting. Perfect for getting the most out of your Zigbee network!


  • ✅ Better stability and performance
  • ✅ Support for newer Zigbee devices
  • ✅ Bug fixes
  • ✅ New features (e.g., Matter/Thread)
  1. Download firmware from GitHub

    • Recommended: sonoff_zbdonglee_zigbee_ncp_8.0.2.0_115200_sw_flow.gbl
  2. Go to Silabs Web Flasher

  3. Click CONNECT and select your dongle

  4. Click CHANGE FIRMWARE

  5. Upload the firmware file

  6. Wait for flashing (about 1-2 minutes)

  7. Update Z2M configuration:

    serial:
    adapter: ember # Change from ezsp to ember
  8. Restart Zigbee2MQTT

Terminal window
# Download firmware
wget https://github.com/Koenkk/Z-Stack-firmware/raw/master/coordinator/Z-Stack_3.x.0/bin/CC1352P2_CC2652P_launchpad_coordinator_20240710.zip
# Extract
unzip CC1352P2_CC2652P_launchpad_coordinator_20240710.zip
# Flash with cc2538-bsl
python3 cc2538-bsl.py -e -v -w --bootloader-sonoff-usb \
CC1352P2_CC2652P_launchpad_coordinator_20240710.hex \
-p /dev/ttyUSB0

Device TypeFunctionExamples
CoordinatorNetwork centerZBDongle-E/P, Conbee II
RouterExtends networkBulbs, plugs (constant power)
End DeviceSensors, battery-poweredDoor sensors, thermometers
# configuration.yaml - Optimal settings
advanced:
# Network key (generate unique)
network_key: GENERATE
# Transmit power (max for better range)
transmit_power: 20
# Channel (avoid WiFi overlap)
# Zigbee channel 11 = WiFi channel 1
# Zigbee channel 15 = WiFi channel 6
# Zigbee channel 20 = WiFi channel 11
# Zigbee channel 25 = Overlap-free
channel: 25
# PAN ID (let Z2M generate)
pan_id: GENERATE
# Increase for large networks
network_key_distribute: true
RouterQualityPriceNote
IKEA TRÅDFRI⭐⭐⭐~$12Cheap, stable
Philips Hue⭐⭐⭐⭐⭐~$25Excellent routing
SONOFF ZBDongle-E (Router)⭐⭐⭐⭐~$18Dedicated router
Aqara Smart Plug⭐⭐⭐⭐~$18Also measures power
SONOFF S26R2ZB⭐⭐~$12Variable quality
Terminal window
# Generate network map via MQTT
mosquitto_pub -t 'zigbee2mqtt/bridge/request/networkmap' \
-m '{"type": "raw", "routes": true}'

Visualize in Z2M Frontend under Map tab.


  • ✅ One command for many devices
  • ✅ Faster than individual commands
  • ✅ Synchronous response (all lights turn on simultaneously)
  • ✅ Reduces network traffic
  1. Open Z2M Frontend
  2. Go to Groups tab
  3. Click Add group
  4. Name the group (e.g., “Living Room Lights”)
  5. Add devices to the group
groups:
'1':
friendly_name: living_room_lights
# Retain MQTT messages (false = faster)
retain: false
# Transition time in seconds
transition: 1
# Update state before confirmation
optimistic: true
# When is the group OFF?
# all_members_off: When ALL devices are off
# last_member_state: When LAST device is off
off_state: 'all_members_off'

Bindings connect devices directly - without going through the coordinator. Perfect for:

  • Switches that control lights directly
  • Switches that work even when Z2M is down
  • Ultra-fast response
  1. Go to device page for the source (e.g., switch)
  2. Click Bind tab
  3. Select Destination (e.g., lamp or group)
  4. Select clusters to bind (On/Off, Level, etc.)
  5. Click Bind
ClusterFunction
genOnOffOn/off
genLevelCtrlBrightness
lightingColorCtrlColor/temperature
closuresWindowCoveringBlinds/covers

devices:
'0x00158d0001234567':
friendly_name: living_room_sensor
# Reduce noise
debounce: 1
# Filter attributes
filtered_attributes:
- linkquality
- voltage
# Retain MQTT messages
retain: true
# Optimistic mode
optimistic: true
# Device-specific settings
occupancy_timeout: 90
no_occupancy_since:
- 60
- 120
- 300
# configuration.yaml
devices: devices.yaml
groups: groups.yaml
# devices.yaml
'0x00158d0001234567':
friendly_name: living_room_sensor
'0x00158d0001234568':
friendly_name: bedroom_sensor
# groups.yaml
'1':
friendly_name: living_room_lights
'2':
friendly_name: all_lights
advanced:
# Logging
log_level: info
log_output:
- console
- file
log_file: zigbee2mqtt_%TIMESTAMP%.log
log_rotation: true
# Performance
cache_state: true
cache_state_persistent: true
cache_state_send_on_startup: true
# Network
last_seen: 'ISO_8601'
elapsed: true
# Security
permit_join: false
# Home Assistant
homeassistant_legacy_entity_attributes: false
legacy_api: false
legacy_availability_payload: false

Terminal window
# 1. Enable permit join on specific router
mosquitto_pub -t 'zigbee2mqtt/bridge/request/permit_join' \
-m '{"value": true, "device": "nearby_router"}'
# 2. Factory reset the device (see manual)
# 3. Move device closer to coordinator
# 4. Check logs
tail -f /opt/zigbee2mqtt/data/log/*/log.log
Terminal window
# WARNING: This deletes all devices!
# Use only as last resort
# 1. Stop Zigbee2MQTT
sudo systemctl stop zigbee2mqtt
# 2. Backup database
cp /opt/zigbee2mqtt/data/database.db /opt/zigbee2mqtt/data/database.db.backup
# 3. Delete database (DANGER!)
rm /opt/zigbee2mqtt/data/database.db
# 4. Start Zigbee2MQTT
sudo systemctl start zigbee2mqtt
# 5. Re-pair all devices
Terminal window
# Realtime logs
journalctl -u zigbee2mqtt -f
# Search for errors
journalctl -u zigbee2mqtt | grep -i error
# Z2M log level
# In configuration.yaml:
advanced:
log_level: debug # warn, info, debug

Ofte stillede spørgsmål

Will I lose my devices when updating firmware?
No! Firmware updates on the coordinator preserve all paired devices. You just need to update the adapter type in configuration (e.g., ezsp → ember).
What's the difference between groups in Z2M vs HA?
Z2M groups use native Zigbee broadcast - one message to all devices. HA groups send individual commands to each device. Z2M groups are faster and more synchronous.
Why isn't my binding working?
Both devices must support the same clusters. Check the device page in Z2M to see supported clusters. Some cheap devices don't support binding.
Which channel should I use?
Channel 25 has the least WiFi overlap. Alternatively: channels 11, 15, or 20 depending on your WiFi channels. Avoid channel 25 if you have many Zigbee 3.0 devices requiring channel change.


Last updated: December 2025


Kommentarer