marvin.im

ConBee II, Home Assistant (hass.io) with Docker on raspberry pi 4 (rpi4)

Setting up your own general Zigbee Gateway is easier as you might think. It works in most cases over several vendors and you don’t need a extra gateway for everyone of them.

Preparation

In order to get it to work properly make sure you get a usb extension or a hub, so the stick gets some space from the raspberry pi’s wifi chip.

You can use USB-Hubs or short extension cables (it’s best to try a few, because some might not work properly)

I strongly recommend to use the USB 2.0 sockets on the RPI4, I had some random disconnects/reconnects on the USB 3.0 sockets.

First connection and Firmware upgrade

First make sure the USB devices is plugged in and recognized. A new devices /dev/ttyACM0 should appear.

Now you can update it’s firmware using the following docker command:

docker run -it --rm --entrypoint "/firmware-update.sh" --privileged --cap-add=ALL -v /dev:/dev -v /lib/modules:/lib/modules -v /sys:/sys marthoc/deconz

Ways to connect to Home Assistant

using deconz

I don’t use this way, cause I read that deconz doesn’t support all device features. But I still keep the setup on the server, so I can debug the ConBee II Stick and also do firmware updates with the container.

with this way, homeassistant should automatically find the deconz service and integrate it into homeassistant. but only if the stick is connected properly.

docker-compose.yml

version: '3'
services:
  deconz:
    image: marthoc/deconz
    network_mode: host
    privileged: true
    restart: always
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ./config:/root/.local/share/dresden-elektronik/deCONZ
    devices:
      - /dev/ttyACM0
    environment:
      - DECONZ_DEVICE=/dev/ttyACM0
      - TZ=Europe/Berlin
#      - DECONZ_VNC_PORT=5900
#      - DECONZ_VNC_MODE=1

you can uncomment the DECONZ_VNC_* environment variables to check the deconz gui for errors. (use remmina or simmilar vnc client to connect to vnc server). Usually it should not be necessary if everything is setup and connected

using zigbee2mqtt (I prefer that one) with mosquitto

setting up a mqtt server - eclipse mosquitto

it’s best to create those files in a extra folder

mosquitto.conf

persistence true
persistence_location /mosquitto/data/
log_dest stdout

docker-compose.yml

version: '3'
services:
  mosquitto:
    image: eclipse-mosquitto
    restart: always
    network_mode: host
    volumes:
     - ./mosquitto.conf:/mosquitto/config/mosquitto.conf
     - ./data:/mosquitto/data

creating zigbee2mqtt and reconfiguring home assistant

docker-compose.yml

version: '3'
services:
  zigbee2mqtt:
    image: koenkk/zigbee2mqtt
    restart: always
    network_mode: host
    privileged: true
    volumes:
     - /run/udev:/run/udev:ro
     - ./config:/app/data
    devices:
     - /dev/ttyACM0
    environment:
     - TZ=Europe/Berlin

start the container, stop and remove the container, and alter the config/configuration.yaml

homeassistant: true
permit_join: true
mqtt:
  base_topic: zigbee2mqtt
  server: 'mqtt://localhost:1883'
serial:
  adapter: deconz

now you can start the zigbee2mqtt container again

also add the following to your home assistant config/configuration.yaml

# start internal mqtt server for zigbee2mqtt connection
mqtt:
  discovery: true
  broker: localhost # Remove if you want to use builtin-in MQTT broker
  # birth_message and will_message is not required anymore for Home Assistant 0.113 >=
  birth_message:
    topic: 'hass/status'
    payload: 'online'
  will_message:
    topic: 'hass/status'
    payload: 'offline'

and restart the home assistant container