@camstack/addon-provider-amcrest 0.2.99 → 0.2.100

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.
Files changed (3) hide show
  1. package/dist/addon.js +165 -11
  2. package/dist/addon.mjs +165 -11
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -7298,6 +7298,23 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
7298
7298
  action: string().min(1),
7299
7299
  input: unknown()
7300
7300
  }), unknown(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
7301
+ new Set([
7302
+ "track",
7303
+ "summary",
7304
+ "face",
7305
+ "identity",
7306
+ "plate",
7307
+ "vehicle",
7308
+ "scene",
7309
+ "motion",
7310
+ "object",
7311
+ "audio"
7312
+ ]);
7313
+ new Set([
7314
+ "motion",
7315
+ "object",
7316
+ "audio"
7317
+ ]);
7301
7318
  var EncodeProfileSchema = object({
7302
7319
  video: object({
7303
7320
  codec: _enum([
@@ -12498,8 +12515,17 @@ method(object({
12498
12515
  }), array(SettingsRecordSchema).readonly()), method(object({
12499
12516
  namespace: string().optional(),
12500
12517
  collection: string(),
12501
- record: SettingsRecordSchema
12502
- }), _void(), { kind: "mutation" }), method(object({
12518
+ record: object({
12519
+ id: string().optional(),
12520
+ data: record(string(), unknown())
12521
+ })
12522
+ }), object({
12523
+ /**
12524
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12525
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12526
+ * primary key — which is the only place an auto key is knowable.
12527
+ */
12528
+ id: union([string(), number()]) }), { kind: "mutation" }), method(object({
12503
12529
  namespace: string().optional(),
12504
12530
  collection: string(),
12505
12531
  records: array(BulkRecordSchema).readonly()
@@ -12608,8 +12634,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
12608
12634
  }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
12609
12635
  namespace: string().optional(),
12610
12636
  collection: string(),
12611
- record: SettingsRecordSchema
12612
- }), _void(), {
12637
+ record: object({
12638
+ id: string().optional(),
12639
+ data: record(string(), unknown())
12640
+ })
12641
+ }), object({
12642
+ /**
12643
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12644
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12645
+ * primary key — which is the only place an auto key is knowable.
12646
+ */
12647
+ id: union([string(), number()]) }), {
12613
12648
  kind: "mutation",
12614
12649
  auth: "admin"
12615
12650
  }), method(object({
@@ -19517,7 +19552,20 @@ var TrackSchema = object({
19517
19552
  ...TrackRetrainFields
19518
19553
  });
19519
19554
  var BaseEventFields = {
19520
- id: string(),
19555
+ /**
19556
+ * A SQLite ROWID, assigned by the database (D474).
19557
+ *
19558
+ * Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
19559
+ * TWICE per row, in the row and in the primary-key index, across 2.1 million
19560
+ * motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
19561
+ * the rowid: the table itself is that B-tree, so the index stops existing
19562
+ * rather than getting smaller. No shorter string does that.
19563
+ *
19564
+ * Defined once here for all three event kinds, which is why they move
19565
+ * together: a per-table migration would have forked this and
19566
+ * `COMMON_BASE_COLUMNS` and reunited them two stages later.
19567
+ */
19568
+ id: number().int(),
19521
19569
  deviceId: number(),
19522
19570
  timestamp: number()
19523
19571
  };
@@ -19536,7 +19584,34 @@ var MotionEventSchema = object({
19536
19584
  /** Omitted in slim projection. */
19537
19585
  frameHeight: number().optional(),
19538
19586
  /** Populated by B5 (recording playback URL for this event). */
19539
- mediaUrl: string().optional()
19587
+ mediaUrl: string().optional(),
19588
+ /**
19589
+ * One row per motion EPISODE, not one per push (D475). `null` while the
19590
+ * episode is still open — a further rising edge extends it in place rather
19591
+ * than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
19592
+ * (the span from the first rising edge to the LAST one, deliberately NOT
19593
+ * `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
19594
+ * movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
19595
+ * motion for an instantaneous trigger).
19596
+ *
19597
+ * **Absent** (not merely `null`) on a row written before D475 — that means
19598
+ * "closed the old way, before this column existed", never "still open".
19599
+ * Nothing in this codebase may read an absent `durationMs` as an open
19600
+ * episode; only `null` means open.
19601
+ */
19602
+ durationMs: number().nullable().optional(),
19603
+ /**
19604
+ * Ms offsets from `timestamp` (the episode's own first rising edge, so the
19605
+ * first entry is always `0`) of every genuine off→on transition the
19606
+ * episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
19607
+ * push: a firmware source that keepalives at ~1 Hz for the whole burst
19608
+ * (Reolink, Hikvision) produces exactly one edge; a source that reports an
19609
+ * explicit `false` mid-episode and then resumes before the quiet window
19610
+ * elapses produces another. Stored compactly — see `motion-edge-codec.ts`
19611
+ * — and decoded back to this shape on read. Absent/empty on a legacy row,
19612
+ * which must never be read as "no episode happened here".
19613
+ */
19614
+ edges: array(number()).readonly().optional()
19540
19615
  });
19541
19616
  /**
19542
19617
  * Which detection SOURCE produced an object event. `pipeline` = the ML
@@ -19591,6 +19666,23 @@ var ObjectEventSchema = object({
19591
19666
  * includes it (it is light). Absent on rows written before this field.
19592
19667
  */
19593
19668
  frameId: string().optional(),
19669
+ /**
19670
+ * A PRODUCER-chosen key that makes a synthetic event's emission idempotent
19671
+ * (D474).
19672
+ *
19673
+ * Only the package detector writes it, and it exists because the event id
19674
+ * stopped being choosable: the delivery and pick-up rows used to BE their
19675
+ * dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
19676
+ * second delivery for this entry" survived a restart. An `INTEGER` rowid is
19677
+ * assigned by SQLite, so that key had to move off the primary key rather
19678
+ * than be dropped — a detector that cannot recognise its own row re-delivers
19679
+ * every parcel on every boot.
19680
+ *
19681
+ * Absent on every other object event, and on every row written before this
19682
+ * field. Never a substitute for `id`: it is unique per (producer, occasion),
19683
+ * not per row, and nothing addresses a row by it.
19684
+ */
19685
+ idempotencyKey: string().optional(),
19594
19686
  /** Omitted in slim projection. */
19595
19687
  trackId: string().optional(),
19596
19688
  className: string(),
@@ -27956,14 +28048,72 @@ authKey: string().optional() }), object({
27956
28048
  * (alert-center, advanced-notifier) can subscribe once and receive
27957
28049
  * motion from every camera.
27958
28050
  */
28051
+ /**
28052
+ * How long after a camera's last rising edge `pipeline-analytics` closes the
28053
+ * motion EPISODE row it kept open for it (D475) — "il delay della cap", in
28054
+ * the operator's words. One authority for the whole system: every provider
28055
+ * that seeds `autoClearAfterMs` on a `Camera` device writes this SAME
28056
+ * constant while `detected: true` (never its own number — Hikvision used to
28057
+ * seed its internal 3 s inactivity timer here, which is a different clock for
28058
+ * a different purpose), and `MotionEpisodeTracker` imports it directly rather
28059
+ * than reading the live cap value on the hot path. A `Sensor` device (HA
28060
+ * binary sensor, Homematic) gets a genuine push both ways and has no episode
28061
+ * to close on a timer, so it writes `null`, never this constant.
28062
+ */
28063
+ var MOTION_CLOSE_AFTER_MS = 15e3;
27959
28064
  var MotionStatusSchema = object({
27960
28065
  detected: boolean(),
27961
28066
  /** Ms epoch of the last detected-true observation. Null if never detected. */
27962
28067
  lastDetectedAt: number().nullable(),
27963
28068
  /**
27964
- * Ms after which `detected` auto-reverts to false if no fresh push
27965
- * arrives. Null means the provider leaves detected state until a
27966
- * native "clear" event.
28069
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
28070
+ * `null` while false and on every `Sensor` device (D475) — see that
28071
+ * constant's doc for the one-authority rule.
28072
+ *
28073
+ * ## Reading this field still arms nothing
28074
+ *
28075
+ * It reads like an instruction to the consumer ("revert after N ms if
28076
+ * no fresh push arrives") and it is not one: nothing in this repo reads
28077
+ * the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
28078
+ * close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
28079
+ * imported constant, not as a read of `device.state.motion.value`, so this
28080
+ * field stays what it always was: DESCRIPTIVE output, mirroring an answer
28081
+ * computed elsewhere. Building a self-clear timer out of a READ of this
28082
+ * field would add a second falling-edge authority beside whichever one
28083
+ * already owns the device, and two that can disagree are worse than one.
28084
+ * Consumers that need a falling edge SHAPED differently — held open across
28085
+ * a flapping source — debounce on their own side and say so, as
28086
+ * `addon-export-alexa/src/motion-clear-hold.ts` and
28087
+ * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
28088
+ *
28089
+ * ## Who writes it
28090
+ *
28091
+ * - **Cameras** — the runner's phase machine, `active → watching` on
28092
+ * `cooldown_expired`, which then writes this slice with
28093
+ * `detected: false` (`handlePhaseChanged` in
28094
+ * `pipeline-runner/index.ts`). It produces the FALLING edge, which
28095
+ * matters most for the sources that only ever push a rising one:
28096
+ * Reolink emits `MotionOnMotionChanged { detected: true }` and never
28097
+ * a false.
28098
+ * - **Sensors** (Home Assistant binary sensors, Homematic) — the
28099
+ * provider pushes the false itself, from the upstream system's own
28100
+ * state change. No phase machine is involved.
28101
+ *
28102
+ * ### The phase machine is CANONICAL, not sole — and that is a defect
28103
+ *
28104
+ * An earlier revision of this docblock (mine, 2026-09-12) claimed the
28105
+ * phase machine is the sole writer for a camera. It is not.
28106
+ * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
28107
+ * `setCapSlice(motionCapability, …)` on their own rising edge, and
28108
+ * Hikvision's comment says why: it read THIS docblock, agreed the
28109
+ * runner is canonical, and wrote anyway to avoid per-tick churn. So
28110
+ * two authorities can disagree about one slice, which this repo
28111
+ * forbids, and the doc said otherwise — which is worse than saying
28112
+ * nothing, because it reads as verification.
28113
+ *
28114
+ * This predates D475 and is not fixed there: the fix touches every
28115
+ * camera provider. Recorded in D475's Consequences. Do not restore the
28116
+ * "sole writer" wording without also removing the other writers.
27967
28117
  */
27968
28118
  autoClearAfterMs: number().nullable()
27969
28119
  });
@@ -28033,7 +28183,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
28033
28183
  */
28034
28184
  runtimeState: MotionStatusSchema,
28035
28185
  /**
28036
- * Runtime-state durability: **session** — self-clearing by construction (`autoClearAfterMs`); a restored `detected: true` is a frozen event, and the next frame re-publishes the real one.
28186
+ * Runtime-state durability: **session** — every writer of this slice
28187
+ * writes only on an EDGE, so a restored `detected: true` would stay
28188
+ * frozen until the next one instead of being corrected. The next edge
28189
+ * re-publishes the real state. (On who the writers are, and why there
28190
+ * is more than one, see `autoClearAfterMs` above.)
28037
28191
  *
28038
28192
  * See `RuntimeStateDurability`. Enforced by
28039
28193
  * `scripts/check-runtime-state-durability.ts`.
@@ -45291,7 +45445,7 @@ var AmcrestCamera = class AmcrestCamera extends BaseDevice {
45291
45445
  this.setCapSlice(motionCapability, {
45292
45446
  detected: true,
45293
45447
  lastDetectedAt: now,
45294
- autoClearAfterMs: null
45448
+ autoClearAfterMs: MOTION_CLOSE_AFTER_MS
45295
45449
  });
45296
45450
  this.ctx.logger.info("amcrest: onboard motion started", { tags: { deviceId: this.id } });
45297
45451
  }
package/dist/addon.mjs CHANGED
@@ -7299,6 +7299,23 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
7299
7299
  action: string().min(1),
7300
7300
  input: unknown()
7301
7301
  }), unknown(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
7302
+ new Set([
7303
+ "track",
7304
+ "summary",
7305
+ "face",
7306
+ "identity",
7307
+ "plate",
7308
+ "vehicle",
7309
+ "scene",
7310
+ "motion",
7311
+ "object",
7312
+ "audio"
7313
+ ]);
7314
+ new Set([
7315
+ "motion",
7316
+ "object",
7317
+ "audio"
7318
+ ]);
7302
7319
  var EncodeProfileSchema = object({
7303
7320
  video: object({
7304
7321
  codec: _enum([
@@ -12499,8 +12516,17 @@ method(object({
12499
12516
  }), array(SettingsRecordSchema).readonly()), method(object({
12500
12517
  namespace: string().optional(),
12501
12518
  collection: string(),
12502
- record: SettingsRecordSchema
12503
- }), _void(), { kind: "mutation" }), method(object({
12519
+ record: object({
12520
+ id: string().optional(),
12521
+ data: record(string(), unknown())
12522
+ })
12523
+ }), object({
12524
+ /**
12525
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12526
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12527
+ * primary key — which is the only place an auto key is knowable.
12528
+ */
12529
+ id: union([string(), number()]) }), { kind: "mutation" }), method(object({
12504
12530
  namespace: string().optional(),
12505
12531
  collection: string(),
12506
12532
  records: array(BulkRecordSchema).readonly()
@@ -12609,8 +12635,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
12609
12635
  }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
12610
12636
  namespace: string().optional(),
12611
12637
  collection: string(),
12612
- record: SettingsRecordSchema
12613
- }), _void(), {
12638
+ record: object({
12639
+ id: string().optional(),
12640
+ data: record(string(), unknown())
12641
+ })
12642
+ }), object({
12643
+ /**
12644
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12645
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12646
+ * primary key — which is the only place an auto key is knowable.
12647
+ */
12648
+ id: union([string(), number()]) }), {
12614
12649
  kind: "mutation",
12615
12650
  auth: "admin"
12616
12651
  }), method(object({
@@ -19518,7 +19553,20 @@ var TrackSchema = object({
19518
19553
  ...TrackRetrainFields
19519
19554
  });
19520
19555
  var BaseEventFields = {
19521
- id: string(),
19556
+ /**
19557
+ * A SQLite ROWID, assigned by the database (D474).
19558
+ *
19559
+ * Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
19560
+ * TWICE per row, in the row and in the primary-key index, across 2.1 million
19561
+ * motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
19562
+ * the rowid: the table itself is that B-tree, so the index stops existing
19563
+ * rather than getting smaller. No shorter string does that.
19564
+ *
19565
+ * Defined once here for all three event kinds, which is why they move
19566
+ * together: a per-table migration would have forked this and
19567
+ * `COMMON_BASE_COLUMNS` and reunited them two stages later.
19568
+ */
19569
+ id: number().int(),
19522
19570
  deviceId: number(),
19523
19571
  timestamp: number()
19524
19572
  };
@@ -19537,7 +19585,34 @@ var MotionEventSchema = object({
19537
19585
  /** Omitted in slim projection. */
19538
19586
  frameHeight: number().optional(),
19539
19587
  /** Populated by B5 (recording playback URL for this event). */
19540
- mediaUrl: string().optional()
19588
+ mediaUrl: string().optional(),
19589
+ /**
19590
+ * One row per motion EPISODE, not one per push (D475). `null` while the
19591
+ * episode is still open — a further rising edge extends it in place rather
19592
+ * than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
19593
+ * (the span from the first rising edge to the LAST one, deliberately NOT
19594
+ * `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
19595
+ * movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
19596
+ * motion for an instantaneous trigger).
19597
+ *
19598
+ * **Absent** (not merely `null`) on a row written before D475 — that means
19599
+ * "closed the old way, before this column existed", never "still open".
19600
+ * Nothing in this codebase may read an absent `durationMs` as an open
19601
+ * episode; only `null` means open.
19602
+ */
19603
+ durationMs: number().nullable().optional(),
19604
+ /**
19605
+ * Ms offsets from `timestamp` (the episode's own first rising edge, so the
19606
+ * first entry is always `0`) of every genuine off→on transition the
19607
+ * episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
19608
+ * push: a firmware source that keepalives at ~1 Hz for the whole burst
19609
+ * (Reolink, Hikvision) produces exactly one edge; a source that reports an
19610
+ * explicit `false` mid-episode and then resumes before the quiet window
19611
+ * elapses produces another. Stored compactly — see `motion-edge-codec.ts`
19612
+ * — and decoded back to this shape on read. Absent/empty on a legacy row,
19613
+ * which must never be read as "no episode happened here".
19614
+ */
19615
+ edges: array(number()).readonly().optional()
19541
19616
  });
19542
19617
  /**
19543
19618
  * Which detection SOURCE produced an object event. `pipeline` = the ML
@@ -19592,6 +19667,23 @@ var ObjectEventSchema = object({
19592
19667
  * includes it (it is light). Absent on rows written before this field.
19593
19668
  */
19594
19669
  frameId: string().optional(),
19670
+ /**
19671
+ * A PRODUCER-chosen key that makes a synthetic event's emission idempotent
19672
+ * (D474).
19673
+ *
19674
+ * Only the package detector writes it, and it exists because the event id
19675
+ * stopped being choosable: the delivery and pick-up rows used to BE their
19676
+ * dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
19677
+ * second delivery for this entry" survived a restart. An `INTEGER` rowid is
19678
+ * assigned by SQLite, so that key had to move off the primary key rather
19679
+ * than be dropped — a detector that cannot recognise its own row re-delivers
19680
+ * every parcel on every boot.
19681
+ *
19682
+ * Absent on every other object event, and on every row written before this
19683
+ * field. Never a substitute for `id`: it is unique per (producer, occasion),
19684
+ * not per row, and nothing addresses a row by it.
19685
+ */
19686
+ idempotencyKey: string().optional(),
19595
19687
  /** Omitted in slim projection. */
19596
19688
  trackId: string().optional(),
19597
19689
  className: string(),
@@ -27957,14 +28049,72 @@ authKey: string().optional() }), object({
27957
28049
  * (alert-center, advanced-notifier) can subscribe once and receive
27958
28050
  * motion from every camera.
27959
28051
  */
28052
+ /**
28053
+ * How long after a camera's last rising edge `pipeline-analytics` closes the
28054
+ * motion EPISODE row it kept open for it (D475) — "il delay della cap", in
28055
+ * the operator's words. One authority for the whole system: every provider
28056
+ * that seeds `autoClearAfterMs` on a `Camera` device writes this SAME
28057
+ * constant while `detected: true` (never its own number — Hikvision used to
28058
+ * seed its internal 3 s inactivity timer here, which is a different clock for
28059
+ * a different purpose), and `MotionEpisodeTracker` imports it directly rather
28060
+ * than reading the live cap value on the hot path. A `Sensor` device (HA
28061
+ * binary sensor, Homematic) gets a genuine push both ways and has no episode
28062
+ * to close on a timer, so it writes `null`, never this constant.
28063
+ */
28064
+ var MOTION_CLOSE_AFTER_MS = 15e3;
27960
28065
  var MotionStatusSchema = object({
27961
28066
  detected: boolean(),
27962
28067
  /** Ms epoch of the last detected-true observation. Null if never detected. */
27963
28068
  lastDetectedAt: number().nullable(),
27964
28069
  /**
27965
- * Ms after which `detected` auto-reverts to false if no fresh push
27966
- * arrives. Null means the provider leaves detected state until a
27967
- * native "clear" event.
28070
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
28071
+ * `null` while false and on every `Sensor` device (D475) — see that
28072
+ * constant's doc for the one-authority rule.
28073
+ *
28074
+ * ## Reading this field still arms nothing
28075
+ *
28076
+ * It reads like an instruction to the consumer ("revert after N ms if
28077
+ * no fresh push arrives") and it is not one: nothing in this repo reads
28078
+ * the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
28079
+ * close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
28080
+ * imported constant, not as a read of `device.state.motion.value`, so this
28081
+ * field stays what it always was: DESCRIPTIVE output, mirroring an answer
28082
+ * computed elsewhere. Building a self-clear timer out of a READ of this
28083
+ * field would add a second falling-edge authority beside whichever one
28084
+ * already owns the device, and two that can disagree are worse than one.
28085
+ * Consumers that need a falling edge SHAPED differently — held open across
28086
+ * a flapping source — debounce on their own side and say so, as
28087
+ * `addon-export-alexa/src/motion-clear-hold.ts` and
28088
+ * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
28089
+ *
28090
+ * ## Who writes it
28091
+ *
28092
+ * - **Cameras** — the runner's phase machine, `active → watching` on
28093
+ * `cooldown_expired`, which then writes this slice with
28094
+ * `detected: false` (`handlePhaseChanged` in
28095
+ * `pipeline-runner/index.ts`). It produces the FALLING edge, which
28096
+ * matters most for the sources that only ever push a rising one:
28097
+ * Reolink emits `MotionOnMotionChanged { detected: true }` and never
28098
+ * a false.
28099
+ * - **Sensors** (Home Assistant binary sensors, Homematic) — the
28100
+ * provider pushes the false itself, from the upstream system's own
28101
+ * state change. No phase machine is involved.
28102
+ *
28103
+ * ### The phase machine is CANONICAL, not sole — and that is a defect
28104
+ *
28105
+ * An earlier revision of this docblock (mine, 2026-09-12) claimed the
28106
+ * phase machine is the sole writer for a camera. It is not.
28107
+ * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
28108
+ * `setCapSlice(motionCapability, …)` on their own rising edge, and
28109
+ * Hikvision's comment says why: it read THIS docblock, agreed the
28110
+ * runner is canonical, and wrote anyway to avoid per-tick churn. So
28111
+ * two authorities can disagree about one slice, which this repo
28112
+ * forbids, and the doc said otherwise — which is worse than saying
28113
+ * nothing, because it reads as verification.
28114
+ *
28115
+ * This predates D475 and is not fixed there: the fix touches every
28116
+ * camera provider. Recorded in D475's Consequences. Do not restore the
28117
+ * "sole writer" wording without also removing the other writers.
27968
28118
  */
27969
28119
  autoClearAfterMs: number().nullable()
27970
28120
  });
@@ -28034,7 +28184,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
28034
28184
  */
28035
28185
  runtimeState: MotionStatusSchema,
28036
28186
  /**
28037
- * Runtime-state durability: **session** — self-clearing by construction (`autoClearAfterMs`); a restored `detected: true` is a frozen event, and the next frame re-publishes the real one.
28187
+ * Runtime-state durability: **session** — every writer of this slice
28188
+ * writes only on an EDGE, so a restored `detected: true` would stay
28189
+ * frozen until the next one instead of being corrected. The next edge
28190
+ * re-publishes the real state. (On who the writers are, and why there
28191
+ * is more than one, see `autoClearAfterMs` above.)
28038
28192
  *
28039
28193
  * See `RuntimeStateDurability`. Enforced by
28040
28194
  * `scripts/check-runtime-state-durability.ts`.
@@ -45292,7 +45446,7 @@ var AmcrestCamera = class AmcrestCamera extends BaseDevice {
45292
45446
  this.setCapSlice(motionCapability, {
45293
45447
  detected: true,
45294
45448
  lastDetectedAt: now,
45295
- autoClearAfterMs: null
45449
+ autoClearAfterMs: MOTION_CLOSE_AFTER_MS
45296
45450
  });
45297
45451
  this.ctx.logger.info("amcrest: onboard motion started", { tags: { deviceId: this.id } });
45298
45452
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-amcrest",
3
- "version": "0.2.99",
3
+ "version": "0.2.100",
4
4
  "description": "Amcrest/Dahua camera device provider addon for CamStack — Dahua CGI over HTTP(S) with digest auth (snapshot, RTSP catalog, PTZ, image/day-night config)",
5
5
  "keywords": [
6
6
  "camstack",