@camstack/addon-provider-rtsp 1.2.97 → 1.2.99
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
|
@@ -7327,6 +7327,23 @@ function errMsg(err) {
|
|
|
7327
7327
|
if (typeof err === "string") return err;
|
|
7328
7328
|
return String(err);
|
|
7329
7329
|
}
|
|
7330
|
+
new Set([
|
|
7331
|
+
"track",
|
|
7332
|
+
"summary",
|
|
7333
|
+
"face",
|
|
7334
|
+
"identity",
|
|
7335
|
+
"plate",
|
|
7336
|
+
"vehicle",
|
|
7337
|
+
"scene",
|
|
7338
|
+
"motion",
|
|
7339
|
+
"object",
|
|
7340
|
+
"audio"
|
|
7341
|
+
]);
|
|
7342
|
+
new Set([
|
|
7343
|
+
"motion",
|
|
7344
|
+
"object",
|
|
7345
|
+
"audio"
|
|
7346
|
+
]);
|
|
7330
7347
|
var EncodeProfileSchema = object({
|
|
7331
7348
|
video: object({
|
|
7332
7349
|
codec: _enum([
|
|
@@ -12559,8 +12576,17 @@ method(object({
|
|
|
12559
12576
|
}), array(SettingsRecordSchema).readonly()), method(object({
|
|
12560
12577
|
namespace: string().optional(),
|
|
12561
12578
|
collection: string(),
|
|
12562
|
-
record:
|
|
12563
|
-
|
|
12579
|
+
record: object({
|
|
12580
|
+
id: string().optional(),
|
|
12581
|
+
data: record(string(), unknown())
|
|
12582
|
+
})
|
|
12583
|
+
}), object({
|
|
12584
|
+
/**
|
|
12585
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12586
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12587
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12588
|
+
*/
|
|
12589
|
+
id: union([string(), number()]) }), { kind: "mutation" }), method(object({
|
|
12564
12590
|
namespace: string().optional(),
|
|
12565
12591
|
collection: string(),
|
|
12566
12592
|
records: array(BulkRecordSchema).readonly()
|
|
@@ -12669,8 +12695,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
|
|
|
12669
12695
|
}), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
|
|
12670
12696
|
namespace: string().optional(),
|
|
12671
12697
|
collection: string(),
|
|
12672
|
-
record:
|
|
12673
|
-
|
|
12698
|
+
record: object({
|
|
12699
|
+
id: string().optional(),
|
|
12700
|
+
data: record(string(), unknown())
|
|
12701
|
+
})
|
|
12702
|
+
}), object({
|
|
12703
|
+
/**
|
|
12704
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12705
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12706
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12707
|
+
*/
|
|
12708
|
+
id: union([string(), number()]) }), {
|
|
12674
12709
|
kind: "mutation",
|
|
12675
12710
|
auth: "admin"
|
|
12676
12711
|
}), method(object({
|
|
@@ -19578,7 +19613,20 @@ var TrackSchema = object({
|
|
|
19578
19613
|
...TrackRetrainFields
|
|
19579
19614
|
});
|
|
19580
19615
|
var BaseEventFields = {
|
|
19581
|
-
|
|
19616
|
+
/**
|
|
19617
|
+
* A SQLite ROWID, assigned by the database (D474).
|
|
19618
|
+
*
|
|
19619
|
+
* Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
|
|
19620
|
+
* TWICE per row, in the row and in the primary-key index, across 2.1 million
|
|
19621
|
+
* motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
|
|
19622
|
+
* the rowid: the table itself is that B-tree, so the index stops existing
|
|
19623
|
+
* rather than getting smaller. No shorter string does that.
|
|
19624
|
+
*
|
|
19625
|
+
* Defined once here for all three event kinds, which is why they move
|
|
19626
|
+
* together: a per-table migration would have forked this and
|
|
19627
|
+
* `COMMON_BASE_COLUMNS` and reunited them two stages later.
|
|
19628
|
+
*/
|
|
19629
|
+
id: number().int(),
|
|
19582
19630
|
deviceId: number(),
|
|
19583
19631
|
timestamp: number()
|
|
19584
19632
|
};
|
|
@@ -19597,7 +19645,34 @@ var MotionEventSchema = object({
|
|
|
19597
19645
|
/** Omitted in slim projection. */
|
|
19598
19646
|
frameHeight: number().optional(),
|
|
19599
19647
|
/** Populated by B5 (recording playback URL for this event). */
|
|
19600
|
-
mediaUrl: string().optional()
|
|
19648
|
+
mediaUrl: string().optional(),
|
|
19649
|
+
/**
|
|
19650
|
+
* One row per motion EPISODE, not one per push (D475). `null` while the
|
|
19651
|
+
* episode is still open — a further rising edge extends it in place rather
|
|
19652
|
+
* than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
|
|
19653
|
+
* (the span from the first rising edge to the LAST one, deliberately NOT
|
|
19654
|
+
* `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
|
|
19655
|
+
* movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
|
|
19656
|
+
* motion for an instantaneous trigger).
|
|
19657
|
+
*
|
|
19658
|
+
* **Absent** (not merely `null`) on a row written before D475 — that means
|
|
19659
|
+
* "closed the old way, before this column existed", never "still open".
|
|
19660
|
+
* Nothing in this codebase may read an absent `durationMs` as an open
|
|
19661
|
+
* episode; only `null` means open.
|
|
19662
|
+
*/
|
|
19663
|
+
durationMs: number().nullable().optional(),
|
|
19664
|
+
/**
|
|
19665
|
+
* Ms offsets from `timestamp` (the episode's own first rising edge, so the
|
|
19666
|
+
* first entry is always `0`) of every genuine off→on transition the
|
|
19667
|
+
* episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
|
|
19668
|
+
* push: a firmware source that keepalives at ~1 Hz for the whole burst
|
|
19669
|
+
* (Reolink, Hikvision) produces exactly one edge; a source that reports an
|
|
19670
|
+
* explicit `false` mid-episode and then resumes before the quiet window
|
|
19671
|
+
* elapses produces another. Stored compactly — see `motion-edge-codec.ts`
|
|
19672
|
+
* — and decoded back to this shape on read. Absent/empty on a legacy row,
|
|
19673
|
+
* which must never be read as "no episode happened here".
|
|
19674
|
+
*/
|
|
19675
|
+
edges: array(number()).readonly().optional()
|
|
19601
19676
|
});
|
|
19602
19677
|
/**
|
|
19603
19678
|
* Which detection SOURCE produced an object event. `pipeline` = the ML
|
|
@@ -19652,6 +19727,23 @@ var ObjectEventSchema = object({
|
|
|
19652
19727
|
* includes it (it is light). Absent on rows written before this field.
|
|
19653
19728
|
*/
|
|
19654
19729
|
frameId: string().optional(),
|
|
19730
|
+
/**
|
|
19731
|
+
* A PRODUCER-chosen key that makes a synthetic event's emission idempotent
|
|
19732
|
+
* (D474).
|
|
19733
|
+
*
|
|
19734
|
+
* Only the package detector writes it, and it exists because the event id
|
|
19735
|
+
* stopped being choosable: the delivery and pick-up rows used to BE their
|
|
19736
|
+
* dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
|
|
19737
|
+
* second delivery for this entry" survived a restart. An `INTEGER` rowid is
|
|
19738
|
+
* assigned by SQLite, so that key had to move off the primary key rather
|
|
19739
|
+
* than be dropped — a detector that cannot recognise its own row re-delivers
|
|
19740
|
+
* every parcel on every boot.
|
|
19741
|
+
*
|
|
19742
|
+
* Absent on every other object event, and on every row written before this
|
|
19743
|
+
* field. Never a substitute for `id`: it is unique per (producer, occasion),
|
|
19744
|
+
* not per row, and nothing addresses a row by it.
|
|
19745
|
+
*/
|
|
19746
|
+
idempotencyKey: string().optional(),
|
|
19655
19747
|
/** Omitted in slim projection. */
|
|
19656
19748
|
trackId: string().optional(),
|
|
19657
19749
|
className: string(),
|
|
@@ -28013,26 +28105,59 @@ authKey: string().optional() }), object({
|
|
|
28013
28105
|
/** Human-readable error when `ok: false`. */
|
|
28014
28106
|
error: string().optional()
|
|
28015
28107
|
}), { kind: "mutation" });
|
|
28016
|
-
/**
|
|
28017
|
-
* Hardware / firmware motion sensor cap — binary detected state plus
|
|
28018
|
-
* a timestamp of the last observation. Distinct from
|
|
28019
|
-
* `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
|
|
28020
|
-
* `motion` is the lightweight readout from on-camera motion (Reolink
|
|
28021
|
-
* `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
|
|
28022
|
-
*
|
|
28023
|
-
* Native-motion providers also fan out to `detection.camera-native`
|
|
28024
|
-
* with `source: 'onboard'` so cross-cutting system services
|
|
28025
|
-
* (alert-center, advanced-notifier) can subscribe once and receive
|
|
28026
|
-
* motion from every camera.
|
|
28027
|
-
*/
|
|
28028
28108
|
var MotionStatusSchema = object({
|
|
28029
28109
|
detected: boolean(),
|
|
28030
28110
|
/** Ms epoch of the last detected-true observation. Null if never detected. */
|
|
28031
28111
|
lastDetectedAt: number().nullable(),
|
|
28032
28112
|
/**
|
|
28033
|
-
*
|
|
28034
|
-
*
|
|
28035
|
-
*
|
|
28113
|
+
* `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
|
|
28114
|
+
* `null` while false and on every `Sensor` device (D475) — see that
|
|
28115
|
+
* constant's doc for the one-authority rule.
|
|
28116
|
+
*
|
|
28117
|
+
* ## Reading this field still arms nothing
|
|
28118
|
+
*
|
|
28119
|
+
* It reads like an instruction to the consumer ("revert after N ms if
|
|
28120
|
+
* no fresh push arrives") and it is not one: nothing in this repo reads
|
|
28121
|
+
* the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
|
|
28122
|
+
* close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
|
|
28123
|
+
* imported constant, not as a read of `device.state.motion.value`, so this
|
|
28124
|
+
* field stays what it always was: DESCRIPTIVE output, mirroring an answer
|
|
28125
|
+
* computed elsewhere. Building a self-clear timer out of a READ of this
|
|
28126
|
+
* field would add a second falling-edge authority beside whichever one
|
|
28127
|
+
* already owns the device, and two that can disagree are worse than one.
|
|
28128
|
+
* Consumers that need a falling edge SHAPED differently — held open across
|
|
28129
|
+
* a flapping source — debounce on their own side and say so, as
|
|
28130
|
+
* `addon-export-alexa/src/motion-clear-hold.ts` and
|
|
28131
|
+
* `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
|
|
28132
|
+
*
|
|
28133
|
+
* ## Who writes it
|
|
28134
|
+
*
|
|
28135
|
+
* - **Cameras** — the runner's phase machine, `active → watching` on
|
|
28136
|
+
* `cooldown_expired`, which then writes this slice with
|
|
28137
|
+
* `detected: false` (`handlePhaseChanged` in
|
|
28138
|
+
* `pipeline-runner/index.ts`). It produces the FALLING edge, which
|
|
28139
|
+
* matters most for the sources that only ever push a rising one:
|
|
28140
|
+
* Reolink emits `MotionOnMotionChanged { detected: true }` and never
|
|
28141
|
+
* a false.
|
|
28142
|
+
* - **Sensors** (Home Assistant binary sensors, Homematic) — the
|
|
28143
|
+
* provider pushes the false itself, from the upstream system's own
|
|
28144
|
+
* state change. No phase machine is involved.
|
|
28145
|
+
*
|
|
28146
|
+
* ### The phase machine is CANONICAL, not sole — and that is a defect
|
|
28147
|
+
*
|
|
28148
|
+
* An earlier revision of this docblock (mine, 2026-09-12) claimed the
|
|
28149
|
+
* phase machine is the sole writer for a camera. It is not.
|
|
28150
|
+
* `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
|
|
28151
|
+
* `setCapSlice(motionCapability, …)` on their own rising edge, and
|
|
28152
|
+
* Hikvision's comment says why: it read THIS docblock, agreed the
|
|
28153
|
+
* runner is canonical, and wrote anyway to avoid per-tick churn. So
|
|
28154
|
+
* two authorities can disagree about one slice, which this repo
|
|
28155
|
+
* forbids, and the doc said otherwise — which is worse than saying
|
|
28156
|
+
* nothing, because it reads as verification.
|
|
28157
|
+
*
|
|
28158
|
+
* This predates D475 and is not fixed there: the fix touches every
|
|
28159
|
+
* camera provider. Recorded in D475's Consequences. Do not restore the
|
|
28160
|
+
* "sole writer" wording without also removing the other writers.
|
|
28036
28161
|
*/
|
|
28037
28162
|
autoClearAfterMs: number().nullable()
|
|
28038
28163
|
});
|
|
@@ -28102,7 +28227,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
|
|
|
28102
28227
|
*/
|
|
28103
28228
|
runtimeState: MotionStatusSchema,
|
|
28104
28229
|
/**
|
|
28105
|
-
* Runtime-state durability: **session** —
|
|
28230
|
+
* Runtime-state durability: **session** — every writer of this slice
|
|
28231
|
+
* writes only on an EDGE, so a restored `detected: true` would stay
|
|
28232
|
+
* frozen until the next one instead of being corrected. The next edge
|
|
28233
|
+
* re-publishes the real state. (On who the writers are, and why there
|
|
28234
|
+
* is more than one, see `autoClearAfterMs` above.)
|
|
28106
28235
|
*
|
|
28107
28236
|
* See `RuntimeStateDurability`. Enforced by
|
|
28108
28237
|
* `scripts/check-runtime-state-durability.ts`.
|
package/dist/addon.mjs
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([
|
|
@@ -12535,8 +12552,17 @@ method(object({
|
|
|
12535
12552
|
}), array(SettingsRecordSchema).readonly()), method(object({
|
|
12536
12553
|
namespace: string().optional(),
|
|
12537
12554
|
collection: string(),
|
|
12538
|
-
record:
|
|
12539
|
-
|
|
12555
|
+
record: object({
|
|
12556
|
+
id: string().optional(),
|
|
12557
|
+
data: record(string(), unknown())
|
|
12558
|
+
})
|
|
12559
|
+
}), object({
|
|
12560
|
+
/**
|
|
12561
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12562
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12563
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12564
|
+
*/
|
|
12565
|
+
id: union([string(), number()]) }), { kind: "mutation" }), method(object({
|
|
12540
12566
|
namespace: string().optional(),
|
|
12541
12567
|
collection: string(),
|
|
12542
12568
|
records: array(BulkRecordSchema).readonly()
|
|
@@ -12645,8 +12671,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
|
|
|
12645
12671
|
}), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
|
|
12646
12672
|
namespace: string().optional(),
|
|
12647
12673
|
collection: string(),
|
|
12648
|
-
record:
|
|
12649
|
-
|
|
12674
|
+
record: object({
|
|
12675
|
+
id: string().optional(),
|
|
12676
|
+
data: record(string(), unknown())
|
|
12677
|
+
})
|
|
12678
|
+
}), object({
|
|
12679
|
+
/**
|
|
12680
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12681
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12682
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12683
|
+
*/
|
|
12684
|
+
id: union([string(), number()]) }), {
|
|
12650
12685
|
kind: "mutation",
|
|
12651
12686
|
auth: "admin"
|
|
12652
12687
|
}), method(object({
|
|
@@ -19554,7 +19589,20 @@ var TrackSchema = object({
|
|
|
19554
19589
|
...TrackRetrainFields
|
|
19555
19590
|
});
|
|
19556
19591
|
var BaseEventFields = {
|
|
19557
|
-
|
|
19592
|
+
/**
|
|
19593
|
+
* A SQLite ROWID, assigned by the database (D474).
|
|
19594
|
+
*
|
|
19595
|
+
* Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
|
|
19596
|
+
* TWICE per row, in the row and in the primary-key index, across 2.1 million
|
|
19597
|
+
* motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
|
|
19598
|
+
* the rowid: the table itself is that B-tree, so the index stops existing
|
|
19599
|
+
* rather than getting smaller. No shorter string does that.
|
|
19600
|
+
*
|
|
19601
|
+
* Defined once here for all three event kinds, which is why they move
|
|
19602
|
+
* together: a per-table migration would have forked this and
|
|
19603
|
+
* `COMMON_BASE_COLUMNS` and reunited them two stages later.
|
|
19604
|
+
*/
|
|
19605
|
+
id: number().int(),
|
|
19558
19606
|
deviceId: number(),
|
|
19559
19607
|
timestamp: number()
|
|
19560
19608
|
};
|
|
@@ -19573,7 +19621,34 @@ var MotionEventSchema = object({
|
|
|
19573
19621
|
/** Omitted in slim projection. */
|
|
19574
19622
|
frameHeight: number().optional(),
|
|
19575
19623
|
/** Populated by B5 (recording playback URL for this event). */
|
|
19576
|
-
mediaUrl: string().optional()
|
|
19624
|
+
mediaUrl: string().optional(),
|
|
19625
|
+
/**
|
|
19626
|
+
* One row per motion EPISODE, not one per push (D475). `null` while the
|
|
19627
|
+
* episode is still open — a further rising edge extends it in place rather
|
|
19628
|
+
* than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
|
|
19629
|
+
* (the span from the first rising edge to the LAST one, deliberately NOT
|
|
19630
|
+
* `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
|
|
19631
|
+
* movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
|
|
19632
|
+
* motion for an instantaneous trigger).
|
|
19633
|
+
*
|
|
19634
|
+
* **Absent** (not merely `null`) on a row written before D475 — that means
|
|
19635
|
+
* "closed the old way, before this column existed", never "still open".
|
|
19636
|
+
* Nothing in this codebase may read an absent `durationMs` as an open
|
|
19637
|
+
* episode; only `null` means open.
|
|
19638
|
+
*/
|
|
19639
|
+
durationMs: number().nullable().optional(),
|
|
19640
|
+
/**
|
|
19641
|
+
* Ms offsets from `timestamp` (the episode's own first rising edge, so the
|
|
19642
|
+
* first entry is always `0`) of every genuine off→on transition the
|
|
19643
|
+
* episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
|
|
19644
|
+
* push: a firmware source that keepalives at ~1 Hz for the whole burst
|
|
19645
|
+
* (Reolink, Hikvision) produces exactly one edge; a source that reports an
|
|
19646
|
+
* explicit `false` mid-episode and then resumes before the quiet window
|
|
19647
|
+
* elapses produces another. Stored compactly — see `motion-edge-codec.ts`
|
|
19648
|
+
* — and decoded back to this shape on read. Absent/empty on a legacy row,
|
|
19649
|
+
* which must never be read as "no episode happened here".
|
|
19650
|
+
*/
|
|
19651
|
+
edges: array(number()).readonly().optional()
|
|
19577
19652
|
});
|
|
19578
19653
|
/**
|
|
19579
19654
|
* Which detection SOURCE produced an object event. `pipeline` = the ML
|
|
@@ -19628,6 +19703,23 @@ var ObjectEventSchema = object({
|
|
|
19628
19703
|
* includes it (it is light). Absent on rows written before this field.
|
|
19629
19704
|
*/
|
|
19630
19705
|
frameId: string().optional(),
|
|
19706
|
+
/**
|
|
19707
|
+
* A PRODUCER-chosen key that makes a synthetic event's emission idempotent
|
|
19708
|
+
* (D474).
|
|
19709
|
+
*
|
|
19710
|
+
* Only the package detector writes it, and it exists because the event id
|
|
19711
|
+
* stopped being choosable: the delivery and pick-up rows used to BE their
|
|
19712
|
+
* dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
|
|
19713
|
+
* second delivery for this entry" survived a restart. An `INTEGER` rowid is
|
|
19714
|
+
* assigned by SQLite, so that key had to move off the primary key rather
|
|
19715
|
+
* than be dropped — a detector that cannot recognise its own row re-delivers
|
|
19716
|
+
* every parcel on every boot.
|
|
19717
|
+
*
|
|
19718
|
+
* Absent on every other object event, and on every row written before this
|
|
19719
|
+
* field. Never a substitute for `id`: it is unique per (producer, occasion),
|
|
19720
|
+
* not per row, and nothing addresses a row by it.
|
|
19721
|
+
*/
|
|
19722
|
+
idempotencyKey: string().optional(),
|
|
19631
19723
|
/** Omitted in slim projection. */
|
|
19632
19724
|
trackId: string().optional(),
|
|
19633
19725
|
className: string(),
|
|
@@ -27989,26 +28081,59 @@ authKey: string().optional() }), object({
|
|
|
27989
28081
|
/** Human-readable error when `ok: false`. */
|
|
27990
28082
|
error: string().optional()
|
|
27991
28083
|
}), { kind: "mutation" });
|
|
27992
|
-
/**
|
|
27993
|
-
* Hardware / firmware motion sensor cap — binary detected state plus
|
|
27994
|
-
* a timestamp of the last observation. Distinct from
|
|
27995
|
-
* `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
|
|
27996
|
-
* `motion` is the lightweight readout from on-camera motion (Reolink
|
|
27997
|
-
* `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
|
|
27998
|
-
*
|
|
27999
|
-
* Native-motion providers also fan out to `detection.camera-native`
|
|
28000
|
-
* with `source: 'onboard'` so cross-cutting system services
|
|
28001
|
-
* (alert-center, advanced-notifier) can subscribe once and receive
|
|
28002
|
-
* motion from every camera.
|
|
28003
|
-
*/
|
|
28004
28084
|
var MotionStatusSchema = object({
|
|
28005
28085
|
detected: boolean(),
|
|
28006
28086
|
/** Ms epoch of the last detected-true observation. Null if never detected. */
|
|
28007
28087
|
lastDetectedAt: number().nullable(),
|
|
28008
28088
|
/**
|
|
28009
|
-
*
|
|
28010
|
-
*
|
|
28011
|
-
*
|
|
28089
|
+
* `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
|
|
28090
|
+
* `null` while false and on every `Sensor` device (D475) — see that
|
|
28091
|
+
* constant's doc for the one-authority rule.
|
|
28092
|
+
*
|
|
28093
|
+
* ## Reading this field still arms nothing
|
|
28094
|
+
*
|
|
28095
|
+
* It reads like an instruction to the consumer ("revert after N ms if
|
|
28096
|
+
* no fresh push arrives") and it is not one: nothing in this repo reads
|
|
28097
|
+
* the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
|
|
28098
|
+
* close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
|
|
28099
|
+
* imported constant, not as a read of `device.state.motion.value`, so this
|
|
28100
|
+
* field stays what it always was: DESCRIPTIVE output, mirroring an answer
|
|
28101
|
+
* computed elsewhere. Building a self-clear timer out of a READ of this
|
|
28102
|
+
* field would add a second falling-edge authority beside whichever one
|
|
28103
|
+
* already owns the device, and two that can disagree are worse than one.
|
|
28104
|
+
* Consumers that need a falling edge SHAPED differently — held open across
|
|
28105
|
+
* a flapping source — debounce on their own side and say so, as
|
|
28106
|
+
* `addon-export-alexa/src/motion-clear-hold.ts` and
|
|
28107
|
+
* `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
|
|
28108
|
+
*
|
|
28109
|
+
* ## Who writes it
|
|
28110
|
+
*
|
|
28111
|
+
* - **Cameras** — the runner's phase machine, `active → watching` on
|
|
28112
|
+
* `cooldown_expired`, which then writes this slice with
|
|
28113
|
+
* `detected: false` (`handlePhaseChanged` in
|
|
28114
|
+
* `pipeline-runner/index.ts`). It produces the FALLING edge, which
|
|
28115
|
+
* matters most for the sources that only ever push a rising one:
|
|
28116
|
+
* Reolink emits `MotionOnMotionChanged { detected: true }` and never
|
|
28117
|
+
* a false.
|
|
28118
|
+
* - **Sensors** (Home Assistant binary sensors, Homematic) — the
|
|
28119
|
+
* provider pushes the false itself, from the upstream system's own
|
|
28120
|
+
* state change. No phase machine is involved.
|
|
28121
|
+
*
|
|
28122
|
+
* ### The phase machine is CANONICAL, not sole — and that is a defect
|
|
28123
|
+
*
|
|
28124
|
+
* An earlier revision of this docblock (mine, 2026-09-12) claimed the
|
|
28125
|
+
* phase machine is the sole writer for a camera. It is not.
|
|
28126
|
+
* `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
|
|
28127
|
+
* `setCapSlice(motionCapability, …)` on their own rising edge, and
|
|
28128
|
+
* Hikvision's comment says why: it read THIS docblock, agreed the
|
|
28129
|
+
* runner is canonical, and wrote anyway to avoid per-tick churn. So
|
|
28130
|
+
* two authorities can disagree about one slice, which this repo
|
|
28131
|
+
* forbids, and the doc said otherwise — which is worse than saying
|
|
28132
|
+
* nothing, because it reads as verification.
|
|
28133
|
+
*
|
|
28134
|
+
* This predates D475 and is not fixed there: the fix touches every
|
|
28135
|
+
* camera provider. Recorded in D475's Consequences. Do not restore the
|
|
28136
|
+
* "sole writer" wording without also removing the other writers.
|
|
28012
28137
|
*/
|
|
28013
28138
|
autoClearAfterMs: number().nullable()
|
|
28014
28139
|
});
|
|
@@ -28078,7 +28203,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
|
|
|
28078
28203
|
*/
|
|
28079
28204
|
runtimeState: MotionStatusSchema,
|
|
28080
28205
|
/**
|
|
28081
|
-
* Runtime-state durability: **session** —
|
|
28206
|
+
* Runtime-state durability: **session** — every writer of this slice
|
|
28207
|
+
* writes only on an EDGE, so a restored `detected: true` would stay
|
|
28208
|
+
* frozen until the next one instead of being corrected. The next edge
|
|
28209
|
+
* re-publishes the real state. (On who the writers are, and why there
|
|
28210
|
+
* is more than one, see `autoClearAfterMs` above.)
|
|
28082
28211
|
*
|
|
28083
28212
|
* See `RuntimeStateDurability`. Enforced by
|
|
28084
28213
|
* `scripts/check-runtime-state-durability.ts`.
|