@camstack/addon-provider-unifi 0.2.96 → 0.2.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addon.js +182 -24
- package/dist/addon.mjs +182 -24
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -7303,6 +7303,23 @@ function errMsg(err) {
|
|
|
7303
7303
|
if (typeof err === "string") return err;
|
|
7304
7304
|
return String(err);
|
|
7305
7305
|
}
|
|
7306
|
+
new Set([
|
|
7307
|
+
"track",
|
|
7308
|
+
"summary",
|
|
7309
|
+
"face",
|
|
7310
|
+
"identity",
|
|
7311
|
+
"plate",
|
|
7312
|
+
"vehicle",
|
|
7313
|
+
"scene",
|
|
7314
|
+
"motion",
|
|
7315
|
+
"object",
|
|
7316
|
+
"audio"
|
|
7317
|
+
]);
|
|
7318
|
+
new Set([
|
|
7319
|
+
"motion",
|
|
7320
|
+
"object",
|
|
7321
|
+
"audio"
|
|
7322
|
+
]);
|
|
7306
7323
|
var EncodeProfileSchema = object({
|
|
7307
7324
|
video: object({
|
|
7308
7325
|
codec: _enum([
|
|
@@ -12503,8 +12520,17 @@ method(object({
|
|
|
12503
12520
|
}), array(SettingsRecordSchema).readonly()), method(object({
|
|
12504
12521
|
namespace: string().optional(),
|
|
12505
12522
|
collection: string(),
|
|
12506
|
-
record:
|
|
12507
|
-
|
|
12523
|
+
record: object({
|
|
12524
|
+
id: string().optional(),
|
|
12525
|
+
data: record(string(), unknown())
|
|
12526
|
+
})
|
|
12527
|
+
}), object({
|
|
12528
|
+
/**
|
|
12529
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12530
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12531
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12532
|
+
*/
|
|
12533
|
+
id: union([string(), number()]) }), { kind: "mutation" }), method(object({
|
|
12508
12534
|
namespace: string().optional(),
|
|
12509
12535
|
collection: string(),
|
|
12510
12536
|
records: array(BulkRecordSchema).readonly()
|
|
@@ -12613,8 +12639,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
|
|
|
12613
12639
|
}), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
|
|
12614
12640
|
namespace: string().optional(),
|
|
12615
12641
|
collection: string(),
|
|
12616
|
-
record:
|
|
12617
|
-
|
|
12642
|
+
record: object({
|
|
12643
|
+
id: string().optional(),
|
|
12644
|
+
data: record(string(), unknown())
|
|
12645
|
+
})
|
|
12646
|
+
}), object({
|
|
12647
|
+
/**
|
|
12648
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12649
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12650
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12651
|
+
*/
|
|
12652
|
+
id: union([string(), number()]) }), {
|
|
12618
12653
|
kind: "mutation",
|
|
12619
12654
|
auth: "admin"
|
|
12620
12655
|
}), method(object({
|
|
@@ -19522,7 +19557,20 @@ var TrackSchema = object({
|
|
|
19522
19557
|
...TrackRetrainFields
|
|
19523
19558
|
});
|
|
19524
19559
|
var BaseEventFields = {
|
|
19525
|
-
|
|
19560
|
+
/**
|
|
19561
|
+
* A SQLite ROWID, assigned by the database (D474).
|
|
19562
|
+
*
|
|
19563
|
+
* Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
|
|
19564
|
+
* TWICE per row, in the row and in the primary-key index, across 2.1 million
|
|
19565
|
+
* motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
|
|
19566
|
+
* the rowid: the table itself is that B-tree, so the index stops existing
|
|
19567
|
+
* rather than getting smaller. No shorter string does that.
|
|
19568
|
+
*
|
|
19569
|
+
* Defined once here for all three event kinds, which is why they move
|
|
19570
|
+
* together: a per-table migration would have forked this and
|
|
19571
|
+
* `COMMON_BASE_COLUMNS` and reunited them two stages later.
|
|
19572
|
+
*/
|
|
19573
|
+
id: number().int(),
|
|
19526
19574
|
deviceId: number(),
|
|
19527
19575
|
timestamp: number()
|
|
19528
19576
|
};
|
|
@@ -19541,7 +19589,34 @@ var MotionEventSchema = object({
|
|
|
19541
19589
|
/** Omitted in slim projection. */
|
|
19542
19590
|
frameHeight: number().optional(),
|
|
19543
19591
|
/** Populated by B5 (recording playback URL for this event). */
|
|
19544
|
-
mediaUrl: string().optional()
|
|
19592
|
+
mediaUrl: string().optional(),
|
|
19593
|
+
/**
|
|
19594
|
+
* One row per motion EPISODE, not one per push (D475). `null` while the
|
|
19595
|
+
* episode is still open — a further rising edge extends it in place rather
|
|
19596
|
+
* than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
|
|
19597
|
+
* (the span from the first rising edge to the LAST one, deliberately NOT
|
|
19598
|
+
* `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
|
|
19599
|
+
* movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
|
|
19600
|
+
* motion for an instantaneous trigger).
|
|
19601
|
+
*
|
|
19602
|
+
* **Absent** (not merely `null`) on a row written before D475 — that means
|
|
19603
|
+
* "closed the old way, before this column existed", never "still open".
|
|
19604
|
+
* Nothing in this codebase may read an absent `durationMs` as an open
|
|
19605
|
+
* episode; only `null` means open.
|
|
19606
|
+
*/
|
|
19607
|
+
durationMs: number().nullable().optional(),
|
|
19608
|
+
/**
|
|
19609
|
+
* Ms offsets from `timestamp` (the episode's own first rising edge, so the
|
|
19610
|
+
* first entry is always `0`) of every genuine off→on transition the
|
|
19611
|
+
* episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
|
|
19612
|
+
* push: a firmware source that keepalives at ~1 Hz for the whole burst
|
|
19613
|
+
* (Reolink, Hikvision) produces exactly one edge; a source that reports an
|
|
19614
|
+
* explicit `false` mid-episode and then resumes before the quiet window
|
|
19615
|
+
* elapses produces another. Stored compactly — see `motion-edge-codec.ts`
|
|
19616
|
+
* — and decoded back to this shape on read. Absent/empty on a legacy row,
|
|
19617
|
+
* which must never be read as "no episode happened here".
|
|
19618
|
+
*/
|
|
19619
|
+
edges: array(number()).readonly().optional()
|
|
19545
19620
|
});
|
|
19546
19621
|
/**
|
|
19547
19622
|
* Which detection SOURCE produced an object event. `pipeline` = the ML
|
|
@@ -19596,6 +19671,23 @@ var ObjectEventSchema = object({
|
|
|
19596
19671
|
* includes it (it is light). Absent on rows written before this field.
|
|
19597
19672
|
*/
|
|
19598
19673
|
frameId: string().optional(),
|
|
19674
|
+
/**
|
|
19675
|
+
* A PRODUCER-chosen key that makes a synthetic event's emission idempotent
|
|
19676
|
+
* (D474).
|
|
19677
|
+
*
|
|
19678
|
+
* Only the package detector writes it, and it exists because the event id
|
|
19679
|
+
* stopped being choosable: the delivery and pick-up rows used to BE their
|
|
19680
|
+
* dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
|
|
19681
|
+
* second delivery for this entry" survived a restart. An `INTEGER` rowid is
|
|
19682
|
+
* assigned by SQLite, so that key had to move off the primary key rather
|
|
19683
|
+
* than be dropped — a detector that cannot recognise its own row re-delivers
|
|
19684
|
+
* every parcel on every boot.
|
|
19685
|
+
*
|
|
19686
|
+
* Absent on every other object event, and on every row written before this
|
|
19687
|
+
* field. Never a substitute for `id`: it is unique per (producer, occasion),
|
|
19688
|
+
* not per row, and nothing addresses a row by it.
|
|
19689
|
+
*/
|
|
19690
|
+
idempotencyKey: string().optional(),
|
|
19599
19691
|
/** Omitted in slim projection. */
|
|
19600
19692
|
trackId: string().optional(),
|
|
19601
19693
|
className: string(),
|
|
@@ -20698,6 +20790,14 @@ var NativeCropResultSchema = object({
|
|
|
20698
20790
|
* set `encodeJpeg: true`; `bytes` is then absent.
|
|
20699
20791
|
*/
|
|
20700
20792
|
jpeg: string().optional(),
|
|
20793
|
+
/**
|
|
20794
|
+
* The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
|
|
20795
|
+
* `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
|
|
20796
|
+
* `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
|
|
20797
|
+
* `bytes` above has crossed this boundary as a `Uint8Array` all along — so
|
|
20798
|
+
* base64 was buying nothing but a multi-megabyte string in the relay's heap.
|
|
20799
|
+
*/
|
|
20800
|
+
jpegBytes: _instanceof(Uint8Array).optional(),
|
|
20701
20801
|
width: number().int().positive(),
|
|
20702
20802
|
height: number().int().positive(),
|
|
20703
20803
|
/**
|
|
@@ -20764,7 +20864,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
|
|
|
20764
20864
|
})]);
|
|
20765
20865
|
/** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
|
|
20766
20866
|
var ParkedTrackFrameSchema = object({
|
|
20767
|
-
|
|
20867
|
+
/**
|
|
20868
|
+
* Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
|
|
20869
|
+
* `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
|
|
20870
|
+
* Exactly one of the two is present.
|
|
20871
|
+
*/
|
|
20872
|
+
jpeg: string().optional(),
|
|
20873
|
+
/** The same JPEG as bytes, for a caller that declared it reads them (D462). */
|
|
20874
|
+
jpegBytes: _instanceof(Uint8Array).optional(),
|
|
20768
20875
|
width: number().int().positive(),
|
|
20769
20876
|
height: number().int().positive(),
|
|
20770
20877
|
/** The frame instant the parcel shows (the caller's clock, echoed back). */
|
|
@@ -21351,6 +21458,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
|
|
|
21351
21458
|
bbox: NativeCropBboxSchema,
|
|
21352
21459
|
maxWidth: number().int().positive().optional(),
|
|
21353
21460
|
/**
|
|
21461
|
+
* The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
|
|
21462
|
+
* back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
|
|
21463
|
+
* wire — never assume consent: a pre-D462 caller parses the field as
|
|
21464
|
+
* base64 and bytes would decode to garbage rather than fail.
|
|
21465
|
+
*/
|
|
21466
|
+
acceptJpegBytes: boolean().optional(),
|
|
21467
|
+
/**
|
|
21354
21468
|
* When `true`, the runner encodes the resolved crop to JPEG ON THE
|
|
21355
21469
|
* OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
|
|
21356
21470
|
* Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
|
|
@@ -21418,7 +21532,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
|
|
|
21418
21532
|
}), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
|
|
21419
21533
|
deviceId: number(),
|
|
21420
21534
|
trackId: string(),
|
|
21421
|
-
kind: ParkedFrameKindSchema
|
|
21535
|
+
kind: ParkedFrameKindSchema,
|
|
21536
|
+
/**
|
|
21537
|
+
* The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
|
|
21538
|
+
* back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
|
|
21539
|
+
* wire — never assume consent: a pre-D462 caller parses the field as
|
|
21540
|
+
* base64 and bytes would decode to garbage rather than fail.
|
|
21541
|
+
*/
|
|
21542
|
+
acceptJpegBytes: boolean().optional()
|
|
21422
21543
|
}), ParkedTrackFrameSchema.nullable()), method(object({
|
|
21423
21544
|
deviceId: number(),
|
|
21424
21545
|
trackId: string()
|
|
@@ -27833,26 +27954,59 @@ authKey: string().optional() }), object({
|
|
|
27833
27954
|
/** Human-readable error when `ok: false`. */
|
|
27834
27955
|
error: string().optional()
|
|
27835
27956
|
}), { kind: "mutation" });
|
|
27836
|
-
/**
|
|
27837
|
-
* Hardware / firmware motion sensor cap — binary detected state plus
|
|
27838
|
-
* a timestamp of the last observation. Distinct from
|
|
27839
|
-
* `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
|
|
27840
|
-
* `motion` is the lightweight readout from on-camera motion (Reolink
|
|
27841
|
-
* `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
|
|
27842
|
-
*
|
|
27843
|
-
* Native-motion providers also fan out to `detection.camera-native`
|
|
27844
|
-
* with `source: 'onboard'` so cross-cutting system services
|
|
27845
|
-
* (alert-center, advanced-notifier) can subscribe once and receive
|
|
27846
|
-
* motion from every camera.
|
|
27847
|
-
*/
|
|
27848
27957
|
var MotionStatusSchema = object({
|
|
27849
27958
|
detected: boolean(),
|
|
27850
27959
|
/** Ms epoch of the last detected-true observation. Null if never detected. */
|
|
27851
27960
|
lastDetectedAt: number().nullable(),
|
|
27852
27961
|
/**
|
|
27853
|
-
*
|
|
27854
|
-
*
|
|
27855
|
-
*
|
|
27962
|
+
* `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
|
|
27963
|
+
* `null` while false and on every `Sensor` device (D475) — see that
|
|
27964
|
+
* constant's doc for the one-authority rule.
|
|
27965
|
+
*
|
|
27966
|
+
* ## Reading this field still arms nothing
|
|
27967
|
+
*
|
|
27968
|
+
* It reads like an instruction to the consumer ("revert after N ms if
|
|
27969
|
+
* no fresh push arrives") and it is not one: nothing in this repo reads
|
|
27970
|
+
* the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
|
|
27971
|
+
* close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
|
|
27972
|
+
* imported constant, not as a read of `device.state.motion.value`, so this
|
|
27973
|
+
* field stays what it always was: DESCRIPTIVE output, mirroring an answer
|
|
27974
|
+
* computed elsewhere. Building a self-clear timer out of a READ of this
|
|
27975
|
+
* field would add a second falling-edge authority beside whichever one
|
|
27976
|
+
* already owns the device, and two that can disagree are worse than one.
|
|
27977
|
+
* Consumers that need a falling edge SHAPED differently — held open across
|
|
27978
|
+
* a flapping source — debounce on their own side and say so, as
|
|
27979
|
+
* `addon-export-alexa/src/motion-clear-hold.ts` and
|
|
27980
|
+
* `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
|
|
27981
|
+
*
|
|
27982
|
+
* ## Who writes it
|
|
27983
|
+
*
|
|
27984
|
+
* - **Cameras** — the runner's phase machine, `active → watching` on
|
|
27985
|
+
* `cooldown_expired`, which then writes this slice with
|
|
27986
|
+
* `detected: false` (`handlePhaseChanged` in
|
|
27987
|
+
* `pipeline-runner/index.ts`). It produces the FALLING edge, which
|
|
27988
|
+
* matters most for the sources that only ever push a rising one:
|
|
27989
|
+
* Reolink emits `MotionOnMotionChanged { detected: true }` and never
|
|
27990
|
+
* a false.
|
|
27991
|
+
* - **Sensors** (Home Assistant binary sensors, Homematic) — the
|
|
27992
|
+
* provider pushes the false itself, from the upstream system's own
|
|
27993
|
+
* state change. No phase machine is involved.
|
|
27994
|
+
*
|
|
27995
|
+
* ### The phase machine is CANONICAL, not sole — and that is a defect
|
|
27996
|
+
*
|
|
27997
|
+
* An earlier revision of this docblock (mine, 2026-09-12) claimed the
|
|
27998
|
+
* phase machine is the sole writer for a camera. It is not.
|
|
27999
|
+
* `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
|
|
28000
|
+
* `setCapSlice(motionCapability, …)` on their own rising edge, and
|
|
28001
|
+
* Hikvision's comment says why: it read THIS docblock, agreed the
|
|
28002
|
+
* runner is canonical, and wrote anyway to avoid per-tick churn. So
|
|
28003
|
+
* two authorities can disagree about one slice, which this repo
|
|
28004
|
+
* forbids, and the doc said otherwise — which is worse than saying
|
|
28005
|
+
* nothing, because it reads as verification.
|
|
28006
|
+
*
|
|
28007
|
+
* This predates D475 and is not fixed there: the fix touches every
|
|
28008
|
+
* camera provider. Recorded in D475's Consequences. Do not restore the
|
|
28009
|
+
* "sole writer" wording without also removing the other writers.
|
|
27856
28010
|
*/
|
|
27857
28011
|
autoClearAfterMs: number().nullable()
|
|
27858
28012
|
});
|
|
@@ -27922,7 +28076,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
|
|
|
27922
28076
|
*/
|
|
27923
28077
|
runtimeState: MotionStatusSchema,
|
|
27924
28078
|
/**
|
|
27925
|
-
* Runtime-state durability: **session** —
|
|
28079
|
+
* Runtime-state durability: **session** — every writer of this slice
|
|
28080
|
+
* writes only on an EDGE, so a restored `detected: true` would stay
|
|
28081
|
+
* frozen until the next one instead of being corrected. The next edge
|
|
28082
|
+
* re-publishes the real state. (On who the writers are, and why there
|
|
28083
|
+
* is more than one, see `autoClearAfterMs` above.)
|
|
27926
28084
|
*
|
|
27927
28085
|
* See `RuntimeStateDurability`. Enforced by
|
|
27928
28086
|
* `scripts/check-runtime-state-durability.ts`.
|
package/dist/addon.mjs
CHANGED
|
@@ -7302,6 +7302,23 @@ function errMsg(err) {
|
|
|
7302
7302
|
if (typeof err === "string") return err;
|
|
7303
7303
|
return String(err);
|
|
7304
7304
|
}
|
|
7305
|
+
new Set([
|
|
7306
|
+
"track",
|
|
7307
|
+
"summary",
|
|
7308
|
+
"face",
|
|
7309
|
+
"identity",
|
|
7310
|
+
"plate",
|
|
7311
|
+
"vehicle",
|
|
7312
|
+
"scene",
|
|
7313
|
+
"motion",
|
|
7314
|
+
"object",
|
|
7315
|
+
"audio"
|
|
7316
|
+
]);
|
|
7317
|
+
new Set([
|
|
7318
|
+
"motion",
|
|
7319
|
+
"object",
|
|
7320
|
+
"audio"
|
|
7321
|
+
]);
|
|
7305
7322
|
var EncodeProfileSchema = object({
|
|
7306
7323
|
video: object({
|
|
7307
7324
|
codec: _enum([
|
|
@@ -12502,8 +12519,17 @@ method(object({
|
|
|
12502
12519
|
}), array(SettingsRecordSchema).readonly()), method(object({
|
|
12503
12520
|
namespace: string().optional(),
|
|
12504
12521
|
collection: string(),
|
|
12505
|
-
record:
|
|
12506
|
-
|
|
12522
|
+
record: object({
|
|
12523
|
+
id: string().optional(),
|
|
12524
|
+
data: record(string(), unknown())
|
|
12525
|
+
})
|
|
12526
|
+
}), object({
|
|
12527
|
+
/**
|
|
12528
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12529
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12530
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12531
|
+
*/
|
|
12532
|
+
id: union([string(), number()]) }), { kind: "mutation" }), method(object({
|
|
12507
12533
|
namespace: string().optional(),
|
|
12508
12534
|
collection: string(),
|
|
12509
12535
|
records: array(BulkRecordSchema).readonly()
|
|
@@ -12612,8 +12638,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
|
|
|
12612
12638
|
}), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
|
|
12613
12639
|
namespace: string().optional(),
|
|
12614
12640
|
collection: string(),
|
|
12615
|
-
record:
|
|
12616
|
-
|
|
12641
|
+
record: object({
|
|
12642
|
+
id: string().optional(),
|
|
12643
|
+
data: record(string(), unknown())
|
|
12644
|
+
})
|
|
12645
|
+
}), object({
|
|
12646
|
+
/**
|
|
12647
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12648
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12649
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12650
|
+
*/
|
|
12651
|
+
id: union([string(), number()]) }), {
|
|
12617
12652
|
kind: "mutation",
|
|
12618
12653
|
auth: "admin"
|
|
12619
12654
|
}), method(object({
|
|
@@ -19521,7 +19556,20 @@ var TrackSchema = object({
|
|
|
19521
19556
|
...TrackRetrainFields
|
|
19522
19557
|
});
|
|
19523
19558
|
var BaseEventFields = {
|
|
19524
|
-
|
|
19559
|
+
/**
|
|
19560
|
+
* A SQLite ROWID, assigned by the database (D474).
|
|
19561
|
+
*
|
|
19562
|
+
* Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
|
|
19563
|
+
* TWICE per row, in the row and in the primary-key index, across 2.1 million
|
|
19564
|
+
* motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
|
|
19565
|
+
* the rowid: the table itself is that B-tree, so the index stops existing
|
|
19566
|
+
* rather than getting smaller. No shorter string does that.
|
|
19567
|
+
*
|
|
19568
|
+
* Defined once here for all three event kinds, which is why they move
|
|
19569
|
+
* together: a per-table migration would have forked this and
|
|
19570
|
+
* `COMMON_BASE_COLUMNS` and reunited them two stages later.
|
|
19571
|
+
*/
|
|
19572
|
+
id: number().int(),
|
|
19525
19573
|
deviceId: number(),
|
|
19526
19574
|
timestamp: number()
|
|
19527
19575
|
};
|
|
@@ -19540,7 +19588,34 @@ var MotionEventSchema = object({
|
|
|
19540
19588
|
/** Omitted in slim projection. */
|
|
19541
19589
|
frameHeight: number().optional(),
|
|
19542
19590
|
/** Populated by B5 (recording playback URL for this event). */
|
|
19543
|
-
mediaUrl: string().optional()
|
|
19591
|
+
mediaUrl: string().optional(),
|
|
19592
|
+
/**
|
|
19593
|
+
* One row per motion EPISODE, not one per push (D475). `null` while the
|
|
19594
|
+
* episode is still open — a further rising edge extends it in place rather
|
|
19595
|
+
* than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
|
|
19596
|
+
* (the span from the first rising edge to the LAST one, deliberately NOT
|
|
19597
|
+
* `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
|
|
19598
|
+
* movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
|
|
19599
|
+
* motion for an instantaneous trigger).
|
|
19600
|
+
*
|
|
19601
|
+
* **Absent** (not merely `null`) on a row written before D475 — that means
|
|
19602
|
+
* "closed the old way, before this column existed", never "still open".
|
|
19603
|
+
* Nothing in this codebase may read an absent `durationMs` as an open
|
|
19604
|
+
* episode; only `null` means open.
|
|
19605
|
+
*/
|
|
19606
|
+
durationMs: number().nullable().optional(),
|
|
19607
|
+
/**
|
|
19608
|
+
* Ms offsets from `timestamp` (the episode's own first rising edge, so the
|
|
19609
|
+
* first entry is always `0`) of every genuine off→on transition the
|
|
19610
|
+
* episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
|
|
19611
|
+
* push: a firmware source that keepalives at ~1 Hz for the whole burst
|
|
19612
|
+
* (Reolink, Hikvision) produces exactly one edge; a source that reports an
|
|
19613
|
+
* explicit `false` mid-episode and then resumes before the quiet window
|
|
19614
|
+
* elapses produces another. Stored compactly — see `motion-edge-codec.ts`
|
|
19615
|
+
* — and decoded back to this shape on read. Absent/empty on a legacy row,
|
|
19616
|
+
* which must never be read as "no episode happened here".
|
|
19617
|
+
*/
|
|
19618
|
+
edges: array(number()).readonly().optional()
|
|
19544
19619
|
});
|
|
19545
19620
|
/**
|
|
19546
19621
|
* Which detection SOURCE produced an object event. `pipeline` = the ML
|
|
@@ -19595,6 +19670,23 @@ var ObjectEventSchema = object({
|
|
|
19595
19670
|
* includes it (it is light). Absent on rows written before this field.
|
|
19596
19671
|
*/
|
|
19597
19672
|
frameId: string().optional(),
|
|
19673
|
+
/**
|
|
19674
|
+
* A PRODUCER-chosen key that makes a synthetic event's emission idempotent
|
|
19675
|
+
* (D474).
|
|
19676
|
+
*
|
|
19677
|
+
* Only the package detector writes it, and it exists because the event id
|
|
19678
|
+
* stopped being choosable: the delivery and pick-up rows used to BE their
|
|
19679
|
+
* dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
|
|
19680
|
+
* second delivery for this entry" survived a restart. An `INTEGER` rowid is
|
|
19681
|
+
* assigned by SQLite, so that key had to move off the primary key rather
|
|
19682
|
+
* than be dropped — a detector that cannot recognise its own row re-delivers
|
|
19683
|
+
* every parcel on every boot.
|
|
19684
|
+
*
|
|
19685
|
+
* Absent on every other object event, and on every row written before this
|
|
19686
|
+
* field. Never a substitute for `id`: it is unique per (producer, occasion),
|
|
19687
|
+
* not per row, and nothing addresses a row by it.
|
|
19688
|
+
*/
|
|
19689
|
+
idempotencyKey: string().optional(),
|
|
19598
19690
|
/** Omitted in slim projection. */
|
|
19599
19691
|
trackId: string().optional(),
|
|
19600
19692
|
className: string(),
|
|
@@ -20697,6 +20789,14 @@ var NativeCropResultSchema = object({
|
|
|
20697
20789
|
* set `encodeJpeg: true`; `bytes` is then absent.
|
|
20698
20790
|
*/
|
|
20699
20791
|
jpeg: string().optional(),
|
|
20792
|
+
/**
|
|
20793
|
+
* The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
|
|
20794
|
+
* `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
|
|
20795
|
+
* `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
|
|
20796
|
+
* `bytes` above has crossed this boundary as a `Uint8Array` all along — so
|
|
20797
|
+
* base64 was buying nothing but a multi-megabyte string in the relay's heap.
|
|
20798
|
+
*/
|
|
20799
|
+
jpegBytes: _instanceof(Uint8Array).optional(),
|
|
20700
20800
|
width: number().int().positive(),
|
|
20701
20801
|
height: number().int().positive(),
|
|
20702
20802
|
/**
|
|
@@ -20763,7 +20863,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
|
|
|
20763
20863
|
})]);
|
|
20764
20864
|
/** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
|
|
20765
20865
|
var ParkedTrackFrameSchema = object({
|
|
20766
|
-
|
|
20866
|
+
/**
|
|
20867
|
+
* Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
|
|
20868
|
+
* `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
|
|
20869
|
+
* Exactly one of the two is present.
|
|
20870
|
+
*/
|
|
20871
|
+
jpeg: string().optional(),
|
|
20872
|
+
/** The same JPEG as bytes, for a caller that declared it reads them (D462). */
|
|
20873
|
+
jpegBytes: _instanceof(Uint8Array).optional(),
|
|
20767
20874
|
width: number().int().positive(),
|
|
20768
20875
|
height: number().int().positive(),
|
|
20769
20876
|
/** The frame instant the parcel shows (the caller's clock, echoed back). */
|
|
@@ -21350,6 +21457,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
|
|
|
21350
21457
|
bbox: NativeCropBboxSchema,
|
|
21351
21458
|
maxWidth: number().int().positive().optional(),
|
|
21352
21459
|
/**
|
|
21460
|
+
* The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
|
|
21461
|
+
* back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
|
|
21462
|
+
* wire — never assume consent: a pre-D462 caller parses the field as
|
|
21463
|
+
* base64 and bytes would decode to garbage rather than fail.
|
|
21464
|
+
*/
|
|
21465
|
+
acceptJpegBytes: boolean().optional(),
|
|
21466
|
+
/**
|
|
21353
21467
|
* When `true`, the runner encodes the resolved crop to JPEG ON THE
|
|
21354
21468
|
* OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
|
|
21355
21469
|
* Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
|
|
@@ -21417,7 +21531,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
|
|
|
21417
21531
|
}), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
|
|
21418
21532
|
deviceId: number(),
|
|
21419
21533
|
trackId: string(),
|
|
21420
|
-
kind: ParkedFrameKindSchema
|
|
21534
|
+
kind: ParkedFrameKindSchema,
|
|
21535
|
+
/**
|
|
21536
|
+
* The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
|
|
21537
|
+
* back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
|
|
21538
|
+
* wire — never assume consent: a pre-D462 caller parses the field as
|
|
21539
|
+
* base64 and bytes would decode to garbage rather than fail.
|
|
21540
|
+
*/
|
|
21541
|
+
acceptJpegBytes: boolean().optional()
|
|
21421
21542
|
}), ParkedTrackFrameSchema.nullable()), method(object({
|
|
21422
21543
|
deviceId: number(),
|
|
21423
21544
|
trackId: string()
|
|
@@ -27832,26 +27953,59 @@ authKey: string().optional() }), object({
|
|
|
27832
27953
|
/** Human-readable error when `ok: false`. */
|
|
27833
27954
|
error: string().optional()
|
|
27834
27955
|
}), { kind: "mutation" });
|
|
27835
|
-
/**
|
|
27836
|
-
* Hardware / firmware motion sensor cap — binary detected state plus
|
|
27837
|
-
* a timestamp of the last observation. Distinct from
|
|
27838
|
-
* `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
|
|
27839
|
-
* `motion` is the lightweight readout from on-camera motion (Reolink
|
|
27840
|
-
* `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
|
|
27841
|
-
*
|
|
27842
|
-
* Native-motion providers also fan out to `detection.camera-native`
|
|
27843
|
-
* with `source: 'onboard'` so cross-cutting system services
|
|
27844
|
-
* (alert-center, advanced-notifier) can subscribe once and receive
|
|
27845
|
-
* motion from every camera.
|
|
27846
|
-
*/
|
|
27847
27956
|
var MotionStatusSchema = object({
|
|
27848
27957
|
detected: boolean(),
|
|
27849
27958
|
/** Ms epoch of the last detected-true observation. Null if never detected. */
|
|
27850
27959
|
lastDetectedAt: number().nullable(),
|
|
27851
27960
|
/**
|
|
27852
|
-
*
|
|
27853
|
-
*
|
|
27854
|
-
*
|
|
27961
|
+
* `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
|
|
27962
|
+
* `null` while false and on every `Sensor` device (D475) — see that
|
|
27963
|
+
* constant's doc for the one-authority rule.
|
|
27964
|
+
*
|
|
27965
|
+
* ## Reading this field still arms nothing
|
|
27966
|
+
*
|
|
27967
|
+
* It reads like an instruction to the consumer ("revert after N ms if
|
|
27968
|
+
* no fresh push arrives") and it is not one: nothing in this repo reads
|
|
27969
|
+
* the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
|
|
27970
|
+
* close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
|
|
27971
|
+
* imported constant, not as a read of `device.state.motion.value`, so this
|
|
27972
|
+
* field stays what it always was: DESCRIPTIVE output, mirroring an answer
|
|
27973
|
+
* computed elsewhere. Building a self-clear timer out of a READ of this
|
|
27974
|
+
* field would add a second falling-edge authority beside whichever one
|
|
27975
|
+
* already owns the device, and two that can disagree are worse than one.
|
|
27976
|
+
* Consumers that need a falling edge SHAPED differently — held open across
|
|
27977
|
+
* a flapping source — debounce on their own side and say so, as
|
|
27978
|
+
* `addon-export-alexa/src/motion-clear-hold.ts` and
|
|
27979
|
+
* `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
|
|
27980
|
+
*
|
|
27981
|
+
* ## Who writes it
|
|
27982
|
+
*
|
|
27983
|
+
* - **Cameras** — the runner's phase machine, `active → watching` on
|
|
27984
|
+
* `cooldown_expired`, which then writes this slice with
|
|
27985
|
+
* `detected: false` (`handlePhaseChanged` in
|
|
27986
|
+
* `pipeline-runner/index.ts`). It produces the FALLING edge, which
|
|
27987
|
+
* matters most for the sources that only ever push a rising one:
|
|
27988
|
+
* Reolink emits `MotionOnMotionChanged { detected: true }` and never
|
|
27989
|
+
* a false.
|
|
27990
|
+
* - **Sensors** (Home Assistant binary sensors, Homematic) — the
|
|
27991
|
+
* provider pushes the false itself, from the upstream system's own
|
|
27992
|
+
* state change. No phase machine is involved.
|
|
27993
|
+
*
|
|
27994
|
+
* ### The phase machine is CANONICAL, not sole — and that is a defect
|
|
27995
|
+
*
|
|
27996
|
+
* An earlier revision of this docblock (mine, 2026-09-12) claimed the
|
|
27997
|
+
* phase machine is the sole writer for a camera. It is not.
|
|
27998
|
+
* `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
|
|
27999
|
+
* `setCapSlice(motionCapability, …)` on their own rising edge, and
|
|
28000
|
+
* Hikvision's comment says why: it read THIS docblock, agreed the
|
|
28001
|
+
* runner is canonical, and wrote anyway to avoid per-tick churn. So
|
|
28002
|
+
* two authorities can disagree about one slice, which this repo
|
|
28003
|
+
* forbids, and the doc said otherwise — which is worse than saying
|
|
28004
|
+
* nothing, because it reads as verification.
|
|
28005
|
+
*
|
|
28006
|
+
* This predates D475 and is not fixed there: the fix touches every
|
|
28007
|
+
* camera provider. Recorded in D475's Consequences. Do not restore the
|
|
28008
|
+
* "sole writer" wording without also removing the other writers.
|
|
27855
28009
|
*/
|
|
27856
28010
|
autoClearAfterMs: number().nullable()
|
|
27857
28011
|
});
|
|
@@ -27921,7 +28075,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
|
|
|
27921
28075
|
*/
|
|
27922
28076
|
runtimeState: MotionStatusSchema,
|
|
27923
28077
|
/**
|
|
27924
|
-
* Runtime-state durability: **session** —
|
|
28078
|
+
* Runtime-state durability: **session** — every writer of this slice
|
|
28079
|
+
* writes only on an EDGE, so a restored `detected: true` would stay
|
|
28080
|
+
* frozen until the next one instead of being corrected. The next edge
|
|
28081
|
+
* re-publishes the real state. (On who the writers are, and why there
|
|
28082
|
+
* is more than one, see `autoClearAfterMs` above.)
|
|
27925
28083
|
*
|
|
27926
28084
|
* See `RuntimeStateDurability`. Enforced by
|
|
27927
28085
|
* `scripts/check-runtime-state-durability.ts`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-provider-unifi",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.98",
|
|
4
4
|
"description": "UniFi Network controller device-provider addon for CamStack — local-controller infra switches/APs (as containers) + network-client presence. NO cameras/Protect.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|