@camstack/addon-provider-reolink 1.2.120 → 1.2.121
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
|
@@ -7341,6 +7341,23 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
|
|
|
7341
7341
|
function sleep$2(ms) {
|
|
7342
7342
|
return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
|
|
7343
7343
|
}
|
|
7344
|
+
new Set([
|
|
7345
|
+
"track",
|
|
7346
|
+
"summary",
|
|
7347
|
+
"face",
|
|
7348
|
+
"identity",
|
|
7349
|
+
"plate",
|
|
7350
|
+
"vehicle",
|
|
7351
|
+
"scene",
|
|
7352
|
+
"motion",
|
|
7353
|
+
"object",
|
|
7354
|
+
"audio"
|
|
7355
|
+
]);
|
|
7356
|
+
new Set([
|
|
7357
|
+
"motion",
|
|
7358
|
+
"object",
|
|
7359
|
+
"audio"
|
|
7360
|
+
]);
|
|
7344
7361
|
var EncodeProfileSchema = object({
|
|
7345
7362
|
video: object({
|
|
7346
7363
|
codec: _enum([
|
|
@@ -13107,8 +13124,17 @@ method(object({
|
|
|
13107
13124
|
}), array(SettingsRecordSchema).readonly()), method(object({
|
|
13108
13125
|
namespace: string().optional(),
|
|
13109
13126
|
collection: string(),
|
|
13110
|
-
record:
|
|
13111
|
-
|
|
13127
|
+
record: object({
|
|
13128
|
+
id: string().optional(),
|
|
13129
|
+
data: record(string(), unknown())
|
|
13130
|
+
})
|
|
13131
|
+
}), object({
|
|
13132
|
+
/**
|
|
13133
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
13134
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
13135
|
+
* primary key — which is the only place an auto key is knowable.
|
|
13136
|
+
*/
|
|
13137
|
+
id: union([string(), number()]) }), { kind: "mutation" }), method(object({
|
|
13112
13138
|
namespace: string().optional(),
|
|
13113
13139
|
collection: string(),
|
|
13114
13140
|
records: array(BulkRecordSchema).readonly()
|
|
@@ -13217,8 +13243,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
|
|
|
13217
13243
|
}), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
|
|
13218
13244
|
namespace: string().optional(),
|
|
13219
13245
|
collection: string(),
|
|
13220
|
-
record:
|
|
13221
|
-
|
|
13246
|
+
record: object({
|
|
13247
|
+
id: string().optional(),
|
|
13248
|
+
data: record(string(), unknown())
|
|
13249
|
+
})
|
|
13250
|
+
}), object({
|
|
13251
|
+
/**
|
|
13252
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
13253
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
13254
|
+
* primary key — which is the only place an auto key is knowable.
|
|
13255
|
+
*/
|
|
13256
|
+
id: union([string(), number()]) }), {
|
|
13222
13257
|
kind: "mutation",
|
|
13223
13258
|
auth: "admin"
|
|
13224
13259
|
}), method(object({
|
|
@@ -20166,7 +20201,20 @@ var TrackSchema = object({
|
|
|
20166
20201
|
...TrackRetrainFields
|
|
20167
20202
|
});
|
|
20168
20203
|
var BaseEventFields = {
|
|
20169
|
-
|
|
20204
|
+
/**
|
|
20205
|
+
* A SQLite ROWID, assigned by the database (D474).
|
|
20206
|
+
*
|
|
20207
|
+
* Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
|
|
20208
|
+
* TWICE per row, in the row and in the primary-key index, across 2.1 million
|
|
20209
|
+
* motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
|
|
20210
|
+
* the rowid: the table itself is that B-tree, so the index stops existing
|
|
20211
|
+
* rather than getting smaller. No shorter string does that.
|
|
20212
|
+
*
|
|
20213
|
+
* Defined once here for all three event kinds, which is why they move
|
|
20214
|
+
* together: a per-table migration would have forked this and
|
|
20215
|
+
* `COMMON_BASE_COLUMNS` and reunited them two stages later.
|
|
20216
|
+
*/
|
|
20217
|
+
id: number().int(),
|
|
20170
20218
|
deviceId: number(),
|
|
20171
20219
|
timestamp: number()
|
|
20172
20220
|
};
|
|
@@ -20185,7 +20233,34 @@ var MotionEventSchema = object({
|
|
|
20185
20233
|
/** Omitted in slim projection. */
|
|
20186
20234
|
frameHeight: number().optional(),
|
|
20187
20235
|
/** Populated by B5 (recording playback URL for this event). */
|
|
20188
|
-
mediaUrl: string().optional()
|
|
20236
|
+
mediaUrl: string().optional(),
|
|
20237
|
+
/**
|
|
20238
|
+
* One row per motion EPISODE, not one per push (D475). `null` while the
|
|
20239
|
+
* episode is still open — a further rising edge extends it in place rather
|
|
20240
|
+
* than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
|
|
20241
|
+
* (the span from the first rising edge to the LAST one, deliberately NOT
|
|
20242
|
+
* `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
|
|
20243
|
+
* movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
|
|
20244
|
+
* motion for an instantaneous trigger).
|
|
20245
|
+
*
|
|
20246
|
+
* **Absent** (not merely `null`) on a row written before D475 — that means
|
|
20247
|
+
* "closed the old way, before this column existed", never "still open".
|
|
20248
|
+
* Nothing in this codebase may read an absent `durationMs` as an open
|
|
20249
|
+
* episode; only `null` means open.
|
|
20250
|
+
*/
|
|
20251
|
+
durationMs: number().nullable().optional(),
|
|
20252
|
+
/**
|
|
20253
|
+
* Ms offsets from `timestamp` (the episode's own first rising edge, so the
|
|
20254
|
+
* first entry is always `0`) of every genuine off→on transition the
|
|
20255
|
+
* episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
|
|
20256
|
+
* push: a firmware source that keepalives at ~1 Hz for the whole burst
|
|
20257
|
+
* (Reolink, Hikvision) produces exactly one edge; a source that reports an
|
|
20258
|
+
* explicit `false` mid-episode and then resumes before the quiet window
|
|
20259
|
+
* elapses produces another. Stored compactly — see `motion-edge-codec.ts`
|
|
20260
|
+
* — and decoded back to this shape on read. Absent/empty on a legacy row,
|
|
20261
|
+
* which must never be read as "no episode happened here".
|
|
20262
|
+
*/
|
|
20263
|
+
edges: array(number()).readonly().optional()
|
|
20189
20264
|
});
|
|
20190
20265
|
/**
|
|
20191
20266
|
* Which detection SOURCE produced an object event. `pipeline` = the ML
|
|
@@ -20240,6 +20315,23 @@ var ObjectEventSchema = object({
|
|
|
20240
20315
|
* includes it (it is light). Absent on rows written before this field.
|
|
20241
20316
|
*/
|
|
20242
20317
|
frameId: string().optional(),
|
|
20318
|
+
/**
|
|
20319
|
+
* A PRODUCER-chosen key that makes a synthetic event's emission idempotent
|
|
20320
|
+
* (D474).
|
|
20321
|
+
*
|
|
20322
|
+
* Only the package detector writes it, and it exists because the event id
|
|
20323
|
+
* stopped being choosable: the delivery and pick-up rows used to BE their
|
|
20324
|
+
* dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
|
|
20325
|
+
* second delivery for this entry" survived a restart. An `INTEGER` rowid is
|
|
20326
|
+
* assigned by SQLite, so that key had to move off the primary key rather
|
|
20327
|
+
* than be dropped — a detector that cannot recognise its own row re-delivers
|
|
20328
|
+
* every parcel on every boot.
|
|
20329
|
+
*
|
|
20330
|
+
* Absent on every other object event, and on every row written before this
|
|
20331
|
+
* field. Never a substitute for `id`: it is unique per (producer, occasion),
|
|
20332
|
+
* not per row, and nothing addresses a row by it.
|
|
20333
|
+
*/
|
|
20334
|
+
idempotencyKey: string().optional(),
|
|
20243
20335
|
/** Omitted in slim projection. */
|
|
20244
20336
|
trackId: string().optional(),
|
|
20245
20337
|
className: string(),
|
|
@@ -28593,26 +28685,59 @@ authKey: string().optional() }), object({
|
|
|
28593
28685
|
/** Human-readable error when `ok: false`. */
|
|
28594
28686
|
error: string().optional()
|
|
28595
28687
|
}), { kind: "mutation" });
|
|
28596
|
-
/**
|
|
28597
|
-
* Hardware / firmware motion sensor cap — binary detected state plus
|
|
28598
|
-
* a timestamp of the last observation. Distinct from
|
|
28599
|
-
* `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
|
|
28600
|
-
* `motion` is the lightweight readout from on-camera motion (Reolink
|
|
28601
|
-
* `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
|
|
28602
|
-
*
|
|
28603
|
-
* Native-motion providers also fan out to `detection.camera-native`
|
|
28604
|
-
* with `source: 'onboard'` so cross-cutting system services
|
|
28605
|
-
* (alert-center, advanced-notifier) can subscribe once and receive
|
|
28606
|
-
* motion from every camera.
|
|
28607
|
-
*/
|
|
28608
28688
|
var MotionStatusSchema = object({
|
|
28609
28689
|
detected: boolean(),
|
|
28610
28690
|
/** Ms epoch of the last detected-true observation. Null if never detected. */
|
|
28611
28691
|
lastDetectedAt: number().nullable(),
|
|
28612
28692
|
/**
|
|
28613
|
-
*
|
|
28614
|
-
*
|
|
28615
|
-
*
|
|
28693
|
+
* `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
|
|
28694
|
+
* `null` while false and on every `Sensor` device (D475) — see that
|
|
28695
|
+
* constant's doc for the one-authority rule.
|
|
28696
|
+
*
|
|
28697
|
+
* ## Reading this field still arms nothing
|
|
28698
|
+
*
|
|
28699
|
+
* It reads like an instruction to the consumer ("revert after N ms if
|
|
28700
|
+
* no fresh push arrives") and it is not one: nothing in this repo reads
|
|
28701
|
+
* the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
|
|
28702
|
+
* close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
|
|
28703
|
+
* imported constant, not as a read of `device.state.motion.value`, so this
|
|
28704
|
+
* field stays what it always was: DESCRIPTIVE output, mirroring an answer
|
|
28705
|
+
* computed elsewhere. Building a self-clear timer out of a READ of this
|
|
28706
|
+
* field would add a second falling-edge authority beside whichever one
|
|
28707
|
+
* already owns the device, and two that can disagree are worse than one.
|
|
28708
|
+
* Consumers that need a falling edge SHAPED differently — held open across
|
|
28709
|
+
* a flapping source — debounce on their own side and say so, as
|
|
28710
|
+
* `addon-export-alexa/src/motion-clear-hold.ts` and
|
|
28711
|
+
* `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
|
|
28712
|
+
*
|
|
28713
|
+
* ## Who writes it
|
|
28714
|
+
*
|
|
28715
|
+
* - **Cameras** — the runner's phase machine, `active → watching` on
|
|
28716
|
+
* `cooldown_expired`, which then writes this slice with
|
|
28717
|
+
* `detected: false` (`handlePhaseChanged` in
|
|
28718
|
+
* `pipeline-runner/index.ts`). It produces the FALLING edge, which
|
|
28719
|
+
* matters most for the sources that only ever push a rising one:
|
|
28720
|
+
* Reolink emits `MotionOnMotionChanged { detected: true }` and never
|
|
28721
|
+
* a false.
|
|
28722
|
+
* - **Sensors** (Home Assistant binary sensors, Homematic) — the
|
|
28723
|
+
* provider pushes the false itself, from the upstream system's own
|
|
28724
|
+
* state change. No phase machine is involved.
|
|
28725
|
+
*
|
|
28726
|
+
* ### The phase machine is CANONICAL, not sole — and that is a defect
|
|
28727
|
+
*
|
|
28728
|
+
* An earlier revision of this docblock (mine, 2026-09-12) claimed the
|
|
28729
|
+
* phase machine is the sole writer for a camera. It is not.
|
|
28730
|
+
* `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
|
|
28731
|
+
* `setCapSlice(motionCapability, …)` on their own rising edge, and
|
|
28732
|
+
* Hikvision's comment says why: it read THIS docblock, agreed the
|
|
28733
|
+
* runner is canonical, and wrote anyway to avoid per-tick churn. So
|
|
28734
|
+
* two authorities can disagree about one slice, which this repo
|
|
28735
|
+
* forbids, and the doc said otherwise — which is worse than saying
|
|
28736
|
+
* nothing, because it reads as verification.
|
|
28737
|
+
*
|
|
28738
|
+
* This predates D475 and is not fixed there: the fix touches every
|
|
28739
|
+
* camera provider. Recorded in D475's Consequences. Do not restore the
|
|
28740
|
+
* "sole writer" wording without also removing the other writers.
|
|
28616
28741
|
*/
|
|
28617
28742
|
autoClearAfterMs: number().nullable()
|
|
28618
28743
|
});
|
|
@@ -28682,7 +28807,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
|
|
|
28682
28807
|
*/
|
|
28683
28808
|
runtimeState: MotionStatusSchema,
|
|
28684
28809
|
/**
|
|
28685
|
-
* Runtime-state durability: **session** —
|
|
28810
|
+
* Runtime-state durability: **session** — every writer of this slice
|
|
28811
|
+
* writes only on an EDGE, so a restored `detected: true` would stay
|
|
28812
|
+
* frozen until the next one instead of being corrected. The next edge
|
|
28813
|
+
* re-publishes the real state. (On who the writers are, and why there
|
|
28814
|
+
* is more than one, see `autoClearAfterMs` above.)
|
|
28686
28815
|
*
|
|
28687
28816
|
* See `RuntimeStateDurability`. Enforced by
|
|
28688
28817
|
* `scripts/check-runtime-state-durability.ts`.
|
package/dist/addon.mjs
CHANGED
|
@@ -7336,6 +7336,23 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
|
|
|
7336
7336
|
function sleep$2(ms) {
|
|
7337
7337
|
return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
|
|
7338
7338
|
}
|
|
7339
|
+
new Set([
|
|
7340
|
+
"track",
|
|
7341
|
+
"summary",
|
|
7342
|
+
"face",
|
|
7343
|
+
"identity",
|
|
7344
|
+
"plate",
|
|
7345
|
+
"vehicle",
|
|
7346
|
+
"scene",
|
|
7347
|
+
"motion",
|
|
7348
|
+
"object",
|
|
7349
|
+
"audio"
|
|
7350
|
+
]);
|
|
7351
|
+
new Set([
|
|
7352
|
+
"motion",
|
|
7353
|
+
"object",
|
|
7354
|
+
"audio"
|
|
7355
|
+
]);
|
|
7339
7356
|
var EncodeProfileSchema = object({
|
|
7340
7357
|
video: object({
|
|
7341
7358
|
codec: _enum([
|
|
@@ -13102,8 +13119,17 @@ method(object({
|
|
|
13102
13119
|
}), array(SettingsRecordSchema).readonly()), method(object({
|
|
13103
13120
|
namespace: string().optional(),
|
|
13104
13121
|
collection: string(),
|
|
13105
|
-
record:
|
|
13106
|
-
|
|
13122
|
+
record: object({
|
|
13123
|
+
id: string().optional(),
|
|
13124
|
+
data: record(string(), unknown())
|
|
13125
|
+
})
|
|
13126
|
+
}), object({
|
|
13127
|
+
/**
|
|
13128
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
13129
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
13130
|
+
* primary key — which is the only place an auto key is knowable.
|
|
13131
|
+
*/
|
|
13132
|
+
id: union([string(), number()]) }), { kind: "mutation" }), method(object({
|
|
13107
13133
|
namespace: string().optional(),
|
|
13108
13134
|
collection: string(),
|
|
13109
13135
|
records: array(BulkRecordSchema).readonly()
|
|
@@ -13212,8 +13238,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
|
|
|
13212
13238
|
}), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
|
|
13213
13239
|
namespace: string().optional(),
|
|
13214
13240
|
collection: string(),
|
|
13215
|
-
record:
|
|
13216
|
-
|
|
13241
|
+
record: object({
|
|
13242
|
+
id: string().optional(),
|
|
13243
|
+
data: record(string(), unknown())
|
|
13244
|
+
})
|
|
13245
|
+
}), object({
|
|
13246
|
+
/**
|
|
13247
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
13248
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
13249
|
+
* primary key — which is the only place an auto key is knowable.
|
|
13250
|
+
*/
|
|
13251
|
+
id: union([string(), number()]) }), {
|
|
13217
13252
|
kind: "mutation",
|
|
13218
13253
|
auth: "admin"
|
|
13219
13254
|
}), method(object({
|
|
@@ -20161,7 +20196,20 @@ var TrackSchema = object({
|
|
|
20161
20196
|
...TrackRetrainFields
|
|
20162
20197
|
});
|
|
20163
20198
|
var BaseEventFields = {
|
|
20164
|
-
|
|
20199
|
+
/**
|
|
20200
|
+
* A SQLite ROWID, assigned by the database (D474).
|
|
20201
|
+
*
|
|
20202
|
+
* Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
|
|
20203
|
+
* TWICE per row, in the row and in the primary-key index, across 2.1 million
|
|
20204
|
+
* motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
|
|
20205
|
+
* the rowid: the table itself is that B-tree, so the index stops existing
|
|
20206
|
+
* rather than getting smaller. No shorter string does that.
|
|
20207
|
+
*
|
|
20208
|
+
* Defined once here for all three event kinds, which is why they move
|
|
20209
|
+
* together: a per-table migration would have forked this and
|
|
20210
|
+
* `COMMON_BASE_COLUMNS` and reunited them two stages later.
|
|
20211
|
+
*/
|
|
20212
|
+
id: number().int(),
|
|
20165
20213
|
deviceId: number(),
|
|
20166
20214
|
timestamp: number()
|
|
20167
20215
|
};
|
|
@@ -20180,7 +20228,34 @@ var MotionEventSchema = object({
|
|
|
20180
20228
|
/** Omitted in slim projection. */
|
|
20181
20229
|
frameHeight: number().optional(),
|
|
20182
20230
|
/** Populated by B5 (recording playback URL for this event). */
|
|
20183
|
-
mediaUrl: string().optional()
|
|
20231
|
+
mediaUrl: string().optional(),
|
|
20232
|
+
/**
|
|
20233
|
+
* One row per motion EPISODE, not one per push (D475). `null` while the
|
|
20234
|
+
* episode is still open — a further rising edge extends it in place rather
|
|
20235
|
+
* than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
|
|
20236
|
+
* (the span from the first rising edge to the LAST one, deliberately NOT
|
|
20237
|
+
* `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
|
|
20238
|
+
* movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
|
|
20239
|
+
* motion for an instantaneous trigger).
|
|
20240
|
+
*
|
|
20241
|
+
* **Absent** (not merely `null`) on a row written before D475 — that means
|
|
20242
|
+
* "closed the old way, before this column existed", never "still open".
|
|
20243
|
+
* Nothing in this codebase may read an absent `durationMs` as an open
|
|
20244
|
+
* episode; only `null` means open.
|
|
20245
|
+
*/
|
|
20246
|
+
durationMs: number().nullable().optional(),
|
|
20247
|
+
/**
|
|
20248
|
+
* Ms offsets from `timestamp` (the episode's own first rising edge, so the
|
|
20249
|
+
* first entry is always `0`) of every genuine off→on transition the
|
|
20250
|
+
* episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
|
|
20251
|
+
* push: a firmware source that keepalives at ~1 Hz for the whole burst
|
|
20252
|
+
* (Reolink, Hikvision) produces exactly one edge; a source that reports an
|
|
20253
|
+
* explicit `false` mid-episode and then resumes before the quiet window
|
|
20254
|
+
* elapses produces another. Stored compactly — see `motion-edge-codec.ts`
|
|
20255
|
+
* — and decoded back to this shape on read. Absent/empty on a legacy row,
|
|
20256
|
+
* which must never be read as "no episode happened here".
|
|
20257
|
+
*/
|
|
20258
|
+
edges: array(number()).readonly().optional()
|
|
20184
20259
|
});
|
|
20185
20260
|
/**
|
|
20186
20261
|
* Which detection SOURCE produced an object event. `pipeline` = the ML
|
|
@@ -20235,6 +20310,23 @@ var ObjectEventSchema = object({
|
|
|
20235
20310
|
* includes it (it is light). Absent on rows written before this field.
|
|
20236
20311
|
*/
|
|
20237
20312
|
frameId: string().optional(),
|
|
20313
|
+
/**
|
|
20314
|
+
* A PRODUCER-chosen key that makes a synthetic event's emission idempotent
|
|
20315
|
+
* (D474).
|
|
20316
|
+
*
|
|
20317
|
+
* Only the package detector writes it, and it exists because the event id
|
|
20318
|
+
* stopped being choosable: the delivery and pick-up rows used to BE their
|
|
20319
|
+
* dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
|
|
20320
|
+
* second delivery for this entry" survived a restart. An `INTEGER` rowid is
|
|
20321
|
+
* assigned by SQLite, so that key had to move off the primary key rather
|
|
20322
|
+
* than be dropped — a detector that cannot recognise its own row re-delivers
|
|
20323
|
+
* every parcel on every boot.
|
|
20324
|
+
*
|
|
20325
|
+
* Absent on every other object event, and on every row written before this
|
|
20326
|
+
* field. Never a substitute for `id`: it is unique per (producer, occasion),
|
|
20327
|
+
* not per row, and nothing addresses a row by it.
|
|
20328
|
+
*/
|
|
20329
|
+
idempotencyKey: string().optional(),
|
|
20238
20330
|
/** Omitted in slim projection. */
|
|
20239
20331
|
trackId: string().optional(),
|
|
20240
20332
|
className: string(),
|
|
@@ -28588,26 +28680,59 @@ authKey: string().optional() }), object({
|
|
|
28588
28680
|
/** Human-readable error when `ok: false`. */
|
|
28589
28681
|
error: string().optional()
|
|
28590
28682
|
}), { kind: "mutation" });
|
|
28591
|
-
/**
|
|
28592
|
-
* Hardware / firmware motion sensor cap — binary detected state plus
|
|
28593
|
-
* a timestamp of the last observation. Distinct from
|
|
28594
|
-
* `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
|
|
28595
|
-
* `motion` is the lightweight readout from on-camera motion (Reolink
|
|
28596
|
-
* `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
|
|
28597
|
-
*
|
|
28598
|
-
* Native-motion providers also fan out to `detection.camera-native`
|
|
28599
|
-
* with `source: 'onboard'` so cross-cutting system services
|
|
28600
|
-
* (alert-center, advanced-notifier) can subscribe once and receive
|
|
28601
|
-
* motion from every camera.
|
|
28602
|
-
*/
|
|
28603
28683
|
var MotionStatusSchema = object({
|
|
28604
28684
|
detected: boolean(),
|
|
28605
28685
|
/** Ms epoch of the last detected-true observation. Null if never detected. */
|
|
28606
28686
|
lastDetectedAt: number().nullable(),
|
|
28607
28687
|
/**
|
|
28608
|
-
*
|
|
28609
|
-
*
|
|
28610
|
-
*
|
|
28688
|
+
* `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
|
|
28689
|
+
* `null` while false and on every `Sensor` device (D475) — see that
|
|
28690
|
+
* constant's doc for the one-authority rule.
|
|
28691
|
+
*
|
|
28692
|
+
* ## Reading this field still arms nothing
|
|
28693
|
+
*
|
|
28694
|
+
* It reads like an instruction to the consumer ("revert after N ms if
|
|
28695
|
+
* no fresh push arrives") and it is not one: nothing in this repo reads
|
|
28696
|
+
* the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
|
|
28697
|
+
* close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
|
|
28698
|
+
* imported constant, not as a read of `device.state.motion.value`, so this
|
|
28699
|
+
* field stays what it always was: DESCRIPTIVE output, mirroring an answer
|
|
28700
|
+
* computed elsewhere. Building a self-clear timer out of a READ of this
|
|
28701
|
+
* field would add a second falling-edge authority beside whichever one
|
|
28702
|
+
* already owns the device, and two that can disagree are worse than one.
|
|
28703
|
+
* Consumers that need a falling edge SHAPED differently — held open across
|
|
28704
|
+
* a flapping source — debounce on their own side and say so, as
|
|
28705
|
+
* `addon-export-alexa/src/motion-clear-hold.ts` and
|
|
28706
|
+
* `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
|
|
28707
|
+
*
|
|
28708
|
+
* ## Who writes it
|
|
28709
|
+
*
|
|
28710
|
+
* - **Cameras** — the runner's phase machine, `active → watching` on
|
|
28711
|
+
* `cooldown_expired`, which then writes this slice with
|
|
28712
|
+
* `detected: false` (`handlePhaseChanged` in
|
|
28713
|
+
* `pipeline-runner/index.ts`). It produces the FALLING edge, which
|
|
28714
|
+
* matters most for the sources that only ever push a rising one:
|
|
28715
|
+
* Reolink emits `MotionOnMotionChanged { detected: true }` and never
|
|
28716
|
+
* a false.
|
|
28717
|
+
* - **Sensors** (Home Assistant binary sensors, Homematic) — the
|
|
28718
|
+
* provider pushes the false itself, from the upstream system's own
|
|
28719
|
+
* state change. No phase machine is involved.
|
|
28720
|
+
*
|
|
28721
|
+
* ### The phase machine is CANONICAL, not sole — and that is a defect
|
|
28722
|
+
*
|
|
28723
|
+
* An earlier revision of this docblock (mine, 2026-09-12) claimed the
|
|
28724
|
+
* phase machine is the sole writer for a camera. It is not.
|
|
28725
|
+
* `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
|
|
28726
|
+
* `setCapSlice(motionCapability, …)` on their own rising edge, and
|
|
28727
|
+
* Hikvision's comment says why: it read THIS docblock, agreed the
|
|
28728
|
+
* runner is canonical, and wrote anyway to avoid per-tick churn. So
|
|
28729
|
+
* two authorities can disagree about one slice, which this repo
|
|
28730
|
+
* forbids, and the doc said otherwise — which is worse than saying
|
|
28731
|
+
* nothing, because it reads as verification.
|
|
28732
|
+
*
|
|
28733
|
+
* This predates D475 and is not fixed there: the fix touches every
|
|
28734
|
+
* camera provider. Recorded in D475's Consequences. Do not restore the
|
|
28735
|
+
* "sole writer" wording without also removing the other writers.
|
|
28611
28736
|
*/
|
|
28612
28737
|
autoClearAfterMs: number().nullable()
|
|
28613
28738
|
});
|
|
@@ -28677,7 +28802,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
|
|
|
28677
28802
|
*/
|
|
28678
28803
|
runtimeState: MotionStatusSchema,
|
|
28679
28804
|
/**
|
|
28680
|
-
* Runtime-state durability: **session** —
|
|
28805
|
+
* Runtime-state durability: **session** — every writer of this slice
|
|
28806
|
+
* writes only on an EDGE, so a restored `detected: true` would stay
|
|
28807
|
+
* frozen until the next one instead of being corrected. The next edge
|
|
28808
|
+
* re-publishes the real state. (On who the writers are, and why there
|
|
28809
|
+
* is more than one, see `autoClearAfterMs` above.)
|
|
28681
28810
|
*
|
|
28682
28811
|
* See `RuntimeStateDurability`. Enforced by
|
|
28683
28812
|
* `scripts/check-runtime-state-durability.ts`.
|