@camstack/addon-provider-wyze 0.2.121 → 0.2.123

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 +336 -206
  2. package/dist/addon.mjs +336 -206
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -31,7 +31,7 @@ let net = require("net");
31
31
  net = __toESM(net, 1);
32
32
  let node_child_process = require("node:child_process");
33
33
  let node_tls = require("node:tls");
34
- //#region ../types/dist/event-category-C5xZWqz6.mjs
34
+ //#region ../types/dist/event-category-BGmz_oxW.mjs
35
35
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
36
36
  EventCategory["SystemBoot"] = "system.boot";
37
37
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -564,6 +564,15 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
564
564
  */
565
565
  EventCategory["PipelineAudioInferenceResult"] = "pipeline.audio-inference-result";
566
566
  EventCategory["DetectionPhaseTransition"] = "detection.phase-transition";
567
+ /**
568
+ * A camera provider's RAW onboard motion push (D673): the `MotionOnMotionChanged`
569
+ * data shape without `triggeredBy`, built by `providerMotionEvent`. Its one
570
+ * consumer is the orchestrator's camera-sensors bridge, which re-emits the
571
+ * camera's EFFECTIVE onboard motion as `MotionOnMotionChanged` (a pass-through
572
+ * for a camera with no attached sensor). Providers must not emit
573
+ * `MotionOnMotionChanged` themselves; `scripts/check-onboard-motion-emitters.ts`
574
+ * keeps it so (camera-grid is a named, deferred exception).
575
+ */
567
576
  EventCategory["ProviderMotion"] = "provider.motion";
568
577
  EventCategory["ProviderDetection"] = "provider.detection";
569
578
  EventCategory["EnrichmentEmbeddingStored"] = "enrichment.embedding.stored";
