@camstack/addon-provider-homematic 1.2.97 → 1.2.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +182 -24
  2. package/dist/addon.mjs +182 -24
  3. 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: SettingsRecordSchema
12565
- }), _void(), { kind: "mutation" }), method(object({
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: SettingsRecordSchema
12675
- }), _void(), {
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
- id: string(),
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(),
@@ -20773,6 +20865,14 @@ var NativeCropResultSchema = object({
20773
20865
  * set `encodeJpeg: true`; `bytes` is then absent.
20774
20866
  */
20775
20867
  jpeg: string().optional(),
20868
+ /**
20869
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20870
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20871
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20872
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20873
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20874
+ */
20875
+ jpegBytes: _instanceof(Uint8Array).optional(),
20776
20876
  width: number().int().positive(),
20777
20877
  height: number().int().positive(),
20778
20878
  /**
@@ -20839,7 +20939,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20839
20939
  })]);
20840
20940
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20841
20941
  var ParkedTrackFrameSchema = object({
20842
- jpeg: string(),
20942
+ /**
20943
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20944
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20945
+ * Exactly one of the two is present.
20946
+ */
20947
+ jpeg: string().optional(),
20948
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20949
+ jpegBytes: _instanceof(Uint8Array).optional(),
20843
20950
  width: number().int().positive(),
20844
20951
  height: number().int().positive(),
20845
20952
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21426,6 +21533,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21426
21533
  bbox: NativeCropBboxSchema,
21427
21534
  maxWidth: number().int().positive().optional(),
21428
21535
  /**
21536
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21537
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21538
+ * wire — never assume consent: a pre-D462 caller parses the field as
21539
+ * base64 and bytes would decode to garbage rather than fail.
21540
+ */
21541
+ acceptJpegBytes: boolean().optional(),
21542
+ /**
21429
21543
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21430
21544
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21431
21545
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21493,7 +21607,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21493
21607
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21494
21608
  deviceId: number(),
21495
21609
  trackId: string(),
21496
- kind: ParkedFrameKindSchema
21610
+ kind: ParkedFrameKindSchema,
21611
+ /**
21612
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21613
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21614
+ * wire — never assume consent: a pre-D462 caller parses the field as
21615
+ * base64 and bytes would decode to garbage rather than fail.
21616
+ */
21617
+ acceptJpegBytes: boolean().optional()
21497
21618
  }), ParkedTrackFrameSchema.nullable()), method(object({
21498
21619
  deviceId: number(),
21499
21620
  trackId: string()
@@ -27891,26 +28012,59 @@ authKey: string().optional() }), object({
27891
28012
  /** Human-readable error when `ok: false`. */
27892
28013
  error: string().optional()
27893
28014
  }), { kind: "mutation" });
27894
- /**
27895
- * Hardware / firmware motion sensor cap — binary detected state plus
27896
- * a timestamp of the last observation. Distinct from
27897
- * `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
27898
- * `motion` is the lightweight readout from on-camera motion (Reolink
27899
- * `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
27900
- *
27901
- * Native-motion providers also fan out to `detection.camera-native`
27902
- * with `source: 'onboard'` so cross-cutting system services
27903
- * (alert-center, advanced-notifier) can subscribe once and receive
27904
- * motion from every camera.
27905
- */
27906
28015
  var MotionStatusSchema = object({
27907
28016
  detected: boolean(),
27908
28017
  /** Ms epoch of the last detected-true observation. Null if never detected. */
27909
28018
  lastDetectedAt: number().nullable(),
27910
28019
  /**
27911
- * Ms after which `detected` auto-reverts to false if no fresh push
27912
- * arrives. Null means the provider leaves detected state until a
27913
- * native "clear" event.
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.
27914
28068
  */
27915
28069
  autoClearAfterMs: number().nullable()
27916
28070
  });
@@ -27980,7 +28134,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
27980
28134
  */
27981
28135
  runtimeState: MotionStatusSchema,
27982
28136
  /**
27983
- * 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.
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.)
27984
28142
  *
27985
28143
  * See `RuntimeStateDurability`. Enforced by
27986
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: SettingsRecordSchema
12566
- }), _void(), { kind: "mutation" }), method(object({
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: SettingsRecordSchema
12676
- }), _void(), {
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
- id: string(),
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(),
@@ -20774,6 +20866,14 @@ var NativeCropResultSchema = object({
20774
20866
  * set `encodeJpeg: true`; `bytes` is then absent.
20775
20867
  */
20776
20868
  jpeg: string().optional(),
20869
+ /**
20870
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20871
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20872
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20873
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20874
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20875
+ */
20876
+ jpegBytes: _instanceof(Uint8Array).optional(),
20777
20877
  width: number().int().positive(),
20778
20878
  height: number().int().positive(),
20779
20879
  /**
@@ -20840,7 +20940,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20840
20940
  })]);
20841
20941
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20842
20942
  var ParkedTrackFrameSchema = object({
20843
- jpeg: string(),
20943
+ /**
20944
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20945
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20946
+ * Exactly one of the two is present.
20947
+ */
20948
+ jpeg: string().optional(),
20949
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20950
+ jpegBytes: _instanceof(Uint8Array).optional(),
20844
20951
  width: number().int().positive(),
20845
20952
  height: number().int().positive(),
20846
20953
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21427,6 +21534,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21427
21534
  bbox: NativeCropBboxSchema,
21428
21535
  maxWidth: number().int().positive().optional(),
21429
21536
  /**
21537
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21538
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21539
+ * wire — never assume consent: a pre-D462 caller parses the field as
21540
+ * base64 and bytes would decode to garbage rather than fail.
21541
+ */
21542
+ acceptJpegBytes: boolean().optional(),
21543
+ /**
21430
21544
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21431
21545
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21432
21546
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21494,7 +21608,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21494
21608
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21495
21609
  deviceId: number(),
21496
21610
  trackId: string(),
21497
- kind: ParkedFrameKindSchema
21611
+ kind: ParkedFrameKindSchema,
21612
+ /**
21613
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21614
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21615
+ * wire — never assume consent: a pre-D462 caller parses the field as
21616
+ * base64 and bytes would decode to garbage rather than fail.
21617
+ */
21618
+ acceptJpegBytes: boolean().optional()
21498
21619
  }), ParkedTrackFrameSchema.nullable()), method(object({
21499
21620
  deviceId: number(),
21500
21621
  trackId: string()
@@ -27892,26 +28013,59 @@ authKey: string().optional() }), object({
27892
28013
  /** Human-readable error when `ok: false`. */
27893
28014
  error: string().optional()
27894
28015
  }), { kind: "mutation" });
