Compare commits
10 Commits
5dfb2f3918
...
ee7fa752bc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee7fa752bc | ||
|
|
36d7745289 | ||
|
|
730f0cdf17 | ||
|
|
408b491ba1 | ||
|
|
4780bc887b | ||
|
|
7a8ef0bd85 | ||
|
|
5ceae952a1 | ||
|
|
070ecf778a | ||
|
|
588de129eb | ||
|
|
d872f005af |
@@ -7,9 +7,6 @@ Zigbee smarthome stack
|
|||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
1. Create `.env` file with `MOSQUITTO_PASSWORD`.
|
```
|
||||||
2. Run setup script
|
./scripts/setup.sh
|
||||||
|
```
|
||||||
```
|
|
||||||
./scripts/setup.sh
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -7,24 +7,18 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- /etc/localtime:/etc/localtime:ro
|
- /etc/localtime:/etc/localtime:ro
|
||||||
- /etc/timezone:/etc/timezone:ro
|
- /etc/timezone:/etc/timezone:ro
|
||||||
- ./mosquitto:/mosquitto
|
- ./mosquitto/config:/mosquitto/config
|
||||||
|
- ./mosquitto/data:/mosquitto/data
|
||||||
|
- ./mosquitto/log:/mosquitto/log
|
||||||
ports:
|
ports:
|
||||||
- 1883:1883
|
- 1883:1883
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "mosquitto_sub", "-t", "$$SYS/#", "-C", "1", "-i", "healthcheck", "-W", "3", "--port", "1880"]
|
|
||||||
start_period: 15s
|
|
||||||
start_interval: 1s
|
|
||||||
interval: 5s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 5
|
|
||||||
|
|
||||||
z2m:
|
z2m:
|
||||||
container_name: zigbee2mqtt
|
container_name: zigbee2mqtt
|
||||||
image: koenkk/zigbee2mqtt
|
image: koenkk/zigbee2mqtt
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
depends_on:
|
depends_on:
|
||||||
mqtt:
|
- mqtt
|
||||||
condition: service_healthy
|
|
||||||
volumes:
|
volumes:
|
||||||
- /etc/localtime:/etc/localtime:ro
|
- /etc/localtime:/etc/localtime:ro
|
||||||
- /etc/timezone:/etc/timezone:ro
|
- /etc/timezone:/etc/timezone:ro
|
||||||
|
|||||||
0
mosquitto/log/.gitkeep
Normal file
0
mosquitto/log/.gitkeep
Normal file
@@ -1,13 +1,34 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
cleanup_except() {
|
||||||
|
local directory=$1
|
||||||
|
local except_file=$2
|
||||||
|
|
||||||
|
# Check if the directory exists
|
||||||
|
if [[ ! -d "$directory" ]]; then
|
||||||
|
echo "Directory does not exist: $directory"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Loop over each file in the directory
|
||||||
|
for file in "$directory"/*
|
||||||
|
do
|
||||||
|
if [[ "$(basename "$file")" != "$except_file" ]]; then
|
||||||
|
# Delete the file
|
||||||
|
rm -rf "$file"
|
||||||
|
echo "Removed $file"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}"))
|
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}"))
|
||||||
REPO_DIR=$(dirname $SCRIPT_DIR)
|
REPO_DIR=$(dirname $SCRIPT_DIR)
|
||||||
|
COMPOSE_FILE=$REPO_DIR/docker-compose.yml
|
||||||
|
|
||||||
rm -rf \
|
docker compose -f $COMPOSE_FILE down
|
||||||
$REPO_DIR/mosquitto/config/pwfile \
|
|
||||||
$REPO_DIR/mosquitto/data/mosquitto.db \
|
cleanup_except "$REPO_DIR/mosquitto/config" mosquitto.conf
|
||||||
$REPO_DIR/zigbee2mqtt/secret.yaml \
|
cleanup_except "$REPO_DIR/mosquitto/data" .gitkeep
|
||||||
$REPO_DIR/zigbee2mqtt/*.json \
|
cleanup_except "$REPO_DIR/mosquitto/log"
|
||||||
$REPO_DIR/zigbee2mqtt/log/* \
|
cleanup_except "$REPO_DIR/zigbee2mqtt" configuration.yaml
|
||||||
$REPO_DIR/zigbee2mqtt/database.db \
|
|
||||||
|
|||||||
@@ -1,22 +1,15 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}"))
|
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}"))
|
||||||
REPO_DIR=$(dirname $SCRIPT_DIR)
|
REPO_DIR=$(dirname $SCRIPT_DIR)
|
||||||
COMPOSE_FILE=$REPO_DIR/docker-compose.yml
|
COMPOSE_FILE=$REPO_DIR/docker-compose.yml
|
||||||
ENV_FILE=$REPO_DIR/.env
|
ENV_FILE=$REPO_DIR/.env
|
||||||
|
|
||||||
if [ ! -f "$ENV_FILE" ]; then
|
echo "Please the mosquitto password:"
|
||||||
echo "Error: .env file not found."
|
read -s MOSQUITTO_PASSWORD
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
source "$ENV_FILE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$MOSQUITTO_PASSWORD" ]; then
|
|
||||||
echo "MOSQUITTO_PASSWORD is not set. Exiting."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
docker compose -f $COMPOSE_FILE run -it --rm mqtt mosquitto_passwd -b -c /mosquitto/config/pwfile homeassistant $MOSQUITTO_PASSWORD
|
docker compose -f $COMPOSE_FILE run -it --rm mqtt mosquitto_passwd -b -c /mosquitto/config/pwfile homeassistant $MOSQUITTO_PASSWORD
|
||||||
|
|
||||||
echo "password: $MOSQUITTO_PASSWORD" > $REPO_DIR/zigbee2mqtt/secret.yaml
|
echo "password: $MOSQUITTO_PASSWORD" > $REPO_DIR/zigbee2mqtt/secret.yaml
|
||||||
|
chmod 600 $REPO_DIR/zigbee2mqtt/secret.yaml
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}"))
|
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}"))
|
||||||
REPO_DIR=$(dirname $SCRIPT_DIR)
|
REPO_DIR=$(dirname $SCRIPT_DIR)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
homeassistant: true
|
homeassistant: true
|
||||||
permit_join: true
|
|
||||||
mqtt:
|
mqtt:
|
||||||
base_topic: zigbee2mqtt
|
base_topic: zigbee2mqtt
|
||||||
client_id: Zigbee2MQTT
|
client_id: Zigbee2MQTT
|
||||||
|
|||||||
Reference in New Issue
Block a user