@@ -5402,7 +5411,7 @@ var ZodIssueCode = {
5402
5411
  var ZodFirstPartyTypeKind;
5403
5412
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5404
5413
  //#endregion
5405
- //#region ../types/dist/sleep-gU6hqv4_.mjs
5414
+ //#region ../types/dist/sleep-CDCONfkt.mjs
5406
5415
  /**
5407
5416
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5408
5417
  * window to float samples (D455).
@@ -7445,7 +7454,7 @@ function errMsg(err) {
7445
7454
  return String(err);
7446
7455
  }
7447
7456
  //#endregion
7448
- //#region ../types/dist/composition-Dq42XWp0.mjs
7457
+ //#region ../types/dist/composition-43aqsZQj.mjs
7449
7458
  /**
7450
7459
  * The ffmpeg build every CamStack node downloads, per platform and arch.
7451
7460
  *
@@ -7502,13 +7511,12 @@ portable("linux64"), portable("linuxarm64"), portable("macarm64"), portable("mac
7502
7511
  * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
7503
7512
  * valutatore puro del suo FRONTE.
7504
7513
  *
7505
- * Viveva dentro il builtin virtual-doorbell
7506
- * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
7507
- * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
7508
- * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
7509
- * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
7510
- * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
7511
- * SPOSTA qui e il doorbell la ri-esporta.
7514
+ * UNA tabella per tutti quelli che chiedono "questo device è ALTO?": il
7515
+ * trigger `RecordingTriggers.sensorDeviceIds` del recorder, i marker dei
7516
+ * sensori della post-analysis, il bridge camera-sensors dell'orchestratore e
7517
+ * le sorgenti di un campanello composto (`doorbellFeatureSources`, D671).
7518
+ * Una seconda copia divergerebbe alla prima cap aggiunta, e il sintomo — "il
7519
+ * sensore fa suonare il campanello ma non registra" — è esattamente D62.
7512
7520
  *
7513
7521
  * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
7514
7522
  * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
@@ -7534,8 +7542,6 @@ var SOURCE_CAP_ACTIVE_FIELD = {
7534
7542
  vibration: "detected",
7535
7543
  tamper: "tampered"
7536
7544
  };
7537
- /** Cap names whose presence in a device's bindings qualify it as a source. */
7538
- var SOURCE_CAPS = Object.keys(SOURCE_CAP_ACTIVE_FIELD);
7539
7545
  /**
7540
7546
  * Error types for the safe expression engine. Two distinct classes so callers
7541
7547
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
@@ -9265,7 +9271,7 @@ var RecordingTriggersSchema = object({
9265
9271
  *
9266
9272
  * Cosa vuol dire "alto" dipende dal TIPO di device e non è deciso qui:
9267
9273
  * `SOURCE_CAP_ACTIVE_FIELD` (`catalogs/sensor-active-state.ts`) è LA tabella,
9268
- * la stessa che il virtual-doorbell usa dal 2026-08-05. Ed è il FRONTE, non
9274
+ * la stessa del campanello composto (D671). Ed è il FRONTE, non
9269
9275
  * il livello: un contatto trovato già aperto al riavvio del runner non fa
9270
9276
  * registrare.
9271
9277
  */
@@ -14779,7 +14785,17 @@ var SiteZoneSchema = object({
14779
14785
  var ProviderStatusSchema = object({
14780
14786
  connected: boolean(),
14781
14787
  deviceCount: number(),
14782
- error: string().optional()
14788
+ error: string().optional(),
14789
+ /**
14790
+ * `'orchestrator'`: this provider writes NO camera's `motion` runtime slice
14791
+ * — the orchestrator is its only writer (D696). Set by `BaseDeviceProvider`,
14792
+ * which every provider bundles, so only a provider BUILT from D696-amended
14793
+ * code says it. ABSENT means an older provider that may still write it (raw
14794
+ * VMD writes, a boot seed), and the orchestrator's provider gate keeps that
14795
+ * provider's cameras unwritten (`camera-sensors/motion-slice-provider-gate.ts`)
14796
+ * — the provider twin of the runner's `getLocalLoad().motionSliceWriter`.
14797
+ */
14798
+ motionSliceWriter: literal("orchestrator").optional()
14783
14799
  });
14784
14800
  object({
14785
14801
  externalId: string(),
@@ -15658,109 +15674,10 @@ method(object({
15658
15674
  deviceIds: array(number()).readonly(),
15659
15675
  caps: array(string()).readonly().optional()
15660
15676
  }), record(string(), record(string(), unknown().nullable())));
15661
- /**
15662
- * Doorbell button cap. Two kinds of providers coexist behind this cap
15663
- * name (same pattern as `snapshot`):
15664
- *
15665
- * - **Native** providers: registered per-device by device-driver
15666
- * addons via `ctx.registerNativeCap` — either on a
15667
- * `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
15668
- * or directly on the camera (Reolink registers at camera level).
15669
- * Emits an `onPressed` event every time the firmware pushes a
15670
- * ring; status tracks the last press and a pressCount since start
15671
- * (diagnostic).
15672
- *
15673
- * - **Wrapper** provider: the `virtual-doorbell` system builtin
15674
- * (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
15675
- * device (contact / switch / event-emitter …) into a doorbell for
15676
- * a camera. `defaultActive: false` — the operator explicitly binds
15677
- * it per camera in the device-bindings UI, then picks the source
15678
- * device + trigger in the per-device settings.
15679
- *
15680
- * The DeviceEventPropagator re-emits `onPressed` on the camera parent
15681
- * — subscribers listening at the camera level receive ring events
15682
- * with `via[]` populated. No code on the parent needed.
15683
- */
15684
- var DoorbellStatusSchema = object({
15685
- /** Ms epoch of the last press. null = never observed since this provider started. */
15686
- lastPressedAt: number().nullable(),
15687
- /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
15688
- pressCountSinceStart: number()
15689
- });
15690
- var DoorbellPressEventSchema = object({
15691
- deviceId: number(),
15692
- timestamp: number()
15693
- });
15694
- /**
15695
- * The `doorbell-source` extension slot's editable value (D648): the camera's
15696
- * virtual-doorbell trigger devices, exactly what the wrapper's
15697
- * `doorbellSources` persists (as `{ deviceId }` records).
15698
- */
15699
- var DoorbellSourceSlotValueSchema = object({ deviceIds: array(number().int().positive()) });
15700
- /**
15701
- * The `doorbell-source` slot — which devices ring this camera's VIRTUAL
15702
- * doorbell, owned by the `virtual-doorbell` wrapper over its
15703
- * `doorbellSources` store (D648). A source rings when one of its
15704
- * `SOURCE_CAPS` rises. Whether the wrapper is bound to the camera at all is a
15705
- * different authority (`deviceManager.setWrapperActive`, D62) — the slot
15706
- * reports it, it never writes it.
15707
- */
15708
- var DOORBELL_SOURCE_SLOT = {
15709
- id: "doorbell-source",
15710
- label: "Doorbell trigger devices",
15711
- description: "Any of these becoming active rings this camera's virtual doorbell: a binary sensor when it goes active, a switch when it turns on.",
15712
- shape: "association",
15713
- hostDeviceTypes: [DeviceType.Camera],
15714
- sourceCaps: SOURCE_CAPS,
15715
- cardinality: "many",
15716
- value: DoorbellSourceSlotValueSchema
15717
- };
15718
- var doorbellCapability = {
15719
- name: "doorbell",
15720
- scope: "device",
15721
- deviceNative: true,
15722
- mode: "singleton",
15723
- kind: "wrapper",
15724
- defaultActive: false,
15725
- deviceTypes: [DeviceType.Button, DeviceType.Camera],
15726
- extensionSlots: [DOORBELL_SOURCE_SLOT],
15727
- methods: {},
15728
- events: {
15729
- /**
15730
- * Fires once per physical press. Reolink delivers via Baichuan
15731
- * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
15732
- * release/duration — it's a pulse.
15733
- */
15734
- onPressed: {
15735
- data: DoorbellPressEventSchema,
15736
- fromState: {
15737
- field: "lastPressedAt",
15738
- on: "advance"
15739
- }
15740
- } },
15741
- status: {
15742
- schema: DoorbellStatusSchema,
15743
- kind: "push"
15744
- },
15745
- /**
15746
- * Runtime-state slice — last press timestamp + lifetime press count.
15747
- * Mirrored by the kernel and readable via
15748
- * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
15749
- * without subscribing.
15750
- */
15751
- runtimeState: DoorbellStatusSchema,
15752
- /**
15753
- * Runtime-state durability: **restored** — a monotonic accumulator: the slice IS the record. `lastPressedAt` is content here, not a clock, so it is deliberately NOT volatile.
15754
- *
15755
- * See `RuntimeStateDurability`. Enforced by
15756
- * `scripts/check-runtime-state-durability.ts`.
15757
- */
15758
- durability: "restored"
15759
- };
15760
- var ExtensionSlotIdSchema = _enum(["doorbell-source", "linked-devices"]);
15761
- DeviceType.Camera, DeviceType.Camera;
15677
+ var ExtensionSlotIdSchema = _enum(["linked-devices"]);
15678
+ DeviceType.Camera;
15762
15679
  /** A slot's editable value, discriminated on `slot`. */
15763
- var ExtensionSlotValueSchema = discriminatedUnion("slot", [DoorbellSourceSlotValueSchema.extend({ slot: literal("doorbell-source") }), LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
15680
+ var ExtensionSlotValueSchema = discriminatedUnion("slot", [LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
15764
15681
  DeviceType.Camera;
15765
15682
  var ExtensionSourceAvailabilitySchema = discriminatedUnion("state", [object({ state: literal("ok") }), object({
15766
15683
  state: literal("unreachable"),
@@ -15797,10 +15714,11 @@ var ExtensionSlotSourceSchema = object({
15797
15714
  });
15798
15715
  /**
15799
15716
  * A DIFFERENT authority that gates whether the slot's sources do anything —
15800
- * reported read-only, named, never written through this contract (D62). The
15801
- * virtual doorbell's sources ring only while the wrapper is bound to the
15802
- * camera, and that binding belongs to `deviceManager.setWrapperActive`.
15803
- * `unknown` means the gate could not be read; it is not "inactive" (D315).
15717
+ * reported read-only, named, never written through this contract (D62) — e.g.
15718
+ * a slot whose sources act only while a wrapper is bound to the host, a
15719
+ * binding that belongs to `deviceManager.setWrapperActive`. No slot reports
15720
+ * one today (`linked-devices` answers `null`). `unknown` means the gate could
15721
+ * not be read; it is not "inactive" (D315).
15804
15722
  */
15805
15723
  var ExtensionSlotActivationSchema = object({
15806
15724
  state: _enum([
@@ -15816,7 +15734,7 @@ var ExtensionSlotRowSchema = discriminatedUnion("state", [object({
15816
15734
  /** `<source>:<slotId>` — the routing key for `listCandidates` / `setSlot`. */
15817
15735
  slotRef: string(),
15818
15736
  slot: ExtensionSlotIdSchema,
15819
- /** Names the store written (D62), e.g. `virtual-doorbell:doorbellSources`. */
15737
+ /** Names the store written (D62), e.g. `device-manager:_linkedDeviceIds`. */
15820
15738
  authority: string(),
15821
15739
  activation: ExtensionSlotActivationSchema.nullable(),
15822
15740
  value: ExtensionSlotValueSchema,
@@ -20339,6 +20257,29 @@ object({
20339
20257
  firstAt: number(),
20340
20258
  lastAt: number()
20341
20259
  });
20260
+ var NC_ALARM_TRIGGERED_MAX_SEC = 3600;
20261
+ var NcAlarmDelaySecSchema = number().int().min(0).max(600);
20262
+ var NcAlarmTriggeredSecSchema = number().int().min(0).max(NC_ALARM_TRIGGERED_MAX_SEC);
20263
+ var uniqueModes = (entries) => new Set(entries.map((e) => e.mode)).size === entries.length;
20264
+ var NcAlarmModeDelaysListSchema = array(object({
20265
+ mode: AlarmArmModeSchema,
20266
+ exitDelaySec: NcAlarmDelaySecSchema.optional(),
20267
+ entryDelaySec: NcAlarmDelaySecSchema.optional(),
20268
+ triggeredDurationSec: NcAlarmTriggeredSecSchema.optional()
20269
+ })).max(8).refine(uniqueModes, { message: "modeDelays: at most one entry per arm mode" });
20270
+ var NcAlarmModeDelaysEditListSchema = array(object({
20271
+ mode: AlarmArmModeSchema,
20272
+ exitDelaySec: NcAlarmDelaySecSchema.nullable().optional(),
20273
+ entryDelaySec: NcAlarmDelaySecSchema.nullable().optional(),
20274
+ triggeredDurationSec: NcAlarmTriggeredSecSchema.nullable().optional()
20275
+ })).max(8).refine(uniqueModes, { message: "modeDelays: at most one edit per arm mode" });
20276
+ /** One switch of the alarm table: put ONE device on, or take it off, ONE mode's list. */
20277
+ var NcAlarmNonBlockingEditSchema = object({
20278
+ mode: AlarmArmModeSchema,
20279
+ deviceId: number().int().positive(),
20280
+ /** true = on the list (may be open, does not block); false = off the list (blocks). */
20281
+ nonBlocking: boolean()
20282
+ });
20342
20283
  /**
20343
20284
  * The per-mode lists, at most one per mode. Two lists for one mode have no
20344
20285
  * meaning a reader could agree on (union? the last one?), so they are refused
@@ -20347,10 +20288,10 @@ object({
20347
20288
  var NcAlarmNonBlockingListSchema = array(object({
20348
20289
  mode: AlarmArmModeSchema,
20349
20290
  deviceIds: array(number().int()).max(200)
20350
- })).max(8).refine((lists) => new Set(lists.map((l) => l.mode)).size === lists.length, { message: "nonBlocking: at most one list per arm mode" });
20291
+ })).max(8).refine(uniqueModes, { message: "nonBlocking: at most one list per arm mode" });
20351
20292
  /**
20352
- * The three durations the panel's state machine runs on, who hears about its
20353
- * transitions, and which openings each mode tolerates.
20293
+ * The three durations — global, and per mode since D697 — the panel's state
20294
+ * machine runs on, who hears about its transitions, and which openings each mode tolerates.
20354
20295
  *
20355
20296
  * They live on the NOTIFICATION-RULES cap, not on `alarm-panel`, on purpose:
20356
20297
  * `alarm-panel` is `deviceNative` and its other provider mirrors somebody
@@ -20360,15 +20301,15 @@ var NcAlarmNonBlockingListSchema = array(object({
20360
20301
  */
20361
20302
  var NcAlarmSettingsSchema = object({
20362
20303
  /** Grace period between arming and the mode taking effect. 0 = immediate. */
20363
- exitDelaySec: number().int().min(0).max(600),
20304
+ exitDelaySec: NcAlarmDelaySecSchema,
20364
20305
  /** Grace period between a trigger and the alarm firing. 0 = immediate. */
20365
- entryDelaySec: number().int().min(0).max(600),
20306
+ entryDelaySec: NcAlarmDelaySecSchema,
20366
20307
  /**
20367
20308
  * How long `triggered` lasts before the panel re-arms itself.
20368
20309
  * **0 = until an operator disarms it** — the behaviour before this field
20369
20310
  * existed, and therefore what an untouched install keeps doing.
20370
20311
  */
20371
- triggeredDurationSec: number().int().min(0).max(3600),
20312
+ triggeredDurationSec: NcAlarmTriggeredSecSchema,
20372
20313
  /**
20373
20314
  * Deprecated by D630 — every transition is announced. Parsed, never read;
20374
20315
  * remove after one release. Optional so an older admin's patch (which still
@@ -20391,17 +20332,30 @@ var NcAlarmSettingsSchema = object({
20391
20332
  * per mode is meaningful. Defaulted to `[]` so a blob stored before D630
20392
20333
  * parses as "every opening blocks" — the behaviour it was written under.
20393
20334
  */
20394
- nonBlocking: NcAlarmNonBlockingListSchema.default([])
20335
+ nonBlocking: NcAlarmNonBlockingListSchema.default([]),
20336
+ /**
20337
+ * Per arm mode, the delays that mode OVERRIDES (D697). A mode with no entry, or an entry
20338
+ * without a field, uses the global value above — so `[]`, the default, is exactly the
20339
+ * behaviour of a blob stored before this field existed. Read through `resolveModeDelays`.
20340
+ */
20341
+ modeDelays: NcAlarmModeDelaysListSchema.default([])
20395
20342
  });
20396
20343
  /**
20397
20344
  * Every field optional — a tab edits one control at a time.
20398
20345
  *
20399
- * `nonBlocking` is re-declared WITHOUT its default: `.partial()` does not
20400
- * remove an inner `.default()`, so a patch that never named the field would
20401
- * parse to `nonBlocking: []` and wipe every mode's list on an unrelated edit
20402
- * (the same trap {@link NcRulePatchSchema} documents).
20346
+ * `nonBlocking` and `modeDelays` are re-declared WITHOUT their defaults:
20347
+ * `.partial()` does not remove an inner `.default()`, so a patch that never
20348
+ * named the field would parse to `[]` and wipe every mode's list on an
20349
+ * unrelated edit (the same trap {@link NcRulePatchSchema} documents). Here
20350
+ * `modeDelays` means EDITS, not the stored overrides.
20403
20351
  */
20404
- var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.extend({ nonBlocking: NcAlarmNonBlockingListSchema }).partial();
20352
+ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.extend({
20353
+ nonBlocking: NcAlarmNonBlockingListSchema,
20354
+ /** Per-mode, per-field edits — NOT the whole list (see NcAlarmModeDelaysEditSchema). */
20355
+ modeDelays: NcAlarmModeDelaysEditListSchema,
20356
+ /** ONE membership change; the panel applies it to the list it holds at its turn. */
20357
+ nonBlockingEdit: NcAlarmNonBlockingEditSchema
20358
+ }).partial().refine((p) => p.nonBlocking === void 0 || p.nonBlockingEdit === void 0, { message: "nonBlocking and nonBlockingEdit are exclusive — send the whole lists or one edit" });
20405
20359
  /**
20406
20360
  * What one arm mode actually arms, DERIVED from the enabled rules gated on it.
20407
20361
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
@@ -20501,6 +20455,28 @@ var NcAlarmConfigSchema = object({
20501
20455
  */
20502
20456
  live: NcAlarmLiveSchema.optional()
20503
20457
  });
20458
+ var NcAlarmSensorReadingSchema = _enum([
20459
+ "open",
20460
+ "closed",
20461
+ "unknown",
20462
+ "not-opening"
20463
+ ]);
20464
+ /** One device's state as the alarm reads it — the classifier the arm check uses. */
20465
+ var NcAlarmSensorStateSchema = object({
20466
+ deviceId: number().int().positive(),
20467
+ reading: NcAlarmSensorReadingSchema,
20468
+ /** The word as read (`open`, `closed`, `unlocked`, `stopped`, …); null when unknown / not an opening. */
20469
+ state: string().nullable(),
20470
+ /** Why `unknown`: the read failed, or the slice holds no word its cap defines (a placeholder included). */
20471
+ unknownWhy: _enum(["read-failed", "unknown-word"]).nullable(),
20472
+ /** The device manager's liveness as the centre mirrors it; null = not known. */
20473
+ online: boolean().nullable()
20474
+ });
20475
+ var NcAlarmSensorsInputSchema = object({ deviceIds: array(number().int().positive()).max(500) });
20476
+ var NcAlarmSensorsSchema = object({
20477
+ sensors: array(NcAlarmSensorStateSchema),
20478
+ readAt: number().int().nonnegative()
20479
+ });
20504
20480
  /**
20505
20481
  * ONE rule's demand on ONE camera's clip ring.
20506
20482
  *
@@ -20591,7 +20567,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
20591
20567
  }), method(object({}), NcAlarmConfigSchema, { auth: "admin" }), method(object({ patch: NcAlarmSettingsPatchSchema }), NcAlarmConfigSchema, {
20592
20568
  kind: "mutation",
20593
20569
  auth: "admin"
20594
- });
20570
+ }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
20595
20571
  /**
20596
20572
  * Zod schemas for persisted record types.
20597
20573
  *
@@ -20938,12 +20914,26 @@ var CameraSensorRefSchema = object({
20938
20914
  function cameraSensorRefKey(ref) {
20939
20915
  return `${ref.addonId}/${ref.stableId}`;
20940
20916
  }
20941
- /** CS-1 accepts exactly one mode; CS-2 (D673) widens it to confirm / replace. */
20942
- var CameraSensorsModeSchema = _enum(["in-addition"]);
20943
- var CameraSensorsConfigSchema = object({
20944
- mode: CameraSensorsModeSchema,
20945
- sensors: array(CameraSensorRefSchema).min(1).max(8)
20946
- }).superRefine((value, ctx) => {
20917
+ /**
20918
+ * A sensor's mode (D673). `in-addition`: its motion is the camera's motion too.
20919
+ * `replace`: its motion is the camera's, and while one is READY the camera's
20920
+ * own motion no longer counts on its own. `confirm`: while one is READY the
20921
+ * camera's own motion counts only while a confirm sensor is active — with or
20922
+ * without a replace sensor (spec C2, the controller's ruling on Q1).
20923
+ */
20924
+ var CameraSensorModeSchema = _enum([
20925
+ "in-addition",
20926
+ "confirm",
20927
+ "replace"
20928
+ ]);
20929
+ /** A stored sensor with no mode — every CS-1 row — is in addition. */
20930
+ var DEFAULT_CAMERA_SENSOR_MODE = "in-addition";
20931
+ /**
20932
+ * A camera's attached sensors. A CS-1 row carried an envelope
20933
+ * `mode: 'in-addition'`: `z.object` drops it on parse, and the PARSED value is
20934
+ * what the write stores (D672 rule 3), so it is never written again.
20935
+ */
20936
+ var CameraSensorsConfigSchema = object({ sensors: array(CameraSensorRefSchema.extend({ mode: CameraSensorModeSchema.default(DEFAULT_CAMERA_SENSOR_MODE) })).min(1).max(8) }).superRefine((value, ctx) => {
20947
20937
  const seen = /* @__PURE__ */ new Set();
20948
20938
  value.sensors.forEach((ref, index) => {
20949
20939
  const key = cameraSensorRefKey(ref);
@@ -20955,39 +20945,41 @@ var CameraSensorsConfigSchema = object({
20955
20945
  seen.add(key);
20956
20946
  });
20957
20947
  });
20958
- var RefFields = {
20948
+ /** Every attachment names its mode; an older orchestrator that does not is in addition. */
20949
+ var AttachmentFields = {
20959
20950
  addonId: string(),
20960
- stableId: string()
20951
+ stableId: string(),
20952
+ mode: CameraSensorModeSchema.default(DEFAULT_CAMERA_SENSOR_MODE)
20961
20953
  };
20962
20954
  var CameraSensorAttachmentSchema = discriminatedUnion("state", [
20963
20955
  object({
20964
- ...RefFields,
20956
+ ...AttachmentFields,
20965
20957
  state: literal("ready"),
20966
20958
  deviceId: number(),
20967
20959
  name: string(),
20968
20960
  caps: array(string()).readonly()
20969
20961
  }),
20970
20962
  object({
20971
- ...RefFields,
20963
+ ...AttachmentFields,
20972
20964
  state: literal("offline"),
20973
20965
  deviceId: number(),
20974
20966
  name: string(),
20975
20967
  reason: _enum(["offline", "disabled"])
20976
20968
  }),
20977
20969
  object({
20978
- ...RefFields,
20970
+ ...AttachmentFields,
20979
20971
  state: literal("missing"),
20980
20972
  reason: string()
20981
20973
  }),
20982
20974
  object({
20983
- ...RefFields,
20975
+ ...AttachmentFields,
20984
20976
  state: literal("unsupported"),
20985
20977
  deviceId: number(),
20986
20978
  name: string(),
20987
20979
  reason: string()
20988
20980
  }),
20989
20981
  object({
20990
- ...RefFields,
20982
+ ...AttachmentFields,
20991
20983
  state: literal("unreadable"),
20992
20984
  reason: string()
20993
20985
  })
@@ -21000,17 +20992,49 @@ var CameraSensorAttachmentSchema = discriminatedUnion("state", [
21000
20992
  * say.
21001
20993
  */
21002
20994
  var CameraSensorsNotForwardedSchema = _enum(["onboard-not-listed", "no-active-detection"]);
20995
+ /** Whether the camera's OWN motion counts on its own (D673 C2), from its READY sensors (C3). */
20996
+ var CameraOwnMotionSchema = _enum([
20997
+ "always",
20998
+ "when-confirmed",
20999
+ "never"
21000
+ ]);
21001
+ /** Confirm / Replace cannot suppress this camera's motion: its provider still emits it directly (D673 C13). */
21002
+ var CameraSensorsNotEnforcedSchema = _enum(["provider-not-split"]);
21003
+ /**
21004
+ * The camera's OWN onboard motion (D696): the raw input the bridge combines,
21005
+ * never the effective value. The camera's `motion` slice is the effective one,
21006
+ * so a view of the camera's own row reads this.
21007
+ * - `atMs`: when the bridge received the camera's last own edge.
21008
+ * - `detected`: evaluated WHEN THE STATUS IS ASKED — the last edge said `true`
21009
+ * AND it is younger than the window the bridge counts the camera's own motion
21010
+ * for (`motionCooldownMs`, floored at two sustain ticks). A camera that never
21011
+ * sends a clear (heartbeats only) therefore reads `false` once no push came
21012
+ * within the window; a status read is a snapshot, so a live view re-asks.
21013
+ * Absent = this orchestrator has not received the camera's own motion since it
21014
+ * started (unknown, never "quiet"), or an orchestrator older than D696.
21015
+ */
21016
+ var CameraRawLevelSchema = object({
21017
+ detected: boolean(),
21018
+ atMs: number()
21019
+ });
21003
21020
  var CameraSensorsStatusSchema = discriminatedUnion("state", [
21004
- object({ state: literal("not-configured") }),
21021
+ object({
21022
+ state: literal("not-configured"),
21023
+ cameraLevel: CameraRawLevelSchema.optional()
21024
+ }),
21005
21025
  object({
21006
21026
  state: literal("unreadable"),
21007
- reason: string()
21027
+ reason: string(),
21028
+ cameraLevel: CameraRawLevelSchema.optional()
21008
21029
  }),
21009
21030
  object({
21010
21031
  state: literal("configured"),
21011
- mode: CameraSensorsModeSchema,
21032
+ cameraLevel: CameraRawLevelSchema.optional(),
21012
21033
  sensors: array(CameraSensorAttachmentSchema).readonly(),
21013
- notForwarded: CameraSensorsNotForwardedSchema.optional()
21034
+ /** Absent = an orchestrator older than CS-2: it does not say (D315). */
21035
+ cameraMotion: CameraOwnMotionSchema.optional(),
21036
+ notForwarded: CameraSensorsNotForwardedSchema.optional(),
21037
+ notEnforced: CameraSensorsNotEnforcedSchema.optional()
21014
21038
  })
21015
21039
  ]);
21016
21040
  Object.freeze({
@@ -24241,8 +24265,10 @@ var RunnerCameraConfigSchema = object({
24241
24265
  * - `analyzer`: ML/frame-diff motion detection (motion-wasm or other
24242
24266
  * analyzer providers) running on decoded frames in this runner.
24243
24267
  * - `onboard`: camera-native motion pushes (Reolink Baichuan, ONVIF
24244
- * analytics). The provider emits ProviderMotion
24245
- * events; the orchestrator forwards to `reportMotion`.
24268
+ * analytics). The provider emits its raw push as `ProviderMotion`
24269
+ * (D673); the orchestrator's camera-sensors bridge re-emits the camera's
24270
+ * effective motion as `MotionOnMotionChanged`, which is what reaches
24271
+ * `reportMotion`.
24246
24272
  */
24247
24273
  motionSources: MotionSourcesSchema.default(["analyzer"]),
24248
24274
  /**
@@ -24419,7 +24445,15 @@ var RunnerLocalLoadSchema = object({
24419
24445
  hasGpu: boolean(),
24420
24446
  inferenceBackend: string().optional(),
24421
24447
  cpuCores: number().optional()
24422
- })
24448
+ }),
24449
+ /**
24450
+ * Who writes a camera's `motion` runtime slice (D696). `'orchestrator'`: this
24451
+ * runner never writes it. ABSENT = a runner older than D696, which still
24452
+ * writes the slice from its phase machine; the orchestrator does not write
24453
+ * while any runner node is absent-or-unanswered, so one slice never has two
24454
+ * writers.
24455
+ */
24456
+ motionSliceWriter: literal("orchestrator").optional()
24423
24457
  });
24424
24458
  /**
24425
24459
  * Aggregate runtime metrics for the runner's whole local pool. Mirrors the
@@ -30052,6 +30086,70 @@ onStatusChanged: { data: object({
30052
30086
  * whether persisting is worth a SQLite commit. */
30053
30087
  volatileStateFields: ["lastChangedAt"]
30054
30088
  };
30089
+ var DoorbellStatusSchema = object({
30090
+ /** Ms epoch of the last press. null = never observed since this provider started. */
30091
+ lastPressedAt: number().nullable(),
30092
+ /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
30093
+ pressCountSinceStart: number()
30094
+ });
30095
+ var DoorbellPressEventSchema = object({
30096
+ deviceId: number(),
30097
+ timestamp: number()
30098
+ });
30099
+ /**
30100
+ * Doorbell button cap. Two kinds of provider serve it, and to every consumer
30101
+ * they are the same cap:
30102
+ *
30103
+ * - **Native** providers, registered per device by a driver addon through
30104
+ * `ctx.registerNativeCap` — a `DeviceType.Button` accessory with
30105
+ * `role: DeviceRole.Doorbell`, or the camera itself (Reolink registers at
30106
+ * camera level). They emit `onPressed` on every firmware ring.
30107
+ * - **A composed doorbell** (D670, D671): a camera's customization gives it
30108
+ * the cap, its `lastPressedAt` rising from the sources the operator
30109
+ * assigned in Customize → Doorbell, and the composer emits `onPressed`
30110
+ * from that field's advance (`fromState`).
30111
+ *
30112
+ * The DeviceEventPropagator re-emits `onPressed` on the camera parent.
30113
+ */
30114
+ var doorbellCapability = {
30115
+ name: "doorbell",
30116
+ scope: "device",
30117
+ deviceNative: true,
30118
+ mode: "singleton",
30119
+ deviceTypes: [DeviceType.Button, DeviceType.Camera],
30120
+ methods: {},
30121
+ events: {
30122
+ /**
30123
+ * Fires once per physical press. Reolink delivers via Baichuan
30124
+ * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
30125
+ * release/duration — it's a pulse.
30126
+ */
30127
+ onPressed: {
30128
+ data: DoorbellPressEventSchema,
30129
+ fromState: {
30130
+ field: "lastPressedAt",
30131
+ on: "advance"
30132
+ }
30133
+ } },
30134
+ status: {
30135
+ schema: DoorbellStatusSchema,
30136
+ kind: "push"
30137
+ },
30138
+ /**
30139
+ * Runtime-state slice — last press timestamp + lifetime press count.
30140
+ * Mirrored by the kernel and readable via
30141
+ * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
30142
+ * without subscribing.
30143
+ */
30144
+ runtimeState: DoorbellStatusSchema,
30145
+ /**
30146
+ * Runtime-state durability: **restored** — a monotonic accumulator: the slice IS the record. `lastPressedAt` is content here, not a clock, so it is deliberately NOT volatile.
30147
+ *
30148
+ * See `RuntimeStateDurability`. Enforced by
30149
+ * `scripts/check-runtime-state-durability.ts`.
30150
+ */
30151
+ durability: "restored"
30152
+ };
30055
30153
  /**
30056
30154
  * Enum-state sensor — a string value picked from a finite option set.
30057
30155
  * Drives HA `sensor` entries with `state_class: enum` (HVAC action
@@ -32196,9 +32294,9 @@ var MotionStatusSchema = object({
32196
32294
  /** Ms epoch of the last detected-true observation. Null if never detected. */
32197
32295
  lastDetectedAt: number().nullable(),
32198
32296
  /**
32199
- * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
32200
- * `null` while false and on every `Sensor` device (D475) — see that
32201
- * constant's doc for the one-authority rule.
32297
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device (the
32298
+ * orchestrator writes it, D696), `null` while false and on every `Sensor`
32299
+ * device (D475) — see that constant's doc for the one-authority rule.
32202
32300
  *
32203
32301
  * ## Reading this field still arms nothing
32204
32302
  *
@@ -32216,34 +32314,31 @@ var MotionStatusSchema = object({
32216
32314
  * `addon-export-alexa/src/motion-clear-hold.ts` and
32217
32315
  * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
32218
32316
  *
32219
- * ## Who writes it
32220
- *
32221
- * - **Cameras** — the runner's phase machine, `active → watching` on
32222
- * `cooldown_expired`, which then writes this slice with
32223
- * `detected: false` (`handlePhaseChanged` in
32224
- * `pipeline-runner/index.ts`). It produces the FALLING edge, which
32225
- * matters most for the sources that only ever push a rising one:
32226
- * Reolink emits `MotionOnMotionChanged { detected: true }` and never
32227
- * a false.
32228
- * - **Sensors** (Home Assistant binary sensors, Homematic) — the
32229
- * provider pushes the false itself, from the upstream system's own
32230
- * state change. No phase machine is involved.
32231
- *
32232
- * ### The phase machine is CANONICAL, not sole — and that is a defect
32233
- *
32234
- * An earlier revision of this docblock (mine, 2026-09-12) claimed the
32235
- * phase machine is the sole writer for a camera. It is not.
32236
- * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
32237
- * `setCapSlice(motionCapability, …)` on their own rising edge, and
32238
- * Hikvision's comment says why: it read THIS docblock, agreed the
32239
- * runner is canonical, and wrote anyway to avoid per-tick churn. So
32240
- * two authorities can disagree about one slice, which this repo
32241
- * forbids, and the doc said otherwise — which is worse than saying
32242
- * nothing, because it reads as verification.
32243
- *
32244
- * This predates D475 and is not fixed there: the fix touches every
32245
- * camera provider. Recorded in D475's Consequences. Do not restore the
32246
- * "sole writer" wording without also removing the other writers.
32317
+ * ## Who writes it (D696)
32318
+ *
32319
+ * - **Cameras** — the orchestrator, and nothing else. It writes the camera's
32320
+ * EFFECTIVE motion (`addon-pipeline-orchestrator`
32321
+ * `camera-sensors/motion-slice.ts`), alongside the effective
32322
+ * `MotionOnMotionChanged` it emits or receives: the camera-sensors bridge
32323
+ * for a split camera, an unsplit emitter's direct event, the analyzer and
32324
+ * device activity, as the camera's `motionSources` counts them. A source
32325
+ * that never sends a clear falls one window after its last `true`.
32326
+ * `lastDetectedAt` moves only on an effective rise. No camera provider
32327
+ * writes this slice (not even a boot seed), and neither does the runner's
32328
+ * phase machine: its phase is "a session is attached" for every on-motion
32329
+ * session, not motion, and it now has its own `DetectionPhaseTransition`.
32330
+ * A provider's `isDetected` answers from the hub's slice.
32331
+ * - **Sensors** (Home Assistant binary sensors, Homematic, Matter, Alexa
32332
+ * imports) — the provider pushes both edges itself, from the upstream
32333
+ * system's own state change. That is the sensor's own fact.
32334
+ *
32335
+ * `scripts/check-onboard-motion-emitters.ts` refuses any other writer of a
32336
+ * `motion` slice; each sensor writer is a named exemption.
32337
+ *
32338
+ * This replaces the D475 §4 rule ("the phase machine is the sole writer").
32339
+ * That rule was never true: Hikvision and Amcrest wrote the slice raw beside
32340
+ * it, every provider seeded it at boot, and every session left it
32341
+ * `detected: true` after its detach.
32247
32342
  */
32248
32343
  autoClearAfterMs: number().nullable()
32249
32344
  });
@@ -32315,11 +32410,12 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
32315
32410
  */
32316
32411
  runtimeState: MotionStatusSchema,
32317
32412
  /**
32318
- * Runtime-state durability: **session** — every writer of this slice
32413
+ * Runtime-state durability: **session** — the writer of this slice
32319
32414
  * writes only on an EDGE, so a restored `detected: true` would stay
32320
32415
  * frozen until the next one instead of being corrected. The next edge
32321
- * re-publishes the real state. (On who the writers are, and why there
32322
- * is more than one, see `autoClearAfterMs` above.)
32416
+ * re-publishes the real state, and the orchestrator re-publishes every
32417
+ * camera when it starts writing (D696; on who writes it, see
32418
+ * `autoClearAfterMs` above).
32323
32419
  *
32324
32420
  * See `RuntimeStateDurability`. Enforced by
32325
32421
  * `scripts/check-runtime-state-durability.ts`.
@@ -34702,8 +34798,7 @@ var ptzAutotrackCapability = {
34702
34798
  deviceNative: true,
34703
34799
  mode: "singleton",
34704
34800
  /**
34705
- * Two kinds of provider behind one name, the same shape `snapshot` and
34706
- * `doorbell` use:
34801
+ * Two kinds of provider behind one name, the same shape `snapshot` uses:
34707
34802
  *
34708
34803
  * - **Native**: the camera's own firmware autotrack, registered per device by
34709
34804
  * the driver when the probe says it exists (Reolink: yes; Hikvision:
@@ -34711,7 +34806,7 @@ var ptzAutotrackCapability = {
34711
34806
  * - **Wrapper**: the emulated implementation (`@camstack/system`'s `autotrack` builtin),
34712
34807
  * which follows a subject with `ptz.move` pulses driven by the detection
34713
34808
  * pipeline. `defaultActive: false` — the operator binds it per camera in
34714
- * the bindings UI, exactly as `virtual-doorbell` is bound.
34809
+ * the bindings UI.
34715
34810
  *
34716
34811
  * The binding chooses WHICH implementation answers; `setEnabled` stays the
34717
34812
  * one switch for the function either way. A camera never has both driving its
@@ -39809,13 +39904,14 @@ var BaseDeviceProvider = class extends BaseAddon {
39809
39904
  async getStatus() {
39810
39905
  const all = await this.ctx.kernel.devices?.getAll() ?? [];
39811
39906
  const summary = this.restoreFailureSummary();
39812
- if (summary === null) return {
39907
+ const base = {
39813
39908
  connected: true,
39814
- deviceCount: all.length
39909
+ deviceCount: all.length,
39910
+ motionSliceWriter: "orchestrator"
39815
39911
  };
39912
+ if (summary === null) return base;
39816
39913
  return {
39817
- connected: true,
39818
- deviceCount: all.length,
39914
+ ...base,
39819
39915
  error: summary
39820
39916
  };
39821
39917
  }
@@ -45251,6 +45347,12 @@ Object.freeze({
45251
45347
  addonId: null,
45252
45348
  access: "view"
45253
45349
  },
45350
+ "notificationRules.getAlarmSensors": {
45351
+ capName: "notification-rules",
45352
+ capScope: "system",
45353
+ addonId: null,
45354
+ access: "view"
45355
+ },
45254
45356
  "notificationRules.getClipRetentionAsks": {
45255
45357
  capName: "notification-rules",
45256
45358
  capScope: "system",
@@ -49734,6 +49836,11 @@ Object.freeze({
49734
49836
  form: "single",
49735
49837
  optional: false
49736
49838
  }],
49839
+ "notificationRules.getAlarmSensors": [{
49840
+ name: "deviceIds",
49841
+ form: "array",
49842
+ optional: false
49843
+ }],
49737
49844
  "notificationRules.setDeviceMuted": [{
49738
49845
  name: "deviceId",
49739
49846
  form: "single",
@@ -51669,6 +51776,25 @@ TimelapseRuleInputSchema.extend({
51669
51776
  createdAt: number(),
51670
51777
  updatedAt: number()
51671
51778
  });
51779
+ async function readHubMotionDetected(deviceState, deviceId) {
51780
+ let slice;
51781
+ try {
51782
+ slice = await deviceState.getCapSlice.query({
51783
+ deviceId,
51784
+ capName: "motion"
51785
+ });
51786
+ } catch (err) {
51787
+ const reason = err instanceof Error ? err.message : String(err);
51788
+ throw new Error(`motion state of device ${deviceId} is unreadable: ${reason}`, { cause: err });
51789
+ }
51790
+ const detected = slice?.["detected"];
51791
+ if (typeof detected !== "boolean") throw new Error(`motion state of device ${deviceId} is not published yet (unknown)`);
51792
+ return detected;
51793
+ }
51794
+ MotionOnMotionChangedDataSchema.omit({ triggeredBy: true });
51795
+ function providerMotionEvent(source, data) {
51796
+ return createEvent(EventCategory.ProviderMotion, source, data);
51797
+ }
51672
51798
  object({
51673
51799
  /**
51674
51800
  * Fraction of the box's own size added on EACH side before cutting.
@@ -56137,16 +56263,18 @@ var WyzeCamera = class extends BaseDevice {
56137
56263
  return null;
56138
56264
  }
56139
56265
  }
56266
+ /**
56267
+ * The native `motion` cap. This provider writes NO `motion` slice (D696): the
56268
+ * orchestrator is its only writer, with the EFFECTIVE motion, on the hub.
56269
+ * `isDetected` answers from the HUB's slice; an unreadable hub, or a slice
56270
+ * nobody has published yet, fails the call — never `false` for unknown
56271
+ * (D49, D393).
56272
+ */
56140
56273
  registerMotionProvider() {
56141
56274
  this.ctx.registerNativeCap(motionCapability, { isDetected: async ({ deviceId }) => {
56142
- if (deviceId !== this.id) return false;
56143
- return this.state.motion.detected ?? false;
56275
+ if (deviceId !== this.id) throw new Error(`WyzeCamera: deviceId mismatch, expected ${this.id}, got ${deviceId}`);
56276
+ return readHubMotionDetected(this.ctx.api.deviceState, this.id);
56144
56277
  } });
56145
- this.setCapSlice(motionCapability, {
56146
- detected: false,
56147
- lastDetectedAt: null,
56148
- autoClearAfterMs: null
56149
- });
56150
56278
  }
56151
56279
  /**
56152
56280
  * Start the configured motion source. `cloud` polls the Wyze events API
@@ -56190,12 +56318,14 @@ var WyzeCamera = class extends BaseDevice {
56190
56318
  }
56191
56319
  }
56192
56320
  /**
56193
- * Emit `MotionOnMotionChanged` (`source: 'onboard'`). The pipeline-runner
56194
- * subscribes and is the sole writer of the `motion` runtime-state slice
56195
- * — symmetric with the Reolink onboard-motion path.
56321
+ * Emit the camera's RAW motion push as `ProviderMotion`
56322
+ * (`source: 'onboard'`, D673). The orchestrator's camera-sensors bridge
56323
+ * re-emits it as the effective `MotionOnMotionChanged`, and the
56324
+ * orchestrator is the only writer of the camera's `motion` runtime-state
56325
+ * slice (D696) — symmetric with the Reolink onboard-motion path.
56196
56326
  */
56197
56327
  emitMotion(timestamp) {
56198
- this.ctx.eventBus.emit(createEvent(EventCategory.MotionOnMotionChanged, {
56328
+ this.ctx.eventBus.emit(providerMotionEvent({
56199
56329
  type: "device",
56200
56330
  id: this.id,
56201
56331
  addonId: WYZE_ADDON_ID,