๐ Overview
This docker-compose.yml
file outlines a multi-container configuration for a home automation system, incorporating Homebridge, Mosquitto, and Zigbee2MQTT. It encompasses essential configurations for each service, including volumes, devices, and environment variables.
This setup serves to seamlessly integrate diverse smart home devices, encompassing lights, sensors, and switches, into the home automation framework. Inter-service communication occurs over the local network throughMQTT andZigbee protocols. The host machine for container execution is aRaspberryPi. Conbee II is the Zigbee USB dongle used for Zigbee device communication.
๐ Configuration
๐๐ผโโ๏ธ Services
๐ Homebridge
The homebridge
service runs the Homebridge server, which acts as a bridge between smart home devices and Appleโs HomeKit. It allows non-HomeKit compatible devices to be controlled via the Home app on iOS devices.
image
: Specifies the Docker image to use for theHomebridge service. In this case, it uses the latest version of the official Homebridge image.restart
: Specifies the restart policy for the container. Thealways
option ensures that the container restarts automatically if it stops.network_mode
: Sets the network mode for the container tohost
, allowing the container to use the host network stack.hostname
: Defines the hostname for the container.container_name
: Specifies the name of the container.volumes
: Maps a local directory (./homebridge
) to the/homebridge
directory in the container. This volume is used to persist Homebridge configuration and data.devices
: Binds the host device/dev/ttyACM0
to the container device/dev/ttyACM0
. This is used to communicate with USB devices connected to the host machine.logging
: Configures the logging driver for the container to write logs to a JSON file.driver
: Specifies the logging driver to use.options
: Specifies additional options for the logging driver, such as the maximum log file size and the number of log files to keep.max-size
: Limits the size of each log file to 10 MB.max-file
: Specifies that only one log file should be kept.
๐ Mosquitto
The mosquitto
service runs the Mosquitto MQTT broker, which facilitates communication between MQTT clients and devices in the home automation system.
image
: Specifies the Docker image to use for theMosquitto service. In this case, it uses the official Eclipse Mosquitto image.restart
: Specifies the restart policy for the container. Theunless-stopped
option ensures that the container restarts unless explicitly stopped.hostname
: Defines the hostname for the container.container_name
: Specifies the name of the container.ports
: Exposes the MQTT broker on ports1883
and9001
on the host machine.volumes
: Maps a local directory (./mosquitto
) to the/mosquitto
directory in the container. This volume is used to persist Mosquitto configuration and data.command
: Specifies the command to run when starting the Mosquitto container. In this case, it runs Mosquitto with a custom configuration file (mosquitto-no-auth.conf
) to disable authentication.
๐ Zigbee2MQTT
The zigbee2mqtt
service runs the Zigbee2MQTT bridge, which allows Zigbee devices to communicate with MQTT clients and other services in the home automation system.
image
: Specifies the Docker image to use for the Zigbee2MQTT service. In this case, it uses version1.20.0
of the official Zigbee2MQTT image.restart
: Specifies the restart policy for the container. Theunless-stopped
option ensures that the container restarts unless explicitly stopped.network_mode
: Sets the network mode for the container tohost
, allowing the container to use the host network stack.hostname
: Defines the hostname for the container.container_name
: Specifies the name of the container.volumes
: Maps local directories (./zigbee2mqtt
and/run/udev
) to directories in the container. These volumes are used to persistZigbee2MQTT configuration and data, as well as to access the hostโsudev
directory.environment
: Sets theTZ
environment variable toEurope/Berlin
, specifying the containerโs time zone.devices
: Binds the host device/dev/ttyACM0
to the container device/dev/ttyACM0
. This is used to communicate with Zigbee USB dongles connected to the host machine.