Compare commits

..

14 Commits

Author SHA1 Message Date
John Lancaster
e7a6a5ab1f script updates 2024-09-29 21:50:12 +00:00
John Lancaster
b2088dd656 submodule update 2024-08-02 12:24:56 -05:00
John Lancaster
4702afa467 script updates 2024-06-15 16:41:08 -05:00
John Lancaster
9ef7d4ec19 readme update 2024-06-15 16:30:03 -05:00
John Lancaster
ec4e5cc46a readme update 2024-06-15 16:29:11 -05:00
John Lancaster
53210d85e3 script updates 2024-06-15 16:25:26 -05:00
John Lancaster
4da1b20875 submodule update 2024-05-27 19:22:40 -05:00
John Lancaster
5483502675 updates to make better use of restic-scripts 2024-05-27 19:21:20 -05:00
John Lancaster
76efdb0274 readme update 2024-05-19 20:37:19 -05:00
John Lancaster
3d2da83452 readme updates 2024-05-19 20:34:59 -05:00
John Lancaster
a431216cfe added readme content 2024-05-19 20:20:16 -05:00
John Lancaster
29079011d7 added backup scripts 2024-05-19 20:11:37 -05:00
John Lancaster
b22f4a436b submodule updates 2024-05-19 19:46:12 -05:00
John Lancaster
d45ba97a8f some updates 2024-05-19 17:17:51 -05:00
14 changed files with 208 additions and 22 deletions

7
.gitmodules vendored Normal file
View 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
View File

@@ -0,0 +1 @@
json

View File

@@ -2,11 +2,48 @@
Zigbee smarthome stack Zigbee smarthome stack
- Mosquitto ([eclipse-mosquitto](https://hub.docker.com/_/eclipse-mosquitto)) | Service | Name | Image |
- Zigbee2MQTT (koenkk/[zigbee2mqtt](https://hub.docker.com/r/koenkk/zigbee2mqtt/)) |---------|-------------|----------------------|
| 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 ## Setup
### 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`

View File

@@ -1,4 +1,6 @@
version: "3" include:
- ./docker-observation/docker-compose.yml
services: services:
mqtt: mqtt:
container_name: mosquitto container_name: mosquitto

1
docker-observation Submodule

Submodule docker-observation added at 1ee44b7b80

1
requirements.txt Normal file
View File

@@ -0,0 +1 @@
pydantic>=2,<3

1
restic-scripts Submodule

Submodule restic-scripts added at 0086878d57

20
scripts/backup.sh Executable file
View 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 "$@"

View File

@@ -1,4 +1,5 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
cleanup_except() { cleanup_except() {
@@ -22,11 +23,10 @@ cleanup_except() {
done done
} }
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}")) readonly SCRIPT_DIR=$(dirname $(readlink -f "${BASH_SOURCE[0]}"))
REPO_DIR=$(dirname $SCRIPT_DIR) readonly REPO_DIR=$(cd $(dirname $SCRIPT_DIR) && pwd)
COMPOSE_FILE=$REPO_DIR/docker-compose.yml
docker compose -f $COMPOSE_FILE down docker compose down
cleanup_except "$REPO_DIR/mosquitto/config" mosquitto.conf cleanup_except "$REPO_DIR/mosquitto/config" mosquitto.conf
cleanup_except "$REPO_DIR/mosquitto/data" .gitkeep cleanup_except "$REPO_DIR/mosquitto/data" .gitkeep

View File

@@ -1,15 +1,16 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}")) readonly SCRIPT_DIR=$(dirname $(readlink -f "${BASH_SOURCE[0]}"))
REPO_DIR=$(dirname $SCRIPT_DIR) readonly REPO_DIR=$(cd $(dirname $SCRIPT_DIR) && pwd)
COMPOSE_FILE=$REPO_DIR/docker-compose.yml
ENV_FILE=$REPO_DIR/.env
echo "Please the mosquitto password:" echo "Please input the mosquitto password:"
read -s 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 echo "password: $MOSQUITTO_PASSWORD" > $REPO_DIR/zigbee2mqtt/secret.yaml
chmod 600 $REPO_DIR/zigbee2mqtt/secret.yaml chmod 600 $REPO_DIR/zigbee2mqtt/secret.yaml

7
scripts/forget.sh Executable file
View 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

View File

@@ -1,11 +1,11 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}")) readonly SCRIPT_DIR=$(dirname $(readlink -f "${BASH_SOURCE[0]}"))
REPO_DIR=$(dirname $SCRIPT_DIR) readonly REPO_DIR=$(cd $(dirname $SCRIPT_DIR) && pwd)
COMPOSE_FILE=$REPO_DIR/docker-compose.yml
$SCRIPT_DIR/clear_data.sh $SCRIPT_DIR/clear_data.sh
$SCRIPT_DIR/create_password.sh $SCRIPT_DIR/create_password.sh
docker compose -f $COMPOSE_FILE up -d docker compose up -d

13
scripts/update.sh Executable file
View 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

View File

@@ -15,3 +15,98 @@ advanced:
device_options: device_options:
legacy: false legacy: false
frontend: true 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