27895
- /**
27896
- * Hardware / firmware motion sensor cap — binary detected state plus
27897
- * a timestamp of the last observation. Distinct from
27898
- * `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
27899
- * `motion` is the lightweight readout from on-camera motion (Reolink
27900
- * `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
27901
- *
27902
- * Native-motion providers also fan out to `detection.camera-native`
27903
- * with `source: 'onboard'` so cross-cutting system services
27904
- * (alert-center, advanced-notifier) can subscribe once and receive
27905
- * motion from every camera.
27906
- */
27907
28016
  var MotionStatusSchema = object({
27908
28017
  detected: boolean(),
27909
28018
  /** Ms epoch of the last detected-true observation. Null if never detected. */
27910
28019
  lastDetectedAt: number().nullable(),
27911
28020
  /**
27912
- * Ms after which `detected` auto-reverts to false if no fresh push
27913
- * arrives. Null means the provider leaves detected state until a
27914
- * native "clear" event.
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.
27915
28069
  */
27916
28070
  autoClearAfterMs: number().nullable()
27917
28071
  });
@@ -27981,7 +28135,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
27981
28135
  */
27982
28136
  runtimeState: MotionStatusSchema,
27983
28137
  /**
27984
- * 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.
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.)
27985
28143
  *
27986
28144
  * See `RuntimeStateDurability`. Enforced by
27987
28145
  * `scripts/check-runtime-state-durability.ts`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-homematic",
3
- "version": "1.2.97",
3
+ "version": "1.2.99",
4
4
  "description": "Homematic / HomematicIP (CCU3 / RaspberryMatic) device-provider addon for CamStack — wraps the nodehomematic library",
5
5
  "keywords": [
6
6
  "camstack",