mirror of
https://github.com/AdrienPoupa/docker-compose-nas.git
synced 2025-05-24 13:41:45 +02:00
feat(homeassistant): Add Mosquitto MQTT broker
This commit is contained in:
parent
5d6b301ec7
commit
558a758e40
@ -46,4 +46,4 @@ HOMEPAGE_VAR_WEATHER_LONG=
|
||||
HOMEPAGE_VAR_WEATHER_UNIT=metric
|
||||
IMMICH_DB_PASSWORD=postgres
|
||||
CALIBRE_USERNAME=admin
|
||||
CALIBRE_PASSWORD=admin123
|
||||
CALIBRE_PASSWORD=admin123
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,4 @@
|
||||
.env
|
||||
*.env
|
||||
.idea
|
||||
docker-compose.override.yml
|
||||
/homepage/logs
|
||||
|
2
homeassistant/.gitignore
vendored
2
homeassistant/.gitignore
vendored
@ -2,3 +2,5 @@
|
||||
!README.md
|
||||
!docker-compose.yml
|
||||
!backup.env.example
|
||||
!mosquitto.env.example
|
||||
!mosquitto/config/mosquitto.conf
|
@ -21,6 +21,18 @@ http:
|
||||
|
||||
Set the `HOMEASSISTANT_ACCESS_TOKEN` for homepage support.
|
||||
|
||||
## MQTT
|
||||
|
||||
If you need to use MQTT, you can enable it by setting `COMPOSE_PROFILES=homeassistant,mqtt`.
|
||||
|
||||
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 above.
|
||||
|
||||
## Backup
|
||||
|
||||
### Enable Backups in HomeAssistant
|
||||
|
@ -34,6 +34,27 @@ services:
|
||||
- homepage.widget.key=${HOMEASSISTANT_ACCESS_TOKEN}
|
||||
profiles:
|
||||
- homeassistant
|
||||
mosquitto:
|
||||
container_name: mosquitto
|
||||
image: eclipse-mosquitto
|
||||
restart: always
|
||||
user: ${USER_ID}:${GROUP_ID}
|
||||
environment:
|
||||
- PUID=${USER_ID}
|
||||
- PGID=${GROUP_ID}
|
||||
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", "-p", "1880", "-t", "$$SYS/#", "-C", "1", "-i", "healthcheck", "-W", "3" ]
|
||||
interval: 1m
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
profiles:
|
||||
- mqtt
|
||||
homeassistant-backup:
|
||||
image: adrienpoupa/rclone-backup:latest
|
||||
container_name: homeassistant-backup
|
||||
|
12
homeassistant/mosquitto/config/mosquitto.conf
Executable file
12
homeassistant/mosquitto/config/mosquitto.conf
Executable file
@ -0,0 +1,12 @@
|
||||
persistence true
|
||||
persistence_location /mosquitto/data
|
||||
|
||||
password_file /mosquitto/config/pwfile
|
||||
allow_anonymous false
|
||||
|
||||
log_dest file /mosquitto/log/mosquitto.log
|
||||
|
||||
listener 1883
|
||||
|
||||
listener 1880 127.0.0.1
|
||||
allow_anonymous true
|
Loading…
x
Reference in New Issue
Block a user