Skip to content

Navigation Menu

Sign in
Sign up

Enhancement: Per-camera motion sensitivity profiles (Day/Night/Storm) via MQTT #20

Open

Description

Summary

Let dealers assign up to three motion-sensitivity profiles per camera — Day, Night, Storm — and have the driver switch between them in real time by publishing to Frigate's runtime MQTT topics. No Frigate restart, no config file edits.

Motivation

Tuning motion sensitivity for Frigate is a one-knob-fits-all-conditions problem today:

  • Rain: outdoor cameras at default threshold 30 latched ON for 20+ hours during a storm. Raising to 40 (still dry) would reduce real-world sensitivity.
  • Night: IR noise and fluctuating exposure make nighttime scenes noisier than daytime — same camera needs different tuning.
  • Daytime placid: low threshold is fine and catches subtle motion you want.

Related real-world incident: #18 (storm day, 10 cameras stuck ON). The fix — raising threshold 30→40 and masking the OSD — worked, but it's now tuned for the worst case. A profile switcher would let us keep daytime sensitivity while bumping threshold when a weather entity reports rain or after sunset.

Why the driver should own this (and not Frigate)

Frigate maintainers explicitly punt this to external automation:

"Frigate doesn't implement this directly — HA, Node-RED, and other popular automation platforms can do this very well already."@hawkeye217, Discussion #18653

Related closed/declined upstream requests:

Community demand is clearly there:

Control4 dealers don't want to write HA automations. This is a natural feature for the driver to own.

Runtime MQTT topics we'll use (Frigate 0.14+)

Confirmed in Frigate MQTT docs:

Topic Payload
`frigate//motion_threshold/set` int 1–255
`frigate//motion_contour_area/set` int (pixels)
`frigate//improve_contrast/set` `ON` / `OFF`
`frigate//motion/set` `ON` / `OFF` (rarely used, listed for completeness)

Each has a matching `/state` topic. Applied instantly, no restart.

Proposed driver design

Per-camera driver properties (Camera driver)

  • Sensitivity Profiles Enabled (bool, default off) — master per-camera toggle.
  • Day Threshold (int, default 30), Day Contour Area (int, default 10), Day Improve Contrast (bool, default on).
  • Night Threshold (int, default 40), Night Contour Area (int), Night Improve Contrast (bool, default on).
  • Storm Threshold (int, default 50), Storm Contour Area (int), Storm Improve Contrast (bool).
  • Current Profile (read-only, shows `Day` | `Night` | `Storm` | `Custom`) — `Custom` when someone has set threshold via the Frigate UI Motion Tuner and values no longer match any profile.

NVR driver properties (global)

  • Profile Switching Source — `External (Composer Programming)` | `Sunrise/Sunset` | `Sunrise/Sunset + Weather Variable`.
  • Weather Storm Variable — name of a C4 boolean variable the dealer maintains (from a weather driver, HA sensor relay, etc.); when true → Storm profile on all cameras with profiles enabled.

Actions (per camera)

  • Set Day Profile, Set Night Profile, Set Storm Profile — Composer-usable actions that apply that profile to this camera.
  • Set All Day / Night / Storm on NVR driver — applies to every camera with profiles enabled.

Programming commands (Composer events in)

  • `SET_MOTION_PROFILE` with profile name — lets the dealer wire to their own logic (lighting scenes, alarm arming, etc.).

Driver behavior

  1. On profile switch, publish all three topics (`motion_threshold/set`, `motion_contour_area/set`, `improve_contrast/set`) for the camera.
  2. Subscribe to the matching `/state` topics — update the Current Profile read-only property based on what Frigate confirms.
  3. On driver reconnect or Frigate restart (detected via `frigate/available` going `offline` → `online`), re-publish the current profile — Frigate's UI Motion Tuner or a restart can overwrite runtime values, so we assert ours on reconnect.
  4. Surface a Current Profile = Custom state cleanly when Frigate's UI tuner has overridden the values; don't fight the dealer-at-the-console.

Known gotcha to document

Per community reports, the Frigate UI's Motion Tuner overwrites MQTT-set values while open. Driver docs should note: close the Motion Tuner before enabling profile switching, and understand that profile switching will snap values back on reconnect or next profile change.

Non-goals

  • No built-in weather fetching — driver consumes a C4 variable or HA-relayed entity. Keeps the driver stateless w.r.t. weather APIs.
  • No automatic threshold tuning based on measured noise — that's a much harder feature. This is explicit profiles only.
  • No profile editor UI beyond Composer properties. Future enhancement candidate.

Relation to other enhancements

  • Pairs well with Enhancement: GitHub-based automatic driver updates #19 (auto-updates) — profile-switching users get improvements automatically.
  • Pairs well with the "motion-stuck watchdog" idea — if profile-switching fails to reach Frigate, the watchdog still synthesizes OFF to keep Last Motion moving.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      AltStyle によって変換されたページ (->オリジナル) /