@camstack/addon-provider-amcrest 0.2.98 → 0.2.100
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 +196 -13
- package/dist/addon.mjs +196 -13
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -7298,6 +7298,23 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
|
|
|
7298
7298
|
action: string().min(1),
|
|
7299
7299
|
input: unknown()
|
|
7300
7300
|
}), unknown(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
|
|
7301
|
+
new Set([
|
|
7302
|
+
"track",
|
|
7303
|
+
"summary",
|
|
7304
|
+
"face",
|
|
7305
|
+
"identity",
|
|
7306
|
+
"plate",
|
|
7307
|
+
"vehicle",
|
|
7308
|
+
"scene",
|
|
7309
|
+
"motion",
|
|
7310
|
+
"object",
|
|
7311
|
+
"audio"
|
|
7312
|
+
]);
|
|
7313
|
+
new Set([
|
|
7314
|
+
"motion",
|
|
7315
|
+
"object",
|
|
7316
|
+
"audio"
|
|
7317
|
+
]);
|
|
7301
7318
|
var EncodeProfileSchema = object({
|
|
7302
7319
|
video: object({
|
|
7303
7320
|
codec: _enum([
|
|
@@ -12498,8 +12515,17 @@ method(object({
|
|
|
12498
12515
|
}), array(SettingsRecordSchema).readonly()), method(object({
|
|
12499
12516
|
namespace: string().optional(),
|
|
12500
12517
|
collection: string(),
|
|
12501
|
-
record:
|
|
12502
|
-
|
|
12518
|
+
record: object({
|
|
12519
|
+
id: string().optional(),
|
|
12520
|
+
data: record(string(), unknown())
|
|
12521
|
+
})
|
|
12522
|
+
}), object({
|
|
12523
|
+
/**
|
|
12524
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12525
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12526
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12527
|
+
*/
|
|
12528
|
+
id: union([string(), number()]) }), { kind: "mutation" }), method(object({
|
|
12503
12529
|
namespace: string().optional(),
|
|
12504
12530
|
collection: string(),
|
|
12505
12531
|
records: array(BulkRecordSchema).readonly()
|
|
@@ -12608,8 +12634,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
|
|
|
12608
12634
|
}), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
|
|
12609
12635
|
namespace: string().optional(),
|
|
12610
12636
|
collection: string(),
|
|
12611
|
-
record:
|
|
12612
|
-
|
|
12637
|
+
record: object({
|
|
12638
|
+
id: string().optional(),
|
|
12639
|
+
data: record(string(), unknown())
|
|
12640
|
+
})
|
|
12641
|
+
}), object({
|
|
12642
|
+
/**
|
|
12643
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12644
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12645
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12646
|
+
*/
|
|
12647
|
+
id: union([string(), number()]) }), {
|
|
12613
12648
|
kind: "mutation",
|
|
12614
12649
|
auth: "admin"
|
|
12615
12650
|
}), method(object({
|
|
@@ -19517,7 +19552,20 @@ var TrackSchema = object({
|
|
|
19517
19552
|
...TrackRetrainFields
|
|
19518
19553
|
});
|
|
19519
19554
|
var BaseEventFields = {
|
|
19520
|
-
|
|
19555
|
+
/**
|
|
19556
|
+
* A SQLite ROWID, assigned by the database (D474).
|
|
19557
|
+
*
|
|
19558
|
+
* Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
|
|
19559
|
+
* TWICE per row, in the row and in the primary-key index, across 2.1 million
|
|
19560
|
+
* motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
|
|
19561
|
+
* the rowid: the table itself is that B-tree, so the index stops existing
|
|
19562
|
+
* rather than getting smaller. No shorter string does that.
|
|
19563
|
+
*
|
|
19564
|
+
* Defined once here for all three event kinds, which is why they move
|
|
19565
|
+
* together: a per-table migration would have forked this and
|
|
19566
|
+
* `COMMON_BASE_COLUMNS` and reunited them two stages later.
|
|
19567
|
+
*/
|
|
19568
|
+
id: number().int(),
|
|
19521
19569
|
deviceId: number(),
|
|
19522
19570
|
timestamp: number()
|
|
19523
19571
|
};
|
|
@@ -19536,7 +19584,34 @@ var MotionEventSchema = object({
|
|
|
19536
19584
|
/** Omitted in slim projection. */
|
|
19537
19585
|
frameHeight: number().optional(),
|
|
19538
19586
|
/** Populated by B5 (recording playback URL for this event). */
|
|
19539
|
-
mediaUrl: string().optional()
|
|
19587
|
+
mediaUrl: string().optional(),
|
|
19588
|
+
/**
|
|
19589
|
+
* One row per motion EPISODE, not one per push (D475). `null` while the
|
|
19590
|
+
* episode is still open — a further rising edge extends it in place rather
|
|
19591
|
+
* than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
|
|
19592
|
+
* (the span from the first rising edge to the LAST one, deliberately NOT
|
|
19593
|
+
* `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
|
|
19594
|
+
* movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
|
|
19595
|
+
* motion for an instantaneous trigger).
|
|
19596
|
+
*
|
|
19597
|
+
* **Absent** (not merely `null`) on a row written before D475 — that means
|
|
19598
|
+
* "closed the old way, before this column existed", never "still open".
|
|
19599
|
+
* Nothing in this codebase may read an absent `durationMs` as an open
|
|
19600
|
+
* episode; only `null` means open.
|
|
19601
|
+
*/
|
|
19602
|
+
durationMs: number().nullable().optional(),
|
|
19603
|
+
/**
|
|
19604
|
+
* Ms offsets from `timestamp` (the episode's own first rising edge, so the
|
|
19605
|
+
* first entry is always `0`) of every genuine off→on transition the
|
|
19606
|
+
* episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
|
|
19607
|
+
* push: a firmware source that keepalives at ~1 Hz for the whole burst
|
|
19608
|
+
* (Reolink, Hikvision) produces exactly one edge; a source that reports an
|
|
19609
|
+
* explicit `false` mid-episode and then resumes before the quiet window
|
|
19610
|
+
* elapses produces another. Stored compactly — see `motion-edge-codec.ts`
|
|
19611
|
+
* — and decoded back to this shape on read. Absent/empty on a legacy row,
|
|
19612
|
+
* which must never be read as "no episode happened here".
|
|
19613
|
+
*/
|
|
19614
|
+
edges: array(number()).readonly().optional()
|
|
19540
19615
|
});
|
|
19541
19616
|
/**
|
|
19542
19617
|
* Which detection SOURCE produced an object event. `pipeline` = the ML
|
|
@@ -19591,6 +19666,23 @@ var ObjectEventSchema = object({
|
|
|
19591
19666
|
* includes it (it is light). Absent on rows written before this field.
|
|
19592
19667
|
*/
|
|
19593
19668
|
frameId: string().optional(),
|
|
19669
|
+
/**
|
|
19670
|
+
* A PRODUCER-chosen key that makes a synthetic event's emission idempotent
|
|
19671
|
+
* (D474).
|
|
19672
|
+
*
|
|
19673
|
+
* Only the package detector writes it, and it exists because the event id
|
|
19674
|
+
* stopped being choosable: the delivery and pick-up rows used to BE their
|
|
19675
|
+
* dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
|
|
19676
|
+
* second delivery for this entry" survived a restart. An `INTEGER` rowid is
|
|
19677
|
+
* assigned by SQLite, so that key had to move off the primary key rather
|
|
19678
|
+
* than be dropped — a detector that cannot recognise its own row re-delivers
|
|
19679
|
+
* every parcel on every boot.
|
|
19680
|
+
*
|
|
19681
|
+
* Absent on every other object event, and on every row written before this
|
|
19682
|
+
* field. Never a substitute for `id`: it is unique per (producer, occasion),
|
|
19683
|
+
* not per row, and nothing addresses a row by it.
|
|
19684
|
+
*/
|
|
19685
|
+
idempotencyKey: string().optional(),
|
|
19594
19686
|
/** Omitted in slim projection. */
|
|
19595
19687
|
trackId: string().optional(),
|
|
19596
19688
|
className: string(),
|
|
@@ -20693,6 +20785,14 @@ var NativeCropResultSchema = object({
|
|
|
20693
20785
|
* set `encodeJpeg: true`; `bytes` is then absent.
|
|
20694
20786
|
*/
|
|
20695
20787
|
jpeg: string().optional(),
|
|
20788
|
+
/**
|
|
20789
|
+
* The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
|
|
20790
|
+
* `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
|
|
20791
|
+
* `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
|
|
20792
|
+
* `bytes` above has crossed this boundary as a `Uint8Array` all along — so
|
|
20793
|
+
* base64 was buying nothing but a multi-megabyte string in the relay's heap.
|
|
20794
|
+
*/
|
|
20795
|
+
jpegBytes: _instanceof(Uint8Array).optional(),
|
|
20696
20796
|
width: number().int().positive(),
|
|
20697
20797
|
height: number().int().positive(),
|
|
20698
20798
|
/**
|
|
@@ -20759,7 +20859,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
|
|
|
20759
20859
|
})]);
|
|
20760
20860
|
/** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
|
|
20761
20861
|
var ParkedTrackFrameSchema = object({
|
|
20762
|
-
|
|
20862
|
+
/**
|
|
20863
|
+
* Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
|
|
20864
|
+
* `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
|
|
20865
|
+
* Exactly one of the two is present.
|
|
20866
|
+
*/
|
|
20867
|
+
jpeg: string().optional(),
|
|
20868
|
+
/** The same JPEG as bytes, for a caller that declared it reads them (D462). */
|
|
20869
|
+
jpegBytes: _instanceof(Uint8Array).optional(),
|
|
20763
20870
|
width: number().int().positive(),
|
|
20764
20871
|
height: number().int().positive(),
|
|
20765
20872
|
/** The frame instant the parcel shows (the caller's clock, echoed back). */
|
|
@@ -21346,6 +21453,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
|
|
|
21346
21453
|
bbox: NativeCropBboxSchema,
|
|
21347
21454
|
maxWidth: number().int().positive().optional(),
|
|
21348
21455
|
/**
|
|
21456
|
+
* The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
|
|
21457
|
+
* back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
|
|
21458
|
+
* wire — never assume consent: a pre-D462 caller parses the field as
|
|
21459
|
+
* base64 and bytes would decode to garbage rather than fail.
|
|
21460
|
+
*/
|
|
21461
|
+
acceptJpegBytes: boolean().optional(),
|
|
21462
|
+
/**
|
|
21349
21463
|
* When `true`, the runner encodes the resolved crop to JPEG ON THE
|
|
21350
21464
|
* OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
|
|
21351
21465
|
* Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
|
|
@@ -21413,7 +21527,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
|
|
|
21413
21527
|
}), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
|
|
21414
21528
|
deviceId: number(),
|
|
21415
21529
|
trackId: string(),
|
|
21416
|
-
kind: ParkedFrameKindSchema
|
|
21530
|
+
kind: ParkedFrameKindSchema,
|
|
21531
|
+
/**
|
|
21532
|
+
* The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
|
|
21533
|
+
* back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
|
|
21534
|
+
* wire — never assume consent: a pre-D462 caller parses the field as
|
|
21535
|
+
* base64 and bytes would decode to garbage rather than fail.
|
|
21536
|
+
*/
|
|
21537
|
+
acceptJpegBytes: boolean().optional()
|
|
21417
21538
|
}), ParkedTrackFrameSchema.nullable()), method(object({
|
|
21418
21539
|
deviceId: number(),
|
|
21419
21540
|
trackId: string()
|
|
@@ -27927,14 +28048,72 @@ authKey: string().optional() }), object({
|
|
|
27927
28048
|
* (alert-center, advanced-notifier) can subscribe once and receive
|
|
27928
28049
|
* motion from every camera.
|
|
27929
28050
|
*/
|
|
28051
|
+
/**
|
|
28052
|
+
* How long after a camera's last rising edge `pipeline-analytics` closes the
|
|
28053
|
+
* motion EPISODE row it kept open for it (D475) — "il delay della cap", in
|
|
28054
|
+
* the operator's words. One authority for the whole system: every provider
|
|
28055
|
+
* that seeds `autoClearAfterMs` on a `Camera` device writes this SAME
|
|
28056
|
+
* constant while `detected: true` (never its own number — Hikvision used to
|
|
28057
|
+
* seed its internal 3 s inactivity timer here, which is a different clock for
|
|
28058
|
+
* a different purpose), and `MotionEpisodeTracker` imports it directly rather
|
|
28059
|
+
* than reading the live cap value on the hot path. A `Sensor` device (HA
|
|
28060
|
+
* binary sensor, Homematic) gets a genuine push both ways and has no episode
|
|
28061
|
+
* to close on a timer, so it writes `null`, never this constant.
|
|
28062
|
+
*/
|
|
28063
|
+
var MOTION_CLOSE_AFTER_MS = 15e3;
|
|
27930
28064
|
var MotionStatusSchema = object({
|
|
27931
28065
|
detected: boolean(),
|
|
27932
28066
|
/** Ms epoch of the last detected-true observation. Null if never detected. */
|
|
27933
28067
|
lastDetectedAt: number().nullable(),
|
|
27934
28068
|
/**
|
|
27935
|
-
*
|
|
27936
|
-
*
|
|
27937
|
-
*
|
|
28069
|
+
* `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
|
|
28070
|
+
* `null` while false and on every `Sensor` device (D475) — see that
|
|
28071
|
+
* constant's doc for the one-authority rule.
|
|
28072
|
+
*
|
|
28073
|
+
* ## Reading this field still arms nothing
|
|
28074
|
+
*
|
|
28075
|
+
* It reads like an instruction to the consumer ("revert after N ms if
|
|
28076
|
+
* no fresh push arrives") and it is not one: nothing in this repo reads
|
|
28077
|
+
* the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
|
|
28078
|
+
* close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
|
|
28079
|
+
* imported constant, not as a read of `device.state.motion.value`, so this
|
|
28080
|
+
* field stays what it always was: DESCRIPTIVE output, mirroring an answer
|
|
28081
|
+
* computed elsewhere. Building a self-clear timer out of a READ of this
|
|
28082
|
+
* field would add a second falling-edge authority beside whichever one
|
|
28083
|
+
* already owns the device, and two that can disagree are worse than one.
|
|
28084
|
+
* Consumers that need a falling edge SHAPED differently — held open across
|
|
28085
|
+
* a flapping source — debounce on their own side and say so, as
|
|
28086
|
+
* `addon-export-alexa/src/motion-clear-hold.ts` and
|
|
28087
|
+
* `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
|
|
28088
|
+
*
|
|
28089
|
+
* ## Who writes it
|
|
28090
|
+
*
|
|
28091
|
+
* - **Cameras** — the runner's phase machine, `active → watching` on
|
|
28092
|
+
* `cooldown_expired`, which then writes this slice with
|
|
28093
|
+
* `detected: false` (`handlePhaseChanged` in
|
|
28094
|
+
* `pipeline-runner/index.ts`). It produces the FALLING edge, which
|
|
28095
|
+
* matters most for the sources that only ever push a rising one:
|
|
28096
|
+
* Reolink emits `MotionOnMotionChanged { detected: true }` and never
|
|
28097
|
+
* a false.
|
|
28098
|
+
* - **Sensors** (Home Assistant binary sensors, Homematic) — the
|
|
28099
|
+
* provider pushes the false itself, from the upstream system's own
|
|
28100
|
+
* state change. No phase machine is involved.
|
|
28101
|
+
*
|
|
28102
|
+
* ### The phase machine is CANONICAL, not sole — and that is a defect
|
|
28103
|
+
*
|
|
28104
|
+
* An earlier revision of this docblock (mine, 2026-09-12) claimed the
|
|
28105
|
+
* phase machine is the sole writer for a camera. It is not.
|
|
28106
|
+
* `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
|
|
28107
|
+
* `setCapSlice(motionCapability, …)` on their own rising edge, and
|
|
28108
|
+
* Hikvision's comment says why: it read THIS docblock, agreed the
|
|
28109
|
+
* runner is canonical, and wrote anyway to avoid per-tick churn. So
|
|
28110
|
+
* two authorities can disagree about one slice, which this repo
|
|
28111
|
+
* forbids, and the doc said otherwise — which is worse than saying
|
|
28112
|
+
* nothing, because it reads as verification.
|
|
28113
|
+
*
|
|
28114
|
+
* This predates D475 and is not fixed there: the fix touches every
|
|
28115
|
+
* camera provider. Recorded in D475's Consequences. Do not restore the
|
|
28116
|
+
* "sole writer" wording without also removing the other writers.
|
|
27938
28117
|
*/
|
|
27939
28118
|
autoClearAfterMs: number().nullable()
|
|
27940
28119
|
});
|
|
@@ -28004,7 +28183,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
|
|
|
28004
28183
|
*/
|
|
28005
28184
|
runtimeState: MotionStatusSchema,
|
|
28006
28185
|
/**
|
|
28007
|
-
* Runtime-state durability: **session** —
|
|
28186
|
+
* Runtime-state durability: **session** — every writer of this slice
|
|
28187
|
+
* writes only on an EDGE, so a restored `detected: true` would stay
|
|
28188
|
+
* frozen until the next one instead of being corrected. The next edge
|
|
28189
|
+
* re-publishes the real state. (On who the writers are, and why there
|
|
28190
|
+
* is more than one, see `autoClearAfterMs` above.)
|
|
28008
28191
|
*
|
|
28009
28192
|
* See `RuntimeStateDurability`. Enforced by
|
|
28010
28193
|
* `scripts/check-runtime-state-durability.ts`.
|
|
@@ -45262,7 +45445,7 @@ var AmcrestCamera = class AmcrestCamera extends BaseDevice {
|
|
|
45262
45445
|
this.setCapSlice(motionCapability, {
|
|
45263
45446
|
detected: true,
|
|
45264
45447
|
lastDetectedAt: now,
|
|
45265
|
-
autoClearAfterMs:
|
|
45448
|
+
autoClearAfterMs: MOTION_CLOSE_AFTER_MS
|
|
45266
45449
|
});
|
|
45267
45450
|
this.ctx.logger.info("amcrest: onboard motion started", { tags: { deviceId: this.id } });
|
|
45268
45451
|
}
|
package/dist/addon.mjs
CHANGED
|
@@ -7299,6 +7299,23 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
|
|
|
7299
7299
|
action: string().min(1),
|
|
7300
7300
|
input: unknown()
|
|
7301
7301
|
}), unknown(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
|
|
7302
|
+
new Set([
|
|
7303
|
+
"track",
|
|
7304
|
+
"summary",
|
|
7305
|
+
"face",
|
|
7306
|
+
"identity",
|
|
7307
|
+
"plate",
|
|
7308
|
+
"vehicle",
|
|
7309
|
+
"scene",
|
|
7310
|
+
"motion",
|
|
7311
|
+
"object",
|
|
7312
|
+
"audio"
|
|
7313
|
+
]);
|
|
7314
|
+
new Set([
|
|
7315
|
+
"motion",
|
|
7316
|
+
"object",
|
|
7317
|
+
"audio"
|
|
7318
|
+
]);
|
|
7302
7319
|
var EncodeProfileSchema = object({
|
|
7303
7320
|
video: object({
|
|
7304
7321
|
codec: _enum([
|
|
@@ -12499,8 +12516,17 @@ method(object({
|
|
|
12499
12516
|
}), array(SettingsRecordSchema).readonly()), method(object({
|
|
12500
12517
|
namespace: string().optional(),
|
|
12501
12518
|
collection: string(),
|
|
12502
|
-
record:
|
|
12503
|
-
|
|
12519
|
+
record: object({
|
|
12520
|
+
id: string().optional(),
|
|
12521
|
+
data: record(string(), unknown())
|
|
12522
|
+
})
|
|
12523
|
+
}), object({
|
|
12524
|
+
/**
|
|
12525
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12526
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12527
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12528
|
+
*/
|
|
12529
|
+
id: union([string(), number()]) }), { kind: "mutation" }), method(object({
|
|
12504
12530
|
namespace: string().optional(),
|
|
12505
12531
|
collection: string(),
|
|
12506
12532
|
records: array(BulkRecordSchema).readonly()
|
|
@@ -12609,8 +12635,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
|
|
|
12609
12635
|
}), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
|
|
12610
12636
|
namespace: string().optional(),
|
|
12611
12637
|
collection: string(),
|
|
12612
|
-
record:
|
|
12613
|
-
|
|
12638
|
+
record: object({
|
|
12639
|
+
id: string().optional(),
|
|
12640
|
+
data: record(string(), unknown())
|
|
12641
|
+
})
|
|
12642
|
+
}), object({
|
|
12643
|
+
/**
|
|
12644
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12645
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12646
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12647
|
+
*/
|
|
12648
|
+
id: union([string(), number()]) }), {
|
|
12614
12649
|
kind: "mutation",
|
|
12615
12650
|
auth: "admin"
|
|
12616
12651
|
}), method(object({
|
|
@@ -19518,7 +19553,20 @@ var TrackSchema = object({
|
|
|
19518
19553
|
...TrackRetrainFields
|
|
19519
19554
|
});
|
|
19520
19555
|
var BaseEventFields = {
|
|
19521
|
-
|
|
19556
|
+
/**
|
|
19557
|
+
* A SQLite ROWID, assigned by the database (D474).
|
|
19558
|
+
*
|
|
19559
|
+
* Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
|
|
19560
|
+
* TWICE per row, in the row and in the primary-key index, across 2.1 million
|
|
19561
|
+
* motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
|
|
19562
|
+
* the rowid: the table itself is that B-tree, so the index stops existing
|
|
19563
|
+
* rather than getting smaller. No shorter string does that.
|
|
19564
|
+
*
|
|
19565
|
+
* Defined once here for all three event kinds, which is why they move
|
|
19566
|
+
* together: a per-table migration would have forked this and
|
|
19567
|
+
* `COMMON_BASE_COLUMNS` and reunited them two stages later.
|
|
19568
|
+
*/
|
|
19569
|
+
id: number().int(),
|
|
19522
19570
|
deviceId: number(),
|
|
19523
19571
|
timestamp: number()
|
|
19524
19572
|
};
|
|
@@ -19537,7 +19585,34 @@ var MotionEventSchema = object({
|
|
|
19537
19585
|
/** Omitted in slim projection. */
|
|
19538
19586
|
frameHeight: number().optional(),
|
|
19539
19587
|
/** Populated by B5 (recording playback URL for this event). */
|
|
19540
|
-
mediaUrl: string().optional()
|
|
19588
|
+
mediaUrl: string().optional(),
|
|
19589
|
+
/**
|
|
19590
|
+
* One row per motion EPISODE, not one per push (D475). `null` while the
|
|
19591
|
+
* episode is still open — a further rising edge extends it in place rather
|
|
19592
|
+
* than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
|
|
19593
|
+
* (the span from the first rising edge to the LAST one, deliberately NOT
|
|
19594
|
+
* `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
|
|
19595
|
+
* movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
|
|
19596
|
+
* motion for an instantaneous trigger).
|
|
19597
|
+
*
|
|
19598
|
+
* **Absent** (not merely `null`) on a row written before D475 — that means
|
|
19599
|
+
* "closed the old way, before this column existed", never "still open".
|
|
19600
|
+
* Nothing in this codebase may read an absent `durationMs` as an open
|
|
19601
|
+
* episode; only `null` means open.
|
|
19602
|
+
*/
|
|
19603
|
+
durationMs: number().nullable().optional(),
|
|
19604
|
+
/**
|
|
19605
|
+
* Ms offsets from `timestamp` (the episode's own first rising edge, so the
|
|
19606
|
+
* first entry is always `0`) of every genuine off→on transition the
|
|
19607
|
+
* episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
|
|
19608
|
+
* push: a firmware source that keepalives at ~1 Hz for the whole burst
|
|
19609
|
+
* (Reolink, Hikvision) produces exactly one edge; a source that reports an
|
|
19610
|
+
* explicit `false` mid-episode and then resumes before the quiet window
|
|
19611
|
+
* elapses produces another. Stored compactly — see `motion-edge-codec.ts`
|
|
19612
|
+
* — and decoded back to this shape on read. Absent/empty on a legacy row,
|
|
19613
|
+
* which must never be read as "no episode happened here".
|
|
19614
|
+
*/
|
|
19615
|
+
edges: array(number()).readonly().optional()
|
|
19541
19616
|
});
|
|
19542
19617
|
/**
|
|
19543
19618
|
* Which detection SOURCE produced an object event. `pipeline` = the ML
|
|
@@ -19592,6 +19667,23 @@ var ObjectEventSchema = object({
|
|
|
19592
19667
|
* includes it (it is light). Absent on rows written before this field.
|
|
19593
19668
|
*/
|
|
19594
19669
|
frameId: string().optional(),
|
|
19670
|
+
/**
|
|
19671
|
+
* A PRODUCER-chosen key that makes a synthetic event's emission idempotent
|
|
19672
|
+
* (D474).
|
|
19673
|
+
*
|
|
19674
|
+
* Only the package detector writes it, and it exists because the event id
|
|
19675
|
+
* stopped being choosable: the delivery and pick-up rows used to BE their
|
|
19676
|
+
* dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
|
|
19677
|
+
* second delivery for this entry" survived a restart. An `INTEGER` rowid is
|
|
19678
|
+
* assigned by SQLite, so that key had to move off the primary key rather
|
|
19679
|
+
* than be dropped — a detector that cannot recognise its own row re-delivers
|
|
19680
|
+
* every parcel on every boot.
|
|
19681
|
+
*
|
|
19682
|
+
* Absent on every other object event, and on every row written before this
|
|
19683
|
+
* field. Never a substitute for `id`: it is unique per (producer, occasion),
|
|
19684
|
+
* not per row, and nothing addresses a row by it.
|
|
19685
|
+
*/
|
|
19686
|
+
idempotencyKey: string().optional(),
|
|
19595
19687
|
/** Omitted in slim projection. */
|
|
19596
19688
|
trackId: string().optional(),
|
|
19597
19689
|
className: string(),
|
|
@@ -20694,6 +20786,14 @@ var NativeCropResultSchema = object({
|
|
|
20694
20786
|
* set `encodeJpeg: true`; `bytes` is then absent.
|
|
20695
20787
|
*/
|
|
20696
20788
|
jpeg: string().optional(),
|
|
20789
|
+
/**
|
|
20790
|
+
* The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
|
|
20791
|
+
* `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
|
|
20792
|
+
* `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
|
|
20793
|
+
* `bytes` above has crossed this boundary as a `Uint8Array` all along — so
|
|
20794
|
+
* base64 was buying nothing but a multi-megabyte string in the relay's heap.
|
|
20795
|
+
*/
|
|
20796
|
+
jpegBytes: _instanceof(Uint8Array).optional(),
|
|
20697
20797
|
width: number().int().positive(),
|
|
20698
20798
|
height: number().int().positive(),
|
|
20699
20799
|
/**
|
|
@@ -20760,7 +20860,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
|
|
|
20760
20860
|
})]);
|
|
20761
20861
|
/** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
|
|
20762
20862
|
var ParkedTrackFrameSchema = object({
|
|
20763
|
-
|
|
20863
|
+
/**
|
|
20864
|
+
* Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
|
|
20865
|
+
* `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
|
|
20866
|
+
* Exactly one of the two is present.
|
|
20867
|
+
*/
|
|
20868
|
+
jpeg: string().optional(),
|
|
20869
|
+
/** The same JPEG as bytes, for a caller that declared it reads them (D462). */
|
|
20870
|
+
jpegBytes: _instanceof(Uint8Array).optional(),
|
|
20764
20871
|
width: number().int().positive(),
|
|
20765
20872
|
height: number().int().positive(),
|
|
20766
20873
|
/** The frame instant the parcel shows (the caller's clock, echoed back). */
|
|
@@ -21347,6 +21454,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
|
|
|
21347
21454
|
bbox: NativeCropBboxSchema,
|
|
21348
21455
|
maxWidth: number().int().positive().optional(),
|
|
21349
21456
|
/**
|
|
21457
|
+
* The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
|
|
21458
|
+
* back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
|
|
21459
|
+
* wire — never assume consent: a pre-D462 caller parses the field as
|
|
21460
|
+
* base64 and bytes would decode to garbage rather than fail.
|
|
21461
|
+
*/
|
|
21462
|
+
acceptJpegBytes: boolean().optional(),
|
|
21463
|
+
/**
|
|
21350
21464
|
* When `true`, the runner encodes the resolved crop to JPEG ON THE
|
|
21351
21465
|
* OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
|
|
21352
21466
|
* Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
|
|
@@ -21414,7 +21528,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
|
|
|
21414
21528
|
}), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
|
|
21415
21529
|
deviceId: number(),
|
|
21416
21530
|
trackId: string(),
|
|
21417
|
-
kind: ParkedFrameKindSchema
|
|
21531
|
+
kind: ParkedFrameKindSchema,
|
|
21532
|
+
/**
|
|
21533
|
+
* The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
|
|
21534
|
+
* back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
|
|
21535
|
+
* wire — never assume consent: a pre-D462 caller parses the field as
|
|
21536
|
+
* base64 and bytes would decode to garbage rather than fail.
|
|
21537
|
+
*/
|
|
21538
|
+
acceptJpegBytes: boolean().optional()
|
|
21418
21539
|
}), ParkedTrackFrameSchema.nullable()), method(object({
|
|
21419
21540
|
deviceId: number(),
|
|
21420
21541
|
trackId: string()
|
|
@@ -27928,14 +28049,72 @@ authKey: string().optional() }), object({
|
|
|
27928
28049
|
* (alert-center, advanced-notifier) can subscribe once and receive
|
|
27929
28050
|
* motion from every camera.
|
|
27930
28051
|
*/
|
|
28052
|
+
/**
|
|
28053
|
+
* How long after a camera's last rising edge `pipeline-analytics` closes the
|
|
28054
|
+
* motion EPISODE row it kept open for it (D475) — "il delay della cap", in
|
|
28055
|
+
* the operator's words. One authority for the whole system: every provider
|
|
28056
|
+
* that seeds `autoClearAfterMs` on a `Camera` device writes this SAME
|
|
28057
|
+
* constant while `detected: true` (never its own number — Hikvision used to
|
|
28058
|
+
* seed its internal 3 s inactivity timer here, which is a different clock for
|
|
28059
|
+
* a different purpose), and `MotionEpisodeTracker` imports it directly rather
|
|
28060
|
+
* than reading the live cap value on the hot path. A `Sensor` device (HA
|
|
28061
|
+
* binary sensor, Homematic) gets a genuine push both ways and has no episode
|
|
28062
|
+
* to close on a timer, so it writes `null`, never this constant.
|
|
28063
|
+
*/
|
|
28064
|
+
var MOTION_CLOSE_AFTER_MS = 15e3;
|
|
27931
28065
|
var MotionStatusSchema = object({
|
|
27932
28066
|
detected: boolean(),
|
|
27933
28067
|
/** Ms epoch of the last detected-true observation. Null if never detected. */
|
|
27934
28068
|
lastDetectedAt: number().nullable(),
|
|
27935
28069
|
/**
|
|
27936
|
-
*
|
|
27937
|
-
*
|
|
27938
|
-
*
|
|
28070
|
+
* `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
|
|
28071
|
+
* `null` while false and on every `Sensor` device (D475) — see that
|
|
28072
|
+
* constant's doc for the one-authority rule.
|
|
28073
|
+
*
|
|
28074
|
+
* ## Reading this field still arms nothing
|
|
28075
|
+
*
|
|
28076
|
+
* It reads like an instruction to the consumer ("revert after N ms if
|
|
28077
|
+
* no fresh push arrives") and it is not one: nothing in this repo reads
|
|
28078
|
+
* the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
|
|
28079
|
+
* close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
|
|
28080
|
+
* imported constant, not as a read of `device.state.motion.value`, so this
|
|
28081
|
+
* field stays what it always was: DESCRIPTIVE output, mirroring an answer
|
|
28082
|
+
* computed elsewhere. Building a self-clear timer out of a READ of this
|
|
28083
|
+
* field would add a second falling-edge authority beside whichever one
|
|
28084
|
+
* already owns the device, and two that can disagree are worse than one.
|
|
28085
|
+
* Consumers that need a falling edge SHAPED differently — held open across
|
|
28086
|
+
* a flapping source — debounce on their own side and say so, as
|
|
28087
|
+
* `addon-export-alexa/src/motion-clear-hold.ts` and
|
|
28088
|
+
* `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
|
|
28089
|
+
*
|
|
28090
|
+
* ## Who writes it
|
|
28091
|
+
*
|
|
28092
|
+
* - **Cameras** — the runner's phase machine, `active → watching` on
|
|
28093
|
+
* `cooldown_expired`, which then writes this slice with
|
|
28094
|
+
* `detected: false` (`handlePhaseChanged` in
|
|
28095
|
+
* `pipeline-runner/index.ts`). It produces the FALLING edge, which
|
|
28096
|
+
* matters most for the sources that only ever push a rising one:
|
|
28097
|
+
* Reolink emits `MotionOnMotionChanged { detected: true }` and never
|
|
28098
|
+
* a false.
|
|
28099
|
+
* - **Sensors** (Home Assistant binary sensors, Homematic) — the
|
|
28100
|
+
* provider pushes the false itself, from the upstream system's own
|
|
28101
|
+
* state change. No phase machine is involved.
|
|
28102
|
+
*
|
|
28103
|
+
* ### The phase machine is CANONICAL, not sole — and that is a defect
|
|
28104
|
+
*
|
|
28105
|
+
* An earlier revision of this docblock (mine, 2026-09-12) claimed the
|
|
28106
|
+
* phase machine is the sole writer for a camera. It is not.
|
|
28107
|
+
* `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
|
|
28108
|
+
* `setCapSlice(motionCapability, …)` on their own rising edge, and
|
|
28109
|
+
* Hikvision's comment says why: it read THIS docblock, agreed the
|
|
28110
|
+
* runner is canonical, and wrote anyway to avoid per-tick churn. So
|
|
28111
|
+
* two authorities can disagree about one slice, which this repo
|
|
28112
|
+
* forbids, and the doc said otherwise — which is worse than saying
|
|
28113
|
+
* nothing, because it reads as verification.
|
|
28114
|
+
*
|
|
28115
|
+
* This predates D475 and is not fixed there: the fix touches every
|
|
28116
|
+
* camera provider. Recorded in D475's Consequences. Do not restore the
|
|
28117
|
+
* "sole writer" wording without also removing the other writers.
|
|
27939
28118
|
*/
|
|
27940
28119
|
autoClearAfterMs: number().nullable()
|
|
27941
28120
|
});
|
|
@@ -28005,7 +28184,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
|
|
|
28005
28184
|
*/
|
|
28006
28185
|
runtimeState: MotionStatusSchema,
|
|
28007
28186
|
/**
|
|
28008
|
-
* Runtime-state durability: **session** —
|
|
28187
|
+
* Runtime-state durability: **session** — every writer of this slice
|
|
28188
|
+
* writes only on an EDGE, so a restored `detected: true` would stay
|
|
28189
|
+
* frozen until the next one instead of being corrected. The next edge
|
|
28190
|
+
* re-publishes the real state. (On who the writers are, and why there
|
|
28191
|
+
* is more than one, see `autoClearAfterMs` above.)
|
|
28009
28192
|
*
|
|
28010
28193
|
* See `RuntimeStateDurability`. Enforced by
|
|
28011
28194
|
* `scripts/check-runtime-state-durability.ts`.
|
|
@@ -45263,7 +45446,7 @@ var AmcrestCamera = class AmcrestCamera extends BaseDevice {
|
|
|
45263
45446
|
this.setCapSlice(motionCapability, {
|
|
45264
45447
|
detected: true,
|
|
45265
45448
|
lastDetectedAt: now,
|
|
45266
|
-
autoClearAfterMs:
|
|
45449
|
+
autoClearAfterMs: MOTION_CLOSE_AFTER_MS
|
|
45267
45450
|
});
|
|
45268
45451
|
this.ctx.logger.info("amcrest: onboard motion started", { tags: { deviceId: this.id } });
|
|
45269
45452
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-provider-amcrest",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.100",
|
|
4
4
|
"description": "Amcrest/Dahua camera device provider addon for CamStack — Dahua CGI over HTTP(S) with digest auth (snapshot, RTSP catalog, PTZ, image/day-night config)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|