Skip to content

Commit

Permalink
fix(mosquitto): Fix healthcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienPoupa committed Jan 5, 2025
1 parent ca093a5 commit bf01df1
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@ HOMEPAGE_VAR_WEATHER_LONG=
HOMEPAGE_VAR_WEATHER_UNIT=metric
IMMICH_DB_PASSWORD=postgres
CALIBRE_USERNAME=admin
CALIBRE_PASSWORD=admin123
CALIBRE_PASSWORD=admin123
MOSQUITTO_USERNAME=
MOSQUITTO_PASSWORD=
7 changes: 3 additions & 4 deletions homeassistant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@ Set the `HOMEASSISTANT_ACCESS_TOKEN` for homepage support.

If you need to use MQTT, you can enable it by setting `COMPOSE_PROFILES=homeassistant,mqtt`.

Copy the Mosquitto environment file to `mosquitto.env` and fill the username and password:
`cp mosquitto.env.exmple mosquitto.env`.
In the root `.env`, fill `MOSQUITTO_USERNAME` and `MOSQUITTO_PASSWORD` with the credentials you want to use.

Start the container, create a user in mosquitto with the following command and the credentials defined in the `mosquitto.env` file:
Start the container, create a user in mosquitto with the following command and the credentials defined previously:

`docker compose exec mosquitto mosquitto_passwd -b /mosquitto/config/pwfile <username> <password>`

Restart the Mosquitto container to apply the changes.

In HomeAssistant, add the MQTT integration with hostname `localhost`, port 1883 and the username and password defined in the `mosquitto.env` file.
In HomeAssistant, add the MQTT integration with hostname `localhost`, port 1883 and the username and password defined above.

## Backup

Expand Down
4 changes: 1 addition & 3 deletions homeassistant/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,14 @@ services:
environment:
- PUID=${USER_ID}
- PGID=${GROUP_ID}
env_file:
- ${CONFIG_ROOT:-.}/homeassistant/mosquitto.env
volumes:
- ${CONFIG_ROOT:-.}/homeassistant/mosquitto/config:/mosquitto/config
- ${CONFIG_ROOT:-.}/homeassistant/mosquitto/data:/mosquitto/data
- ${CONFIG_ROOT:-.}/homeassistant/mosquitto/log:/mosquitto/log
ports:
- "1883:1883"
healthcheck:
test: [ "CMD", "mosquitto_sub", "-u", "$$MOSQUITTO_USERNAME", "-P", "$$MOSQUITTO_PASSWORD", "-h", "localhost", "-t", "$$SYS/broker/uptime", "-i", "docker_health_check", "-C", "1" ]
test: [ "CMD", "mosquitto_sub", "-u", "$${MOSQUITTO_USERNAME}", "-P", "$${MOSQUITTO_PASSWORD}", "-h", "localhost", "-t", "$$SYS/broker/uptime", "-i", "docker_health_check", "-C", "1" ]
interval: 1m
timeout: 10s
retries: 3
Expand Down
2 changes: 0 additions & 2 deletions homeassistant/mosquitto.env.example

This file was deleted.

2 changes: 1 addition & 1 deletion homeassistant/mosquitto/config/mosquitto.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
persistence true
persistence_location /mosquitto/data/
persistence_location /mosquitto/data

password_file /mosquitto/config/pwfile
allow_anonymous false
Expand Down

0 comments on commit bf01df1

Please sign in to comment.