scene-monitor
scene-monitor — device-scoped reference-region state cap.
scene-monitor — device-scoped reference-region state cap. An operator marks a rect ROI on a camera frame and names one or more states; the engine (pipeline-analytics, designated post-processing node) reports which state is active on an ongoing basis. Two operator-selectable check modes share every- thing except the comparator: similarity (CLIP cosine at the same ROI coords vs condition-tagged references) and llm (vision-LLM judgment over the crop).
That is the wrong shape for the thing: a scene is a standing question about the property ("is the bin still out"), and the operator's question is "which of my scenes have tripped", across every camera at once — not "what does camera 102 think". Buried one camera deep it also could not be found. The surface is now a top-level admin page (/scenes, pages/Scenes.tsx) that lists every scene on every camera and picks the camera inside the create flow, the same shape Events and Faces have.
The consequence to keep in mind: host/scene-monitor-editor is gone from HOST_WIDGETS too. scripts/check-host-widget-resolves.ts asserts BOTH directions, so a registration nobody declares fails exactly as loudly as a declaration nobody registers. The editor is imported directly by the page.
status.kind:'push' — the engine pushes on every hysteresis flip / availability change; consumers never poll.
Extensible condition tag. Seeded 'day' | 'ir' (the two variants the operator captures) plus 'night' | 'dawn' | 'dusk' from the resolver's sun-times band. Open by design so more can be added without a wire break.
Matching does NOT fall back across conditions: cross-condition cosines are not comparable, so "I have never seen this scene in this light" is reported as unknown, never guessed. A day reference scored against an IR frame collapses the cosine and would latch a false alarm every single night.
At a glance
| Capability | scene-monitor |
| Provided by | An addon wraps the device and provides it. It is bound to a device through the device bindings and can be bound automatically to compatible devices. |
| Active providers per device | one |
| Device types | camera |
| Source | packages/types/src/capabilities/scene-monitor.cap.ts |
Methods
| Method | Kind | Required of a provider | Access |
|---|---|---|---|
listScenes | query | yes | default |
listScenesBatch | query | yes | default |
createScene | mutation | yes | admin |
updateScene | mutation | yes | admin |
deleteScene | mutation | yes | admin |
captureReference | mutation | yes | admin |
deleteReference | mutation | yes | admin |
recheckNow | mutation | yes | admin |
resetScene | mutation | yes | admin |
listScenes
query
Input
| Field | Type | Required | Description |
|---|---|---|---|
deviceId | number | yes |
Output
| Field | Type | Required | Description |
|---|---|---|---|
monitors | ({ id: string; label: string; roi: { kind: "rect"; x: number; y: number; width: number; height: number }; enabled: boolean; triggerMode: "periodic" | "on-motion" | "both"; checkIntervalSec?: number; check: { mode: "simil… | yes | |
lastFetchedAt | number | yes |
listScenesBatch
query
The same answer, for a SET of cameras, in one round trip.
/scenes renders every camera and re-reads them on a 30s safety-net poll behind the push slice. Fanned out client-side that was one query per camera — 29 round trips through the browser, the hub and the post-analysis runner every 30 seconds to read an in-memory map the owner had already merged. The work is unchanged (statusFor per device, all in-process at the owner); what collapses is the transport.
A camera that cannot answer still gets a row, with status: null — see { ids: a caller that asked for twenty-nine and got twenty-seven cannot tell which two are missing, or that any are.
Input
| Field | Type | Required | Description |
|---|---|---|---|
deviceIds | number[] | yes |
Output
({ deviceId: number; status: { monitors: SceneMonitorSchema[]; lastFetchedAt: number } | null })[]
createScene
mutation
Input
| Field | Type | Required | Description |
|---|---|---|---|
deviceId | number | yes | |
label | string | yes | |
roi | { kind: "rect"; x: number; y: number; width: number; height: number } | yes | |
check | { mode: "similarity"; threshold: number; hysteresisCount: number } | { mode: "llm"; prompt: string; profileId?: string; hysteresisCount: number } | yes | |
triggerMode | "periodic" | "on-motion" | "both" | no | |
checkIntervalSec | number | no |
Output
| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | |
label | string | yes | |
roi | { kind: "rect"; x: number; y: number; width: number; height: number } | yes | |
enabled | boolean | yes | |
triggerMode | "periodic" | "on-motion" | "both" | yes | |
checkIntervalSec | number | no | |
check | { mode: "similarity"; threshold: number; hysteresisCount: number } | { mode: "llm"; prompt: string; profileId?: string; hysteresisCount: number } | yes | |
states | ({ id: string; label: string; references: ({ embedding: number[]; modelId: string; condition: string; capturedAt: number; thumbnailMediaId?: number; anchorEmbedding?: number[] })[]; textPrompts?: string[]; referenceCount… | yes | |
currentStateId | string | null | yes | |
lastCheckedAt | number | null | yes | |
lastConfidence | number | null | yes | |
currentCondition | string | null | yes | |
availability | "ok" | "unavailable" | yes | |
unavailableReason | string | null | yes | |
baselineStateId | string | null | yes | No mode: 'boolean' | 'states' field: it would be a second source of truth over a distinction the data already makes (states.length === 1). Which state is "the initial screen". null until the first capture. |
emit | "latched" | "live" | no (default "latched") | Which boolean drives notification rules and any export. |
verdict | "matched" | "diverged" | "unknown" | yes | Live: does the region match the baseline RIGHT NOW. |
latched | boolean | yes | Has it been diverged at least once since armedAt — the operator's boolean. |
armedAt | number | yes | Last reset (or creation). |
divergedAt | number | null | yes | |
restoredAt | number | null | yes | |
quietSeconds | number | no (default 60) | A check is only COUNTED when the device has been quiet this long. Motion during the window DISCARDS the observation — a car pulling up in front of the bin must not be able to spend hysteresis credit. |
minObservationSpacingSec | number | no (default 120) | |
confirm | { enabled?: boolean; prompt: string; profileId?: string; timeoutMs?: number; maxImagePx?: number; onTimeout?: "flip" | "hold" } | no | Vision-model adjudication of a candidate flip. Similarity primary only. |
anchorThreshold | number | no (default 0.85) | Whole-frame anchor cosine below which a flip is REFUSED as view-shifted. |
autoRestore | boolean | no (default false) | Clear the latch on its own when the scene matches again? Default false — restoredAt and the scene-restored edge are recorded regardless, so an automation can react to the bin coming back without the operator's own alarm silently clearing itself. |
onUncoveredCondition | "skip" | "judge-anyway" | no (default "skip") | What to do when the current light has no reference of its own. See { |
suspendedCondition | string | null | no (default null) | The light whose checks are currently being SAT OUT under onUncoveredCondition: 'skip' — null when the scene is checking normally. Engine-reported and advisory only: it moves no verdict, no latch and no hysteresis. It exists so the card can say "night (IR) — checks paused, nothing captured in this light" in the same calm voice as the coverage line, because the alternative is a scene that silently stops answering after sunset with nothing anywhere saying why. A skipped check must never read as a broken one. |
unavailable | "no-reference-for-condition" | "view-shifted" | "no-vision-profile" | "encoder-model-changed" | "no-snapshot" | null | yes | Named cause when verdict === 'unknown'. |
coveredConditions | string[] | yes | Conditions that have at least one comparable reference — the coverage line ("day ✓ · ir ✓ · dusk ✗") that turns a silent fallback into a visible fact. |
updateScene
mutation
Input
| Field | Type | Required | Description |
|---|---|---|---|
deviceId | number | yes | |
monitorId | string | yes | |
patch | { label?: string; roi?: { kind: "rect"; x: number; y: number; width: number; height: number }; enabled?: boolean; triggerMode?: "periodic" | "on-motion" | "both"; checkIntervalSec?: number; check?: { mode: "similarity"; … | yes |
Output
Nothing.
deleteScene
mutation
Input
| Field | Type | Required | Description |
|---|---|---|---|
deviceId | number | yes | |
monitorId | string | yes |
Output
Nothing.
captureReference
mutation
Input
| Field | Type | Required | Description |
|---|---|---|---|
deviceId | number | yes | |
monitorId | string | yes | |
stateId | string | no | |
label | string | no | |
condition | string | no |
Output
| Field | Type | Required | Description |
|---|---|---|---|
stateId | string | yes | |
referenceCount | number | yes |
deleteReference
mutation
Input
| Field | Type | Required | Description |
|---|---|---|---|
deviceId | number | yes | |
monitorId | string | yes | |
stateId | string | yes | |
index | number | yes |
Output
Nothing.
recheckNow
mutation
Input
| Field | Type | Required | Description |
|---|---|---|---|
deviceId | number | yes | |
monitorId | string | yes |
Output
Nothing.
Actions (offered in automations and on device cards)
| Action | Label | Sets |
|---|---|---|
sceneMonitor.recheck | Re-check a scene |
resetScene
mutation
Clear the latch, re-arm, and — by default — RE-CAPTURE the baseline for the CURRENT condition. The bin never goes back in exactly the same spot; "reset" in the operator's head means this is the new normal, and re-capture is what makes the feature self-healing against slow drift instead of failing silently weeks later.
Reachable from three surfaces on this one mutation: the scene card, a notification button (an onTrigger sequence with a kind:'command' step — no new Notification-Center code at all), and tRPC for scripts.
Input
| Field | Type | Required | Description |
|---|---|---|---|
deviceId | number | yes | |
monitorId | string | yes | |
recapture | boolean | no | Defaults to TRUE at the provider seam — see SCENE_RESET_RECAPTURES. |
Output
Nothing.
Runtime state
The state Dominevo keeps for each device with this capability, readable without calling the provider.
| Field | Type | Required | Description |
|---|---|---|---|
monitors | ({ id: string; label: string; roi: { kind: "rect"; x: number; y: number; width: number; height: number }; enabled: boolean; triggerMode: "periodic" | "on-motion" | "both"; checkIntervalSec?: number; check: { mode: "simil… | yes | |
lastFetchedAt | number | yes |