@camstack/addon-provider-unifi 0.2.97 → 0.2.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addon.js +151 -22
- package/dist/addon.mjs +151 -22
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -7303,6 +7303,23 @@ function errMsg(err) {
|
|
|
7303
7303
|
if (typeof err === "string") return err;
|
|
7304
7304
|
return String(err);
|
|
7305
7305
|
}
|
|
7306
|
+
new Set([
|
|
7307
|
+
"track",
|
|
7308
|
+
"summary",
|
|
7309
|
+
"face",
|
|
7310
|
+
"identity",
|
|
7311
|
+
"plate",
|
|
7312
|
+
"vehicle",
|
|
7313
|
+
"scene",
|
|
7314
|
+
"motion",
|
|
7315
|
+
"object",
|
|
7316
|
+
"audio"
|
|
7317
|
+
]);
|
|
7318
|
+
new Set([
|
|
7319
|
+
"motion",
|
|
7320
|
+
"object",
|
|
7321
|
+
"audio"
|
|
7322
|
+
]);
|
|
7306
7323
|
var EncodeProfileSchema = object({
|
|
7307
7324
|
video: object({
|
|
7308
7325
|
codec: _enum([
|
|
@@ -12503,8 +12520,17 @@ method(object({
|
|
|
12503
12520
|
}), array(SettingsRecordSchema).readonly()), method(object({
|
|
12504
12521
|
namespace: string().optional(),
|
|
12505
12522
|
collection: string(),
|
|
12506
|
-
record:
|
|
12507
|
-
|
|
12523
|
+
record: object({
|
|
12524
|
+
id: string().optional(),
|
|
12525
|
+
data: record(string(), unknown())
|
|
12526
|
+
})
|
|
12527
|
+
}), object({
|
|
12528
|
+
/**
|
|
12529
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12530
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12531
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12532
|
+
*/
|
|
12533
|
+
id: union([string(), number()]) }), { kind: "mutation" }), method(object({
|
|
12508
12534
|
namespace: string().optional(),
|
|
12509
12535
|
collection: string(),
|
|
12510
12536
|
records: array(BulkRecordSchema).readonly()
|
|
@@ -12613,8 +12639,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
|
|
|
12613
12639
|
}), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
|
|
12614
12640
|
namespace: string().optional(),
|
|
12615
12641
|
collection: string(),
|
|
12616
|
-
record:
|
|
12617
|
-
|
|
12642
|
+
record: object({
|
|
12643
|
+
id: string().optional(),
|
|
12644
|
+
data: record(string(), unknown())
|
|
12645
|
+
})
|
|
12646
|
+
}), object({
|
|
12647
|
+
/**
|
|
12648
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12649
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12650
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12651
|
+
*/
|
|
12652
|
+
id: union([string(), number()]) }), {
|
|
12618
12653
|
kind: "mutation",
|
|
12619
12654
|
auth: "admin"
|
|
12620
12655
|
}), method(object({
|
|
@@ -19522,7 +19557,20 @@ var TrackSchema = object({
|
|
|
19522
19557
|
...TrackRetrainFields
|
|
19523
19558
|
});
|
|
19524
19559
|
var BaseEventFields = {
|
|
19525
|
-
|
|
19560
|
+
/**
|
|
19561
|
+
* A SQLite ROWID, assigned by the database (D474).
|
|
19562
|
+
*
|
|
19563
|
+
* Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
|
|
19564
|
+
* TWICE per row, in the row and in the primary-key index, across 2.1 million
|
|
19565
|
+
* motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
|
|
19566
|
+
* the rowid: the table itself is that B-tree, so the index stops existing
|
|
19567
|
+
* rather than getting smaller. No shorter string does that.
|
|
19568
|
+
*
|
|
19569
|
+
* Defined once here for all three event kinds, which is why they move
|
|
19570
|
+
* together: a per-table migration would have forked this and
|
|
19571
|
+
* `COMMON_BASE_COLUMNS` and reunited them two stages later.
|
|
19572
|
+
*/
|
|
19573
|
+
id: number().int(),
|
|
19526
19574
|
deviceId: number(),
|
|
19527
19575
|
timestamp: number()
|
|
19528
19576
|
};
|
|
@@ -19541,7 +19589,34 @@ var MotionEventSchema = object({
|
|
|
19541
19589
|
/** Omitted in slim projection. */
|
|
19542
19590
|
frameHeight: number().optional(),
|
|
19543
19591
|
/** Populated by B5 (recording playback URL for this event). */
|
|
19544
|
-
mediaUrl: string().optional()
|
|
19592
|
+
mediaUrl: string().optional(),
|
|
19593
|
+
/**
|
|
19594
|
+
* One row per motion EPISODE, not one per push (D475). `null` while the
|
|
19595
|
+
* episode is still open — a further rising edge extends it in place rather
|
|
19596
|
+
* than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
|
|
19597
|
+
* (the span from the first rising edge to the LAST one, deliberately NOT
|
|
19598
|
+
* `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
|
|
19599
|
+
* movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
|
|
19600
|
+
* motion for an instantaneous trigger).
|
|
19601
|
+
*
|
|
19602
|
+
* **Absent** (not merely `null`) on a row written before D475 — that means
|
|
19603
|
+
* "closed the old way, before this column existed", never "still open".
|
|
19604
|
+
* Nothing in this codebase may read an absent `durationMs` as an open
|
|
19605
|
+
* episode; only `null` means open.
|
|
19606
|
+
*/
|
|
19607
|
+
durationMs: number().nullable().optional(),
|
|
19608
|
+
/**
|
|
19609
|
+
* Ms offsets from `timestamp` (the episode's own first rising edge, so the
|
|
19610
|
+
* first entry is always `0`) of every genuine off→on transition the
|
|
19611
|
+
* episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
|
|
19612
|
+
* push: a firmware source that keepalives at ~1 Hz for the whole burst
|
|
19613
|
+
* (Reolink, Hikvision) produces exactly one edge; a source that reports an
|
|
19614
|
+
* explicit `false` mid-episode and then resumes before the quiet window
|
|
19615
|
+
* elapses produces another. Stored compactly — see `motion-edge-codec.ts`
|
|
19616
|
+
* — and decoded back to this shape on read. Absent/empty on a legacy row,
|
|
19617
|
+
* which must never be read as "no episode happened here".
|
|
19618
|
+
*/
|
|
19619
|
+
edges: array(number()).readonly().optional()
|
|
19545
19620
|
});
|
|
19546
19621
|
/**
|
|
19547
19622
|
* Which detection SOURCE produced an object event. `pipeline` = the ML
|
|
@@ -19596,6 +19671,23 @@ var ObjectEventSchema = object({
|
|
|
19596
19671
|
* includes it (it is light). Absent on rows written before this field.
|
|
19597
19672
|
*/
|
|
19598
19673
|
frameId: string().optional(),
|
|
19674
|
+
/**
|
|
19675
|
+
* A PRODUCER-chosen key that makes a synthetic event's emission idempotent
|
|
19676
|
+
* (D474).
|
|
19677
|
+
*
|
|
19678
|
+
* Only the package detector writes it, and it exists because the event id
|
|
19679
|
+
* stopped being choosable: the delivery and pick-up rows used to BE their
|
|
19680
|
+
* dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
|
|
19681
|
+
* second delivery for this entry" survived a restart. An `INTEGER` rowid is
|
|
19682
|
+
* assigned by SQLite, so that key had to move off the primary key rather
|
|
19683
|
+
* than be dropped — a detector that cannot recognise its own row re-delivers
|
|
19684
|
+
* every parcel on every boot.
|
|
19685
|
+
*
|
|
19686
|
+
* Absent on every other object event, and on every row written before this
|
|
19687
|
+
* field. Never a substitute for `id`: it is unique per (producer, occasion),
|
|
19688
|
+
* not per row, and nothing addresses a row by it.
|
|
19689
|
+
*/
|
|
19690
|
+
idempotencyKey: string().optional(),
|
|
19599
19691
|
/** Omitted in slim projection. */
|
|
19600
19692
|
trackId: string().optional(),
|
|
19601
19693
|
className: string(),
|
|
@@ -27862,26 +27954,59 @@ authKey: string().optional() }), object({
|
|
|
27862
27954
|
/** Human-readable error when `ok: false`. */
|
|
27863
27955
|
error: string().optional()
|
|
27864
27956
|
}), { kind: "mutation" });
|
|
27865
|
-
/**
|
|
27866
|
-
* Hardware / firmware motion sensor cap — binary detected state plus
|
|
27867
|
-
* a timestamp of the last observation. Distinct from
|
|
27868
|
-
* `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
|
|
27869
|
-
* `motion` is the lightweight readout from on-camera motion (Reolink
|
|
27870
|
-
* `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
|
|
27871
|
-
*
|
|
27872
|
-
* Native-motion providers also fan out to `detection.camera-native`
|
|
27873
|
-
* with `source: 'onboard'` so cross-cutting system services
|
|
27874
|
-
* (alert-center, advanced-notifier) can subscribe once and receive
|
|
27875
|
-
* motion from every camera.
|
|
27876
|
-
*/
|
|
27877
27957
|
var MotionStatusSchema = object({
|
|
27878
27958
|
detected: boolean(),
|
|
27879
27959
|
/** Ms epoch of the last detected-true observation. Null if never detected. */
|
|
27880
27960
|
lastDetectedAt: number().nullable(),
|
|
27881
27961
|
/**
|
|
27882
|
-
*
|
|
27883
|
-
*
|
|
27884
|
-
*
|
|
27962
|
+
* `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
|
|
27963
|
+
* `null` while false and on every `Sensor` device (D475) — see that
|
|
27964
|
+
* constant's doc for the one-authority rule.
|
|
27965
|
+
*
|
|
27966
|
+
* ## Reading this field still arms nothing
|
|
27967
|
+
*
|
|
27968
|
+
* It reads like an instruction to the consumer ("revert after N ms if
|
|
27969
|
+
* no fresh push arrives") and it is not one: nothing in this repo reads
|
|
27970
|
+
* the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
|
|
27971
|
+
* close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
|
|
27972
|
+
* imported constant, not as a read of `device.state.motion.value`, so this
|
|
27973
|
+
* field stays what it always was: DESCRIPTIVE output, mirroring an answer
|
|
27974
|
+
* computed elsewhere. Building a self-clear timer out of a READ of this
|
|
27975
|
+
* field would add a second falling-edge authority beside whichever one
|
|
27976
|
+
* already owns the device, and two that can disagree are worse than one.
|
|
27977
|
+
* Consumers that need a falling edge SHAPED differently — held open across
|
|
27978
|
+
* a flapping source — debounce on their own side and say so, as
|
|
27979
|
+
* `addon-export-alexa/src/motion-clear-hold.ts` and
|
|
27980
|
+
* `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
|
|
27981
|
+
*
|
|
27982
|
+
* ## Who writes it
|
|
27983
|
+
*
|
|
27984
|
+
* - **Cameras** — the runner's phase machine, `active → watching` on
|
|
27985
|
+
* `cooldown_expired`, which then writes this slice with
|
|
27986
|
+
* `detected: false` (`handlePhaseChanged` in
|
|
27987
|
+
* `pipeline-runner/index.ts`). It produces the FALLING edge, which
|
|
27988
|
+
* matters most for the sources that only ever push a rising one:
|
|
27989
|
+
* Reolink emits `MotionOnMotionChanged { detected: true }` and never
|
|
27990
|
+
* a false.
|
|
27991
|
+
* - **Sensors** (Home Assistant binary sensors, Homematic) — the
|
|
27992
|
+
* provider pushes the false itself, from the upstream system's own
|
|
27993
|
+
* state change. No phase machine is involved.
|
|
27994
|
+
*
|
|
27995
|
+
* ### The phase machine is CANONICAL, not sole — and that is a defect
|
|
27996
|
+
*
|
|
27997
|
+
* An earlier revision of this docblock (mine, 2026-09-12) claimed the
|
|
27998
|
+
* phase machine is the sole writer for a camera. It is not.
|
|
27999
|
+
* `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
|
|
28000
|
+
* `setCapSlice(motionCapability, …)` on their own rising edge, and
|
|
28001
|
+
* Hikvision's comment says why: it read THIS docblock, agreed the
|
|
28002
|
+
* runner is canonical, and wrote anyway to avoid per-tick churn. So
|
|
28003
|
+
* two authorities can disagree about one slice, which this repo
|
|
28004
|
+
* forbids, and the doc said otherwise — which is worse than saying
|
|
28005
|
+
* nothing, because it reads as verification.
|
|
28006
|
+
*
|
|
28007
|
+
* This predates D475 and is not fixed there: the fix touches every
|
|
28008
|
+
* camera provider. Recorded in D475's Consequences. Do not restore the
|
|
28009
|
+
* "sole writer" wording without also removing the other writers.
|
|
27885
28010
|
*/
|
|
27886
28011
|
autoClearAfterMs: number().nullable()
|
|
27887
28012
|
});
|
|
@@ -27951,7 +28076,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
|
|
|
27951
28076
|
*/
|
|
27952
28077
|
runtimeState: MotionStatusSchema,
|
|
27953
28078
|
/**
|
|
27954
|
-
* Runtime-state durability: **session** —
|
|
28079
|
+
* Runtime-state durability: **session** — every writer of this slice
|
|
28080
|
+
* writes only on an EDGE, so a restored `detected: true` would stay
|
|
28081
|
+
* frozen until the next one instead of being corrected. The next edge
|
|
28082
|
+
* re-publishes the real state. (On who the writers are, and why there
|
|
28083
|
+
* is more than one, see `autoClearAfterMs` above.)
|
|
27955
28084
|
*
|
|
27956
28085
|
* See `RuntimeStateDurability`. Enforced by
|
|
27957
28086
|
* `scripts/check-runtime-state-durability.ts`.
|
package/dist/addon.mjs
CHANGED
|
@@ -7302,6 +7302,23 @@ function errMsg(err) {
|
|
|
7302
7302
|
if (typeof err === "string") return err;
|
|
7303
7303
|
return String(err);
|
|
7304
7304
|
}
|
|
7305
|
+
new Set([
|
|
7306
|
+
"track",
|
|
7307
|
+
"summary",
|
|
7308
|
+
"face",
|
|
7309
|
+
"identity",
|
|
7310
|
+
"plate",
|
|
7311
|
+
"vehicle",
|
|
7312
|
+
"scene",
|
|
7313
|
+
"motion",
|
|
7314
|
+
"object",
|
|
7315
|
+
"audio"
|
|
7316
|
+
]);
|
|
7317
|
+
new Set([
|
|
7318
|
+
"motion",
|
|
7319
|
+
"object",
|
|
7320
|
+
"audio"
|
|
7321
|
+
]);
|
|
7305
7322
|
var EncodeProfileSchema = object({
|
|
7306
7323
|
video: object({
|
|
7307
7324
|
codec: _enum([
|
|
@@ -12502,8 +12519,17 @@ method(object({
|
|
|
12502
12519
|
}), array(SettingsRecordSchema).readonly()), method(object({
|
|
12503
12520
|
namespace: string().optional(),
|
|
12504
12521
|
collection: string(),
|
|
12505
|
-
record:
|
|
12506
|
-
|
|
12522
|
+
record: object({
|
|
12523
|
+
id: string().optional(),
|
|
12524
|
+
data: record(string(), unknown())
|
|
12525
|
+
})
|
|
12526
|
+
}), object({
|
|
12527
|
+
/**
|
|
12528
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12529
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12530
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12531
|
+
*/
|
|
12532
|
+
id: union([string(), number()]) }), { kind: "mutation" }), method(object({
|
|
12507
12533
|
namespace: string().optional(),
|
|
12508
12534
|
collection: string(),
|
|
12509
12535
|
records: array(BulkRecordSchema).readonly()
|
|
@@ -12612,8 +12638,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
|
|
|
12612
12638
|
}), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
|
|
12613
12639
|
namespace: string().optional(),
|
|
12614
12640
|
collection: string(),
|
|
12615
|
-
record:
|
|
12616
|
-
|
|
12641
|
+
record: object({
|
|
12642
|
+
id: string().optional(),
|
|
12643
|
+
data: record(string(), unknown())
|
|
12644
|
+
})
|
|
12645
|
+
}), object({
|
|
12646
|
+
/**
|
|
12647
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12648
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12649
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12650
|
+
*/
|
|
12651
|
+
id: union([string(), number()]) }), {
|
|
12617
12652
|
kind: "mutation",
|
|
12618
12653
|
auth: "admin"
|
|
12619
12654
|
}), method(object({
|
|
@@ -19521,7 +19556,20 @@ var TrackSchema = object({
|
|
|
19521
19556
|
...TrackRetrainFields
|
|
19522
19557
|
});
|
|
19523
19558
|
var BaseEventFields = {
|
|
19524
|
-
|
|
19559
|
+
/**
|
|
19560
|
+
* A SQLite ROWID, assigned by the database (D474).
|
|
19561
|
+
*
|
|
19562
|
+
* Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
|
|
19563
|
+
* TWICE per row, in the row and in the primary-key index, across 2.1 million
|
|
19564
|
+
* motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
|
|
19565
|
+
* the rowid: the table itself is that B-tree, so the index stops existing
|
|
19566
|
+
* rather than getting smaller. No shorter string does that.
|
|
19567
|
+
*
|
|
19568
|
+
* Defined once here for all three event kinds, which is why they move
|
|
19569
|
+
* together: a per-table migration would have forked this and
|
|
19570
|
+
* `COMMON_BASE_COLUMNS` and reunited them two stages later.
|
|
19571
|
+
*/
|
|
19572
|
+
id: number().int(),
|
|
19525
19573
|
deviceId: number(),
|
|
19526
19574
|
timestamp: number()
|
|
19527
19575
|
};
|
|
@@ -19540,7 +19588,34 @@ var MotionEventSchema = object({
|
|
|
19540
19588
|
/** Omitted in slim projection. */
|
|
19541
19589
|
frameHeight: number().optional(),
|
|
19542
19590
|
/** Populated by B5 (recording playback URL for this event). */
|
|
19543
|
-
mediaUrl: string().optional()
|
|
19591
|
+
mediaUrl: string().optional(),
|
|
19592
|
+
/**
|
|
19593
|
+
* One row per motion EPISODE, not one per push (D475). `null` while the
|
|
19594
|
+
* episode is still open — a further rising edge extends it in place rather
|
|
19595
|
+
* than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
|
|
19596
|
+
* (the span from the first rising edge to the LAST one, deliberately NOT
|
|
19597
|
+
* `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
|
|
19598
|
+
* movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
|
|
19599
|
+
* motion for an instantaneous trigger).
|
|
19600
|
+
*
|
|
19601
|
+
* **Absent** (not merely `null`) on a row written before D475 — that means
|
|
19602
|
+
* "closed the old way, before this column existed", never "still open".
|
|
19603
|
+
* Nothing in this codebase may read an absent `durationMs` as an open
|
|
19604
|
+
* episode; only `null` means open.
|
|
19605
|
+
*/
|
|
19606
|
+
durationMs: number().nullable().optional(),
|
|
19607
|
+
/**
|
|
19608
|
+
* Ms offsets from `timestamp` (the episode's own first rising edge, so the
|
|
19609
|
+
* first entry is always `0`) of every genuine off→on transition the
|
|
19610
|
+
* episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
|
|
19611
|
+
* push: a firmware source that keepalives at ~1 Hz for the whole burst
|
|
19612
|
+
* (Reolink, Hikvision) produces exactly one edge; a source that reports an
|
|
19613
|
+
* explicit `false` mid-episode and then resumes before the quiet window
|
|
19614
|
+
* elapses produces another. Stored compactly — see `motion-edge-codec.ts`
|
|
19615
|
+
* — and decoded back to this shape on read. Absent/empty on a legacy row,
|
|
19616
|
+
* which must never be read as "no episode happened here".
|
|
19617
|
+
*/
|
|
19618
|
+
edges: array(number()).readonly().optional()
|
|
19544
19619
|
});
|
|
19545
19620
|
/**
|
|
19546
19621
|
* Which detection SOURCE produced an object event. `pipeline` = the ML
|
|
@@ -19595,6 +19670,23 @@ var ObjectEventSchema = object({
|
|
|
19595
19670
|
* includes it (it is light). Absent on rows written before this field.
|
|
19596
19671
|
*/
|
|
19597
19672
|
frameId: string().optional(),
|
|
19673
|
+
/**
|
|
19674
|
+
* A PRODUCER-chosen key that makes a synthetic event's emission idempotent
|
|
19675
|
+
* (D474).
|
|
19676
|
+
*
|
|
19677
|
+
* Only the package detector writes it, and it exists because the event id
|
|
19678
|
+
* stopped being choosable: the delivery and pick-up rows used to BE their
|
|
19679
|
+
* dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
|
|
19680
|
+
* second delivery for this entry" survived a restart. An `INTEGER` rowid is
|
|
19681
|
+
* assigned by SQLite, so that key had to move off the primary key rather
|
|
19682
|
+
* than be dropped — a detector that cannot recognise its own row re-delivers
|
|
19683
|
+
* every parcel on every boot.
|
|
19684
|
+
*
|
|
19685
|
+
* Absent on every other object event, and on every row written before this
|
|
19686
|
+
* field. Never a substitute for `id`: it is unique per (producer, occasion),
|
|
19687
|
+
* not per row, and nothing addresses a row by it.
|
|
19688
|
+
*/
|
|
19689
|
+
idempotencyKey: string().optional(),
|
|
19598
19690
|
/** Omitted in slim projection. */
|
|
19599
19691
|
trackId: string().optional(),
|
|
19600
19692
|
className: string(),
|
|
@@ -27861,26 +27953,59 @@ authKey: string().optional() }), object({
|
|
|
27861
27953
|
/** Human-readable error when `ok: false`. */
|
|
27862
27954
|
error: string().optional()
|
|
27863
27955
|
}), { kind: "mutation" });
|
|
27864
|
-
/**
|
|
27865
|
-
* Hardware / firmware motion sensor cap — binary detected state plus
|
|
27866
|
-
* a timestamp of the last observation. Distinct from
|
|
27867
|
-
* `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
|
|
27868
|
-
* `motion` is the lightweight readout from on-camera motion (Reolink
|
|
27869
|
-
* `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
|
|
27870
|
-
*
|
|
27871
|
-
* Native-motion providers also fan out to `detection.camera-native`
|
|
27872
|
-
* with `source: 'onboard'` so cross-cutting system services
|
|
27873
|
-
* (alert-center, advanced-notifier) can subscribe once and receive
|
|
27874
|
-
* motion from every camera.
|
|
27875
|
-
*/
|
|
27876
27956
|
var MotionStatusSchema = object({
|
|
27877
27957
|
detected: boolean(),
|
|
27878
27958
|
/** Ms epoch of the last detected-true observation. Null if never detected. */
|
|
27879
27959
|
lastDetectedAt: number().nullable(),
|
|
27880
27960
|
/**
|
|
27881
|
-
*
|
|
27882
|
-
*
|
|
27883
|
-
*
|
|
27961
|
+
* `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
|
|
27962
|
+
* `null` while false and on every `Sensor` device (D475) — see that
|
|
27963
|
+
* constant's doc for the one-authority rule.
|
|
27964
|
+
*
|
|
27965
|
+
* ## Reading this field still arms nothing
|
|
27966
|
+
*
|
|
27967
|
+
* It reads like an instruction to the consumer ("revert after N ms if
|
|
27968
|
+
* no fresh push arrives") and it is not one: nothing in this repo reads
|
|
27969
|
+
* the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
|
|
27970
|
+
* close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
|
|
27971
|
+
* imported constant, not as a read of `device.state.motion.value`, so this
|
|
27972
|
+
* field stays what it always was: DESCRIPTIVE output, mirroring an answer
|
|
27973
|
+
* computed elsewhere. Building a self-clear timer out of a READ of this
|
|
27974
|
+
* field would add a second falling-edge authority beside whichever one
|
|
27975
|
+
* already owns the device, and two that can disagree are worse than one.
|
|
27976
|
+
* Consumers that need a falling edge SHAPED differently — held open across
|
|
27977
|
+
* a flapping source — debounce on their own side and say so, as
|
|
27978
|
+
* `addon-export-alexa/src/motion-clear-hold.ts` and
|
|
27979
|
+
* `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
|
|
27980
|
+
*
|
|
27981
|
+
* ## Who writes it
|
|
27982
|
+
*
|
|
27983
|
+
* - **Cameras** — the runner's phase machine, `active → watching` on
|
|
27984
|
+
* `cooldown_expired`, which then writes this slice with
|
|
27985
|
+
* `detected: false` (`handlePhaseChanged` in
|
|
27986
|
+
* `pipeline-runner/index.ts`). It produces the FALLING edge, which
|
|
27987
|
+
* matters most for the sources that only ever push a rising one:
|
|
27988
|
+
* Reolink emits `MotionOnMotionChanged { detected: true }` and never
|
|
27989
|
+
* a false.
|
|
27990
|
+
* - **Sensors** (Home Assistant binary sensors, Homematic) — the
|
|
27991
|
+
* provider pushes the false itself, from the upstream system's own
|
|
27992
|
+
* state change. No phase machine is involved.
|
|
27993
|
+
*
|
|
27994
|
+
* ### The phase machine is CANONICAL, not sole — and that is a defect
|
|
27995
|
+
*
|
|
27996
|
+
* An earlier revision of this docblock (mine, 2026-09-12) claimed the
|
|
27997
|
+
* phase machine is the sole writer for a camera. It is not.
|
|
27998
|
+
* `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
|
|
27999
|
+
* `setCapSlice(motionCapability, …)` on their own rising edge, and
|
|
28000
|
+
* Hikvision's comment says why: it read THIS docblock, agreed the
|
|
28001
|
+
* runner is canonical, and wrote anyway to avoid per-tick churn. So
|
|
28002
|
+
* two authorities can disagree about one slice, which this repo
|
|
28003
|
+
* forbids, and the doc said otherwise — which is worse than saying
|
|
28004
|
+
* nothing, because it reads as verification.
|
|
28005
|
+
*
|
|
28006
|
+
* This predates D475 and is not fixed there: the fix touches every
|
|
28007
|
+
* camera provider. Recorded in D475's Consequences. Do not restore the
|
|
28008
|
+
* "sole writer" wording without also removing the other writers.
|
|
27884
28009
|
*/
|
|
27885
28010
|
autoClearAfterMs: number().nullable()
|
|
27886
28011
|
});
|
|
@@ -27950,7 +28075,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
|
|
|
27950
28075
|
*/
|
|
27951
28076
|
runtimeState: MotionStatusSchema,
|
|
27952
28077
|
/**
|
|
27953
|
-
* Runtime-state durability: **session** —
|
|
28078
|
+
* Runtime-state durability: **session** — every writer of this slice
|
|
28079
|
+
* writes only on an EDGE, so a restored `detected: true` would stay
|
|
28080
|
+
* frozen until the next one instead of being corrected. The next edge
|
|
28081
|
+
* re-publishes the real state. (On who the writers are, and why there
|
|
28082
|
+
* is more than one, see `autoClearAfterMs` above.)
|
|
27954
28083
|
*
|
|
27955
28084
|
* See `RuntimeStateDurability`. Enforced by
|
|
27956
28085
|
* `scripts/check-runtime-state-durability.ts`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-provider-unifi",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.98",
|
|
4
4
|
"description": "UniFi Network controller device-provider addon for CamStack — local-controller infra switches/APs (as containers) + network-client presence. NO cameras/Protect.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|