# Frigate NVR — Deployment Plan

Not yet deployed. The HACS `custom_components/frigate` integration is already on the HA instance, but no Frigate server exists to talk to.

## What Frigate brings
- Object detection (person/car/dog/etc.) on camera streams, with far fewer false-positives than the Tapo built-in motion/person detection.
- Timeline of detected events with snapshot + 10s clip per event.
- RTSP relay + re-stream (can replace go2rtc in HA for this camera).
- HA integration exposes: `binary_sensor.<camera>_person_occupancy`, `sensor.<camera>_person_count`, `image.<camera>_person_snapshot`, `camera.<camera>_person` image for the latest detection, and per-zone variants.

## Stack required on concord-nuc

```yaml
# concord_nuc/frigate.yaml (new compose to add)
services:
  frigate-mqtt:
    image: eclipse-mosquitto:2
    container_name: frigate-mqtt
    restart: unless-stopped
    ports:
      - "1883:1883"
    volumes:
      - /home/vish/docker/mosquitto/config:/mosquitto/config
      - /home/vish/docker/mosquitto/data:/mosquitto/data

  frigate:
    image: ghcr.io/blakeblackshear/frigate:stable
    container_name: frigate
    restart: unless-stopped
    privileged: true   # for /dev/dri passthrough if using Intel QuickSync
    shm_size: 512mb
    ports:
      - "5000:5000"     # web UI
      - "8554:8554"     # RTSP relay
      - "8555:8555/tcp"
      - "8555:8555/udp" # WebRTC
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /home/vish/docker/frigate/config:/config
      - /home/vish/docker/frigate/media:/media/frigate
      - type: tmpfs
        target: /tmp/cache
        tmpfs:
          size: 1000000000
    devices:
      - /dev/dri/renderD128  # Intel iGPU (NUC6i3SYB has HD 520)
    depends_on:
      - frigate-mqtt
```

## Frigate config (`/home/vish/docker/frigate/config/config.yml`)

```yaml
mqtt:
  host: frigate-mqtt
  port: 1883

cameras:
  bedroom:
    ffmpeg:
      inputs:
        - path: rtsp://vishinator:<PASSWORD>@192.168.68.67:554/stream1
          roles: [detect, record]
    detect:
      width: 1920
      height: 1080
      fps: 5
    objects:
      track: [person, cat, dog]
    record:
      enabled: true
      retain:
        days: 7
        mode: motion
    snapshots:
      enabled: true
      retain:
        default: 30

# NUC6i3 has no NPU/GPU for ML — use CPU detector
detectors:
  cpu1:
    type: cpu
    num_threads: 3
```

## HA integration wiring

The `custom_components/frigate` integration config entry needs:
- `url`: `http://localhost:5000` (Frigate UI on concord-nuc)
- `password`: (if auth enabled)

Add via **Settings → Devices & Services → Add Integration → Frigate**.

## Dashboard changes (after deployment)

Update `dashboards/cameras.yaml` Bedroom section:
- Replace `camera.vish_bedroom_camera_4k_hd_stream` with `camera.bedroom_frigate` (Frigate's re-stream)
- Add `binary_sensor.bedroom_person_occupancy` to picture-glance entities
- Add a "Recent Events" card: `custom:frigate-card` or a logbook filtered to Frigate sensors

## Storage considerations
- 7-day retention with motion-mode recording on one 1080p/5fps stream ≈ 30-60 GB on the NUC's SSD (currently 73% full at 26 GB free).
- Either allocate a larger disk, **change retain days to 2-3**, or mount `/media/frigate` to an NFS share on Atlantis (has ~TB free).

## Why deferred

1. Takes 1-2h to set up cleanly (MQTT configured, RTSP credentials tested, model tuned).
2. NUC6i3 CPU is weak — detection on a single 1080p@5fps stream will probably max out the CPU. An Intel Coral TPU ($75) would fix this.
3. The existing Tapo built-in motion/person detection already surfaces to HA via `tapo_control`; it's noisy but functional.

Pick this back up when:
- You want real person-detection events + timeline
- OR you add more cameras (Tapo's per-camera detection doesn't scale well)
- OR you buy a Coral TPU
