@camstack/addon-terminal 0.1.102 → 0.1.103
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 +151 -22
- package/dist/addon.mjs +151 -22
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -7394,6 +7394,23 @@ function errMsg(err) {
|
|
|
7394
7394
|
if (typeof err === "string") return err;
|
|
7395
7395
|
return String(err);
|
|
7396
7396
|
}
|
|
7397
|
+
new Set([
|
|
7398
|
+
"track",
|
|
7399
|
+
"summary",
|
|
7400
|
+
"face",
|
|
7401
|
+
"identity",
|
|
7402
|
+
"plate",
|
|
7403
|
+
"vehicle",
|
|
7404
|
+
"scene",
|
|
7405
|
+
"motion",
|
|
7406
|
+
"object",
|
|
7407
|
+
"audio"
|
|
7408
|
+
]);
|
|
7409
|
+
new Set([
|
|
7410
|
+
"motion",
|
|
7411
|
+
"object",
|
|
7412
|
+
"audio"
|
|
7413
|
+
]);
|
|
7397
7414
|
var EncodeProfileSchema = object({
|
|
7398
7415
|
video: object({
|
|
7399
7416
|
codec: _enum([
|
|
@@ -12602,8 +12619,17 @@ method(object({
|
|
|
12602
12619
|
}), array(SettingsRecordSchema).readonly()), method(object({
|
|
12603
12620
|
namespace: string().optional(),
|
|
12604
12621
|
collection: string(),
|
|
12605
|
-
record:
|
|
12606
|
-
|
|
12622
|
+
record: object({
|
|
12623
|
+
id: string().optional(),
|
|
12624
|
+
data: record(string(), unknown())
|
|
12625
|
+
})
|
|
12626
|
+
}), object({
|
|
12627
|
+
/**
|
|
12628
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12629
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12630
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12631
|
+
*/
|
|
12632
|
+
id: union([string(), number()]) }), { kind: "mutation" }), method(object({
|
|
12607
12633
|
namespace: string().optional(),
|
|
12608
12634
|
collection: string(),
|
|
12609
12635
|
records: array(BulkRecordSchema).readonly()
|
|
@@ -12712,8 +12738,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
|
|
|
12712
12738
|
}), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
|
|
12713
12739
|
namespace: string().optional(),
|
|
12714
12740
|
collection: string(),
|
|
12715
|
-
record:
|
|
12716
|
-
|
|
12741
|
+
record: object({
|
|
12742
|
+
id: string().optional(),
|
|
12743
|
+
data: record(string(), unknown())
|
|
12744
|
+
})
|
|
12745
|
+
}), object({
|
|
12746
|
+
/**
|
|
12747
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12748
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12749
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12750
|
+
*/
|
|
12751
|
+
id: union([string(), number()]) }), {
|
|
12717
12752
|
kind: "mutation",
|
|
12718
12753
|
auth: "admin"
|
|
12719
12754
|
}), method(object({
|
|
@@ -19540,7 +19575,20 @@ var TrackSchema = object({
|
|
|
19540
19575
|
...TrackRetrainFields
|
|
19541
19576
|
});
|
|
19542
19577
|
var BaseEventFields = {
|
|
19543
|
-
|
|
19578
|
+
/**
|
|
19579
|
+
* A SQLite ROWID, assigned by the database (D474).
|
|
19580
|
+
*
|
|
19581
|
+
* Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
|
|
19582
|
+
* TWICE per row, in the row and in the primary-key index, across 2.1 million
|
|
19583
|
+
* motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
|
|
19584
|
+
* the rowid: the table itself is that B-tree, so the index stops existing
|
|
19585
|
+
* rather than getting smaller. No shorter string does that.
|
|
19586
|
+
*
|
|
19587
|
+
* Defined once here for all three event kinds, which is why they move
|
|
19588
|
+
* together: a per-table migration would have forked this and
|
|
19589
|
+
* `COMMON_BASE_COLUMNS` and reunited them two stages later.
|
|
19590
|
+
*/
|
|
19591
|
+
id: number().int(),
|
|
19544
19592
|
deviceId: number(),
|
|
19545
19593
|
timestamp: number()
|
|
19546
19594
|
};
|
|
@@ -19559,7 +19607,34 @@ var MotionEventSchema = object({
|
|
|
19559
19607
|
/** Omitted in slim projection. */
|
|
19560
19608
|
frameHeight: number().optional(),
|
|
19561
19609
|
/** Populated by B5 (recording playback URL for this event). */
|
|
19562
|
-
mediaUrl: string().optional()
|
|
19610
|
+
mediaUrl: string().optional(),
|
|
19611
|
+
/**
|
|
19612
|
+
* One row per motion EPISODE, not one per push (D475). `null` while the
|
|
19613
|
+
* episode is still open — a further rising edge extends it in place rather
|
|
19614
|
+
* than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
|
|
19615
|
+
* (the span from the first rising edge to the LAST one, deliberately NOT
|
|
19616
|
+
* `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
|
|
19617
|
+
* movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
|
|
19618
|
+
* motion for an instantaneous trigger).
|
|
19619
|
+
*
|
|
19620
|
+
* **Absent** (not merely `null`) on a row written before D475 — that means
|
|
19621
|
+
* "closed the old way, before this column existed", never "still open".
|
|
19622
|
+
* Nothing in this codebase may read an absent `durationMs` as an open
|
|
19623
|
+
* episode; only `null` means open.
|
|
19624
|
+
*/
|
|
19625
|
+
durationMs: number().nullable().optional(),
|
|
19626
|
+
/**
|
|
19627
|
+
* Ms offsets from `timestamp` (the episode's own first rising edge, so the
|
|
19628
|
+
* first entry is always `0`) of every genuine off→on transition the
|
|
19629
|
+
* episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
|
|
19630
|
+
* push: a firmware source that keepalives at ~1 Hz for the whole burst
|
|
19631
|
+
* (Reolink, Hikvision) produces exactly one edge; a source that reports an
|
|
19632
|
+
* explicit `false` mid-episode and then resumes before the quiet window
|
|
19633
|
+
* elapses produces another. Stored compactly — see `motion-edge-codec.ts`
|
|
19634
|
+
* — and decoded back to this shape on read. Absent/empty on a legacy row,
|
|
19635
|
+
* which must never be read as "no episode happened here".
|
|
19636
|
+
*/
|
|
19637
|
+
edges: array(number()).readonly().optional()
|
|
19563
19638
|
});
|
|
19564
19639
|
/**
|
|
19565
19640
|
* Which detection SOURCE produced an object event. `pipeline` = the ML
|
|
@@ -19614,6 +19689,23 @@ var ObjectEventSchema = object({
|
|
|
19614
19689
|
* includes it (it is light). Absent on rows written before this field.
|
|
19615
19690
|
*/
|
|
19616
19691
|
frameId: string().optional(),
|
|
19692
|
+
/**
|
|
19693
|
+
* A PRODUCER-chosen key that makes a synthetic event's emission idempotent
|
|
19694
|
+
* (D474).
|
|
19695
|
+
*
|
|
19696
|
+
* Only the package detector writes it, and it exists because the event id
|
|
19697
|
+
* stopped being choosable: the delivery and pick-up rows used to BE their
|
|
19698
|
+
* dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
|
|
19699
|
+
* second delivery for this entry" survived a restart. An `INTEGER` rowid is
|
|
19700
|
+
* assigned by SQLite, so that key had to move off the primary key rather
|
|
19701
|
+
* than be dropped — a detector that cannot recognise its own row re-delivers
|
|
19702
|
+
* every parcel on every boot.
|
|
19703
|
+
*
|
|
19704
|
+
* Absent on every other object event, and on every row written before this
|
|
19705
|
+
* field. Never a substitute for `id`: it is unique per (producer, occasion),
|
|
19706
|
+
* not per row, and nothing addresses a row by it.
|
|
19707
|
+
*/
|
|
19708
|
+
idempotencyKey: string().optional(),
|
|
19617
19709
|
/** Omitted in slim projection. */
|
|
19618
19710
|
trackId: string().optional(),
|
|
19619
19711
|
className: string(),
|
|
@@ -28011,26 +28103,59 @@ authKey: string().optional() }), object({
|
|
|
28011
28103
|
/** Human-readable error when `ok: false`. */
|
|
28012
28104
|
error: string().optional()
|
|
28013
28105
|
}), { kind: "mutation" });
|
|
28014
|
-
/**
|
|
28015
|
-
* Hardware / firmware motion sensor cap — binary detected state plus
|
|
28016
|
-
* a timestamp of the last observation. Distinct from
|
|
28017
|
-
* `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
|
|
28018
|
-
* `motion` is the lightweight readout from on-camera motion (Reolink
|
|
28019
|
-
* `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
|
|
28020
|
-
*
|
|
28021
|
-
* Native-motion providers also fan out to `detection.camera-native`
|
|
28022
|
-
* with `source: 'onboard'` so cross-cutting system services
|
|
28023
|
-
* (alert-center, advanced-notifier) can subscribe once and receive
|
|
28024
|
-
* motion from every camera.
|
|
28025
|
-
*/
|
|
28026
28106
|
var MotionStatusSchema = object({
|
|
28027
28107
|
detected: boolean(),
|
|
28028
28108
|
/** Ms epoch of the last detected-true observation. Null if never detected. */
|
|
28029
28109
|
lastDetectedAt: number().nullable(),
|
|
28030
28110
|
/**
|
|
28031
|
-
*
|
|
28032
|
-
*
|
|
28033
|
-
*
|
|
28111
|
+
* `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
|
|
28112
|
+
* `null` while false and on every `Sensor` device (D475) — see that
|
|
28113
|
+
* constant's doc for the one-authority rule.
|
|
28114
|
+
*
|
|
28115
|
+
* ## Reading this field still arms nothing
|
|
28116
|
+
*
|
|
28117
|
+
* It reads like an instruction to the consumer ("revert after N ms if
|
|
28118
|
+
* no fresh push arrives") and it is not one: nothing in this repo reads
|
|
28119
|
+
* the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
|
|
28120
|
+
* close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
|
|
28121
|
+
* imported constant, not as a read of `device.state.motion.value`, so this
|
|
28122
|
+
* field stays what it always was: DESCRIPTIVE output, mirroring an answer
|
|
28123
|
+
* computed elsewhere. Building a self-clear timer out of a READ of this
|
|
28124
|
+
* field would add a second falling-edge authority beside whichever one
|
|
28125
|
+
* already owns the device, and two that can disagree are worse than one.
|
|
28126
|
+
* Consumers that need a falling edge SHAPED differently — held open across
|
|
28127
|
+
* a flapping source — debounce on their own side and say so, as
|
|
28128
|
+
* `addon-export-alexa/src/motion-clear-hold.ts` and
|
|
28129
|
+
* `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
|
|
28130
|
+
*
|
|
28131
|
+
* ## Who writes it
|
|
28132
|
+
*
|
|
28133
|
+
* - **Cameras** — the runner's phase machine, `active → watching` on
|
|
28134
|
+
* `cooldown_expired`, which then writes this slice with
|
|
28135
|
+
* `detected: false` (`handlePhaseChanged` in
|
|
28136
|
+
* `pipeline-runner/index.ts`). It produces the FALLING edge, which
|
|
28137
|
+
* matters most for the sources that only ever push a rising one:
|
|
28138
|
+
* Reolink emits `MotionOnMotionChanged { detected: true }` and never
|
|
28139
|
+
* a false.
|
|
28140
|
+
* - **Sensors** (Home Assistant binary sensors, Homematic) — the
|
|
28141
|
+
* provider pushes the false itself, from the upstream system's own
|
|
28142
|
+
* state change. No phase machine is involved.
|
|
28143
|
+
*
|
|
28144
|
+
* ### The phase machine is CANONICAL, not sole — and that is a defect
|
|
28145
|
+
*
|
|
28146
|
+
* An earlier revision of this docblock (mine, 2026-09-12) claimed the
|
|
28147
|
+
* phase machine is the sole writer for a camera. It is not.
|
|
28148
|
+
* `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
|
|
28149
|
+
* `setCapSlice(motionCapability, …)` on their own rising edge, and
|
|
28150
|
+
* Hikvision's comment says why: it read THIS docblock, agreed the
|
|
28151
|
+
* runner is canonical, and wrote anyway to avoid per-tick churn. So
|
|
28152
|
+
* two authorities can disagree about one slice, which this repo
|
|
28153
|
+
* forbids, and the doc said otherwise — which is worse than saying
|
|
28154
|
+
* nothing, because it reads as verification.
|
|
28155
|
+
*
|
|
28156
|
+
* This predates D475 and is not fixed there: the fix touches every
|
|
28157
|
+
* camera provider. Recorded in D475's Consequences. Do not restore the
|
|
28158
|
+
* "sole writer" wording without also removing the other writers.
|
|
28034
28159
|
*/
|
|
28035
28160
|
autoClearAfterMs: number().nullable()
|
|
28036
28161
|
});
|
|
@@ -28100,7 +28225,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
|
|
|
28100
28225
|
*/
|
|
28101
28226
|
runtimeState: MotionStatusSchema,
|
|
28102
28227
|
/**
|
|
28103
|
-
* Runtime-state durability: **session** —
|
|
28228
|
+
* Runtime-state durability: **session** — every writer of this slice
|
|
28229
|
+
* writes only on an EDGE, so a restored `detected: true` would stay
|
|
28230
|
+
* frozen until the next one instead of being corrected. The next edge
|
|
28231
|
+
* re-publishes the real state. (On who the writers are, and why there
|
|
28232
|
+
* is more than one, see `autoClearAfterMs` above.)
|
|
28104
28233
|
*
|
|
28105
28234
|
* See `RuntimeStateDurability`. Enforced by
|
|
28106
28235
|
* `scripts/check-runtime-state-durability.ts`.
|
package/dist/addon.mjs
CHANGED
|
@@ -7371,6 +7371,23 @@ function errMsg(err) {
|
|
|
7371
7371
|
if (typeof err === "string") return err;
|
|
7372
7372
|
return String(err);
|
|
7373
7373
|
}
|
|
7374
|
+
new Set([
|
|
7375
|
+
"track",
|
|
7376
|
+
"summary",
|
|
7377
|
+
"face",
|
|
7378
|
+
"identity",
|
|
7379
|
+
"plate",
|
|
7380
|
+
"vehicle",
|
|
7381
|
+
"scene",
|
|
7382
|
+
"motion",
|
|
7383
|
+
"object",
|
|
7384
|
+
"audio"
|
|
7385
|
+
]);
|
|
7386
|
+
new Set([
|
|
7387
|
+
"motion",
|
|
7388
|
+
"object",
|
|
7389
|
+
"audio"
|
|
7390
|
+
]);
|
|
7374
7391
|
var EncodeProfileSchema = object({
|
|
7375
7392
|
video: object({
|
|
7376
7393
|
codec: _enum([
|
|
@@ -12579,8 +12596,17 @@ method(object({
|
|
|
12579
12596
|
}), array(SettingsRecordSchema).readonly()), method(object({
|
|
12580
12597
|
namespace: string().optional(),
|
|
12581
12598
|
collection: string(),
|
|
12582
|
-
record:
|
|
12583
|
-
|
|
12599
|
+
record: object({
|
|
12600
|
+
id: string().optional(),
|
|
12601
|
+
data: record(string(), unknown())
|
|
12602
|
+
})
|
|
12603
|
+
}), object({
|
|
12604
|
+
/**
|
|
12605
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12606
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12607
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12608
|
+
*/
|
|
12609
|
+
id: union([string(), number()]) }), { kind: "mutation" }), method(object({
|
|
12584
12610
|
namespace: string().optional(),
|
|
12585
12611
|
collection: string(),
|
|
12586
12612
|
records: array(BulkRecordSchema).readonly()
|
|
@@ -12689,8 +12715,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
|
|
|
12689
12715
|
}), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
|
|
12690
12716
|
namespace: string().optional(),
|
|
12691
12717
|
collection: string(),
|
|
12692
|
-
record:
|
|
12693
|
-
|
|
12718
|
+
record: object({
|
|
12719
|
+
id: string().optional(),
|
|
12720
|
+
data: record(string(), unknown())
|
|
12721
|
+
})
|
|
12722
|
+
}), object({
|
|
12723
|
+
/**
|
|
12724
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12725
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12726
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12727
|
+
*/
|
|
12728
|
+
id: union([string(), number()]) }), {
|
|
12694
12729
|
kind: "mutation",
|
|
12695
12730
|
auth: "admin"
|
|
12696
12731
|
}), 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(),
|
|
@@ -27988,26 +28080,59 @@ authKey: string().optional() }), object({
|
|
|
27988
28080
|
/** Human-readable error when `ok: false`. */
|
|
27989
28081
|
error: string().optional()
|
|
27990
28082
|
}), { kind: "mutation" });
|
|
27991
|
-
/**
|
|
27992
|
-
* Hardware / firmware motion sensor cap — binary detected state plus
|
|
27993
|
-
* a timestamp of the last observation. Distinct from
|
|
27994
|
-
* `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
|
|
27995
|
-
* `motion` is the lightweight readout from on-camera motion (Reolink
|
|
27996
|
-
* `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
|
|
27997
|
-
*
|
|
27998
|
-
* Native-motion providers also fan out to `detection.camera-native`
|
|
27999
|
-
* with `source: 'onboard'` so cross-cutting system services
|
|
28000
|
-
* (alert-center, advanced-notifier) can subscribe once and receive
|
|
28001
|
-
* motion from every camera.
|
|
28002
|
-
*/
|
|
28003
28083
|
var MotionStatusSchema = object({
|
|
28004
28084
|
detected: boolean(),
|
|
28005
28085
|
/** Ms epoch of the last detected-true observation. Null if never detected. */
|
|
28006
28086
|
lastDetectedAt: number().nullable(),
|
|
28007
28087
|
/**
|
|
28008
|
-
*
|
|
28009
|
-
*
|
|
28010
|
-
*
|
|
28088
|
+
* `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
|
|
28089
|
+
* `null` while false and on every `Sensor` device (D475) — see that
|
|
28090
|
+
* constant's doc for the one-authority rule.
|
|
28091
|
+
*
|
|
28092
|
+
* ## Reading this field still arms nothing
|
|
28093
|
+
*
|
|
28094
|
+
* It reads like an instruction to the consumer ("revert after N ms if
|
|
28095
|
+
* no fresh push arrives") and it is not one: nothing in this repo reads
|
|
28096
|
+
* the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
|
|
28097
|
+
* close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
|
|
28098
|
+
* imported constant, not as a read of `device.state.motion.value`, so this
|
|
28099
|
+
* field stays what it always was: DESCRIPTIVE output, mirroring an answer
|
|
28100
|
+
* computed elsewhere. Building a self-clear timer out of a READ of this
|
|
28101
|
+
* field would add a second falling-edge authority beside whichever one
|
|
28102
|
+
* already owns the device, and two that can disagree are worse than one.
|
|
28103
|
+
* Consumers that need a falling edge SHAPED differently — held open across
|
|
28104
|
+
* a flapping source — debounce on their own side and say so, as
|
|
28105
|
+
* `addon-export-alexa/src/motion-clear-hold.ts` and
|
|
28106
|
+
* `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
|
|
28107
|
+
*
|
|
28108
|
+
* ## Who writes it
|
|
28109
|
+
*
|
|
28110
|
+
* - **Cameras** — the runner's phase machine, `active → watching` on
|
|
28111
|
+
* `cooldown_expired`, which then writes this slice with
|
|
28112
|
+
* `detected: false` (`handlePhaseChanged` in
|
|
28113
|
+
* `pipeline-runner/index.ts`). It produces the FALLING edge, which
|
|
28114
|
+
* matters most for the sources that only ever push a rising one:
|
|
28115
|
+
* Reolink emits `MotionOnMotionChanged { detected: true }` and never
|
|
28116
|
+
* a false.
|
|
28117
|
+
* - **Sensors** (Home Assistant binary sensors, Homematic) — the
|
|
28118
|
+
* provider pushes the false itself, from the upstream system's own
|
|
28119
|
+
* state change. No phase machine is involved.
|
|
28120
|
+
*
|
|
28121
|
+
* ### The phase machine is CANONICAL, not sole — and that is a defect
|
|
28122
|
+
*
|
|
28123
|
+
* An earlier revision of this docblock (mine, 2026-09-12) claimed the
|
|
28124
|
+
* phase machine is the sole writer for a camera. It is not.
|
|
28125
|
+
* `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
|
|
28126
|
+
* `setCapSlice(motionCapability, …)` on their own rising edge, and
|
|
28127
|
+
* Hikvision's comment says why: it read THIS docblock, agreed the
|
|
28128
|
+
* runner is canonical, and wrote anyway to avoid per-tick churn. So
|
|
28129
|
+
* two authorities can disagree about one slice, which this repo
|
|
28130
|
+
* forbids, and the doc said otherwise — which is worse than saying
|
|
28131
|
+
* nothing, because it reads as verification.
|
|
28132
|
+
*
|
|
28133
|
+
* This predates D475 and is not fixed there: the fix touches every
|
|
28134
|
+
* camera provider. Recorded in D475's Consequences. Do not restore the
|
|
28135
|
+
* "sole writer" wording without also removing the other writers.
|
|
28011
28136
|
*/
|
|
28012
28137
|
autoClearAfterMs: number().nullable()
|
|
28013
28138
|
});
|
|
@@ -28077,7 +28202,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
|
|
|
28077
28202
|
*/
|
|
28078
28203
|
runtimeState: MotionStatusSchema,
|
|
28079
28204
|
/**
|
|
28080
|
-
* Runtime-state durability: **session** —
|
|
28205
|
+
* Runtime-state durability: **session** — every writer of this slice
|
|
28206
|
+
* writes only on an EDGE, so a restored `detected: true` would stay
|
|
28207
|
+
* frozen until the next one instead of being corrected. The next edge
|
|
28208
|
+
* re-publishes the real state. (On who the writers are, and why there
|
|
28209
|
+
* is more than one, see `autoClearAfterMs` above.)
|
|
28081
28210
|
*
|
|
28082
28211
|
* See `RuntimeStateDurability`. Enforced by
|
|
28083
28212
|
* `scripts/check-runtime-state-durability.ts`.
|