@camstack/addon-provider-homematic 1.2.98 → 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
|
@@ -7312,6 +7312,23 @@ function errMsg(err) {
|
|
|
7312
7312
|
if (typeof err === "string") return err;
|
|
7313
7313
|
return String(err);
|
|
7314
7314
|
}
|
|
7315
|
+
new Set([
|
|
7316
|
+
"track",
|
|
7317
|
+
"summary",
|
|
7318
|
+
"face",
|
|
7319
|
+
"identity",
|
|
7320
|
+
"plate",
|
|
7321
|
+
"vehicle",
|
|
7322
|
+
"scene",
|
|
7323
|
+
"motion",
|
|
7324
|
+
"object",
|
|
7325
|
+
"audio"
|
|
7326
|
+
]);
|
|
7327
|
+
new Set([
|
|
7328
|
+
"motion",
|
|
7329
|
+
"object",
|
|
7330
|
+
"audio"
|
|
7331
|
+
]);
|
|
7315
7332
|
var EncodeProfileSchema = object({
|
|
7316
7333
|
video: object({
|
|
7317
7334
|
codec: _enum([
|
|
@@ -12561,8 +12578,17 @@ method(object({
|
|
|
12561
12578
|
}), array(SettingsRecordSchema).readonly()), method(object({
|
|
12562
12579
|
namespace: string().optional(),
|
|
12563
12580
|
collection: string(),
|
|
12564
|
-
record:
|
|
12565
|
-
|
|
12581
|
+
record: object({
|
|
12582
|
+
id: string().optional(),
|
|
12583
|
+
data: record(string(), unknown())
|
|
12584
|
+
})
|
|
12585
|
+
}), object({
|
|
12586
|
+
/**
|
|
12587
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12588
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12589
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12590
|
+
*/
|
|
12591
|
+
id: union([string(), number()]) }), { kind: "mutation" }), method(object({
|
|
12566
12592
|
namespace: string().optional(),
|
|
12567
12593
|
collection: string(),
|
|
12568
12594
|
records: array(BulkRecordSchema).readonly()
|
|
@@ -12671,8 +12697,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
|
|
|
12671
12697
|
}), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
|
|
12672
12698
|
namespace: string().optional(),
|
|
12673
12699
|
collection: string(),
|
|
12674
|
-
record:
|
|
12675
|
-
|
|
12700
|
+
record: object({
|
|
12701
|
+
id: string().optional(),
|
|
12702
|
+
data: record(string(), unknown())
|
|
12703
|
+
})
|
|
12704
|
+
}), object({
|
|
12705
|
+
/**
|
|
12706
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12707
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12708
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12709
|
+
*/
|
|
12710
|
+
id: union([string(), number()]) }), {
|
|
12676
12711
|
kind: "mutation",
|
|
12677
12712
|
auth: "admin"
|
|
12678
12713
|
}), method(object({
|
|
@@ -19597,7 +19632,20 @@ var TrackSchema = object({
|
|
|
19597
19632
|
...TrackRetrainFields
|
|
19598
19633
|
});
|
|
19599
19634
|
var BaseEventFields = {
|
|
19600
|
-
|
|
19635
|
+
/**
|
|
19636
|
+
* A SQLite ROWID, assigned by the database (D474).
|
|
19637
|
+
*
|
|
19638
|
+
* Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
|
|
19639
|
+
* TWICE per row, in the row and in the primary-key index, across 2.1 million
|
|
19640
|
+
* motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
|
|
19641
|
+
* the rowid: the table itself is that B-tree, so the index stops existing
|
|
19642
|
+
* rather than getting smaller. No shorter string does that.
|
|
19643
|
+
*
|
|
19644
|
+
* Defined once here for all three event kinds, which is why they move
|
|
19645
|
+
* together: a per-table migration would have forked this and
|
|
19646
|
+
* `COMMON_BASE_COLUMNS` and reunited them two stages later.
|
|
19647
|
+
*/
|
|
19648
|
+
id: number().int(),
|
|
19601
19649
|
deviceId: number(),
|
|
19602
19650
|
timestamp: number()
|
|
19603
19651
|
};
|
|
@@ -19616,7 +19664,34 @@ var MotionEventSchema = object({
|
|
|
19616
19664
|
/** Omitted in slim projection. */
|
|
19617
19665
|
frameHeight: number().optional(),
|
|
19618
19666
|
/** Populated by B5 (recording playback URL for this event). */
|
|
19619
|
-
mediaUrl: string().optional()
|
|
19667
|
+
mediaUrl: string().optional(),
|
|
19668
|
+
/**
|
|
19669
|
+
* One row per motion EPISODE, not one per push (D475). `null` while the
|
|
19670
|
+
* episode is still open — a further rising edge extends it in place rather
|
|
19671
|
+
* than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
|
|
19672
|
+
* (the span from the first rising edge to the LAST one, deliberately NOT
|
|
19673
|
+
* `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
|
|
19674
|
+
* movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
|
|
19675
|
+
* motion for an instantaneous trigger).
|
|
19676
|
+
*
|
|
19677
|
+
* **Absent** (not merely `null`) on a row written before D475 — that means
|
|
19678
|
+
* "closed the old way, before this column existed", never "still open".
|
|
19679
|
+
* Nothing in this codebase may read an absent `durationMs` as an open
|
|
19680
|
+
* episode; only `null` means open.
|
|
19681
|
+
*/
|
|
19682
|
+
durationMs: number().nullable().optional(),
|
|
19683
|
+
/**
|
|
19684
|
+
* Ms offsets from `timestamp` (the episode's own first rising edge, so the
|
|
19685
|
+
* first entry is always `0`) of every genuine off→on transition the
|
|
19686
|
+
* episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
|
|
19687
|
+
* push: a firmware source that keepalives at ~1 Hz for the whole burst
|
|
19688
|
+
* (Reolink, Hikvision) produces exactly one edge; a source that reports an
|
|
19689
|
+
* explicit `false` mid-episode and then resumes before the quiet window
|
|
19690
|
+
* elapses produces another. Stored compactly — see `motion-edge-codec.ts`
|
|
19691
|
+
* — and decoded back to this shape on read. Absent/empty on a legacy row,
|
|
19692
|
+
* which must never be read as "no episode happened here".
|
|
19693
|
+
*/
|
|
19694
|
+
edges: array(number()).readonly().optional()
|
|
19620
19695
|
});
|
|
19621
19696
|
/**
|
|
19622
19697
|
* Which detection SOURCE produced an object event. `pipeline` = the ML
|
|
@@ -19671,6 +19746,23 @@ var ObjectEventSchema = object({
|
|
|
19671
19746
|
* includes it (it is light). Absent on rows written before this field.
|
|
19672
19747
|
*/
|
|
19673
19748
|
frameId: string().optional(),
|
|
19749
|
+
/**
|
|
19750
|
+
* A PRODUCER-chosen key that makes a synthetic event's emission idempotent
|
|
19751
|
+
* (D474).
|
|
19752
|
+
*
|
|
19753
|
+
* Only the package detector writes it, and it exists because the event id
|
|
19754
|
+
* stopped being choosable: the delivery and pick-up rows used to BE their
|
|
19755
|
+
* dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
|
|
19756
|
+
* second delivery for this entry" survived a restart. An `INTEGER` rowid is
|
|
19757
|
+
* assigned by SQLite, so that key had to move off the primary key rather
|
|
19758
|
+
* than be dropped — a detector that cannot recognise its own row re-delivers
|
|
19759
|
+
* every parcel on every boot.
|
|
19760
|
+
*
|
|
19761
|
+
* Absent on every other object event, and on every row written before this
|
|
19762
|
+
* field. Never a substitute for `id`: it is unique per (producer, occasion),
|
|
19763
|
+
* not per row, and nothing addresses a row by it.
|
|
19764
|
+
*/
|
|
19765
|
+
idempotencyKey: string().optional(),
|
|
19674
19766
|
/** Omitted in slim projection. */
|
|
19675
19767
|
trackId: string().optional(),
|
|
19676
19768
|
className: string(),
|
|
@@ -27920,26 +28012,59 @@ authKey: string().optional() }), object({
|
|
|
27920
28012
|
/** Human-readable error when `ok: false`. */
|
|
27921
28013
|
error: string().optional()
|
|
27922
28014
|
}), { kind: "mutation" });
|
|
27923
|
-
/**
|
|
27924
|
-
* Hardware / firmware motion sensor cap — binary detected state plus
|
|
27925
|
-
* a timestamp of the last observation. Distinct from
|
|
27926
|
-
* `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
|
|
27927
|
-
* `motion` is the lightweight readout from on-camera motion (Reolink
|
|
27928
|
-
* `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
|
|
27929
|
-
*
|
|
27930
|
-
* Native-motion providers also fan out to `detection.camera-native`
|
|
27931
|
-
* with `source: 'onboard'` so cross-cutting system services
|
|
27932
|
-
* (alert-center, advanced-notifier) can subscribe once and receive
|
|
27933
|
-
* motion from every camera.
|
|
27934
|
-
*/
|
|
27935
28015
|
var MotionStatusSchema = object({
|
|
27936
28016
|
detected: boolean(),
|
|
27937
28017
|
/** Ms epoch of the last detected-true observation. Null if never detected. */
|
|
27938
28018
|
lastDetectedAt: number().nullable(),
|
|
27939
28019
|
/**
|
|
27940
|
-
*
|
|
27941
|
-
*
|
|
27942
|
-
*
|
|
28020
|
+
* `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
|
|
28021
|
+
* `null` while false and on every `Sensor` device (D475) — see that
|
|
28022
|
+
* constant's doc for the one-authority rule.
|
|
28023
|
+
*
|
|
28024
|
+
* ## Reading this field still arms nothing
|
|
28025
|
+
*
|
|
28026
|
+
* It reads like an instruction to the consumer ("revert after N ms if
|
|
28027
|
+
* no fresh push arrives") and it is not one: nothing in this repo reads
|
|
28028
|
+
* the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
|
|
28029
|
+
* close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
|
|
28030
|
+
* imported constant, not as a read of `device.state.motion.value`, so this
|
|
28031
|
+
* field stays what it always was: DESCRIPTIVE output, mirroring an answer
|
|
28032
|
+
* computed elsewhere. Building a self-clear timer out of a READ of this
|
|
28033
|
+
* field would add a second falling-edge authority beside whichever one
|
|
28034
|
+
* already owns the device, and two that can disagree are worse than one.
|
|
28035
|
+
* Consumers that need a falling edge SHAPED differently — held open across
|
|
28036
|
+
* a flapping source — debounce on their own side and say so, as
|
|
28037
|
+
* `addon-export-alexa/src/motion-clear-hold.ts` and
|
|
28038
|
+
* `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
|
|
28039
|
+
*
|
|
28040
|
+
* ## Who writes it
|
|
28041
|
+
*
|
|
28042
|
+
* - **Cameras** — the runner's phase machine, `active → watching` on
|
|
28043
|
+
* `cooldown_expired`, which then writes this slice with
|
|
28044
|
+
* `detected: false` (`handlePhaseChanged` in
|
|
28045
|
+
* `pipeline-runner/index.ts`). It produces the FALLING edge, which
|
|
28046
|
+
* matters most for the sources that only ever push a rising one:
|
|
28047
|
+
* Reolink emits `MotionOnMotionChanged { detected: true }` and never
|
|
28048
|
+
* a false.
|
|
28049
|
+
* - **Sensors** (Home Assistant binary sensors, Homematic) — the
|
|
28050
|
+
* provider pushes the false itself, from the upstream system's own
|
|
28051
|
+
* state change. No phase machine is involved.
|
|
28052
|
+
*
|
|
28053
|
+
* ### The phase machine is CANONICAL, not sole — and that is a defect
|
|
28054
|
+
*
|
|
28055
|
+
* An earlier revision of this docblock (mine, 2026-09-12) claimed the
|
|
28056
|
+
* phase machine is the sole writer for a camera. It is not.
|
|
28057
|
+
* `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
|
|
28058
|
+
* `setCapSlice(motionCapability, …)` on their own rising edge, and
|
|
28059
|
+
* Hikvision's comment says why: it read THIS docblock, agreed the
|
|
28060
|
+
* runner is canonical, and wrote anyway to avoid per-tick churn. So
|
|
28061
|
+
* two authorities can disagree about one slice, which this repo
|
|
28062
|
+
* forbids, and the doc said otherwise — which is worse than saying
|
|
28063
|
+
* nothing, because it reads as verification.
|
|
28064
|
+
*
|
|
28065
|
+
* This predates D475 and is not fixed there: the fix touches every
|
|
28066
|
+
* camera provider. Recorded in D475's Consequences. Do not restore the
|
|
28067
|
+
* "sole writer" wording without also removing the other writers.
|
|
27943
28068
|
*/
|
|
27944
28069
|
autoClearAfterMs: number().nullable()
|
|
27945
28070
|
});
|
|
@@ -28009,7 +28134,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
|
|
|
28009
28134
|
*/
|
|
28010
28135
|
runtimeState: MotionStatusSchema,
|
|
28011
28136
|
/**
|
|
28012
|
-
* Runtime-state durability: **session** —
|
|
28137
|
+
* Runtime-state durability: **session** — every writer of this slice
|
|
28138
|
+
* writes only on an EDGE, so a restored `detected: true` would stay
|
|
28139
|
+
* frozen until the next one instead of being corrected. The next edge
|
|
28140
|
+
* re-publishes the real state. (On who the writers are, and why there
|
|
28141
|
+
* is more than one, see `autoClearAfterMs` above.)
|
|
28013
28142
|
*
|
|
28014
28143
|
* See `RuntimeStateDurability`. Enforced by
|
|
28015
28144
|
* `scripts/check-runtime-state-durability.ts`.
|
package/dist/addon.mjs
CHANGED
|
@@ -7313,6 +7313,23 @@ function errMsg(err) {
|
|
|
7313
7313
|
if (typeof err === "string") return err;
|
|
7314
7314
|
return String(err);
|
|
7315
7315
|
}
|
|
7316
|
+
new Set([
|
|
7317
|
+
"track",
|
|
7318
|
+
"summary",
|
|
7319
|
+
"face",
|
|
7320
|
+
"identity",
|
|
7321
|
+
"plate",
|
|
7322
|
+
"vehicle",
|
|
7323
|
+
"scene",
|
|
7324
|
+
"motion",
|
|
7325
|
+
"object",
|
|
7326
|
+
"audio"
|
|
7327
|
+
]);
|
|
7328
|
+
new Set([
|
|
7329
|
+
"motion",
|
|
7330
|
+
"object",
|
|
7331
|
+
"audio"
|
|
7332
|
+
]);
|
|
7316
7333
|
var EncodeProfileSchema = object({
|
|
7317
7334
|
video: object({
|
|
7318
7335
|
codec: _enum([
|
|
@@ -12562,8 +12579,17 @@ method(object({
|
|
|
12562
12579
|
}), array(SettingsRecordSchema).readonly()), method(object({
|
|
12563
12580
|
namespace: string().optional(),
|
|
12564
12581
|
collection: string(),
|
|
12565
|
-
record:
|
|
12566
|
-
|
|
12582
|
+
record: object({
|
|
12583
|
+
id: string().optional(),
|
|
12584
|
+
data: record(string(), unknown())
|
|
12585
|
+
})
|
|
12586
|
+
}), object({
|
|
12587
|
+
/**
|
|
12588
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12589
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12590
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12591
|
+
*/
|
|
12592
|
+
id: union([string(), number()]) }), { kind: "mutation" }), method(object({
|
|
12567
12593
|
namespace: string().optional(),
|
|
12568
12594
|
collection: string(),
|
|
12569
12595
|
records: array(BulkRecordSchema).readonly()
|
|
@@ -12672,8 +12698,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
|
|
|
12672
12698
|
}), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
|
|
12673
12699
|
namespace: string().optional(),
|
|
12674
12700
|
collection: string(),
|
|
12675
|
-
record:
|
|
12676
|
-
|
|
12701
|
+
record: object({
|
|
12702
|
+
id: string().optional(),
|
|
12703
|
+
data: record(string(), unknown())
|
|
12704
|
+
})
|
|
12705
|
+
}), object({
|
|
12706
|
+
/**
|
|
12707
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12708
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12709
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12710
|
+
*/
|
|
12711
|
+
id: union([string(), number()]) }), {
|
|
12677
12712
|
kind: "mutation",
|
|
12678
12713
|
auth: "admin"
|
|
12679
12714
|
}), method(object({
|
|
@@ -19598,7 +19633,20 @@ var TrackSchema = object({
|
|
|
19598
19633
|
...TrackRetrainFields
|
|
19599
19634
|
});
|
|
19600
19635
|
var BaseEventFields = {
|
|
19601
|
-
|
|
19636
|
+
/**
|
|
19637
|
+
* A SQLite ROWID, assigned by the database (D474).
|
|
19638
|
+
*
|
|
19639
|
+
* Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
|
|
19640
|
+
* TWICE per row, in the row and in the primary-key index, across 2.1 million
|
|
19641
|
+
* motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
|
|
19642
|
+
* the rowid: the table itself is that B-tree, so the index stops existing
|
|
19643
|
+
* rather than getting smaller. No shorter string does that.
|
|
19644
|
+
*
|
|
19645
|
+
* Defined once here for all three event kinds, which is why they move
|
|
19646
|
+
* together: a per-table migration would have forked this and
|
|
19647
|
+
* `COMMON_BASE_COLUMNS` and reunited them two stages later.
|
|
19648
|
+
*/
|
|
19649
|
+
id: number().int(),
|
|
19602
19650
|
deviceId: number(),
|
|
19603
19651
|
timestamp: number()
|
|
19604
19652
|
};
|
|
@@ -19617,7 +19665,34 @@ var MotionEventSchema = object({
|
|
|
19617
19665
|
/** Omitted in slim projection. */
|
|
19618
19666
|
frameHeight: number().optional(),
|
|
19619
19667
|
/** Populated by B5 (recording playback URL for this event). */
|
|
19620
|
-
mediaUrl: string().optional()
|
|
19668
|
+
mediaUrl: string().optional(),
|
|
19669
|
+
/**
|
|
19670
|
+
* One row per motion EPISODE, not one per push (D475). `null` while the
|
|
19671
|
+
* episode is still open — a further rising edge extends it in place rather
|
|
19672
|
+
* than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
|
|
19673
|
+
* (the span from the first rising edge to the LAST one, deliberately NOT
|
|
19674
|
+
* `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
|
|
19675
|
+
* movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
|
|
19676
|
+
* motion for an instantaneous trigger).
|
|
19677
|
+
*
|
|
19678
|
+
* **Absent** (not merely `null`) on a row written before D475 — that means
|
|
19679
|
+
* "closed the old way, before this column existed", never "still open".
|
|
19680
|
+
* Nothing in this codebase may read an absent `durationMs` as an open
|
|
19681
|
+
* episode; only `null` means open.
|
|
19682
|
+
*/
|
|
19683
|
+
durationMs: number().nullable().optional(),
|
|
19684
|
+
/**
|
|
19685
|
+
* Ms offsets from `timestamp` (the episode's own first rising edge, so the
|
|
19686
|
+
* first entry is always `0`) of every genuine off→on transition the
|
|
19687
|
+
* episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
|
|
19688
|
+
* push: a firmware source that keepalives at ~1 Hz for the whole burst
|
|
19689
|
+
* (Reolink, Hikvision) produces exactly one edge; a source that reports an
|
|
19690
|
+
* explicit `false` mid-episode and then resumes before the quiet window
|
|
19691
|
+
* elapses produces another. Stored compactly — see `motion-edge-codec.ts`
|
|
19692
|
+
* — and decoded back to this shape on read. Absent/empty on a legacy row,
|
|
19693
|
+
* which must never be read as "no episode happened here".
|
|
19694
|
+
*/
|
|
19695
|
+
edges: array(number()).readonly().optional()
|
|
19621
19696
|
});
|
|
19622
19697
|
/**
|
|
19623
19698
|
* Which detection SOURCE produced an object event. `pipeline` = the ML
|
|
@@ -19672,6 +19747,23 @@ var ObjectEventSchema = object({
|
|
|
19672
19747
|
* includes it (it is light). Absent on rows written before this field.
|
|
19673
19748
|
*/
|
|
19674
19749
|
frameId: string().optional(),
|
|
19750
|
+
/**
|
|
19751
|
+
* A PRODUCER-chosen key that makes a synthetic event's emission idempotent
|
|
19752
|
+
* (D474).
|
|
19753
|
+
*
|
|
19754
|
+
* Only the package detector writes it, and it exists because the event id
|
|
19755
|
+
* stopped being choosable: the delivery and pick-up rows used to BE their
|
|
19756
|
+
* dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
|
|
19757
|
+
* second delivery for this entry" survived a restart. An `INTEGER` rowid is
|
|
19758
|
+
* assigned by SQLite, so that key had to move off the primary key rather
|
|
19759
|
+
* than be dropped — a detector that cannot recognise its own row re-delivers
|
|
19760
|
+
* every parcel on every boot.
|
|
19761
|
+
*
|
|
19762
|
+
* Absent on every other object event, and on every row written before this
|
|
19763
|
+
* field. Never a substitute for `id`: it is unique per (producer, occasion),
|
|
19764
|
+
* not per row, and nothing addresses a row by it.
|
|
19765
|
+
*/
|
|
19766
|
+
idempotencyKey: string().optional(),
|
|
19675
19767
|
/** Omitted in slim projection. */
|
|
19676
19768
|
trackId: string().optional(),
|
|
19677
19769
|
className: string(),
|
|
@@ -27921,26 +28013,59 @@ authKey: string().optional() }), object({
|
|
|
27921
28013
|
/** Human-readable error when `ok: false`. */
|
|
27922
28014
|
error: string().optional()
|
|
27923
28015
|
}), { kind: "mutation" });
|
|
27924
|
-
/**
|
|
27925
|
-
* Hardware / firmware motion sensor cap — binary detected state plus
|
|
27926
|
-
* a timestamp of the last observation. Distinct from
|
|
27927
|
-
* `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
|
|
27928
|
-
* `motion` is the lightweight readout from on-camera motion (Reolink
|
|
27929
|
-
* `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
|
|
27930
|
-
*
|
|
27931
|
-
* Native-motion providers also fan out to `detection.camera-native`
|
|
27932
|
-
* with `source: 'onboard'` so cross-cutting system services
|
|
27933
|
-
* (alert-center, advanced-notifier) can subscribe once and receive
|
|
27934
|
-
* motion from every camera.
|
|
27935
|
-
*/
|
|
27936
28016
|
var MotionStatusSchema = object({
|
|
27937
28017
|
detected: boolean(),
|
|
27938
28018
|
/** Ms epoch of the last detected-true observation. Null if never detected. */
|
|
27939
28019
|
lastDetectedAt: number().nullable(),
|
|
27940
28020
|
/**
|
|
27941
|
-
*
|
|
27942
|
-
*
|
|
27943
|
-
*
|
|
28021
|
+
* `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
|
|
28022
|
+
* `null` while false and on every `Sensor` device (D475) — see that
|
|
28023
|
+
* constant's doc for the one-authority rule.
|
|
28024
|
+
*
|
|
28025
|
+
* ## Reading this field still arms nothing
|
|
28026
|
+
*
|
|
28027
|
+
* It reads like an instruction to the consumer ("revert after N ms if
|
|
28028
|
+
* no fresh push arrives") and it is not one: nothing in this repo reads
|
|
28029
|
+
* the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
|
|
28030
|
+
* close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
|
|
28031
|
+
* imported constant, not as a read of `device.state.motion.value`, so this
|
|
28032
|
+
* field stays what it always was: DESCRIPTIVE output, mirroring an answer
|
|
28033
|
+
* computed elsewhere. Building a self-clear timer out of a READ of this
|
|
28034
|
+
* field would add a second falling-edge authority beside whichever one
|
|
28035
|
+
* already owns the device, and two that can disagree are worse than one.
|
|
28036
|
+
* Consumers that need a falling edge SHAPED differently — held open across
|
|
28037
|
+
* a flapping source — debounce on their own side and say so, as
|
|
28038
|
+
* `addon-export-alexa/src/motion-clear-hold.ts` and
|
|
28039
|
+
* `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
|
|
28040
|
+
*
|
|
28041
|
+
* ## Who writes it
|
|
28042
|
+
*
|
|
28043
|
+
* - **Cameras** — the runner's phase machine, `active → watching` on
|
|
28044
|
+
* `cooldown_expired`, which then writes this slice with
|
|
28045
|
+
* `detected: false` (`handlePhaseChanged` in
|
|
28046
|
+
* `pipeline-runner/index.ts`). It produces the FALLING edge, which
|
|
28047
|
+
* matters most for the sources that only ever push a rising one:
|
|
28048
|
+
* Reolink emits `MotionOnMotionChanged { detected: true }` and never
|
|
28049
|
+
* a false.
|
|
28050
|
+
* - **Sensors** (Home Assistant binary sensors, Homematic) — the
|
|
28051
|
+
* provider pushes the false itself, from the upstream system's own
|
|
28052
|
+
* state change. No phase machine is involved.
|
|
28053
|
+
*
|
|
28054
|
+
* ### The phase machine is CANONICAL, not sole — and that is a defect
|
|
28055
|
+
*
|
|
28056
|
+
* An earlier revision of this docblock (mine, 2026-09-12) claimed the
|
|
28057
|
+
* phase machine is the sole writer for a camera. It is not.
|
|
28058
|
+
* `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
|
|
28059
|
+
* `setCapSlice(motionCapability, …)` on their own rising edge, and
|
|
28060
|
+
* Hikvision's comment says why: it read THIS docblock, agreed the
|
|
28061
|
+
* runner is canonical, and wrote anyway to avoid per-tick churn. So
|
|
28062
|
+
* two authorities can disagree about one slice, which this repo
|
|
28063
|
+
* forbids, and the doc said otherwise — which is worse than saying
|
|
28064
|
+
* nothing, because it reads as verification.
|
|
28065
|
+
*
|
|
28066
|
+
* This predates D475 and is not fixed there: the fix touches every
|
|
28067
|
+
* camera provider. Recorded in D475's Consequences. Do not restore the
|
|
28068
|
+
* "sole writer" wording without also removing the other writers.
|
|
27944
28069
|
*/
|
|
27945
28070
|
autoClearAfterMs: number().nullable()
|
|
27946
28071
|
});
|
|
@@ -28010,7 +28135,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
|
|
|
28010
28135
|
*/
|
|
28011
28136
|
runtimeState: MotionStatusSchema,
|
|
28012
28137
|
/**
|
|
28013
|
-
* Runtime-state durability: **session** —
|
|
28138
|
+
* Runtime-state durability: **session** — every writer of this slice
|
|
28139
|
+
* writes only on an EDGE, so a restored `detected: true` would stay
|
|
28140
|
+
* frozen until the next one instead of being corrected. The next edge
|
|
28141
|
+
* re-publishes the real state. (On who the writers are, and why there
|
|
28142
|
+
* is more than one, see `autoClearAfterMs` above.)
|
|
28014
28143
|
*
|
|
28015
28144
|
* See `RuntimeStateDurability`. Enforced by
|
|
28016
28145
|
* `scripts/check-runtime-state-durability.ts`.
|
package/package.json
CHANGED