diff --git a/.gitignore b/.gitignore index 57e4aff..80d2253 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ +# Virtual environments +.kuma_venv/ +venv/ +.envs/ + # Environment and secrets .env .env.* @@ -276,6 +281,7 @@ side-agent/manifest/ # Claude Code session data and instructions .claude/ CLAUDE.md +QWEN.md # Gitea runtime data (sessions, SSH keys, databases) gitea/ diff --git a/.qwen/settings.json b/.qwen/settings.json new file mode 100644 index 0000000..9a52ef3 --- /dev/null +++ b/.qwen/settings.json @@ -0,0 +1,41 @@ +{ + "permissions": { + "allow": [ + "Bash(mkdir *)", + "Bash(docker compose up *)", + "Bash(sleep *)", + "Bash(curl *)", + "Bash(docker inspect *)", + "Bash(python3 *)", + "Bash(docker logs *)", + "Bash(docker cp *)", + "Bash(docker exec *)", + "Bash(import *)", + "Bash(kuma_url *)", + "Bash(token *)", + "Bash(as *)", + "Bash(1].strip)", + "Bash(break)", + "Bash(print)", + "Bash(exit)", + "Bash(monitors *)", + "Bash(])", + "Bash(sio *)", + "Bash(sio.connect)", + "Bash(r *)", + "Bash('loginbytoken', *)", + "Bash(else:)", + "Bash(sio.disconnect)", + "Bash(added *)", + "Bash(p *)", + "Bash(elif *)", + "Bash(try:)", + "Bash('add', *)", + "Bash(except *)", + "Bash(time.sleep)", + "Bash(pyeof)", + "Bash(docker ps *)" + ] + }, + "$version": 3 +} \ No newline at end of file diff --git a/.qwen/settings.json.orig b/.qwen/settings.json.orig new file mode 100644 index 0000000..9a9e4cc --- /dev/null +++ b/.qwen/settings.json.orig @@ -0,0 +1,7 @@ +{ + "permissions": { + "allow": [ + "Bash(mkdir *)" + ] + } +} \ No newline at end of file diff --git a/OPENCLAW_SETUP.md b/OPENCLAW_SETUP.md index 4f2752b..cb27de8 100644 --- a/OPENCLAW_SETUP.md +++ b/OPENCLAW_SETUP.md @@ -1,6 +1,6 @@ # OpenClaw Setup Guide -**OpenClaw**: Personal AI Assistant that executes actions (emails, calendar, shell commands, API integrations) +> Personal AI Assistant that executes actions - emails, calendar, shell commands, API integrations. ## Quick Setup @@ -13,11 +13,14 @@ nano ~/.openclaw_secrets ``` Fill in: -- `ANTHROPIC_API_KEY` - Claude API from Anthropic -- `OPENAI_API_KEY` - GPT-4 / Codex from OpenAI -- `GITHUB_TOKEN` - GitHub Copilot API access -- `TWILIO_*` - WhatsApp integration (optional) -- `TELEGRAM_*` - Telegram bot integration (optional) + +| Secret | Purpose | +|--------|---------| +| `ANTHROPIC_API_KEY` | Claude API from Anthropic | +| `OPENAI_API_KEY` | GPT-4 / Codex from OpenAI | +| `GITHUB_TOKEN` | GitHub Copilot API access | +| `TWILIO_*` | WhatsApp integration (optional) | +| `TELEGRAM_*` | Telegram bot integration (optional) | ### 2. Load Secrets @@ -31,73 +34,90 @@ Or they auto-load when you open a new shell (bashrc sources them). ```bash cd ~/mydocker -docker-compose up -d openclaw +docker compose up -d openclaw ``` -## Access OpenClaw +## Access ### Web UI -- **URL**: https://openclaw.sebson.space (via Traefik) -- **Port**: 3000 -- Interface for managing tasks, memory, integrations + +| Detail | Value | +|--------|-------| +| URL | https://openclaw.sebson.space (via Traefik) | +| Port | 3000 | +| Purpose | Task management, memory, integrations | ### CLI + ```bash # Helper function (auto-loaded) openclaw-cli "do something" # Or directly -docker-compose exec openclaw openclaw "command" +docker compose exec openclaw openclaw "command" ``` -### WhatsApp -Send message to configured Twilio number → OpenClaw responds and executes +### Telegram (Primary) -### Telegram -Send message to bot (if `TELEGRAM_BOT_TOKEN` configured) +- Enabled - requires `TELEGRAM_BOT_TOKEN` and `TELEGRAM_CHAT_ID` +- Bot responds to messages and executes actions + +### WhatsApp (Placeholder) + +- Disabled by default (can be enabled) +- Requires Twilio account + `TWILIO_*` variables +- Set `"enabled": true` in config to activate ### API -- **Endpoint**: http://localhost:3001 -- **Usage**: + +| Detail | Value | +|--------|-------| +| Internal | http://localhost:3007 (changed from 3001 to avoid Grafana conflict) | +| Via Traefik | https://api.openclaw.sebson.space (optional - requires DNS record) | + ```bash -curl -X POST http://localhost:3001/api/execute \ +curl -X POST http://localhost:3007/api/execute \ -H "Content-Type: application/json" \ -d '{"action":"email","to":"user@example.com","subject":"test"}' ``` +## Port Mapping + +| Host | Container | Purpose | +|------|-----------|---------| +| 3000 | 3000 | Web UI | +| 3007 | 3001 | API | + ## Bash Helpers Auto-added to `~/.bashrc`: -```bash -# Check which integrations are configured -openclaw-secrets - -# Start the service -openclaw-start - -# View logs -openclaw-logs - -# Execute command via CLI -openclaw-cli "send email to john@example.com saying hello" -``` +| Command | Description | +|---------|-------------| +| `openclaw-secrets` | Check which integrations are configured | +| `openclaw-start` | Start the service | +| `openclaw-logs` | View logs | +| `openclaw-cli "..."` | Execute command via CLI | ## Configuration -**File**: `/home/seba/mydocker/openclaw-config.json` +**File:** `/home/seba/mydocker/openclaw-config.json` Key settings: -- `ai.provider` - Default AI model (claude, gpt, copilot) -- `integrations` - Enable/disable services (WhatsApp, Telegram, Gmail, GitHub, etc.) -- `system.sandbox` - Run in sandbox mode (safe) -- `system.shellAccess` - Allow shell command execution -- `webUI.port` - Web interface port (3000) -- `api.port` - REST API port (3001) -## AI Models Priority +| Setting | Description | +|---------|-------------| +| `ai.provider` | Default AI model (claude, gpt, copilot) | +| `integrations` | Enable/disable services (WhatsApp, Telegram, Gmail, GitHub, etc.) | +| `system.sandbox` | Run in sandbox mode (safe) | +| `system.shellAccess` | Allow shell command execution | +| `webUI.port` | Web interface port (3000) | +| `api.port` | REST API port (3001 internally, mapped to 3007) | + +## AI Model Priority + +OpenClaw tries models in order: -OpenClaw tries in order: 1. **Claude** (Anthropic) - Recommended, most capable 2. **GPT-4** (OpenAI) - Alternative 3. **Copilot** (GitHub) - Code-focused @@ -106,26 +126,23 @@ Configure via `OPENCLAW_MODEL` env var or config file. ## Persistent Memory -- **Location**: `/data/memory` (Docker volume) -- **Survives restarts**: Yes -- **Clearable**: `docker-compose down` won't delete it +- **Location:** `/data/memory` (Docker volume) +- **Survives restarts:** Yes +- **Clearable:** `docker compose down` will NOT delete it -Memory stores: -- Your preferences -- Past conversations -- Learned patterns -- Custom skills +Stores: preferences, past conversations, learned patterns, custom skills. -## Security & Sandbox +## Security + +> **Important considerations:** -**⚠️ Important**: - OpenClaw runs with shell access (configurable via `system.shellAccess`) - Docker container is sandboxed from host -- API keys stored in environment (not in code) +- API keys stored in environment variables (not in code) - Config file mounted read-only **To disable shell access** (safer): -Edit `openclaw-config.json`: + ```json "system": { "shellAccess": false @@ -134,149 +151,92 @@ Edit `openclaw-config.json`: Then restart: ```bash -docker-compose restart openclaw +docker compose restart openclaw ``` -## Skills & Plugins +## Capabilities OpenClaw can: - Read/write files - Execute shell commands (if enabled) - Call APIs (50+ integrations) -- Send emails, messages +- Send emails and messages - Manage calendars -- **Write its own plugins** (with safe limits) +- Write its own plugins (with safe limits) ## Troubleshooting -### Check Secrets Are Loaded ```bash +# Check secrets are loaded openclaw-secrets -``` -### View Logs -```bash +# View logs openclaw-logs -``` -### Rebuild Image -```bash -docker-compose build --no-cache openclaw -``` +# Rebuild image +docker compose build --no-cache openclaw -### Full Reset (deletes memory) -```bash -docker-compose down openclaw +# Full reset (DELETES memory) +docker compose down openclaw docker volume rm mydocker_openclaw_memory -docker-compose up -d openclaw +docker compose up -d openclaw ``` ## Integration Examples -### Send Email (via Gmail) ```bash +# Send email openclaw-cli "send email to boss@company.com subject 'report' body 'attached is...'" -``` -### Check Calendar -```bash +# Check calendar openclaw-cli "what's on my calendar tomorrow" -``` -### Execute Command -```bash +# Execute command openclaw-cli "run git status in /home/seba/project" -``` -### GitHub Action -```bash +# GitHub action openclaw-cli "create pull request to close issue #123" -``` -## Environment Variables - -All OpenClaw settings via `.env`: -```bash -ANTHROPIC_API_KEY=sk-ant-... -OPENAI_API_KEY=sk-... -GITHUB_TOKEN=ghp_... -TWILIO_ACCOUNT_SID=AC... -TWILIO_AUTH_TOKEN=... -TELEGRAM_BOT_TOKEN=... +# Send Telegram message +openclaw-cli "send message to telegram: hello" ``` ## Docker Commands ```bash # Start -docker-compose up -d openclaw +docker compose up -d openclaw # Stop -docker-compose stop openclaw +docker compose stop openclaw # Restart -docker-compose restart openclaw +docker compose restart openclaw -# View logs -docker-compose logs -f openclaw +# Follow logs +docker compose logs -f openclaw # Shell access -docker-compose exec openclaw /bin/bash +docker compose exec openclaw /bin/bash # Delete service (keeps memory/config) -docker-compose down openclaw +docker compose down openclaw # Rebuild -docker-compose build --no-cache openclaw && docker-compose up -d openclaw +docker compose build --no-cache openclaw && docker compose up -d openclaw ``` -## Next Steps +## Quick Start Checklist -1. ✅ Add your API keys to `~/.openclaw_secrets` -2. ✅ Run `source ~/.openclaw_secrets` -3. ✅ Start service: `openclaw-start` -4. ✅ Access Web UI: https://openclaw.sebson.space -5. ✅ Try CLI: `openclaw-cli "hello"` -6. ✅ Set up WhatsApp/Telegram (optional) +1. Add API keys to `~/.openclaw_secrets` +2. Run `source ~/.openclaw_secrets` +3. Start service: `openclaw-start` +4. Access Web UI: https://openclaw.sebson.space +5. Try CLI: `openclaw-cli "hello"` +6. Set up Telegram (optional) -## Useful Resources +## Resources -- **GitHub**: https://github.com/openclaw/openclaw -- **Docs**: https://openclaw.ai/docs -- **API Docs**: https://openclaw.ai/api - -## Domeny - -### Web UI -- Domain: `openclaw.sebson.space` (dodane do DNS) -- Internal: `http://localhost:3000` -- Via Traefik: `https://openclaw.sebson.space` - -### API -- Internal: `http://localhost:3007` (changed from 3001 to avoid Grafana conflict) -- Via Traefik: `https://api.openclaw.sebson.space` (optional - requires DNS record) - -## Port Mapping - -``` -Host → Container -3000 → 3000 (Web UI) -3007 → 3001 (API) -``` - -## Komunikacja - -### Telegram ✅ (primary) -- Enabled -- Wymaga: `TELEGRAM_BOT_TOKEN`, `TELEGRAM_CHAT_ID` -- Bot will respond to messages and execute actions - -### WhatsApp (placeholder) -- Disabled (ale możesz włączyć) -- Wymaga: Twilio account + `TWILIO_*` variables -- Jeśli będziesz chcieć - wystarczy zmienić `"enabled": false` na `true` w config - -### CLI ✅ (always available) -```bash -openclaw-cli "send message to telegram: hello" -``` +- **GitHub:** https://github.com/openclaw/openclaw +- **Docs:** https://openclaw.ai/docs +- **API Docs:** https://openclaw.ai/api diff --git a/README.md b/README.md new file mode 100644 index 0000000..66d09c3 --- /dev/null +++ b/README.md @@ -0,0 +1,157 @@ +# MyDocker - Home Infrastructure Stack + +> Docker Compose based home infrastructure with 40+ services. Domain: **sebson.space** + +## Quick Start + +```bash +cd /home/seba/mydocker + +docker compose up -d # Start all services +docker compose down # Stop all +docker compose ps # Running containers +docker compose logs -f # Follow logs +docker compose restart # Restart single service + +./upgrade-container-by-name.sh # Upgrade service +./upgrade-container-by-name.sh prune # Upgrade + prune old images +./backup_db.sh # DB backup -> Google Drive +``` + +## Architecture Overview + +``` + Internet + | + [ Traefik v3.6.8 ] + TLS (Let's Encrypt ACME) + | + ┌─────────────────────┼─────────────────────┐ + | | | + [Public Services] [Monitoring Stack] [Security Layer] + | | | + Home Assistant Prometheus CrowdSec + Bitwarden Grafana traefik-bouncer + Immich VictoriaMetrics + Jellyfin Loki + Promtail + HA Dashboard cAdvisor + Brana Frontend Node Exporter + OpenClaw mktxp, ping-exporter + Smartctl Exporter +``` + +## Services by Category + +### Gateway & Security + +| Service | URL | Description | +|---------|-----|-------------| +| [Traefik](traefik/README.md) | https://traefik.sebson.space | Reverse proxy, TLS, geo-blocking | +| [CrowdSec](crowdsec/README.md) | local only | IPS, log analysis, Telegram alerts | +| [Bitwarden](bitwarden/README.md) | https://bward.sebson.space | Password manager (Vaultwarden + YubiKey 2FA) | + +### Home Automation & IoT + +| Service | URL | Description | +|---------|-----|-------------| +| [Home Assistant](homeassistant/README.md) | https://ha.sebson.space | Central automation engine | +| [ESPHome](esphome/README.md) | http://localhost:6052 | ESP8266/ESP32 firmware OTA | +| [Mosquitto](mosquitto/README.md) | 192.168.1.132:1883 | MQTT broker | +| [UniFi](unifi-config/README.md) | https://192.168.1.239:8443 | Network controller (MongoDB backend) | +| [Brana Frontend](brana-frontend/README.md) | https://brana.sebson.space | Gate control panel (mobile-first) | +| [HA Dashboard](ha-dashboard/README.md) | https://hadash.sebson.space | Flask ops dashboard | + +### Surveillance & Cameras + +| Service | URL | Description | +|---------|-----|-------------| +| [Frigate](frigate/README.md) | http://acemagic:5000 | NVR + AI object detection (Coral TPU) | +| [Camera LLM](camera-llm/README.md) | local API | LLM-powered camera memory (ChromaDB RAG) | +| [Timelapse](timelapse_service/README.md) | cron-based | Auto timelapse generation from camera frames | + +### Media & Storage + +| Service | URL | Description | +|---------|-----|-------------| +| [Jellyfin](jellyfin/README.md) | https://jfin.sebson.space | Media server (movies, series, music) | +| [Immich](immich/README.md) | https://immch.sebson.space | Self-hosted photo gallery (AI face recognition) | +| [Prowlarr](prowlarr/README.md) | http://localhost:9696 | Indexer manager (VPN-routed) | +| [Duplicati](duplicati/README.md) | http://localhost:8200 | Encrypted incremental backups | + +### Monitoring Stack + +``` +[Docker Containers] ──> Promtail ──> Loki ──> Grafana + | ^ + v | + cAdvisor ──> Prometheus ──> VictoriaMetrics + | | + Node Exporter ──────────┘ + mktxp (MikroTik) + ping-exporter + smartctl-exporter + PostgreSQL exporter +``` + +| Service | URL | Description | +|---------|-----|-------------| +| [Prometheus](prometheus/README.md) | https://prom.sebson.space | Metrics collection (30d retention) | +| [Grafana](grafana/README.md) | https://grafana.sebson.space | Dashboards + alerts (Telegram) | +| [Uptime Kuma](uptime-kuma/README.md) | https://kuma.sebson.space | External uptime monitoring + status page | +| [Loki](loki/README.md) | http://loki:3100 | Log aggregation (31d retention) | +| [Promtail](promtail/README.md) | port 9080 | Log shipper (Docker socket discovery) | +| [mktxp](mktxp/README.md) | http://localhost:49090 | MikroTik router metrics | +| [ping-exporter](pingexporter/README.md) | http://localhost:9427 | ICMP latency monitoring | + +### Custom Services + +| Service | Description | +|---------|-------------| +| [side-agent](side-agent/README.md) | Camera snapshot detector, container version checker, backup scheduler | +| [log-ingester](log-ingester/README.md) | RAG ingestion of Frigate/HA/Docker logs into ChromaDB | +| [OpenClaw](OPENCLAW_SETUP.md) | Personal AI assistant (CLI, Telegram, Web UI) | + +## Network Architecture + +### Host Network Services +These services run on `network_mode: host` for mDNS, Bluetooth, or device discovery: +- Home Assistant, ESPHome, Mosquitto, UniFi, Node Exporter, ping-exporter + +### VPN Namespace (Gluetun) +Services routed through NordVPN (Germany) via `network_mode: "service:gluetun"`: +- qBittorrent, Radarr, Prowlarr + +## Storage Layout + +| Mount | Capacity | Purpose | +|-------|----------|---------| +| `/media/seagata16t` | 16TB HDD | Immich photos, Jellyfin media, timelapses, camera archives | +| `/media/evo2t` | 2TB SSD | Frigate recordings, Duplicati backups, side-agent data | +| `/media/asustor` | NAS | rsync backup destination | +| `/media/wd1t` | 1TB | Secondary media storage | + +## Key Files + +| File | Purpose | +|------|---------| +| `docker-compose.yaml` | Single source of truth (2000+ lines) | +| `.env` | Secrets and environment variables | +| `./upgrade-container-by-name.sh` | Per-service container upgrade | +| `./backup_db.sh` | PostgreSQL backup to Google Drive via rclone | +| `./watchdog.sh` | Service health monitoring | +| `./truncate_logs.sh` | Log file size management | +| `side-agent/manifest/container_versions.yaml` | Tracked container versions | + +## Torrent Box (Subproject) + +Separate Makefile-managed stack in `./torrent-box-with-vpn/`: + +```bash +cd torrent-box-with-vpn +make start / stop / restart +make update_containers # pull + restart all +make generate_certificate +make backup +``` + +> The legacy `transmission-vpn` service in docker-compose is deprecated and replaced by this subproject. diff --git a/bitwarden/README.md b/bitwarden/README.md index 395b0fe..34059f5 100644 --- a/bitwarden/README.md +++ b/bitwarden/README.md @@ -1,52 +1,53 @@ # Bitwarden / Vaultwarden -Menedzer hasel oparty na Vaultwarden (kompatybilny z klientami Bitwarden). Backend PostgreSQL, uwierzytelnianie dwuetapowe przez YubiKey. +> Password manager compatible with all Bitwarden clients. PostgreSQL backend with YubiKey 2FA. -## URL / Dostep +## Access -- URL: https://bward.sebson.space -- Port wewnetrzny: 9989->80 -- Logowanie: email + haslo + YubiKey OTP +| Endpoint | Details | +|----------|---------| +| Public URL | https://bward.sebson.space | +| Internal Port | `9989 -> 80` | +| Login | Email + Password + YubiKey OTP | -## Konfiguracja +## Configuration -- Obraz: `vaultwarden/server` -- Baza danych: PostgreSQL na `postgres18:5432/bitwarden` -- 2FA: YubiKey (YUBICO_CLIENT_ID + YUBICO_SECRET_KEY z `.env`) -- Wlasny serwer weryfikacji Yubico: `bward.sebson.space/wsapi/2.0/verify` -- Konfiguracja przez zmienne srodowiskowe w `.env` +- **Image:** `vaultwarden/server` +- **Database:** PostgreSQL on `postgres18:5432` (database: `bitwarden`) +- **2FA:** YubiKey (`YUBICO_CLIENT_ID` + `YUBICO_SECRET_KEY` from `.env`) +- **Yubico verification:** self-hosted at `bward.sebson.space/wsapi/2.0/verify` -## Storage / Dane +## Storage -| Sciezka | Zawartosc | -|---------|-----------| -| `./bitwarden/attachments/` | zalaczniki do wpisow | -| `./bitwarden/sends/` | pliki Bitwarden Send | -| `./bitwarden/icon_cache/` | cache ikon stron | -| `./bitwarden/tmp/` | pliki tymczasowe | -| `./bitwarden/rsa_key.pem` | klucz prywatny RSA | -| `./bitwarden/rsa_key.pub.pem` | klucz publiczny RSA | +| Path | Contents | +|------|----------| +| `./bitwarden/attachments/` | Entry attachments | +| `./bitwarden/sends/` | Bitwarden Send files | +| `./bitwarden/icon_cache/` | Website icon cache | +| `./bitwarden/tmp/` | Temporary files | +| `./bitwarden/rsa_key.pem` | RSA private key | +| `./bitwarden/rsa_key.pub.pem` | RSA public key | -Dane haseł sa w bazie PostgreSQL (`bitwarden` DB na `postgres18`). +Password data itself is stored in PostgreSQL (`bitwarden` DB on `postgres18`). -## Powiazania +## Dependencies -- **postgres18** - glowna baza danych -- **Traefik** - reverse proxy, TLS -- **YubiKey** - sprzętowy klucz 2FA (serwer weryfikacji hostowany lokalnie) +- **postgres18** - primary database +- **Traefik** - reverse proxy with TLS +- **YubiKey** - hardware 2FA key (local verification server) -## Przydatne komendy +## Useful Commands ```bash -# Logi +# Follow logs docker compose logs -f vaultwarden -# Backup bazy (przez ogolny skrypt) +# Database backup (via general script) ./backup_db.sh # Restart docker compose restart vaultwarden -# Eksport/import przez klientow Bitwarden CLI: +# Export/import via Bitwarden CLI bw export --format json ``` diff --git a/brana-frontend/README.md b/brana-frontend/README.md index db2e714..b8f9df0 100644 --- a/brana-frontend/README.md +++ b/brana-frontend/README.md @@ -1,38 +1,44 @@ -# brana-frontend +# Brana Frontend - Gate Control Panel -Customowy panel sterowania brama wjazdowa. Statyczna strona HTML serwowana przez nginx, komunikujaca sie bezposrednio z Home Assistant przez REST API. Zbudowana mobilnie (max-width 420px, dark mode). +> Static HTML page served by nginx, communicating directly with Home Assistant via REST API. Mobile-first design (max-width 420px, dark mode). -## URL / Dostep +## Access -- https://brana.sebson.space (port 9080 -> 80) +| Endpoint | Details | +|----------|---------| +| Public URL | https://brana.sebson.space | +| Internal Port | `9080 -> 80` | -## Co robi +## Features -- Wyswietla aktualny stan bramy (open/closed/unknown) z Home Assistant -- Przyciski: otworz brame, zamknij brame, stop -- Wywoluje serwisy HA przez `https://ha.sebson.space` (Content-Security-Policy zezwala tylko na ten host) -- Modal z polem na token HA (przechowywany w localStorage) -- Statusy: ready (zielony), processing (niebieski, animacja), error (czerwony) +- Displays current gate state (open/closed/unknown) from Home Assistant +- Action buttons: **open**, **close**, **stop** +- Calls HA services via `https://ha.sebson.space` (CSP allows only this host) +- Modal dialog for entering HA token (stored in localStorage) +- Status indicators: + - **Ready** - green + - **Processing** - blue (animated) + - **Error** - red -## Konfiguracja nginx +## Nginx Configuration -- Naglowki bezpieczenstwa: X-Frame-Options DENY, CSP, X-Content-Type-Options -- Real IP z naglowka X-Real-IP (trust 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 - Traefik) -- Gzip dla assets +- Security headers: `X-Frame-Options DENY`, `Content-Security-Policy`, `X-Content-Type-Options` +- Real IP from `X-Real-IP` header (trusts `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16` - Traefik ranges) +- Gzip compression for assets - `/health` - health check endpoint -## Przydatne komendy +## Useful Commands ```bash -# Logi nginx +# Follow nginx logs docker compose logs -f brana-frontend -# Weryfikacja configu nginx +# Validate nginx config docker exec brana-frontend nginx -t -# Przeladowanie nginx bez restartu +# Reload config without restart docker exec brana-frontend nginx -s reload -# Rebuild po zmianach w index.html +# Rebuild after changes to index.html docker compose build brana-frontend && docker compose up -d brana-frontend ``` diff --git a/camera-llm/README.md b/camera-llm/README.md index 8b14190..eaadaf4 100644 --- a/camera-llm/README.md +++ b/camera-llm/README.md @@ -1,62 +1,65 @@ -# camera-llm +# Camera LLM - AI Camera Memory -System pamieci kamer oparty na LLM. Dwa komponenty: `camera-memory` co sekunde pobiera klatki z kamer Frigate, opisuje je przez model wizyjny i zapisuje embeddingi do ChromaDB; `camera-api` udostepnia interfejs webowy i API do zadawania pytan o to co dzialo sie na kamerach. +> LLM-powered camera memory system. Captures frames from Frigate cameras, describes them with a vision model, stores embeddings in ChromaDB, and answers natural language questions about camera activity. -## Architektura +## Architecture ``` [Frigate /api//latest.jpg] | v -[camera-memory] --> moondream (opis klatki) --> nomic-embed-text (embedding) --> ChromaDB camera_frames +[camera-memory] -- moondream (frame description) --> nomic-embed-text (embedding) --> ChromaDB "camera_frames" | v -[camera-api] <-- uzytkownik pyta --> ChromaDB (semantic search) --> mistral (odpowiedz) --> wynik +[camera-api] <-- user asks question --> ChromaDB (semantic search) --> mistral (answer) --> result ``` -## Komponenty +## Components ### camera-memory -- Pobiera co INTERVAL sekund najnowsza klatke z kazdej kamery przez Frigate API -- Wysyla do modelu `moondream` prompt: "Describe briefly: people (gender, clothing, action), vehicles (color, type), animals, packages, unusual activity." -- Tworzy embedding przez `nomic-embed-text` i zapisuje w kolekcji `camera_frames` -- Co 3600 iteracji usuwa wpisy starsze niz RETENTION_HOURS (domyslnie 72h) +- Fetches the latest frame from each camera every `INTERVAL` seconds via Frigate API +- Sends to `moondream` vision model with prompt: *"Describe briefly: people (gender, clothing, action), vehicles (color, type), animals, packages, unusual activity."* +- Creates embedding via `nomic-embed-text` and stores in `camera_frames` collection +- Every 3600 iterations, removes entries older than `RETENTION_HOURS` (default: 72h) ### camera-api -- FastAPI + wbudowany HTML frontend (dark mode, PL) -- `GET /` - interfejs webowy do zadawania pytan po polsku -- `GET /ask?q=...` - odpowiedz przez RAG (ChromaDB + mistral), zwraca answer + sources -- `GET /recent?camera=&hours=1` - ostatnie obserwacje -- `GET /stats` - liczba zapisanych klatek -- `GET /health` - health check +- FastAPI + built-in HTML frontend (dark mode, Polish language) -## Konfiguracja (zmienne env) +| Endpoint | Description | +|----------|-------------| +| `GET /` | Web interface for asking questions (Polish) | +| `GET /ask?q=...` | RAG answer via ChromaDB + mistral, returns `answer` + `sources` | +| `GET /recent?camera=&hours=1` | Recent observations | +| `GET /stats` | Number of stored frames | +| `GET /health` | Health check | -| Zmienna | Domyslnie | Opis | -|---------|-----------|------| -| `FRIGATE_URL` | `http://frigate:5000` | Adres API Frigate | -| `OLLAMA_URL` | `http://ollama:11434` | Adres Ollama | -| `CHROMA_URL` | `http://chromadb:8000` | Adres ChromaDB | -| `CAMERAS` | `front_door` | Lista kamer oddzielona przecinkami | -| `INTERVAL` | `1` | Interwał pobierania klatek (sekundy) | -| `RETENTION_HOURS` | `72` | Czas retencji wpisow w ChromaDB | +## Environment Variables -## Przydatne komendy +| Variable | Default | Description | +|----------|---------|-------------| +| `FRIGATE_URL` | `http://frigate:5000` | Frigate API URL | +| `OLLAMA_URL` | `http://ollama:11434` | Ollama URL | +| `CHROMA_URL` | `http://chromadb:8000` | ChromaDB URL | +| `CAMERAS` | `front_door` | Comma-separated camera list | +| `INTERVAL` | `1` | Frame capture interval (seconds) | +| `RETENTION_HOURS` | `72` | Data retention in ChromaDB | + +## Useful Commands ```bash -# Logi +# Follow logs docker compose logs -f camera-memory docker compose logs -f camera-api -# Ile klatek jest w pamieci +# Check how many frames are stored curl http://localhost:/stats -# Pytanie przez API -curl "http://localhost:/ask?q=czy+bylo+dzisiaj+czerwone+auto" +# Ask a question via API +curl "http://localhost:/ask?q=was+there+a+red+car+today" -# Ostatnie obserwacje z konkretnej kamery (ostatnia godzina) +# Recent observations from a specific camera (last hour) curl "http://localhost:/recent?camera=reolink_1&hours=1" # Rebuild diff --git a/crowdsec/README.md b/crowdsec/README.md index 4f8b4da..70e5f80 100644 --- a/crowdsec/README.md +++ b/crowdsec/README.md @@ -1,107 +1,98 @@ -# CrowdSec - dokumentacja +# CrowdSec - Intrusion Prevention System -## Jak działa +> Analyzes logs from multiple services and blocks malicious IPs via Traefik bouncer. Sends Telegram alerts on detections. -CrowdSec analizuje logi i blokuje złośliwe IP przez dwa komponenty: +## How It Works ``` -Logi → crowdsec (analiza) → decyzja BAN → traefik-bouncer (egzekucja) - → powiadomienie Telegram +Logs → crowdsec (analysis) → BAN decision → traefik-bouncer (enforcement) + → Telegram notification ``` -**traefik-bouncer** sprawdza każde żądanie przez Traefika pod CrowdSec API (`crowdsec:8080`). Jeśli IP ma aktywny ban - zwraca 403. +**traefik-bouncer** checks every request through Traefik against the CrowdSec API (`crowdsec:8080`). Returns `403` if the IP has an active ban. -## Telegram - jak działa +## Telegram Notifications -Powiadomienia idą przez plugin HTTP (`conf/notifications/http.yaml`), który wysyła POST do Telegram Bot API. +Notifications are sent via the HTTP plugin (`conf/notifications/http.yaml`) posting to the Telegram Bot API. -**Przepływ:** -1. CrowdSec wykrywa atak (np. brute-force SSH, skanowanie HTTP) -2. Profil w `conf/profiles.yaml` dopasowuje alert → przypisuje powiadomienie `http_default` -3. Plugin HTTP czeka 30s na grupowanie alertów, potem wysyła POST: +### Flow + +1. CrowdSec detects an attack (SSH brute-force, HTTP scanning, etc.) +2. Profile in `conf/profiles.yaml` matches the alert → assigns `http_default` notification +3. HTTP plugin waits 30s to group alerts, then sends POST: ``` POST https://api.telegram.org/bot/sendMessage { "chat_id": 5479795256, "parse_mode": "HTML", - "text": "🚨 CrowdSec Alert\n🔒 Scenariusz: ...\n🌍 IP: ...\n📊 Liczba zdarzeń: ..." + "text": "🚨 CrowdSec Alert\n🔒 Scenario: ...\n🌍 IP: ...\n📊 Event count: ..." } ``` -**Zmienne środowiskowe** (w `.env`): -``` -TELEGRAM_BOT_TOKEN=5580892376:AAHjXRq... -TELEGRAM_CHAT_ID=5479795256 -``` +Environment variables (`TELEGRAM_BOT_TOKEN`, `TELEGRAM_CHAT_ID`) are configured in `docker-compose.yaml`. -Bot token i chat ID skonfigurowane w docker-compose.yaml i przekazywane do kontenera. Format wiadomości edytowalny w `conf/notifications/http.yaml`. +## Monitored Log Sources (`conf/acquis.yaml`) -## Monitorowane źródła logów (`conf/acquis.yaml`) - -| Źródło | Typ | Ścieżka/kontener | -|--------|-----|-----------------| +| Source | Type | Path/Container | +|--------|------|----------------| | SSH | syslog | `/var/log/auth.log` | | Traefik | traefik | `/var/log/traefik/access.log` | | Jellyfin | jellyfin | `/var/log/jellyfin/log_*.log` | -| Grafana | docker | kontener `grafana` | -| Bitwarden | Vaultwarden | kontener `bitwarden` | +| Grafana | docker | `grafana` container | +| Bitwarden | vaultwarden | `bitwarden` container | -## Aktywne kolekcje (scenarios + parsery) +## Active Collections (Scenarios + Parsers) -- `crowdsecurity/linux` + `sshd` - SSH brute-force -- `crowdsecurity/traefik` + `nginx` - HTTP ataki przez Traefik -- `crowdsecurity/http-cve` - znane CVE (log4j, Spring4Shell, etc.) -- `crowdsecurity/base-http-scenarios` - skanowanie, traversal, bad UA -- `crowdsecurity/home-assistant` - brute-force HA -- `crowdsecurity/whitelist-good-actors` - SEO boty, CDN -- `Dominic-Wagner/vaultwarden` - BF Bitwarden -- `LePresidente/grafana` + `jellyfin` - BF Grafana/Jellyfin +| Collection | Purpose | +|------------|---------| +| `crowdsecurity/linux` + `sshd` | SSH brute-force | +| `crowdsecurity/traefik` + `nginx` | HTTP attacks via Traefik | +| `crowdsecurity/http-cve` | Known CVEs (log4j, Spring4Shell, etc.) | +| `crowdsecurity/base-http-scenarios` | Scanning, path traversal, bad user agents | +| `crowdsecurity/home-assistant` | HA brute-force | +| `crowdsecurity/whitelist-good-actors` | SEO bots, CDNs | +| `Dominic-Wagner/vaultwarden` | Bitwarden brute-force | +| `LePresidente/grafana` + `jellyfin` | Grafana/Jellyfin brute-force | -## Whitelista (`conf/parsers/s02-enrich/my-whitelist.yaml`) +## Whitelist (Never Banned) -Nigdy nie banowane: -- `127.0.0.1` -- `192.168.1.0/24` (LAN) -- `10.13.13.0/24` (VPN WireGuard) -- `81.201.50.209` (domowy publiczny IP) -- `212.222.3.226` (IP z pracy) +| IP/Range | Description | +|----------|-------------| +| `127.0.0.1` | Localhost | +| `192.168.1.0/24` | LAN | +| `10.13.13.0/24` | WireGuard VPN | +| `81.201.50.209` | Home public IP | +| `212.222.3.226` | Work IP | -## Profile i decyzje (`conf/profiles.yaml`) +## Profiles & Decisions (`conf/profiles.yaml`) -Dwa profile: -- `default_ip_remediation` - ban IP na 4h -- `default_range_remediation` - ban całego /24 na 4h +| Profile | Action | Notification | +|---------|--------|--------------| +| `default_ip_remediation` | Ban IP for 4h | Telegram | +| `default_range_remediation` | Ban entire /24 for 4h | Telegram | -Oba wysyłają powiadomienie `http_default` (Telegram). - -## Przydatne komendy +## Useful Commands ```bash -# Skrypty w crowdsec/bin/ -./crowdsec/bin/alerts-list # lista alertów -./crowdsec/bin/decisions # aktywne bany -./crowdsec/bin/metrics # statystyki parsowania +# Helper scripts in crowdsec/bin/ +./crowdsec/bin/alerts-list # List recent alerts +./crowdsec/bin/decisions # Active bans +./crowdsec/bin/metrics # Parsing statistics -# Bezpośrednio +# Direct cscli commands docker exec crowdsec cscli alerts list docker exec crowdsec cscli decisions list -docker exec crowdsec cscli decisions delete --ip 1.2.3.4 # odbanuj IP -docker exec crowdsec cscli decisions add --ip 1.2.3.4 --duration 24h # ręczny ban +docker exec crowdsec cscli decisions delete --ip 1.2.3.4 # Unban IP +docker exec crowdsec cscli decisions add --ip 1.2.3.4 --duration 24h # Manual ban -# Test powiadomienia Telegram +# Test Telegram notification docker exec crowdsec cscli notifications test http_default -``` -## Ręczny ban IP - -```bash +# Manual ban with custom duration docker exec crowdsec cscli decisions add --ip 1.2.3.4 --duration 168h --reason "manual" -``` -## Logi - -```bash +# Follow logs docker logs crowdsec --tail 100 -f docker logs traefik-bouncer --tail 50 ``` diff --git a/docker-compose.yaml b/docker-compose.yaml index 345780f..60e47e3 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -988,3 +988,16 @@ services: devices: - /dev/net/tun + uptime-kuma: + image: louislam/uptime-kuma + container_name: uptime-kuma + restart: unless-stopped + volumes: + - ${PWD}/uptime-kuma/data:/app/data + labels: + - "traefik.enable=true" + - "traefik.http.routers.uptime-kuma.rule=Host(`kuma.sebson.space`)" + - "traefik.http.routers.uptime-kuma.entrypoints=websecure" + - "traefik.http.routers.uptime-kuma.tls.certresolver=mytlschallenge" + - "traefik.http.services.uptime-kuma.loadbalancer.server.port=3001" + diff --git a/duplicati/README.md b/duplicati/README.md index dce6ce8..fe400a9 100644 --- a/duplicati/README.md +++ b/duplicati/README.md @@ -1,58 +1,57 @@ -# Duplicati +# Duplicati - Encrypted Backups -Narzedzie do tworzenia szyfrowanych, przyrostowych kopii zapasowych. Interfejs webowy dostepny przez przegladarke. +> Web-based incremental backup tool with AES-256 encryption. Local access only. -## URL / Dostep +## Access -- UI: http://localhost:8200 (brak publicznego dostępu przez Traefik) -- Dostep tylko z sieci lokalnej lub przez VPN/tunel +| Endpoint | Details | +|----------|---------| +| Web UI | http://localhost:8200 | +| Public access | None (LAN/VPN only) | -## Konfiguracja +## Configuration -- Port: 8200 -- Konfiguracja jobow backupu przechowywana w `./duplicati/config/` -- Harmonogram i ustawienia definiowane przez UI +- **Port:** 8200 +- **Job config:** stored in `./duplicati/config/` (SQLite database) +- Schedule and settings managed via the web UI -### Zrodla backupu +### Backup Sources -| Zrodlo | Opis | -|--------|------| -| `/home/seba` | katalog domowy | -| `/home/seba/mydocker` | caly stack Docker | -| `/home/seba/git.repos` | repozytoria git | +| Source | Description | +|--------|-------------| +| `/home/seba` | Home directory | +| `/home/seba/mydocker` | Entire Docker stack | +| `/home/seba/git.repos` | Git repositories | -### Cel backupu +### Backup Destinations -| Lokalizacja | Opis | -|-------------|------| -| `/media/evo2t/backups` | lokalny dysk SSD | -| `/media/seagata16t/` | 16TB dysk HDD | +| Location | Description | +|----------|-------------| +| `/media/evo2t/backups` | Local SSD disk | +| `/media/seagata16t/` | 16TB HDD | -## Storage / Dane +## Storage -| Sciezka | Zawartosc | -|---------|-----------| -| `./duplicati/config/` | konfiguracja jobow, baza SQLite | +| Path | Contents | +|------|----------| +| `./duplicati/config/` | Job configurations, SQLite database | -## Powiazania +All source directories are mounted read-only. Destination disks are read-write. -- Montuje wiele katalogow hosta jako read-only (zrodla) -- Montuje dyski docelowe jako read-write - -## Przydatne komendy +## Useful Commands ```bash -# Logi +# Follow logs docker compose logs -f duplicati # Restart docker compose restart duplicati -# Przywrocenie pliku przez CLI (wewnatrz kontenera) +# Restore entire backup (inside container) docker exec -it duplicati dotnet /app/duplicati/Duplicati.CommandLine.dll restore \ "your-backup-path" --targetpath="/restore" -# Przywrocenie konkretnego pliku +# Restore a specific file docker exec -it duplicati dotnet /app/duplicati/Duplicati.CommandLine.dll restore \ "file://backup/path" --restore-path="/tmp/restore" --include="**/myfile.txt" ``` diff --git a/esphome/README.md b/esphome/README.md index ac5fd11..826e55d 100644 --- a/esphome/README.md +++ b/esphome/README.md @@ -1,59 +1,60 @@ -# ESPHome +# ESPHome - ESP Firmware Dashboard -Dashboard do kompilacji firmware i zarzadzania urzadzeniami ESP8266/ESP32. Udostepnia OTA (aktualizacje Over-the-Air) i integracje z Home Assistant przez API natywne. +> Web dashboard for compiling firmware and managing ESP8266/ESP32 devices. Provides OTA updates and native API integration with Home Assistant. -## URL / Dostep +## Access -- Dashboard: http://localhost:6052 (brak reverse proxy, dostep lokalny) -- Port: 6052 (host network) +| Endpoint | Details | +|----------|---------| +| Dashboard | http://localhost:6052 | +| Network | `network_mode: host` (required for OTA + mDNS discovery) | -## Konfiguracja +## Configuration -- Obraz: `esphome/esphome` -- Siec: `network_mode: host` (wymagane do OTA i odkrywania urzadzen przez mDNS) -- Pliki YAML urzadzen: `./esphome/*.yaml` -- Sekrety: `./esphome/secrets.yaml` +- **Image:** `esphome/esphome` +- **Device YAML:** `./esphome/*.yaml` +- **Secrets:** `./esphome/secrets.yaml` -## Urzadzenia +## Devices -| Plik YAML | Urzadzenie | Opis | -|-----------|-----------|------| -| `sonoff_mini_hall.yaml` | Sonoff Mini (ESP8266) | Oswietlenie gorne w przedpokoju (192.168.20.62) | -| `sonoff_mini_stefi.yaml` | Sonoff Mini | Oswietlenie w pokoju Stefi | -| `sonoff_mini_small_hall.yaml` | Sonoff Mini | Maly przedpokoj | -| `sonoff_mini_driveway` | Sonoff Mini | Oswietlenie podjazdu | -| `sonoff-mini-r2-1.yaml` | Sonoff Mini R2 | Przekaznik #1 | -| `sonoff-mini-r2-2.yaml` | Sonoff Mini R2 | Przekaznik #2 | -| `sonoff-mini-digestor.yaml` | Sonoff Mini | Okap kuchenny | -| `sonoff-mini-kitchen-led.yaml` | Sonoff Mini | Tasmowanie LED w kuchni | -| `sonofft13guk.yaml` | Sonoff T1 | Przelacznik dotykowy | -| `bathroom-shelly-1l-01.yaml` | Shelly 1L | Oswietlenie lazienki | -| `light_driveway.yaml` | ESP (custom) | Inteligentne oswietlenie podjazdu | -| `esp_mini_office.yaml` | ESP32 Mini | Biuro | -| `esp_woox_dining.yaml` | ESP Woox | Jadalnia | -| `esp_woox_fan.yaml` | ESP Woox | Wentylator | -| `lsmin-gat/` | LSMini | Brama | +| YAML File | Device | Description | +|-----------|--------|-------------| +| `sonoff_mini_hall.yaml` | Sonoff Mini (ESP8266) | Hallway ceiling light (192.168.20.62) | +| `sonoff_mini_stefi.yaml` | Sonoff Mini | Stefi's room light | +| `sonoff_mini_small_hall.yaml` | Sonoff Mini | Small hallway | +| `sonoff_mini_driveway.yaml` | Sonoff Mini | Driveway light | +| `sonoff-mini-r2-1.yaml` | Sonoff Mini R2 | Relay #1 | +| `sonoff-mini-r2-2.yaml` | Sonoff Mini R2 | Relay #2 | +| `sonoff-mini-digestor.yaml` | Sonoff Mini | Kitchen hood | +| `sonoff-mini-kitchen-led.yaml` | Sonoff Mini | Kitchen LED strip | +| `sonofft13guk.yaml` | Sonoff T1 | Touch switch | +| `bathroom-shelly-1l-01.yaml` | Shelly 1L | Bathroom light | +| `light_driveway.yaml` | ESP (custom) | Smart driveway lighting | +| `esp_mini_office.yaml` | ESP32 Mini | Office | +| `esp_woox_dining.yaml` | ESP Woox | Dining room | +| `esp_woox_fan.yaml` | ESP Woox | Fan | +| `lsmin-gat/` | LSMini | Gate | -Urzadzenia laczya sie przez WiFi IoT (VLAN 20, `wifi_ssid_iot`) z WPA2 oraz posiadaja fallback AP. +All devices connect via WiFi IoT network (VLAN 20, `wifi_ssid_iot`) with WPA2 and have a fallback AP. -## Architektura / Powiazania +## Architecture ``` ESPHome Dashboard - ├── kompiluje firmware i wgrywa OTA do urzadzen ESP - ├── urzadzenia ESP raportuja stany do Home Assistant przez API natywne - └── czesc urzadzen komunikuje sie rowniez przez MQTT (Mosquitto) + ├── Compiles firmware and flashes OTA to ESP devices + ├── Devices report states to Home Assistant via native API + └── Some devices also communicate via MQTT (Mosquitto) ``` -## Przydatne komendy +## Useful Commands ```bash -# Logi dashboardu +# Follow dashboard logs docker compose logs -f esphome # Restart docker compose restart esphome -# Kompilacja i wgranie firmware (z linii polecen, poza dashboardem) +# Compile and flash firmware from CLI docker compose exec esphome esphome run /config/sonoff_mini_hall.yaml ``` diff --git a/frigate/README.md b/frigate/README.md index 3aa4af1..31f1dd6 100644 --- a/frigate/README.md +++ b/frigate/README.md @@ -1,89 +1,90 @@ -# Frigate +# Frigate - AI-Powered NVR -System NVR (Network Video Recorder) z detekcja obiektow AI w czasie rzeczywistym. Obsluguje 8 kamer, wykrywa osoby, samochody, psy i koty, integruje sie z Home Assistant przez MQTT. +> Real-time object detection NVR system. 8 cameras, detects persons, cars, dogs and cats. Integrates with Home Assistant via MQTT. -## URL / Dostep +## Access -- UI: http://acemagic:5000 (dostep lokalny, brak Traefik) -- API: http://acemagic:5000/api/ -- go2rtc restream: http://acemagic:8554/ (RTSP) +| Endpoint | Details | +|----------|---------| +| Web UI | http://acemagic:5000 (local only, no Traefik) | +| API | http://acemagic:5000/api/ | +| go2rtc restream | http://acemagic:8554/ (RTSP) | -## Konfiguracja +## Configuration -- Wersja konfiguracji: `0.17-0` (config.yml) -- Limit RAM: 6 GB (`mem_limit: 6g`) -- Plik konfiguracyjny: `./frigate/config.yml` -- Nagrania: `/media/evo2t/frigate/` (szybkie SSD) -- Baza danych: `./frigate/frigate.db` (SQLite) +- **Config version:** `0.17-0` (`config.yml`) +- **RAM limit:** 6 GB +- **MQTT:** `192.168.1.132:1883` (Mosquitto), topic prefix `frigate` -### Akceleracja +### Hardware Acceleration -- **Detekcja AI**: Google Coral TPU USB (`device: usb`) -- **Dekodowanie wideo**: AMD GPU `radeonsi` przez VAAPI (hwaccel) -- **MQTT**: `192.168.1.132:1883` (Mosquitto), topic prefix `frigate` +| Component | Hardware | Purpose | +|-----------|----------|---------| +| Google Coral TPU | USB (`device: usb`) | AI object detection | +| AMD GPU `radeonsi` | VAAPI | Video decoding (hwaccel) | -## Kamery +## Cameras -| Nazwa | Model | IP | Sledzone obiekty | Strefy | -|-------|-------|-----|-----------------|--------| -| `frigate_reolink_1` | Reolink | 192.168.1.101 | person, car, dog | parking, driveway, r1_my-garden | -| `frigate_reolink_2` | Reolink | 192.168.1.62 | person, dog | my_sidewalk | -| `frigate_reolink_3` | Reolink | 192.168.1.150 | person, car, dog | terrace, kennel, my-garden | -| `frigate_reolink_4` | Reolink | 192.168.1.168 | person, car, dog | main_area, entrance | -| `frigate_reolink_5` | Reolink | 192.168.1.172 | person, dog | terrace | -| `frigate_hikvision_2` | Hikvision | 192.168.1.65 | person, car, dog | my-garden | -| `frigate_hikvision_4` | Hikvision (domofon) | 192.168.1.127 | person | street-left, robo, at-gate | -| `mercusys_mc200` | Mercusys (wew.) | 192.168.20.33 | person, cat | - | +| Name | Model | IP | Tracked Objects | Zones | +|------|-------|-----|-----------------|-------| +| `reolink_1` | Reolink | 192.168.1.101 | person, car, dog | parking, driveway, r1_my-garden | +| `reolink_2` | Reolink | 192.168.1.62 | person, dog | my_sidewalk | +| `reolink_3` | Reolink | 192.168.1.150 | person, car, dog | terrace, kennel, my-garden | +| `reolink_4` | Reolink | 192.168.1.168 | person, car, dog | main_area, entrance | +| `reolink_5` | Reolink | 192.168.1.172 | person, dog | terrace | +| `hikvision_2` | Hikvision | 192.168.1.65 | person, car, dog | my-garden | +| `hikvision_4` | Hikvision (intercom) | 192.168.1.127 | person | street-left, robo, at-gate | +| `mercusys_mc200` | Mercusys (indoor) | 192.168.20.33 | person, cat | - | -Wszystkie strumienie sa reroutowane przez wbudowany go2rtc (RTSP restream) w celu oszczednosci RAM - Frigate pobiera jeden strumien z go2rtc zamiast bezposrednio z kamery. +All streams are rerouted through built-in go2rtc (RTSP restream) to save RAM - Frigate pulls one stream from go2rtc instead of directly from each camera. -## Retencja nagran +## Retention -| Typ | Czas | -|-----|------| -| Snapshoty (osoby) | 3650 dni (10 lat) | -| Snapshoty (samochody) | 180 dni | -| Snapshoty (domyslnie) | 365 dni | -| Nagrania - alerty | 30 dni | -| Nagrania - detekcje | 90 dni | -| Nagrania ciagle (hikvision_4) | 90 dni | -| Nagrania z ruchem | 7 dni (tylko reolink_1) | +| Type | Duration | +|------|----------| +| Snapshots (persons) | 3650 days (10 years) | +| Snapshots (cars) | 180 days | +| Snapshots (default) | 365 days | +| Recordings - alerts | 30 days | +| Recordings - detections | 90 days | +| Continuous recordings (hikvision_4) | 90 days | +| Recordings with motion | 7 days (reolink_1 only) | -Jakosc snapshotow: 90%, z czystymi kopiami (`clean_copy: true`). +Snapshot quality: 90%, with clean copies (`clean_copy: true`). -## Architektura / Powiazania +## Architecture ``` -Kamery IP (RTSP) - └── go2rtc (restream wewnetrzny) - └── Frigate detekcja (Coral TPU, 640x360@7-10fps) - ├── MQTT -> Mosquitto -> Home Assistant (zdarzenia, binarki) - ├── nagrania -> /media/evo2t/frigate/ - └── snapshoty -> frigate.db + /media/evo2t/frigate/clips/ +Camera IP (RTSP) + └── go2rtc (internal restream) + └── Frigate detection (Coral TPU, 640x360 @ 7-10fps) + ├── MQTT → Mosquitto → Home Assistant (events, binary sensors) + ├── recordings → /media/evo2t/frigate/ + └── snapshots → frigate.db + /media/evo2t/frigate/clips/ ``` -## Klucze konfiguracji +## Key Configuration Details -- Detekcja: 640x360, 7-10 fps (sub-stream), stationary object suppression -- Wyszukiwanie semantyczne: wlaczone (model `small`) -- Birdseye: 1920x1080, tryb continuous -- Maski ruchu dla kazdej kamery (eliminacja falszywych alarow od cieni, znakow drogowych) +- Detection: 640x360, 7-10 fps (sub-stream), stationary object suppression +- Semantic search: enabled (model `small`) +- Birdseye: 1920x1080, continuous mode +- Motion masks per camera (eliminates false alarms from shadows, road signs) -## Przydatne komendy +## Useful Commands ```bash -# Logi +# Follow logs docker compose logs -f frigate # Restart docker compose restart frigate -# Sprawdzenie zuzycia RAM przez Frigate +# Check RAM usage docker stats frigate --no-stream -# Podglad zdarzen MQTT z Frigate -mosquitto_sub -h 192.168.1.132 -u mosquitto -P -t 'frigate/#' -v +# Watch Frigate MQTT events +mosquitto_sub -h 192.168.1.132 -u mosquitto -P -t 'frigate/#' -v -# Czyszczenie starych nagran recznie (Frigate ma to automatyczne) -# Uzyj UI Frigate: http://acemagic:5000 -> Storage +# Clean old recordings manually (auto-handled by Frigate) +# Use UI: http://acemagic:5000 → Storage ``` diff --git a/grafana/README.md b/grafana/README.md index c69828d..136982d 100644 --- a/grafana/README.md +++ b/grafana/README.md @@ -1,59 +1,67 @@ -# Grafana +# Grafana - Monitoring Dashboards -Platforma do wizualizacji metryk i logów. Wyswietla dane z VictoriaMetrics (metryki) oraz Loki (logi). Wysyla alerty przez Telegram. +> Visualization platform for metrics (VictoriaMetrics) and logs (Loki). Sends alerts via Telegram. -## URL / Dostep +## Access -- Publiczny: https://grafana.sebson.space -- Lokalny: http://localhost:3001 -- Login: `seba` (haslo z `.env`: `GRAFANA_ADMIN_PASSWORD`) +| Endpoint | Details | +|----------|---------| +| Public URL | https://grafana.sebson.space | +| Internal | http://localhost:3001 | +| Login | `seba` (password in `.env`: `GRAFANA_ADMIN_PASSWORD`) | -## Konfiguracja +## Configuration -Provisioning automatyczny z `./etc/grafana/provisioning/`: +Automatically provisioned from `./etc/grafana/provisioning/`: -- `datasources/datasource.yaml` - 3 zrodla danych: - - **VictoriaMetrics** (domyslne) - `http://victoriametrics:8428`, uid: `prometheus` - - **Prometheus-Raw** - `http://prometheus:9090` z basic auth - - **Loki** - `http://loki:3100`, max 1000 linii -- `dashboards/` - preinstalowane dashboardy JSON: - - `home-assistant.json` - metryki Home Assistant - - `ping-monitoring.json` - monitoring dostepnosci sieci - - `node-exporter-*.json`, `node.exporter.server.metrics.json` - metryki hostow - - `traefik2.json` - metryki reverse proxy - - `system-monitoring-complete.json` - ogolny monitoring systemu - - `mazda.json`, `windows-wmi.json` - dodatkowe zrodla +### Data Sources -Plugin: `grafana-piechart-panel` +| Source | URL | UID | Notes | +|--------|-----|-----|-------| +| **VictoriaMetrics** (default) | `http://victoriametrics:8428` | `prometheus` | Long-term metrics | +| **Prometheus-Raw** | `http://prometheus:9090` | - | With basic auth | +| **Loki** | `http://loki:3100` | `loki` | Max 1000 lines per query | -Alerty Telegram: `GF_UNIFIED_ALERTING_ENABLED=true`, bot token i chat ID z `.env` (`TELEGRAM_BOT_TOKEN`, `TELEGRAM_CHAT_ID`). +### Pre-installed Dashboards -## Co monitoruje / metryki +- `home-assistant.json` - HA entity metrics +- `ping-monitoring.json` - Network availability +- `node-exporter-*.json`, `node.exporter.server.metrics.json` - Host metrics +- `traefik2.json` - Reverse proxy metrics +- `system-monitoring-complete.json` - Overall system monitoring +- `mazda.json`, `windows-wmi.json` - Additional sources -Grafana sama w sobie nie zbiera metryk - wizualizuje dane z innych serwisow: -- Metryki systemowe hostow (CPU, RAM, dyski, siec) -- Metryki kontenerow Docker (cAdvisor) -- Metryki Home Assistant (encje, stany) -- Metryki Traefik (requesty, latencja) -- Logi kontenerow (przez Loki) -- Ping/dostepnosc urzadzen +**Plugin:** `grafana-piechart-panel` -## Powiazania z innymi serwisami +**Alerts:** Telegram via Grafana Unified Alerting (`GF_UNIFIED_ALERTING_ENABLED=true`). Bot token and chat ID from `.env`. -| Serwis | Rola | -|--------|------| -| VictoriaMetrics | glowne zrodlo danych (dlugoterminowe metryki) | -| Prometheus | zrodlo surowych metryk (krotkoterminowe) | -| Loki | zrodlo logow kontenerow | -| Alertmanager | opcjonalnie (alerty SA zarzadzane przez Grafana Unified Alerting) | +## Monitored Metrics -## Przydatne komendy +Grafana visualizes data from other services: + +- Host system metrics (CPU, RAM, disks, network) +- Docker container metrics (cAdvisor) +- Home Assistant metrics (entities, states) +- Traefik metrics (requests, latency) +- Container logs (via Loki) +- Ping / device availability + +## Dependencies + +| Service | Role | +|---------|------| +| VictoriaMetrics | Primary data source (long-term metrics) | +| Prometheus | Raw metrics source (short-term) | +| Loki | Container log source | +| Alertmanager | Optional (alerts managed by Grafana Unified Alerting) | + +## Useful Commands ```bash # Restart docker compose restart grafana -# Logi +# Follow logs docker compose logs -f grafana # Upgrade diff --git a/ha-dashboard/README.md b/ha-dashboard/README.md index 00ba58b..cfef2ee 100644 --- a/ha-dashboard/README.md +++ b/ha-dashboard/README.md @@ -1,71 +1,81 @@ -# HA Dashboard (Brana) +# HA Dashboard - Operations Panel -Niestandardowa aplikacja webowa Flask bedaca centralnym panelem operacyjnym dla calej infrastruktury domowej. Agreguje dane z Home Assistant, PostgreSQL, Docker i Crowdsec w jednym widoku. +> Custom Flask application serving as the central operations dashboard for the entire home infrastructure. Aggregates data from Home Assistant, PostgreSQL, Docker and CrowdSec into a single view. -## URL / Dostep +## Access -- Panel: https://hadash.sebson.space -- Port lokalny: 9081 -> 8080 -- Wymagane logowanie (rejestracja z zatwierdzeniem przez administratora) +| Endpoint | Details | +|----------|---------| +| Public URL | https://hadash.sebson.space | +| Internal Port | `9081 -> 8080` | +| Auth | Login required (registration with admin approval) | -## Konfiguracja +## Configuration -- Zbudowany lokalnie z `./ha-dashboard/Dockerfile` (Python 3.12-slim + Flask) -- Zaleznosci: `flask`, `psycopg2-binary`, `requests`, `docker` -- Zmienne srodowiskowe: `DB_HOST`, `DB_PORT`, `DB_USER`, `DB_PASS`, `HA_URL`, `HA_TOKEN`, `SECRET_KEY` -- Wolumeny: - - `/var/run/docker.sock` - dostep do Docker API (informacje o kontenerach, Crowdsec) - - `./backup.log` -> `/backup.log` - log backupow bazy danych - - `./ha-dashboard/auth/` -> `/auth/` - katalog uwierzytelnienia uzytkownikow - - `./homeassistant/config/` -> `/ha_config/` - dostep do rejestrow ZigBee i urzadzen HA +- Built locally from `./ha-dashboard/Dockerfile` (Python 3.12-slim + Flask) +- **Dependencies:** `flask`, `psycopg2-binary`, `requests`, `docker` +- **Environment:** `DB_HOST`, `DB_PORT`, `DB_USER`, `DB_PASS`, `HA_URL`, `HA_TOKEN`, `SECRET_KEY` -## Architektura / Powiazania +### Volumes + +| Mount | Container Path | Purpose | +|-------|---------------|---------| +| `/var/run/docker.sock` | - | Docker API access (container info, CrowdSec exec) | +| `./backup.log` | `/backup.log` | Database backup log | +| `./ha-dashboard/auth/` | `/auth/` | User authentication files | +| `./homeassistant/config/` | `/ha_config/` | HA device registry, ZigBee database | + +## Architecture ``` HA Dashboard (Flask) - ├── Home Assistant REST API - stany encji, automatyzacje, logbook - ├── PostgreSQL 18 - rozmiary baz homeassistant i bitwarden - ├── Docker socket - lista kontenerow, exec do crowdsec - ├── /ha_config/zigbee.db - baza ZigBee (ostatnia aktywnosc, LQI) - └── /backup.log - historia backupow PostgreSQL + ├── Home Assistant REST API - entity states, automations, logbook + ├── PostgreSQL 18 - homeassistant & bitwarden DB sizes + ├── Docker socket - container list, exec into crowdsec + ├── /ha_config/zigbee.db - ZigBee DB (last_seen, LQI) + └── /backup.log - PostgreSQL backup history ``` -## Dostepne widoki / API +## API Endpoints -| Endpoint | Opis | -|----------|------| -| `/` | Glowny dashboard (SPA) | -| `/api/overview` | Osoby w domu, otwarte okna/drzwi, temperatury, status Mazdy, backup | -| `/api/home` | Stan bramy, automatyzacje bramy, lista swiatel z jasnosciami | -| `/api/power` | Aktualne zuzycie energii (zacisk glowny, NAS, Shelly, Tasmota) | -| `/api/frigate` | Ostatnie 9 detekcji z kamer Frigate (obrazy przez proxy) | -| `/api/automations` | Statystyki automatyzacji HA, ostatnio uruchomione | -| `/api/containers` | Status wszystkich kontenerow Docker | -| `/api/crowdsec` | Aktywne bany i ostatnie alerty Crowdsec | -| `/api/db` | Rozmiary baz danych i top 10 tabel | -| `/api/bitwarden` | Statystyki Vaultwarden (liczba hasel wg typu) | -| `/api/zigbee` | Lista urzadzen ZigBee z last_seen, LQI i poziomem baterii | -| `/api/gate/events` | Historia otwarc bramy z bazy PostgreSQL | -| `/api/gate/logbook` | Logbook bramy i automatyzacji z HA API | -| `/api/scene/all_lights_off` | Wlaczenie sceny "wszystkie swiatla wylaczone" | -| `/api/toggle/` | Wylaczenie dowolnej encji HA | +| Endpoint | Description | +|----------|-------------| +| `/` | Main dashboard (SPA) | +| `/api/overview` | People at home, open windows/doors, temperatures, Mazda status, backup | +| `/api/home` | Gate state, gate automations, light list with brightness | +| `/api/power` | Current power consumption (main clamp, NAS, Shelly, Tasmota) | +| `/api/frigate` | Last 9 Frigate detections (images proxied) | +| `/api/automations` | HA automation stats, recently triggered | +| `/api/containers` | All Docker container statuses | +| `/api/crowdsec` | Active bans and recent alerts | +| `/api/db` | Database sizes and top 10 tables | +| `/api/bitwarden` | Vaultwarden stats (password count by type) | +| `/api/zigbee` | ZigBee devices with last_seen, LQI and battery level | +| `/api/gate/events` | Gate open events from PostgreSQL | +| `/api/gate/logbook` | Gate logbook and automations from HA API | +| `/api/scene/all_lights_off` | Trigger "all lights off" scene | +| `/api/toggle/` | Toggle any HA entity | -## System uwierzytelnienia +## Authentication -Dwuetapowy: uzytkownik rejestruje sie (`/register`), konto wymaga recznego zatwierdzenia przez administratora (stworzenie pliku w `auth/approved/`). Sesje Flask z kluczem `SECRET_KEY`. +Two-step: user registers at `/register`, account requires manual admin approval (creation of file at `auth/approved/`). Flask sessions keyed by `SECRET_KEY`. -## Przydatne komendy +### Approving a User ```bash -# Rebuild po zmianach kodu -docker compose build ha-dashboard && docker compose up -d ha-dashboard - -# Logi -docker compose logs -f ha-dashboard - -# Zatwierdzenie nowego uzytkownika +# Approve a pending user touch ./ha-dashboard/auth/approved/ -# Lista oczekujacych na zatwierdzenie +# List pending users ls ./ha-dashboard/auth/pending/ ``` + +## Useful Commands + +```bash +# Rebuild after code changes +docker compose build ha-dashboard && docker compose up -d ha-dashboard + +# Follow logs +docker compose logs -f ha-dashboard +``` diff --git a/ha-dashboard/templates/index.html b/ha-dashboard/templates/index.html index 5d3c38b..4229f59 100644 --- a/ha-dashboard/templates/index.html +++ b/ha-dashboard/templates/index.html @@ -313,6 +313,7 @@

🏠 HA Dashboard — sebson.space