docs(cameras): implementation plan for the Reolink E1 / Frigate stack

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ginnoirandClaude Opus 5.5 committed 2026-10-08 01:17:04 -05:00
1 parent 392939ac53
commit dee126cd55
2 files changed
+574 -3

No files matched your search

@@ -0,0 +1,571 @@
# Reolink E1 → Frigate Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** Live view of the Reolink E1 at `cam.ginnoir.com` (behind Authentik) plus person/pet
detection snapshots with ntfy pushes, all running on valhalla.
**Architecture:** New Portainer git stack `stacks/cameras/` with three containers:
- `neolink` bridges the E1's proprietary Baichuan protocol (:9000, the only open port) to RTSP.
- `frigate` re-streams neolink through its built-in go2rtc, runs OpenVINO detection on the CPU
against the sub stream, and stores snapshots. Recording is off.
- `frigate-notify` polls Frigate's internal API and posts to ntfy.
Caddy fronts Frigate's :8971 with Authentik forward_auth, and Frigate trusts the
`X-Authentik-Username` header.
**Tech Stack:** Frigate 0.17.2, neolink v0.6.2 (QuantumEntangledAndy fork), frigate-notify
v0.5.4, Caddy, Authentik proxy provider (forward_single), ntfy, Portainer git stacks.
**Spec:** `docs/superpowers/specs/2026-10-08-reolink-camera-frigate-design.md`
**Facts established 2026-10-08:**
- Camera:
- E1 at 192.168.1.99, DHCP-reserved in OPNsense.
- Only TCP 9000 is open (80/443/554/1935/8000 closed).
- Login is the `admin` account; ginnoir supplied the password in chat. It is never written
into docs.
- valhalla CPU: 52× Xeon E5-2697 v3 (Haswell, AVX2).
- Frigate's docs list OpenVINO for Skylake+, so Haswell is unofficial.
- Fallback: Frigate's `type: cpu` tflite detector, which is fine for one camera at 5 fps.
- ntfy: the anonymous user has read-write access to all non-listed topics, so the new topic
`cameras` needs no token. Post internally to `http://ntfy:80` over `edge`.
- Authentik:
- Pattern B reference is proxy provider pk 8 (`homelab-uptime`): `mode: forward_single`,
authorization flow `b88daebc-…`, invalidation flow `3259f9c5-…`, embedded outpost
`f508ee32-d41b-43b3-8252-25e59b198797`.
- Host paths:
- `/config` is owned by ginnoir.
- `/storage1/labdata` is root-owned, so use `sudo` (passwordless sudo works).
- The repo-file bind gotcha: Portainer's checkout won't materialize sibling repo files,
so configs are seeded to absolute `/config/<svc>/` paths.
---
## File structure
| File | Responsibility |
|---|---|
| `stacks/cameras/docker-compose.yml` | The three services, the `cameras` network, binds |
| `stacks/cameras/stack.env` | `TZ` (the env_file convention; no secrets needed here) |
| `stacks/cameras/neolink/neolink.toml` | Canonical neolink config incl. camera creds (secrets versioned by policy); seeded to `/config/neolink/` |
| `stacks/cameras/frigate/config.yml` | Canonical Frigate config; seeded to `/config/frigate/` |
| `stacks/cameras/frigate-notify/config.yml` | Canonical notifier config; seeded to `/config/frigate-notify/` |
| `Caddyfile` | New `cam.ginnoir.com` site block |
| `bookmarks-*.html` | Regenerated by `scripts/gen-bookmarks.ps1` |
| `CLAUDE.md` | Add `cameras/` to the layout tree |
---
### Task 1: Prove the camera speaks to neolink (pre-flight)
This is the "failing test" for the whole effort. If neolink can't log in to this firmware,
the design changes, so check it before writing any stack files.
**Files:**
- Create (scratch, on valhalla only): `/tmp/neolink-test/neolink.toml`
- [ ] **Step 1: Write a throwaway neolink config on valhalla**
```bash
ssh ginnoir@valhalla 'mkdir -p /tmp/neolink-test && cat > /tmp/neolink-test/neolink.toml' <<'EOF'
bind = "0.0.0.0"
[[cameras]]
name = "e1"
username = "admin"
password = "<E1 admin password from chat>"
address = "192.168.1.99:9000"
stream = "both"
EOF
```
- [ ] **Step 2: Run neolink for 25 s and probe the RTSP output with ffprobe**
```bash
ssh ginnoir@valhalla '
docker network create neotest >/dev/null 2>&1
docker run -d --rm --name neotest --network neotest -v /tmp/neolink-test/neolink.toml:/etc/neolink.toml:ro quantumentangledandy/neolink:v0.6.2
sleep 20
docker run --rm --network neotest linuxserver/ffmpeg:latest -v error -rtsp_transport tcp -i rtsp://neotest:8554/e1/subStream -frames:v 1 -f null - && echo SUB_OK
docker run --rm --network neotest --entrypoint ffprobe linuxserver/ffmpeg:latest -v error -rtsp_transport tcp -show_entries stream=codec_name,width,height -of csv=p=0 rtsp://neotest:8554/e1/mainStream
docker logs neotest 2>&1 | tail -15
docker stop neotest; docker network rm neotest; rm -rf /tmp/neolink-test'
```
Expected: `SUB_OK`, then a main-stream line like `h264,1920,1080` (or 2304×1296), and the
neolink logs show `e1: Connected and logged in`.
If the login fails or a stream never appears, repeat with image `quantumentangledandy/neolink:latest`
(master, 2025-01). If that works, pin the digest of `:latest` in Task 2 instead of `v0.6.2`.
If both fail, **stop and report to ginnoir**: the E1 firmware isn't supported, and the
fallback is the Reolink app only.
- [ ] **Step 3: Note the main-stream resolution.** It goes in Frigate's config as a comment
and confirms the sub stream is 640×360. If ffprobe on the sub stream reports something
else, use that size in Task 2's `detect:` block.
---
### Task 2: Stack files in the repo
**Files:**
- Create: `stacks/cameras/docker-compose.yml`
- Create: `stacks/cameras/stack.env`
- Create: `stacks/cameras/neolink/neolink.toml`
- Create: `stacks/cameras/frigate/config.yml`
- Create: `stacks/cameras/frigate-notify/config.yml`
- [ ] **Step 1: Write `stacks/cameras/docker-compose.yml`**
```yaml
# cameras stack — Reolink E1 live view + detection snapshots.
#
# The E1 (192.168.1.99) has NO RTSP/RTMP/ONVIF: only Reolink's Baichuan protocol on
# :9000. neolink logs in over Baichuan and re-serves rtsp://neolink:8554/e1/{main,sub}Stream
# on the private cameras net (unauthenticated, so it is never on edge). frigate's
# built-in go2rtc is the only neolink client; the browser gets MSE through Caddy.
#
# Recording is OFF — snapshots only (/storage1/labdata/frigate). Detection is OpenVINO on
# CPU, deliberately not the P100 (llama-swap owns its VRAM; CDI breaks after reboots).
#
# Configs are host-managed at /config/<svc>/ (Portainer's checkout won't materialize a
# relative repo-file bind). The copies under stacks/cameras/*/ are canonical; on change,
# copy them to valhalla (see homelab-apply). All images pinned out of Watchtower:
# frigate's config schema breaks between minor releases.
services:
neolink:
image: quantumentangledandy/neolink:v0.6.2
container_name: neolink
restart: unless-stopped
labels:
- "com.centurylabs.watchtower.enable=false"
env_file: stack.env
networks: [cameras]
volumes:
- /config/neolink/neolink.toml:/etc/neolink.toml:ro
frigate:
image: ghcr.io/blakeblackshear/frigate:0.17.2
container_name: frigate
restart: unless-stopped
labels:
- "com.centurylabs.watchtower.enable=false"
env_file: stack.env
shm_size: "256mb"
depends_on: [neolink]
networks: [edge, cameras]
volumes:
- /config/frigate:/config
- /storage1/labdata/frigate:/media/frigate
- type: tmpfs
target: /tmp/cache
tmpfs:
size: 1000000000
frigate-notify:
image: ghcr.io/0x2142/frigate-notify:v0.5.4
container_name: frigate-notify
restart: unless-stopped
labels:
- "com.centurylabs.watchtower.enable=false"
env_file: stack.env
depends_on: [frigate]
# cameras -> frigate:5000 API; edge -> ntfy:80
networks: [cameras, edge]
volumes:
- /config/frigate-notify/config.yml:/app/config.yml:ro
networks:
edge:
external: true
cameras:
name: cameras
```
- [ ] **Step 2: Write `stacks/cameras/stack.env`**
```
TZ=America/Chicago
```
- [ ] **Step 3: Write `stacks/cameras/neolink/neolink.toml`** (real password from chat)
```toml
# Seeded to /config/neolink/neolink.toml on valhalla. Secrets versioned by policy.
bind = "0.0.0.0"
[[cameras]]
name = "e1"
username = "admin"
password = "<E1 admin password from chat>"
address = "192.168.1.99:9000"
stream = "both"
```
- [ ] **Step 4: Write `stacks/cameras/frigate/config.yml`**
```yaml
# Seeded to /config/frigate/config.yml on valhalla. Frigate 0.17.2 schema.
# Caddy terminates TLS + Authentik forward_auth in front of :8971.
mqtt:
enabled: false
tls:
enabled: false
auth:
enabled: false
proxy:
separator: "|"
header_map:
user: x-authentik-username
default_role: admin
detectors:
ov:
type: openvino
device: CPU
model:
width: 300
height: 300
input_tensor: nhwc
input_pixel_format: bgr
path: /openvino-model/ssdlite_mobilenet_v2.xml
labelmap_path: /openvino-model/coco_91cl_bkgr.txt
go2rtc:
streams:
e1:
- rtsp://neolink:8554/e1/mainStream
e1_sub:
- rtsp://neolink:8554/e1/subStream
record:
enabled: false
snapshots:
enabled: true
bounding_box: true
retain:
default: 30
objects:
track: [person, dog, cat]
cameras:
e1:
ffmpeg:
inputs:
- path: rtsp://127.0.0.1:8554/e1_sub
input_args: preset-rtsp-restream
roles: [detect]
detect:
width: 640
height: 360
fps: 5
live:
streams:
Main: e1
Sub: e1_sub
```
- [ ] **Step 5: Write `stacks/cameras/frigate-notify/config.yml`**
```yaml
# Seeded to /config/frigate-notify/config.yml on valhalla. frigate-notify v0.5.4.
frigate:
server: http://frigate:5000
public_url: https://cam.ginnoir.com
startup_check:
attempts: 10
interval: 30
webapi:
enabled: true
interval: 30
mqtt:
enabled: false
alerts:
general:
title: E1
snap_bbox: true
notify_once: true
labels:
allow: [person, dog, cat]
ntfy:
enabled: true
server: http://ntfy:80
topic: cameras
monitor:
enabled: false
```
- [ ] **Step 6: Lint the compose file locally**
```bash
docker compose -f stacks/cameras/docker-compose.yml config --quiet && echo COMPOSE_OK
```
Expected: `COMPOSE_OK`. If Docker isn't installed on the workstation, run it on valhalla
from a scp'd copy instead.
- [ ] **Step 7: Check LF line endings and commit (don't push yet)**
```bash
git add stacks/cameras
git ls-files --eol stacks/cameras | grep -v "i/lf" || echo ALL_LF
git commit -m "feat(cameras): neolink + frigate + frigate-notify stack for the Reolink E1"
```
Expected: `ALL_LF`.
---
### Task 3: Seed host config + data dirs
- [ ] **Step 1: Copy the three configs to valhalla and create the snapshot dir**
```bash
scp stacks/cameras/neolink/neolink.toml ginnoir@valhalla:/tmp/neolink.toml
scp stacks/cameras/frigate/config.yml ginnoir@valhalla:/tmp/frigate-config.yml
scp stacks/cameras/frigate-notify/config.yml ginnoir@valhalla:/tmp/frigate-notify.yml
ssh ginnoir@valhalla '
mkdir -p /config/neolink /config/frigate /config/frigate-notify
install -m 600 /tmp/neolink.toml /config/neolink/neolink.toml
install -m 644 /tmp/frigate-config.yml /config/frigate/config.yml
install -m 644 /tmp/frigate-notify.yml /config/frigate-notify/config.yml
rm /tmp/neolink.toml /tmp/frigate-config.yml /tmp/frigate-notify.yml
sudo mkdir -p /storage1/labdata/frigate
ls -l /config/neolink /config/frigate /config/frigate-notify; ls -ld /storage1/labdata/frigate'
```
Expected: the three files are present, and `/storage1/labdata/frigate` exists. The containers
run as root, so root ownership is fine.
---
### Task 4: Register the Portainer git stack
- [ ] **Step 1: Push the commit**
```bash
git push
```
- [ ] **Step 2: Copy git settings from an existing stack.**
- Use the Portainer MCP (`StackList` / `StackInspect` with a `select`; call `get_guidance`
first) to read the git URL, the reference `refs/heads/main`, the auth (the stacks'
fine-grained PAT, **not** the runner PAT), and the auto-update interval `5m` from a
working stack such as `notify`.
- [ ] **Step 3: Create the stack.**
- Call `StackCreateDockerStandaloneRepository` on endpoint 3:
- name `cameras`
- `composeFile: stacks/cameras/docker-compose.yml`
- same git URL/auth
- `autoUpdate.interval: "5m"`
- **empty `env`**
- The MCP call times out but succeeds. Poll `StackList` until `cameras` appears and note
its id.
- [ ] **Step 4: Verify the env is empty and the containers are up**
```powershell
./scripts/check-portainer-stack-env.ps1
ssh -o BatchMode=yes ginnoir@valhalla "docker ps --filter name=neolink --filter name=frigate --format 'table {{.Names}}\t{{.Status}}'"
```
Expected: the env check passes, and all three containers are `Up` (frigate `(healthy)`
after ~1–2 min).
- [ ] **Step 5: Verify a healthy Portainer dir** (the stray-.git gotcha)
```bash
ssh ginnoir@valhalla 'sudo ls -a /config/portainer/compose/<id>/'
```
Expected: no `.git` entry.
---
### Task 5: Verify the pipeline inside the host (before exposing it)
- [ ] **Step 1: Check the logs**
```bash
ssh -o BatchMode=yes ginnoir@valhalla "docker logs neolink 2>&1 | tail -10; docker logs frigate 2>&1 | grep -iE 'error|openvino|e1|detector' | tail -25"
```
Expected:
- neolink is logged in to `e1`.
- Frigate shows no config validation error, starts the `ov` detector, and the `e1` camera
has no repeated `No frames received` lines.
If OpenVINO fails on Haswell (an `Illegal instruction` or OpenVINO plugin error), replace
the `detectors:` + `model:` blocks in `stacks/cameras/frigate/config.yml` with:
```yaml
detectors:
cpu1:
type: cpu
num_threads: 3
```
Then re-seed (Task 3, Step 1, frigate config only), `docker restart frigate`, commit, and push.
- [ ] **Step 2: Check the camera stats from the internal API**
```bash
ssh -o BatchMode=yes ginnoir@valhalla "docker run --rm --network cameras curlimages/curl -s http://frigate:5000/api/stats" | python -c "import sys,json;d=json.load(sys.stdin);print(d['cameras']['e1']['camera_fps'], d['detectors'])"
```
Expected: `camera_fps` ≈ 5.0, and the detector `inference_speed` is a number (a few to tens
of ms).
---
### Task 6: Authentik proxy provider + application
- [ ] **Step 1: Create the proxy provider**
- `mcp__authentik__authentik_write` operation for creating a proxy provider (look up the
exact name with `operation="help"` and grep for `ProxyProvider`). Params:
```json
{
"name": "homelab-cam",
"authorization_flow": "b88daebc-c54d-4e85-ae27-8b47384d5d74",
"invalidation_flow": "3259f9c5-7eab-40bf-81cb-2b0ede6eb7b3",
"mode": "forward_single",
"external_host": "https://cam.ginnoir.com",
"internal_host": "http://frigate:8971",
"intercept_header_auth": true,
"access_token_validity": "hours=1"
}
```
Note the returned `pk`.
- [ ] **Step 2: Create the application:** `{"name": "Frigate", "slug": "cam", "provider": <pk>}`.
- [ ] **Step 3: Add `<pk>` to the embedded outpost**
- The outpost is `f508ee32-d41b-43b3-8252-25e59b198797`. Read its current `providers`
list, append `<pk>`, and update with the full list. **Never send a partial list** — that
would unbind the other 19 services.
- Verify with `ListOutposts`: the providers now include `<pk>` and still include `8`.
---
### Task 7: Caddy site + bookmarks
**Files:**
- Modify: `Caddyfile` (append after the `uptime.ginnoir.com` block)
- Modify: `bookmarks-domains.html`, `bookmarks-ports.html` (generated)
- [ ] **Step 1: Add the site block**
```caddy
cam.ginnoir.com {
import internal_only
route {
import authentik_outpost
handle {
import authentik_forward_auth
reverse_proxy frigate:8971
}
}
}
```
- [ ] **Step 2: Validate the Caddyfile on valhalla before pushing**
```bash
scp Caddyfile ginnoir@valhalla:/tmp/Caddyfile.test
ssh ginnoir@valhalla "docker cp /tmp/Caddyfile.test caddy:/tmp/Caddyfile.test && docker exec caddy caddy validate --config /tmp/Caddyfile.test --adapter caddyfile; rm /tmp/Caddyfile.test"
```
Expected: `Valid configuration`.
- [ ] **Step 3: Regenerate the bookmarks, commit, and push**
```powershell
./scripts/gen-bookmarks.ps1
git add Caddyfile bookmarks-domains.html bookmarks-ports.html
git commit -m "feat(cameras): cam.ginnoir.com behind Authentik forward_auth"
git push
```
- [ ] **Step 4: Confirm Gitea Actions reloaded Caddy and the cert was issued**
```bash
ssh -o BatchMode=yes ginnoir@valhalla "docker logs --since 5m caddy 2>&1 | grep -iE 'cam.ginnoir|error' | tail"
curl -sI https://cam.ginnoir.com | head -3
```
Expected:
- The certificate is obtained for `cam.ginnoir.com`.
- The curl (from the LAN) returns `302` to `auth.ginnoir.com`.
- If Gitea Actions didn't fire, fall back to `powershell -File apply-compose.ps1 -Caddy`.
---
### Task 8: End-to-end verification + monitoring
- [ ] **Step 1: Check the live view in a browser**
- In the built-in browser, open `https://cam.ginnoir.com`. Expect the Authentik login.
**Do not enter credentials** — ginnoir logs in.
- Then confirm the live view plays smoothly (MSE) and the user menu shows `ginnoir` (the
proxy header was mapped).
- [ ] **Step 2: Detection test (ginnoir walks in front of the camera)**
- Subscribe to the `cameras` topic in the ntfy app first.
- Then confirm:
```bash
ssh -o BatchMode=yes ginnoir@valhalla "docker run --rm --network cameras curlimages/curl -s 'http://frigate:5000/api/events?limit=3' ; sudo ls -lt /storage1/labdata/frigate/clips | head -5; docker logs --tail 20 frigate-notify"
```
Expected:
- A `person` event exists.
- A `e1-*.jpg` snapshot is in `clips/`.
- frigate-notify logs `Sent notification via ntfy`.
- The push with the image arrives on the phone.
- [ ] **Step 3: Add an Uptime Kuma monitor**
- Use `mcp__uptime-kuma__createMonitor`: type `http`, name `Frigate`, URL
`http://frigate:5000/api/version`, interval 60.
- Use the same notification(s) as existing monitors (`listNotifications`, then copy the
ids from a peer monitor).
- Confirm it is green with `getMonitorSummary`.
- If Kuma isn't on `edge`/`cameras` and can't resolve `frigate`, use
`https://cam.ginnoir.com/api/version` with accepted status `200-399` instead.
- [ ] **Step 4: Check the CPU cost**
```bash
ssh -o BatchMode=yes ginnoir@valhalla "docker stats --no-stream neolink frigate frigate-notify"
```
Expected: the total is well under 2 cores. Note the figure in the memory entry.
---
### Task 9: Docs + memory
- [ ] **Step 1: Update `CLAUDE.md`.** In the layout tree, add
`│ ├── cameras/ # neolink (E1 Baichuan→RTSP), frigate, frigate-notify`.
Commit and push.
- [ ] **Step 2: Write the memory file** `cameras-stack.md`:
- E1 has no RTSP → neolink
- Portainer stack id
- Configs host-seeded at /config/{neolink,frigate,frigate-notify}
- OpenVINO-on-Haswell result
- ntfy topic `cameras`
- Pinned versions
- Add the pointer line to `MEMORY.md`.
- [ ] **Step 3: Mirror to the Obsidian vault** via the Obsidian MCP (the standing rule).
If the MCP is still unreachable, as it was at session start, tell ginnoir and wait. Never
write to CouchDB directly.
@@ -65,7 +65,7 @@ Baichuan session no matter how many viewers there are.
- `ghcr.io/0x2142/frigate-notify:<pinned>`
- `env_file: stack.env`
- Config at `/config/frigate-notify/config.yml`
- Network: `cameras`, plus egress to reach ntfy's public URL (same pattern as vigilant)
- Networks: `cameras` (frigate API :5000) and `edge` (ntfy:80)
### `stacks/cameras/stack.env`
@@ -74,8 +74,8 @@ Var names are exactly what the containers read:
- Camera credentials do **not** go here. Neolink's TOML has no env substitution, so they
live in `stacks/cameras/neolink/neolink.toml` (secrets are versioned in the private repo
by policy), which is seeded to `/config/neolink/`
- frigate-notify ntfy settings: server `https://ntfy.ginnoir.com`, topic, and an ntfy access
token (ntfy has `NTFY_ENABLE_LOGIN=true`)
- Only `TZ`. frigate-notify posts to `http://ntfy:80` topic `cameras` over `edge`; ntfy's
anonymous user has read-write on unlisted topics, so no token is needed
### Frigate `config.yml`