commit 3674dd747eca3c98238c4b91416dcc7f3342e331 Author: David Gwilliam Date: Tue Jun 30 19:17:18 2026 -0700 Initial: RPi Docker Compose stack - Mosquitto MQTT broker - Zigbee2MQTT with BLZ dongle (ThirdReality, BL702, Pine64 fork) - Node-RED 5.0 with dashboard - justfile for remote management diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..1393e65 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,53 @@ +services: + mosquitto: + image: eclipse-mosquitto:latest + container_name: mosquitto + restart: unless-stopped + user: "1883:1883" + ports: + - "1883:1883" + volumes: + - ./mosquitto/config:/mosquitto/config + - ./mosquitto/data:/mosquitto/data + - ./mosquitto/log:/mosquitto/log + + zigbee2mqtt: + image: ghcr.io/pine64/zigbee2mqtt:latest-dev # BLZ fork, NOT koenkk + container_name: zigbee2mqtt + restart: unless-stopped + depends_on: + - mosquitto + ports: + - "8080:8080" + volumes: + - ./zigbee2mqtt:/app/data + devices: + - /dev/ttyUSB0:/dev/ttyUSB0 + environment: + TZ: America/Los_Angeles + + # govee2mqtt: + # image: ghcr.io/wez/govee2mqtt:latest + # container_name: govee2mqtt + # restart: unless-stopped + # network_mode: host + # environment: + # GOVEE_EMAIL: your@email.com + # GOVEE_PASSWORD: yourpassword + # GOVEE_API_KEY: your-api-key + # MQTT_HOST: 127.0.0.1 + # TZ: America/Los_Angeles + # + nodered: + image: nodered/node-red:latest + container_name: nodered + restart: unless-stopped + depends_on: + - mosquitto + user: "1000:1000" + ports: + - "1880:1880" + volumes: + - ./nodered:/data + environment: + TZ: America/Los_Angeles diff --git a/justfile b/justfile new file mode 100644 index 0000000..4545165 --- /dev/null +++ b/justfile @@ -0,0 +1,106 @@ +# rpi-zigbee-stack — Docker Compose stack management for RPi 3B+ + +set export +RPI := "root@192.168.9.147" +COMPOSE := "/root/compose.yaml" + +# Default: show stack status +default: + ssh {{RPI}} "docker compose -f {{COMPOSE}} ps" + +# ---- Service management ---- + +# Start all services +up: + ssh {{RPI}} "docker compose -f {{COMPOSE}} up -d" + +# Stop all services +down: + ssh {{RPI}} "docker compose -f {{COMPOSE}} down" + +# Restart all services +restart: + ssh {{RPI}} "docker compose -f {{COMPOSE}} restart" + +# Restart a specific service +restart-svc SERVICE: + ssh {{RPI}} "docker compose -f {{COMPOSE}} restart {{SERVICE}}" + +# Pull latest images +pull: + ssh {{RPI}} "docker compose -f {{COMPOSE}} pull" + +# ---- Logs ---- + +# Tail all logs +logs: + ssh {{RPI}} "docker compose -f {{COMPOSE}} logs --tail 50" + +# Follow all logs +logs-follow: + ssh {{RPI}} "docker compose -f {{COMPOSE}} logs -f" + +# Logs for a specific service +logs-svc SERVICE: + ssh {{RPI}} "docker compose -f {{COMPOSE}} logs --tail 50 {{SERVICE}}" + +# ---- Zigbee ---- + +# Show zigbee2mqtt status +zb-status: + ssh {{RPI}} "docker logs zigbee2mqtt --tail 10 2>&1" + +# Permit zigbee joining for 60 seconds +zb-permit: + ssh {{RPI}} "docker exec mosquitto mosquitto_pub -t zigbee2mqtt/bridge/request/permit_join -m '{\"value\":true,\"time\":60}'" + +# Disable zigbee joining +zb-deny: + ssh {{RPI}} "docker exec mosquitto mosquitto_pub -t zigbee2mqtt/bridge/request/permit_join -m '{\"value\":false}'" + +# List zigbee devices +zb-devices: + ssh {{RPI}} "docker exec mosquitto mosquitto_pub -t zigbee2mqtt/bridge/request/devices -m ''" + +# ---- Node-RED ---- + +# Open Node-RED editor +nr-editor: + xdg-open http://192.168.9.147:1880 2>/dev/null || open http://192.168.9.147:1880 2>/dev/null + +# Open Node-RED dashboard +nr-dashboard: + xdg-open http://192.168.9.147:1880/ui 2>/dev/null || open http://192.168.9.147:1880/ui 2>/dev/null + +# ---- Maintenance ---- + +# Sync compose.yaml and configs to RPi +sync: + scp compose.yaml {{RPI}}:/root/compose.yaml + scp mosquitto.conf {{RPI}}:/root/mosquitto/config/mosquitto.conf + scp zigbee2mqtt.yaml {{RPI}}:/root/zigbee2mqtt/configuration.yaml + @echo "Configs synced to RPi. Run 'just restart' to apply." + +# Full redeploy: sync configs + restart +redeploy: sync restart + +# Show disk usage on RPi +df: + ssh {{RPI}} "df -h / /var/lib/docker" + +# Show Docker disk usage +docker-df: + ssh {{RPI}} "docker system df" + +# Prune unused Docker images/volumes +prune: + ssh {{RPI}} "docker system prune -f" + +# ---- Snapshots ---- + +# Backup current RPi configs to local repo +backup: + ssh {{RPI}} "cat /root/compose.yaml" > compose.yaml + ssh {{RPI}} "cat /root/mosquitto/config/mosquitto.conf" > mosquitto.conf + ssh {{RPI}} "cat /root/zigbee2mqtt/configuration.yaml" > zigbee2mqtt.yaml + @echo "Backed up. Run git diff to see changes." diff --git a/mosquitto.conf b/mosquitto.conf new file mode 100644 index 0000000..8c1df4a --- /dev/null +++ b/mosquitto.conf @@ -0,0 +1,6 @@ +listener 1883 +allow_anonymous true + +persistence true +persistence_location /mosquitto/data +log_dest file /mosquitto/log/mosquitto.log diff --git a/nodered-package.json b/nodered-package.json new file mode 100644 index 0000000..b788fd4 --- /dev/null +++ b/nodered-package.json @@ -0,0 +1,6 @@ +{ + "name": "node-red-project", + "description": "A Node-RED Project", + "version": "0.0.1", + "private": true +} \ No newline at end of file diff --git a/nodered-settings.js b/nodered-settings.js new file mode 100644 index 0000000..17ec274 --- /dev/null +++ b/nodered-settings.js @@ -0,0 +1,30 @@ +/** + * This is the default settings file provided by Node-RED. + * + * It can contain any valid JavaScript code that will get run when Node-RED + * is started. + * + * Lines that start with // are commented out. + * Each entry should be separated from the entries above and below by a comma ',' + * + * For more information about individual settings, refer to the documentation: + * https://nodered.org/docs/user-guide/runtime/configuration + * + * The settings are split into the following sections: + * - Flow File and User Directory Settings + * - Security + * - Server Settings + * - Runtime Settings + * - Editor Settings + * - Node Settings + * + **/ + +module.exports = { + +/******************************************************************************* + * Flow File and User Directory Settings + * - flowFile + * - credentialSecret + * - flowFilePretty + * - userDir diff --git a/zigbee2mqtt.yaml b/zigbee2mqtt.yaml new file mode 100644 index 0000000..009cbcb --- /dev/null +++ b/zigbee2mqtt.yaml @@ -0,0 +1,15 @@ +version: 5 +mqtt: + base_topic: zigbee2mqtt + server: mqtt://mosquitto:1883 +serial: + port: /dev/ttyUSB0 + adapter: blz + baudrate: 2000000 + rtscts: false +advanced: + log_level: debug +frontend: + enabled: true + port: 8080 +permit_join: true