I recently embarked on a project to set up Zigbee2MQTT on my Raspberry Pi to integrate with Home Assistant. Initially, I thought it would be a straightforward process, but it turned out to be quite a journey. Here’s how I tackled it and what I learned along the way.
The Challenge
I sourced a ZBT-1 Zigbee dongle and decided to set up Zigbee2MQTT on a separate Raspberry Pi linked to my main HA instance via MQTT. This setup would allow me to place the Pi in a location with better coverage for my entire house and garden. However, I had no prior experience with Docker or Zigbee, only a basic understanding of MQTT.
The first hurdle was getting Zigbee2MQTT to work with Docker. I followed some online guides, but they didn’t quite work as expected. After several failed attempts, I discovered that there was a known issue with Docker setups that used the wrong file and incorrect protocol. This realization was a turning point.
The Solution
I decided to start fresh and carefully piece together the correct configuration. Here’s what I did:
-
Docker and Portainer Setup
I installed Docker and Portainer on my Raspberry Pi to manage containers more effectively. -
Finding the Correct Docker Image
I queried the Docker Hub registry to find the latest compatible version of Zigbee2MQTT for my hardware. This involved using the manifest digest number to ensure compatibility. -
Configuring Zigbee2MQTT
I created adocker-compose.ymlfile with the necessary settings, including the correct port for the Zigbee dongle (/dev/ttyUSB0). Here’s the configuration I used:
yaml
version: “3.9”
services:
zigbee2mqtt:
container_name: zigbee2mqttv6
image: ghcr.io/koenkk/zigbee2mqtt:latest@sha256:0c63fa0bbe82aa6a8ec38497b40badf8586413c7833fd6d03a0815db864e412e
restart: unless-stopped
ports:
- “8080:8080”
devices:
- “/dev/ttyUSB0”
volumes:
- ./data:/app/data
- /run/udev:/run/udev:ro
environment:
- TZ=Europe/London
-
Connecting to Home Assistant
After setting up Zigbee2MQTT, I configured it to connect to my Home Assistant MQTT broker. This involved setting the correct user and password for authentication, which I initially overlooked. -
Final Configuration
I edited theconfiguration.yamlfile to ensure the Zigbee2MQTT integration was properly configured with my dongle and settings. Here’s a snippet of the final configuration:
yaml
mqtt:
base_topic: zigbee2mqtt
server: mqtt://192.168.1.141:1883
user: xxxxx
password: xxxxx
serial:
port: /dev/ttyUSB0
adapter: ember
baudrate: 115200
rtscts: false
frontend:
enabled: true
port: 8080
homeassistant:
enabled: true
Lessons Learned
- Persistence Pays Off: Don’t give up if you encounter issues. There’s always a solution if you keep searching and experimenting.
- Community Resources: Forums and documentation are invaluable. I relied heavily on resources from pimylifeup.com and GitHub issues to troubleshoot.
- Attention to Detail: Configuring Docker and MQTT requires careful attention to settings like ports, volumes, and environment variables.
Final Thoughts
Setting up Zigbee2MQTT was a rewarding experience. It allowed me to integrate my Zigbee devices seamlessly into Home Assistant, enhancing my smart home setup. If you’re considering a similar project, I encourage you to dive in—it’s challenging but ultimately very satisfying!
Happy tinkering! ![]()