Configuring the Zigbee2MQTT Docker container for use with Home Assistant

Introduction

Zigbee is a standards-based wireless technology developed to enable low-cost, low-power wireless machine-to-machine (M2M) and internet of things (IoT) networks.
Zigbee is for low-data rate, low-power applications and is an open standard. This, theoretically, enables the mixing of implementations from different manufacturers, but in practice, Zigbee products have been extended and customized by vendors and, thus, plagued by interoperability issues. In contrast to Wi-Fi networks used to connect endpoints to high-speed networks, Zigbee supports much lower data rates and uses a mesh networking protocol to avoid hub devices and create a self-healing architecture.

Zigbee2MQTT is a Gateway application that connects Zigbee networks to MQTT networks.

What do we need to use Zigbee?

A Zigbee Adapter which is the interface between the host where you run Zigbee2MQTT and the Zigbee radio communication. Zigbee2MQTT supports a variety of adapters with different kind of connections like USB, GPIO or remote via WIFI or Ethernet.
In my case I use the SONOFF Zigbee 3.0 USB Dongle Plus. We also need a broker like Mosquitto. But you can have any broker you want.

The Docker Compose File

---
version: '3.8'
services:

  zigbee2mqtt:
    image: koenkk/zigbee2mqtt:latest
    hostname: zigbee2mqtt
    container_name: zigbee2mqtt
    restart: unless-stopped
    network_mode: host
    security_opt:
      - no-new-privileges:true
    environment:
      - TZ=Europe/Stockholm
    ports:
      - 8080:8080
    volumes:
      - /opt/zigbee2mqtt/config:/app/data
      - /run/udev:/run/udev:ro
      - /etc/localtime:/etc/localtime:ro
    devices:
      - /dev/ttyUSB0:/dev/ttyUSB0
    labels:
      - com.centurylinklabs.watchtower.enable=true

Zigbee2MQTT configuration File

Inside /opt/zigbee2mqtt/config/ you will have a file called configuration.yaml

homeassistant: true

permit_join: false

mqtt:
  base_topic: zigbee2mqtt
  server: mqtt://localhost:1883
  user: my_user
  password: my_password

serial:
  port: /dev/ttyUSB0

frontend:
  port: 8080
  auth_token: another_password

Web interface

A web interface is available at http://localhost:8080.

A lot more information is available from the website below.


Home | Zigbee2MQTT
Zigbee to MQTT bridge, get rid of your proprietary Zigbee bridges