Compare commits
24 Commits
5dfb2f3918
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e7a6a5ab1f | ||
|
|
b2088dd656 | ||
|
|
4702afa467 | ||
|
|
9ef7d4ec19 | ||
|
|
ec4e5cc46a | ||
|
|
53210d85e3 | ||
|
|
4da1b20875 | ||
|
|
5483502675 | ||
|
|
76efdb0274 | ||
|
|
3d2da83452 | ||
|
|
a431216cfe | ||
|
|
29079011d7 | ||
|
|
b22f4a436b | ||
|
|
d45ba97a8f | ||
|
|
ee7fa752bc | ||
|
|
36d7745289 | ||
|
|
730f0cdf17 | ||
|
|
408b491ba1 | ||
|
|
4780bc887b | ||
|
|
7a8ef0bd85 | ||
|
|
5ceae952a1 | ||
|
|
070ecf778a | ||
|
|
588de129eb | ||
|
|
d872f005af |
7
.gitmodules
vendored
Normal file
7
.gitmodules
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
[submodule "docker-observation"]
|
||||
path = docker-observation
|
||||
url = https://gitea.john-stream.com/john/docker-observation.git
|
||||
branch = main
|
||||
[submodule "restic-scripts"]
|
||||
path = restic-scripts
|
||||
url = https://gitea.john-stream.com/john/restic-scripts
|
||||
1
.python-version
Normal file
1
.python-version
Normal file
@@ -0,0 +1 @@
|
||||
json
|
||||
44
README.md
44
README.md
@@ -2,14 +2,48 @@
|
||||
|
||||
Zigbee smarthome stack
|
||||
|
||||
- Mosquitto ([eclipse-mosquitto](https://hub.docker.com/_/eclipse-mosquitto))
|
||||
- Zigbee2MQTT (koenkk/[zigbee2mqtt](https://hub.docker.com/r/koenkk/zigbee2mqtt/))
|
||||
| Service | Name | Image |
|
||||
|---------|-------------|----------------------|
|
||||
| mqtt | mosquitto | [eclipse-mosquitto] |
|
||||
| z2m | zigbee2mqtt | [koenkk/zigbee2mqtt] |
|
||||
|
||||
[eclipse-mosquitto]: https://hub.docker.com/_/eclipse-mosquitto
|
||||
[koenkk/zigbee2mqtt]: https://hub.docker.com/r/koenkk/zigbee2mqtt
|
||||
|
||||
## Setup
|
||||
|
||||
1. Create `.env` file with `MOSQUITTO_PASSWORD`.
|
||||
2. Run setup script
|
||||
### 1. Create LXC in Proxmox
|
||||
|
||||
```title="Proxmox helper script"
|
||||
bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/docker.sh)"
|
||||
```
|
||||
./scripts/setup.sh
|
||||
|
||||
### 2. Clone repo
|
||||
|
||||
```bash
|
||||
git clone https://gitea.john-stream.com/john/zigbee-stack
|
||||
```
|
||||
|
||||
### 3. Setup script
|
||||
|
||||
```bash
|
||||
./zigbee-stack/scripts/setup.sh
|
||||
```
|
||||
|
||||
Process:
|
||||
|
||||
- clears all the existing data, except certain files
|
||||
- asks for a new MQTT password, which gets saved in `./zigbee2mqtt/secret.yaml`
|
||||
- runs `docker compose up ...`
|
||||
|
||||
### 4. Mount backup
|
||||
|
||||
Mount from within Proxmox using the `pct` tool.
|
||||
|
||||
```bash
|
||||
pct set $VMID -mp0 $BACKUP_DIR,mp=/mnt/backups
|
||||
```
|
||||
|
||||
### 5. Set env variables
|
||||
|
||||
Follow [instructions](https://gitea.john-stream.com/john/restic-scripts#environment-variables) as part of `restic-scripts`
|
||||
@@ -1,4 +1,6 @@
|
||||
version: "3"
|
||||
include:
|
||||
- ./docker-observation/docker-compose.yml
|
||||
|
||||
services:
|
||||
mqtt:
|
||||
container_name: mosquitto
|
||||
@@ -7,24 +9,18 @@ services:
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- ./mosquitto:/mosquitto
|
||||
- ./mosquitto/config:/mosquitto/config
|
||||
- ./mosquitto/data:/mosquitto/data
|
||||
- ./mosquitto/log:/mosquitto/log
|
||||
ports:
|
||||
- 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:
|
||||
container_name: zigbee2mqtt
|
||||
image: koenkk/zigbee2mqtt
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
mqtt:
|
||||
condition: service_healthy
|
||||
- mqtt
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
|
||||
1
docker-observation
Submodule
1
docker-observation
Submodule
Submodule docker-observation added at 1ee44b7b80
0
mosquitto/log/.gitkeep
Normal file
0
mosquitto/log/.gitkeep
Normal file
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
pydantic>=2,<3
|
||||
1
restic-scripts
Submodule
1
restic-scripts
Submodule
Submodule restic-scripts added at 0086878d57
20
scripts/backup.sh
Executable file
20
scripts/backup.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
if [ -z "$BACKUP_DIR" ]; then
|
||||
echo "Error: BACKUP_DIR is not set."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$RESTIC_REPOSITORY" ]; then
|
||||
echo "Error: RESTIC_REPOSITORY is not set."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$RESTIC_PASSWORD" ]; then
|
||||
echo "Error: RESTIC_PASSWORD is not set."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
python -m restic.backup --project zigbee-stack --services mqtt,z2m "$@"
|
||||
@@ -1,13 +1,34 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}"))
|
||||
REPO_DIR=$(dirname $SCRIPT_DIR)
|
||||
cleanup_except() {
|
||||
local directory=$1
|
||||
local except_file=$2
|
||||
|
||||
rm -rf \
|
||||
$REPO_DIR/mosquitto/config/pwfile \
|
||||
$REPO_DIR/mosquitto/data/mosquitto.db \
|
||||
$REPO_DIR/zigbee2mqtt/secret.yaml \
|
||||
$REPO_DIR/zigbee2mqtt/*.json \
|
||||
$REPO_DIR/zigbee2mqtt/log/* \
|
||||
$REPO_DIR/zigbee2mqtt/database.db \
|
||||
# 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
|
||||
}
|
||||
|
||||
readonly SCRIPT_DIR=$(dirname $(readlink -f "${BASH_SOURCE[0]}"))
|
||||
readonly REPO_DIR=$(cd $(dirname $SCRIPT_DIR) && pwd)
|
||||
|
||||
docker compose down
|
||||
|
||||
cleanup_except "$REPO_DIR/mosquitto/config" mosquitto.conf
|
||||
cleanup_except "$REPO_DIR/mosquitto/data" .gitkeep
|
||||
cleanup_except "$REPO_DIR/mosquitto/log"
|
||||
cleanup_except "$REPO_DIR/zigbee2mqtt" configuration.yaml
|
||||
|
||||
@@ -1,22 +1,16 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}"))
|
||||
REPO_DIR=$(dirname $SCRIPT_DIR)
|
||||
COMPOSE_FILE=$REPO_DIR/docker-compose.yml
|
||||
ENV_FILE=$REPO_DIR/.env
|
||||
set -e
|
||||
|
||||
if [ ! -f "$ENV_FILE" ]; then
|
||||
echo "Error: .env file not found."
|
||||
exit 1
|
||||
else
|
||||
source "$ENV_FILE"
|
||||
fi
|
||||
readonly SCRIPT_DIR=$(dirname $(readlink -f "${BASH_SOURCE[0]}"))
|
||||
readonly REPO_DIR=$(cd $(dirname $SCRIPT_DIR) && pwd)
|
||||
|
||||
if [ -z "$MOSQUITTO_PASSWORD" ]; then
|
||||
echo "MOSQUITTO_PASSWORD is not set. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
echo "Please input the mosquitto password:"
|
||||
read -s MOSQUITTO_PASSWORD
|
||||
|
||||
docker compose -f $COMPOSE_FILE run -it --rm mqtt mosquitto_passwd -b -c /mosquitto/config/pwfile homeassistant $MOSQUITTO_PASSWORD
|
||||
docker compose run -it --rm mqtt mosquitto_passwd -b -c /mosquitto/config/pwfile homeassistant $MOSQUITTO_PASSWORD
|
||||
|
||||
chown root:root $REPO_DIR/mosquitto/config/pwfile
|
||||
|
||||
echo "password: $MOSQUITTO_PASSWORD" > $REPO_DIR/zigbee2mqtt/secret.yaml
|
||||
chmod 600 $REPO_DIR/zigbee2mqtt/secret.yaml
|
||||
|
||||
7
scripts/forget.sh
Executable file
7
scripts/forget.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
python -m restic.forget \
|
||||
--keep-last 5 \
|
||||
--keep-weekly 8 \
|
||||
--keep-monthly 12 \
|
||||
--keep-yearly 7
|
||||
@@ -1,10 +1,11 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}"))
|
||||
REPO_DIR=$(dirname $SCRIPT_DIR)
|
||||
COMPOSE_FILE=$REPO_DIR/docker-compose.yml
|
||||
set -e
|
||||
|
||||
readonly SCRIPT_DIR=$(dirname $(readlink -f "${BASH_SOURCE[0]}"))
|
||||
readonly REPO_DIR=$(cd $(dirname $SCRIPT_DIR) && pwd)
|
||||
|
||||
$SCRIPT_DIR/clear_data.sh
|
||||
$SCRIPT_DIR/create_password.sh
|
||||
|
||||
docker compose -f $COMPOSE_FILE up -d
|
||||
docker compose up -d
|
||||
|
||||
13
scripts/update.sh
Executable file
13
scripts/update.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}"))
|
||||
REPO_DIR=$(dirname $SCRIPT_DIR)
|
||||
cd $REPO_DIR
|
||||
|
||||
git submodule update --remote --init
|
||||
|
||||
alias compose="compose -f $REPO_DIR/docker-compose.yml"
|
||||
docker compose pull
|
||||
docker compose up -d
|
||||
@@ -1,5 +1,4 @@
|
||||
homeassistant: true
|
||||
permit_join: true
|
||||
mqtt:
|
||||
base_topic: zigbee2mqtt
|
||||
client_id: Zigbee2MQTT
|
||||
@@ -16,3 +15,98 @@ advanced:
|
||||
device_options:
|
||||
legacy: false
|
||||
frontend: true
|
||||
devices:
|
||||
'0x54ef4410005ca806':
|
||||
friendly_name: Bathroom Motion
|
||||
'0x00158d0006ca3f53':
|
||||
friendly_name: Bedroom Motion
|
||||
'0x00158d000894fb3a':
|
||||
friendly_name: Closet Motion
|
||||
'0x00158d0006c49d5f':
|
||||
friendly_name: Kitchen Motion
|
||||
'0x00158d0007e22931':
|
||||
friendly_name: Cube 1
|
||||
'0x7cb03eaa00a698a6':
|
||||
friendly_name: Server Lamp
|
||||
'0x7cb03eaa00a68979':
|
||||
friendly_name: Desk Lamp
|
||||
'0xa4c138f4c2fce2ed':
|
||||
friendly_name: Couch Corner
|
||||
'0xa4c1388ed789ca18':
|
||||
friendly_name: Kitchen
|
||||
description: Under cabinet lights
|
||||
'0xf0d1b8000001ccc4':
|
||||
friendly_name: Bedside 2
|
||||
'0xf0d1b80000021416':
|
||||
friendly_name: Bedside 1
|
||||
description: Nearest to the door
|
||||
'0x00158d0006ba2970':
|
||||
friendly_name: Living Room Button
|
||||
legacy: false
|
||||
'0x00158d0006f3a190':
|
||||
friendly_name: Bedroom Button 1
|
||||
description: Nearest to the door
|
||||
'0x00158d0006ba47e9':
|
||||
friendly_name: Bedroom Button 2
|
||||
'0x00158d0007004bc5':
|
||||
friendly_name: Bathroom Button
|
||||
'0x00158d0006ba29fb':
|
||||
friendly_name: Kitchen Button
|
||||
'0x00158d0006ca405f':
|
||||
friendly_name: Laundry Motion
|
||||
'0x7cb03eaa00a69ad3':
|
||||
friendly_name: Patio
|
||||
'0xf0d1b8000001d920':
|
||||
friendly_name: Laundry
|
||||
'0x001788010ce41962':
|
||||
friendly_name: Closet Back
|
||||
'0x001788010ce41939':
|
||||
friendly_name: Closet Front
|
||||
'0x001788010cdfb112':
|
||||
friendly_name: Bathroom Middle
|
||||
'0x001788010c752d04':
|
||||
friendly_name: Bathroom Right
|
||||
'0x001788010cdfb05e':
|
||||
friendly_name: Bathroom Left
|
||||
'0x00124b0022305984':
|
||||
friendly_name: Overhead 1
|
||||
'0x00124b0022305ad5':
|
||||
friendly_name: Overhead 2
|
||||
'0x00124b0022305735':
|
||||
friendly_name: Overhead 3
|
||||
'0x00158d0007ef801d':
|
||||
friendly_name: Back
|
||||
'0x00158d00067960ef':
|
||||
friendly_name: Front
|
||||
'0xa4c1385e575697be':
|
||||
friendly_name: RGBCCT Strip
|
||||
'0x00158d0006a0cebe':
|
||||
friendly_name: Living Room Motion
|
||||
groups:
|
||||
'1':
|
||||
friendly_name: living_room
|
||||
devices:
|
||||
- 0x7cb03eaa00a698a6/3
|
||||
- 0x7cb03eaa00a68979/3
|
||||
'2':
|
||||
friendly_name: bedroom
|
||||
devices:
|
||||
- 0xf0d1b80000021416/1
|
||||
- 0xf0d1b8000001ccc4/1
|
||||
'3':
|
||||
friendly_name: closet
|
||||
devices:
|
||||
- 0x001788010ce41962/11
|
||||
- 0x001788010ce41939/11
|
||||
'4':
|
||||
friendly_name: bathroom
|
||||
devices:
|
||||
- 0x001788010cdfb05e/11
|
||||
- 0x001788010cdfb112/11
|
||||
- 0x001788010c752d04/11
|
||||
'5':
|
||||
friendly_name: overhead
|
||||
devices:
|
||||
- 0x00124b0022305984/1
|
||||
- 0x00124b0022305ad5/1
|
||||
- 0x00124b0022305735/1
|
||||
Reference in New Issue
Block a user