diff --git a/.env.example b/.env.example index 1aac38d..7c0f809 100644 --- a/.env.example +++ b/.env.example @@ -46,4 +46,6 @@ HOMEPAGE_VAR_WEATHER_LONG= HOMEPAGE_VAR_WEATHER_UNIT=metric IMMICH_DB_PASSWORD=postgres CALIBRE_USERNAME=admin -CALIBRE_PASSWORD=admin123 \ No newline at end of file +CALIBRE_PASSWORD=admin123 +MOSQUITTO_USERNAME= +MOSQUITTO_PASSWORD= \ No newline at end of file diff --git a/homeassistant/README.md b/homeassistant/README.md index 51a5c04..ce79c83 100644 --- a/homeassistant/README.md +++ b/homeassistant/README.md @@ -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 ` 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 diff --git a/homeassistant/docker-compose.yml b/homeassistant/docker-compose.yml index 34fcad8..08ea030 100644 --- a/homeassistant/docker-compose.yml +++ b/homeassistant/docker-compose.yml @@ -42,8 +42,6 @@ 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 @@ -51,7 +49,7 @@ services: 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 diff --git a/homeassistant/mosquitto.env.example b/homeassistant/mosquitto.env.example deleted file mode 100644 index 2e8e41a..0000000 --- a/homeassistant/mosquitto.env.example +++ /dev/null @@ -1,2 +0,0 @@ -MOSQUITTO_USERNAME= -MOSQUITTO_PASSWORD= \ No newline at end of file diff --git a/homeassistant/mosquitto/config/mosquitto.conf b/homeassistant/mosquitto/config/mosquitto.conf index a4ddd45..3686f18 100755 --- a/homeassistant/mosquitto/config/mosquitto.conf +++ b/homeassistant/mosquitto/config/mosquitto.conf @@ -1,5 +1,5 @@ persistence true -persistence_location /mosquitto/data/ +persistence_location /mosquitto/data password_file /mosquitto/config/pwfile allow_anonymous false