Files
homelabstack/docs/superpowers/specs/2026-10-08-reolink-camera-frigate-design.md
T
ginnoirandClaude Opus 5.5 981c7a65b5 fix(cameras): PTZ page waits for each step's OK, drops zoom, narrows MQTT ACL
neolink 0.6.2 moves for amount/32 s per command and queues them, so the page
sends the next step only after the previous reply; in/out are todo!() upstream.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 02:05:46 -05:00

197 lines
8.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Reolink E1 → Frigate on valhalla (live view + detection snapshots)
**Date:** 2026-10-08
**Status:** Approved design, pending implementation plan
## Goal
Watch a Reolink E1 (indoor pan/tilt, WiFi, plug-in power) live from a browser, and keep a
snapshot whenever a person or pet is detected, with an ntfy push. Continuous recording is
explicitly **out of scope**.
## Decisions
| Decision | Choice | Why |
|---|---|---|
| NVR software | Frigate | Object detection + snapshots + built-in go2rtc live view in one container |
| Detector | OpenVINO on CPU | One 640×360 sub-stream at 5 fps is negligible on the R730XD Xeons. Keeps the camera off the P100, which llama-swap fills with hot-swapped models and whose CDI device breaks after every reboot (`nvidia-modeset`, see jellyfin/llama-swap exit 255) |
| Recording | Off (`record.enabled: false`) | User wants live view + snapshots only |
| Tracked objects | `person`, `dog`, `cat` | Person + pet snapshots |
| Snapshot retention | 30 days | Small files; no redundancy needed |
| Notifications | `frigate-notify` sidecar → ntfy | Polls Frigate's API, so no MQTT broker needed |
| Access | `cam.ginnoir.com`, `internal_only` + Authentik forward_auth (Pattern B) | Frigate has no OIDC. Remote access goes over the tailnet |
| Image versions | Frigate + frigate-notify pinned, `com.centurylabs.watchtower.enable=false` | Frigate config schema breaks between minor releases |
## Architecture
```
Reolink E1 (WiFi, 192.168.1.99) — Baichuan :9001 ONLY (no RTSP/RTMP/HTTP/ONVIF)
│
▼
neolink (Baichuan → RTSP bridge, serves rtsp://neolink:8554/e1/{mainStream,subStream})
│ mainStream ──► go2rtc (inside frigate) ──► browser MSE via Caddy
│ subStream ──► frigate detect (OpenVINO CPU)
▼
frigate ──snapshots──► /storage1/labdata/frigate/
▲
│ HTTP API (cameras net)
frigate-notify ──► https://ntfy.ginnoir.com/<topic> (snapshot attached)
```
**The original E1 has no RTSP.** A port probe from valhalla on 2026-10-08 found only 9000
open (80/443/554/1935/8000 closed), and the app's Server Settings shows only the media port.
Neolink speaks Reolink's proprietary Baichuan protocol on :9000 and re-serves the streams
as RTSP. It is the only camera client. go2rtc re-streams neolink, so the E1 sees one
Baichuan session no matter how many viewers there are.
## Components
### `stacks/cameras/docker-compose.yml` (new Portainer git stack)
- **`neolink`**
- `quantumentangledandy/neolink:<pinned>` (the maintained fork)
- Config at `/config/neolink/neolink.toml`: camera `e1`, `address = "192.168.1.99:9001"`,
username/password, `stream = "both"`
- Network: `cameras` only. The RTSP output is unauthenticated, but only frigate can reach it
- **`frigate`**
- `ghcr.io/blakeblackshear/frigate:<pinned stable>` (non-GPU image; OpenVINO CPU is built in)
- `env_file: stack.env`, `shm_size: 256mb`, tmpfs `/tmp/cache` (1 GB)
- Binds:
- `/config/frigate:/config` (config.yml + frigate.db)
- `/storage1/labdata/frigate:/media/frigate` (snapshots)
- Networks: `edge` (Caddy) and `cameras` (private, for frigate-notify)
- No published ports. The UI (8971) is reached only through Caddy
- **`frigate-notify`**
- `ghcr.io/0x2142/frigate-notify:<pinned>`
- `env_file: stack.env`
- Config at `/config/frigate-notify/config.yml`
- Networks: `cameras` (frigate API :5000) and `edge` (ntfy:80)
### `stacks/cameras/stack.env`
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/`
- 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`
- Canonical copy at `stacks/cameras/frigate/config.yml`, seeded once to
`/config/frigate/config.yml` on the host
- The bind must be absolute `/config`, because the Portainer checkout doesn't materialize
sibling repo files
- Contents:
- `auth.enabled: false`
- `proxy.header_map.user: x-authentik-username`
- `detectors: ov: {type: openvino, device: CPU}` with the bundled SSDLite model
- `go2rtc.streams.e1` = `rtsp://neolink:8554/e1/mainStream`,
`e1_sub` = `rtsp://neolink:8554/e1/subStream`
- `cameras.e1`:
- Detect role on `rtsp://127.0.0.1:8554/e1_sub`, 640×360 at 5 fps
- `record.enabled: false`
- `snapshots: {enabled: true, retain: {default: 30}, bounding_box: true}`
- `objects.track: [person, dog, cat]`
- `live.stream_name: e1`
### Caddyfile
```caddy
cam.ginnoir.com {
import internal_only
route {
import authentik_outpost
handle {
import authentik_forward_auth
reverse_proxy frigate:8971
}
}
}
```
### Authentik
- Proxy provider + application `cam` (forward-auth, single application), bound to the
embedded outpost, following the existing Pattern B services
## Camera-side prerequisites (manual, ginnoir)
1. ~~Enable RTSP~~: not available on the E1. Neolink replaces it.
2. Camera credentials: admin account (provided 2026-10-08).
3. DHCP static reservation in OPNsense for 192.168.1.99 (confirm it is a reservation, not
just the current lease).
4. Keep the Reolink app free of other viewers during testing. The E1 allows few
simultaneous Baichuan sessions.
5. Make sure the E1 is on a 2.4 GHz SSID with decent signal. WiFi drops show up as Frigate
"no frames" warnings.
## Error handling / operations
- **Camera offline:** Frigate retries ffmpeg on its own. An Uptime Kuma monitor on Frigate's
`/api/version` covers the container, and frigate-notify can alert on camera-offline.
- **Recovering from /storage1 unmount:** `storage1-guard.service` already blocks guests
without a real `/storage1`, so snapshots won't land on the empty virtiofs mountpoint.
- **Upgrades:** bump pinned tags manually after reading Frigate's release notes for config
migrations.
## Verification
0. `neolink` logs show a login to `e1` and both streams available.
1. The `frigate` container stays healthy. Its logs show the `e1` and `e1_sub` streams
connected and the OpenVINO detector loaded on CPU.
2. `https://cam.ginnoir.com` redirects to Authentik on the LAN. After login it shows a
smooth live view (MSE).
3. Walking in front of the camera creates a `person` event with a snapshot under
`/storage1/labdata/frigate/clips/`, and an ntfy push with the image arrives.
4. Frigate's system page shows detector inference time and CPU use in a sane range.
5. An Uptime Kuma monitor exists and is green.
6. `scripts/gen-bookmarks.ps1` regenerated, and the Portainer stack registered with empty
UI env vars (`scripts/check-portainer-stack-env.ps1`).
---
## Addendum (2026-10-08): pan/tilt control page
Frigate's PTZ UI needs ONVIF, which the E1 lacks. Neolink exposes PTZ over MQTT, so:
```
browser cam.ginnoir.com/ptz/ (static page, Authentik-gated)
├─ video: go2rtc <video-stream> → wss://cam.ginnoir.com/live/mse/api/ws?src=e1 (Frigate)
└─ MQTT over wss://cam.ginnoir.com/mqtt → mosquitto:8083 (websockets)
│
neolink (now `mqtt-rtsp`) ◄── mosquitto:1883 ────┘ topics neolink/e1/control/ptz[/preset]
```
- **`mosquitto`**
- `eclipse-mosquitto:2.0.22`, pinned, on the `cameras` + `edge` networks.
- `per_listener_settings true`.
- **:1883 (neolink):** password auth, user `neolink`.
- **:8083 (websockets, browser via Caddy):** anonymous, but the ACL restricts anonymous
clients to:
- publish: `neolink/e1/control/ptz`, `neolink/e1/control/ptz/preset`,
`neolink/e1/query/ptz/preset`
- read: `neolink/e1/status`, `neolink/e1/status/ptz`, `neolink/status` (not `status/#`: preview flood)
- **not** `neolink/config`, which echoes the camera password and can rewrite the live
config.
- Authentik forward_auth on the `/mqtt` path is the browser-side gate.
- **neolink**
- Command → `mqtt-rtsp`.
- Preview, motion, and light MQTT features are disabled (preview would push a base64 JPEG
every 2 s).
- **Page**
- `stacks/cameras/ptz/` (`index.html` + vendored `mqtt.min.js` 5.15.2 + go2rtc 1.9.10
`video-rtc.js`/`video-stream.js`). Seeded to `/config/caddy/site/cam-ptz/`, which Caddy
serves as `/srv/cam-ptz`.
- Arrow pad (press-and-hold sends repeated moves), zoom in/out, a speed slider, a preset
list (from `/query/ptz/preset`), and "save current as preset".
- **Caddy** (inside the existing `cam.ginnoir.com` forward_auth route):
- `handle_path /ptz/*` → file_server
- `handle /mqtt` → `reverse_proxy mosquitto:8083`
- everything else → frigate
- **Verify:**
- A `mosquitto_pub` of `left` from inside the network visibly pans the camera.
- The page loads, video plays, and the arrows move the camera.
- An anonymous subscribe to `neolink/config` is denied.