Import UniFi Protect live views + optional auto-resync

views ls/dump/import copy a Protect live view (cameras + grid) into a
layout; grid inferred from slot count (asymmetric presets TBD, see
views dump). Imported layouts link back via protect_view.

Daemon re-syncs the active linked view every view_refresh_seconds (0=
off), so Protect-side edits appear on the wall. Needs the controller
password at runtime; off by default keeps the wall credential-free.

Shared viewmap package used by CLI and daemon.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Levi Woodard
2026-07-02 07:13:51 -05:00
parent 9da5ace150
commit 291d37ec83
8 changed files with 420 additions and 3 deletions

View File

@@ -146,6 +146,36 @@ rtsp-streamer layout set quad # switch live (persists the choice)
rtsp-streamer version # baked-in git commit / build date
```
## UniFi Protect live views
Copy a saved Protect "Live View" (its cameras and grid) straight into a layout:
```sh
rtsp-streamer views ls # list the controller's live views
rtsp-streamer views import "All Cameras" # import one as a layout
rtsp-streamer views import --all # import every view
rtsp-streamer views dump # raw view JSON (for tuning odd layouts)
```
Cameras are matched by Protect id, so run `discover` first. Grid size is
inferred from the slot count (asymmetric "1 big + N" presets land as an even
grid for now — send me `views dump` output to map exact sizing). An imported
layout is **linked** to its view (`protect_view:` in the config).
### Auto-resync
Set `view_refresh_seconds` (e.g. `300`) and the daemon re-pulls the active
layout's linked view on that interval — edits you make in Protect (add/remove a
camera, reorder) show up on the wall automatically. This is the **one** feature
that needs controller credentials **at runtime**, so export the password for the
daemon (in the kiosk user's `~/.bash_profile`, before the sway launcher):
```sh
# ~/.bash_profile
export RTSP_STREAMER_PASSWORD='…'
```
Leave `view_refresh_seconds` at 0 (default) and the wall stays credential-free.
## Deploy to a Pi (boot straight to the wall)
First-time setup (run `install.sh` **as the user you'll run the wall as** — pass
@@ -255,9 +285,11 @@ pegged, work through:
## Roadmap
- **Import views from the UniFi Protect UI** — read Protect's pre-made
multi-camera views/layouts and copy them into rtsp-streamer layouts, so you
don't rebuild an arrangement you already made in Protect.
- **Exact sizing for asymmetric Protect views** — `views import` reproduces the
cameras and an even grid today; mapping Protect's `layout` preset id to
spanning tiles (1-big-plus-N, etc.) is the next refinement.
- Slot cycling — Protect slots can rotate through multiple cameras; we take the
first. Honor `cycleMode`/`cycleInterval`.
- Layout rotation / cycling on a timer (the daemon already re-tiles on demand).
- TUI create / delete / rename layouts (today the TUI only *edits* existing
ones; new layouts are added in YAML).