Skip to content
/ hass Public

Docker Home Assistant, Mosquitto, and Zigbee2MQTT

Notifications You must be signed in to change notification settings

slochewie/hass

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Home Assistant with Mosquitto and Zigbee2MQTT in Docker

Installation

mkdir -p $HOME/docker/hass
cd $HOME/docker/hass
git clone https://github.com/slochewie/hass.git
docker-compose pull
docker-compose up -d

Edit Zigbee2MQTT's configuration.yml to your needs

nano $HOME/docker/hass/zigbee2mqtt/data/configuration.yml

Edit Mosquitto's mosquito.conf to your needs. By default the existing file should work as is with no authentication needed. This is fine for initial usage making sure it works, but authentication should be added.

nano $HOME/docker/hass/mosquitto/config/mosquitto.conf

The Mosquitto container runs the mosquitto server under UID 1883 and GID 1883. I've tried changing this in the docker-compose file with no luck. My workaround to avoid read/write errors is to chown the mosquitto directory with 1883:1883

sudo chown -R 1883:1883 $HOME/docker/hass/mosquitto/config/mosquitto

Restart Mosquitto and Zigbee2MQTT

docker-compose restart mosquitto zigbee2mqtt

To update all

docker-compose pull
docker-compose up -d

To update Home Asssitant

docker-compose pull homeassistant
docker-compose up -d homeassistant

To update Mosquitto

docker-compose pull mosquitto
docker-compose up -d mosquitto

To update Zigbee2MQTT

docker-compose pull zigbee2mqtt
docker-compose up -d zigbee2mqtt

To restart Home Assistant

docker-compose restart homeassistant

To restart Mosquitto

docker-compose restart mosquitto

To restart Zigbee2MQTT

docker-compose restart zigbee2mqtt

Adding Mosquitto User Authentication

The mosquitto.conf in this repo has user authentication disabled and allows anonymous connections. Perform the following steps to setup user authentication and disable anonymous connections to Mosquitto.

Change to an user of your liking. This user and password will also be used in Home Assistant when adding MQTT support. I typically use hass_mqtt as the user but it's entirely up to you.

docker-compose exec mosquitto mosquitto_passwd -c /mosquitto/config/password_file <user>

You'll be prompted for a password twice. Enter it twice.

Now edit the mosquitto conf file.

sudo nano ./mosquitto/config/mosquitto.config

Find the line

allow_anonymous true

Change it to

allow_anonymous false

Find the line

#password_file

Change it to

password_file /mosquitto/config/password_file

Restart Mosquitto

docker-compose restart zigbee2mqtt

Configure Zigbee2MQTT to authenticate against Mosquitto

The Zigbee2MQTT configuration file in this repo is not configured for authentication either. To cnange it follow the steps below.

sudo nano $HOME/docker/hass/zigbee2mqtt/data/configuration.yaml

Change

# Zigbee2MQTT configuration file
homeassistant: true
permit_join: true
mqtt:
  base_topic: zigbee2mqtt
  server: <LAN ip address of server>
#  user: <user>
#  password: <password>

to

# Zigbee2MQTT configuration file
homeassistant: true
permit_join: true
mqtt:
  base_topic: zigbee2mqtt
  server: <LAN ip address of Mosquitto server>
  user: <mosquitto_user>
  password: <mosquitto_password>

Restart Zigbee2MQTT

docker-compose restart zigbee2mqtt

Add MQTT/Zigbee2MQTT to Home Assistant

Login to Home Assistant

Go to Settings -> Devices & Services -> Add Integration

Search for MQTT and add it.

Input the MQTT Server's IP Addreess, user name, and password.

Home Assistant and Zigbee2MQTT web admins

Home Assistant http://server-ip:8123

Zigbee2MQTT http://server-ip:8989

Addendum

This README works out of the box with the SONOFF Zigbee 3.0 USB Dongle Plus-P or SONOFF Zigbee 3.0 USB Dongle Plus-E only requiring minor changes. I have not tested it with other Zigbee controllers but it should work as a fairly accurate guideline.

Author

Aaron Wilson https://niteowl.dev

License

MIT License

About

Docker Home Assistant, Mosquitto, and Zigbee2MQTT

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published