@camstack/addon-provider-homeassistant 1.2.150 → 1.2.151

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/addon.js CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_dist = require("./dist-B-PoT2TH.js");
2
+ const require_dist = require("./dist-Cn_fSOpM.js");
3
3
  let node_crypto = require("node:crypto");
4
4
  let node_zlib = require("node:zlib");
5
5
  //#region src/ha-admin-link.ts
package/dist/addon.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as parseAdminBase, A as contactCapability, At as union, B as gasCapability, C as buildAddonRouteProvider, Ct as array, D as climateControlCapability, Dt as object, E as carbonMonoxideCapability, Et as number, G as lockControlCapability, H as humiditySensorCapability, I as enumSensorCapability, J as normalizeUnit, K as mediaPlayerCapability, L as eventEmitterCapability, M as coverCapability, Mt as url, N as deviceAdminLinkCapability, Nt as EventCategory, O as colorCapability, Ot as record, P as deviceAdoptionCapability, R as fanControlCapability, S as brokerCapability, St as _enum, T as buttonCapability, Tt as literal, U as imageCapability, V as humidifierCapability, W as lawnMowerControlCapability, X as notifierCapability, Y as notificationOutputCapability, Z as numericSensorCapability, _ as automationControlCapability, _t as DeviceType, at as smokeCapability, b as binaryCapability, bt as createEvent, ct as temperatureSensorCapability, d as TargetSchema, dt as valveCapability, et as powerMeterCapability, f as accessoriesCapability, ft as vibrationCapability, g as ambientLightSensorCapability, gt as DeviceRole, h as alarmPanelCapability, ht as DeviceFeature, it as scriptRunnerCapability, j as controlCapability, jt as unknown, k as connectivityCapability, kt as string, lt as updateCapability, m as airQualitySensorCapability, mt as weatherCapability, n as BaseDevice, nt as presenceCapability, ot as switchCapability, p as addonRoutesCapability, pt as waterHeaterCapability, q as motionCapability, r as BaseDeviceProvider, rt as pressureSensorCapability, s as EnumSensorDateTimeFormatSchema, st as tamperCapability, tt as prepareNotification, ut as vacuumControlCapability, v as batteryCapability, vt as errMsg, w as buildDeviceAdminUrl, wt as discriminatedUnion, x as brightnessCapability, y as bestLocationMatch, z as floodCapability } from "./dist-BwAVAaOH.mjs";
1
+ import { $ as parseAdminBase, A as contactCapability, At as union, B as gasCapability, C as buildAddonRouteProvider, Ct as array, D as climateControlCapability, Dt as object, E as carbonMonoxideCapability, Et as number, G as lockControlCapability, H as humiditySensorCapability, I as enumSensorCapability, J as normalizeUnit, K as mediaPlayerCapability, L as eventEmitterCapability, M as coverCapability, Mt as url, N as deviceAdminLinkCapability, Nt as EventCategory, O as colorCapability, Ot as record, P as deviceAdoptionCapability, R as fanControlCapability, S as brokerCapability, St as _enum, T as buttonCapability, Tt as literal, U as imageCapability, V as humidifierCapability, W as lawnMowerControlCapability, X as notifierCapability, Y as notificationOutputCapability, Z as numericSensorCapability, _ as automationControlCapability, _t as DeviceType, at as smokeCapability, b as binaryCapability, bt as createEvent, ct as temperatureSensorCapability, d as TargetSchema, dt as valveCapability, et as powerMeterCapability, f as accessoriesCapability, ft as vibrationCapability, g as ambientLightSensorCapability, gt as DeviceRole, h as alarmPanelCapability, ht as DeviceFeature, it as scriptRunnerCapability, j as controlCapability, jt as unknown, k as connectivityCapability, kt as string, lt as updateCapability, m as airQualitySensorCapability, mt as weatherCapability, n as BaseDevice, nt as presenceCapability, ot as switchCapability, p as addonRoutesCapability, pt as waterHeaterCapability, q as motionCapability, r as BaseDeviceProvider, rt as pressureSensorCapability, s as EnumSensorDateTimeFormatSchema, st as tamperCapability, tt as prepareNotification, ut as vacuumControlCapability, v as batteryCapability, vt as errMsg, w as buildDeviceAdminUrl, wt as discriminatedUnion, x as brightnessCapability, y as bestLocationMatch, z as floodCapability } from "./dist-DFsf2z4Q.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { brotliCompressSync, deflateSync, gzipSync } from "node:zlib";
4
4
  //#region src/ha-admin-link.ts
@@ -1,5 +1,5 @@
1
1
  require("node:crypto");
2
- //#region ../types/dist/event-category-C5xZWqz6.mjs
2
+ //#region ../types/dist/event-category-BGmz_oxW.mjs
3
3
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4
4
  EventCategory["SystemBoot"] = "system.boot";
5
5
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -532,6 +532,15 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
532
532
  */
533
533
  EventCategory["PipelineAudioInferenceResult"] = "pipeline.audio-inference-result";
534
534
  EventCategory["DetectionPhaseTransition"] = "detection.phase-transition";
535
+ /**
536
+ * A camera provider's RAW onboard motion push (D673): the `MotionOnMotionChanged`
537
+ * data shape without `triggeredBy`, built by `providerMotionEvent`. Its one
538
+ * consumer is the orchestrator's camera-sensors bridge, which re-emits the
539
+ * camera's EFFECTIVE onboard motion as `MotionOnMotionChanged` (a pass-through
540
+ * for a camera with no attached sensor). Providers must not emit
541
+ * `MotionOnMotionChanged` themselves; `scripts/check-onboard-motion-emitters.ts`
542
+ * keeps it so (camera-grid is a named, deferred exception).
543
+ */
535
544
  EventCategory["ProviderMotion"] = "provider.motion";
536
545
  EventCategory["ProviderDetection"] = "provider.detection";
537
546
  EventCategory["EnrichmentEmbeddingStored"] = "enrichment.embedding.stored";
@@ -5370,7 +5379,7 @@ var ZodIssueCode = {
5370
5379
  var ZodFirstPartyTypeKind;
5371
5380
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5372
5381
  //#endregion
5373
- //#region ../types/dist/sleep-gU6hqv4_.mjs
5382
+ //#region ../types/dist/sleep-CDCONfkt.mjs
5374
5383
  /**
5375
5384
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5376
5385
  * window to float samples (D455).
@@ -7472,7 +7481,7 @@ function errMsg(err) {
7472
7481
  return String(err);
7473
7482
  }
7474
7483
  //#endregion
7475
- //#region ../types/dist/composition-Dq42XWp0.mjs
7484
+ //#region ../types/dist/composition-43aqsZQj.mjs
7476
7485
  /**
7477
7486
  * The ffmpeg build every CamStack node downloads, per platform and arch.
7478
7487
  *
@@ -7529,13 +7538,12 @@ portable("linux64"), portable("linuxarm64"), portable("macarm64"), portable("mac
7529
7538
  * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
7530
7539
  * valutatore puro del suo FRONTE.
7531
7540
  *
7532
- * Viveva dentro il builtin virtual-doorbell
7533
- * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
7534
- * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
7535
- * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
7536
- * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
7537
- * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
7538
- * SPOSTA qui e il doorbell la ri-esporta.
7541
+ * UNA tabella per tutti quelli che chiedono "questo device è ALTO?": il
7542
+ * trigger `RecordingTriggers.sensorDeviceIds` del recorder, i marker dei
7543
+ * sensori della post-analysis, il bridge camera-sensors dell'orchestratore e
7544
+ * le sorgenti di un campanello composto (`doorbellFeatureSources`, D671).
7545
+ * Una seconda copia divergerebbe alla prima cap aggiunta, e il sintomo — "il
7546
+ * sensore fa suonare il campanello ma non registra" — è esattamente D62.
7539
7547
  *
7540
7548
  * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
7541
7549
  * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
@@ -7561,8 +7569,6 @@ var SOURCE_CAP_ACTIVE_FIELD = {
7561
7569
  vibration: "detected",
7562
7570
  tamper: "tampered"
7563
7571
  };
7564
- /** Cap names whose presence in a device's bindings qualify it as a source. */
7565
- var SOURCE_CAPS = Object.keys(SOURCE_CAP_ACTIVE_FIELD);
7566
7572
  /**
7567
7573
  * Error types for the safe expression engine. Two distinct classes so callers
7568
7574
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
@@ -9416,7 +9422,7 @@ var RecordingTriggersSchema = object({
9416
9422
  *
9417
9423
  * Cosa vuol dire "alto" dipende dal TIPO di device e non è deciso qui:
9418
9424
  * `SOURCE_CAP_ACTIVE_FIELD` (`catalogs/sensor-active-state.ts`) è LA tabella,
9419
- * la stessa che il virtual-doorbell usa dal 2026-08-05. Ed è il FRONTE, non
9425
+ * la stessa del campanello composto (D671). Ed è il FRONTE, non
9420
9426
  * il livello: un contatto trovato già aperto al riavvio del runner non fa
9421
9427
  * registrare.
9422
9428
  */
@@ -16094,109 +16100,10 @@ method(object({
16094
16100
  deviceIds: array(number()).readonly(),
16095
16101
  caps: array(string()).readonly().optional()
16096
16102
  }), record(string(), record(string(), unknown().nullable())));
16097
- /**
16098
- * Doorbell button cap. Two kinds of providers coexist behind this cap
16099
- * name (same pattern as `snapshot`):
16100
- *
16101
- * - **Native** providers: registered per-device by device-driver
16102
- * addons via `ctx.registerNativeCap` — either on a
16103
- * `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
16104
- * or directly on the camera (Reolink registers at camera level).
16105
- * Emits an `onPressed` event every time the firmware pushes a
16106
- * ring; status tracks the last press and a pressCount since start
16107
- * (diagnostic).
16108
- *
16109
- * - **Wrapper** provider: the `virtual-doorbell` system builtin
16110
- * (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
16111
- * device (contact / switch / event-emitter …) into a doorbell for
16112
- * a camera. `defaultActive: false` — the operator explicitly binds
16113
- * it per camera in the device-bindings UI, then picks the source
16114
- * device + trigger in the per-device settings.
16115
- *
16116
- * The DeviceEventPropagator re-emits `onPressed` on the camera parent
16117
- * — subscribers listening at the camera level receive ring events
16118
- * with `via[]` populated. No code on the parent needed.
16119
- */
16120
- var DoorbellStatusSchema = object({
16121
- /** Ms epoch of the last press. null = never observed since this provider started. */
16122
- lastPressedAt: number().nullable(),
16123
- /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
16124
- pressCountSinceStart: number()
16125
- });
16126
- var DoorbellPressEventSchema = object({
16127
- deviceId: number(),
16128
- timestamp: number()
16129
- });
16130
- /**
16131
- * The `doorbell-source` extension slot's editable value (D648): the camera's
16132
- * virtual-doorbell trigger devices, exactly what the wrapper's
16133
- * `doorbellSources` persists (as `{ deviceId }` records).
16134
- */
16135
- var DoorbellSourceSlotValueSchema = object({ deviceIds: array(number().int().positive()) });
16136
- /**
16137
- * The `doorbell-source` slot — which devices ring this camera's VIRTUAL
16138
- * doorbell, owned by the `virtual-doorbell` wrapper over its
16139
- * `doorbellSources` store (D648). A source rings when one of its
16140
- * `SOURCE_CAPS` rises. Whether the wrapper is bound to the camera at all is a
16141
- * different authority (`deviceManager.setWrapperActive`, D62) — the slot
16142
- * reports it, it never writes it.
16143
- */
16144
- var DOORBELL_SOURCE_SLOT = {
16145
- id: "doorbell-source",
16146
- label: "Doorbell trigger devices",
16147
- 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.",
16148
- shape: "association",
16149
- hostDeviceTypes: [DeviceType.Camera],
16150
- sourceCaps: SOURCE_CAPS,
16151
- cardinality: "many",
16152
- value: DoorbellSourceSlotValueSchema
16153
- };
16154
- var doorbellCapability = {
16155
- name: "doorbell",
16156
- scope: "device",
16157
- deviceNative: true,
16158
- mode: "singleton",
16159
- kind: "wrapper",
16160
- defaultActive: false,
16161
- deviceTypes: [DeviceType.Button, DeviceType.Camera],
16162
- extensionSlots: [DOORBELL_SOURCE_SLOT],
16163
- methods: {},
16164
- events: {
16165
- /**
16166
- * Fires once per physical press. Reolink delivers via Baichuan
16167
- * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
16168
- * release/duration — it's a pulse.
16169
- */
16170
- onPressed: {
16171
- data: DoorbellPressEventSchema,
16172
- fromState: {
16173
- field: "lastPressedAt",
16174
- on: "advance"
16175
- }
16176
- } },
16177
- status: {
16178
- schema: DoorbellStatusSchema,
16179
- kind: "push"
16180
- },
16181
- /**
16182
- * Runtime-state slice — last press timestamp + lifetime press count.
16183
- * Mirrored by the kernel and readable via
16184
- * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
16185
- * without subscribing.
16186
- */
16187
- runtimeState: DoorbellStatusSchema,
16188
- /**
16189
- * 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.
16190
- *
16191
- * See `RuntimeStateDurability`. Enforced by
16192
- * `scripts/check-runtime-state-durability.ts`.
16193
- */
16194
- durability: "restored"
16195
- };
16196
- var ExtensionSlotIdSchema = _enum(["doorbell-source", "linked-devices"]);
16197
- DeviceType.Camera, DeviceType.Camera;
16103
+ var ExtensionSlotIdSchema = _enum(["linked-devices"]);
16104
+ DeviceType.Camera;
16198
16105
  /** A slot's editable value, discriminated on `slot`. */
16199
- var ExtensionSlotValueSchema = discriminatedUnion("slot", [DoorbellSourceSlotValueSchema.extend({ slot: literal("doorbell-source") }), LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
16106
+ var ExtensionSlotValueSchema = discriminatedUnion("slot", [LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
16200
16107
  DeviceType.Camera;
16201
16108
  var ExtensionSourceAvailabilitySchema = discriminatedUnion("state", [object({ state: literal("ok") }), object({
16202
16109
  state: literal("unreachable"),
@@ -16233,10 +16140,11 @@ var ExtensionSlotSourceSchema = object({
16233
16140
  });
16234
16141
  /**
16235
16142
  * A DIFFERENT authority that gates whether the slot's sources do anything —
16236
- * reported read-only, named, never written through this contract (D62). The
16237
- * virtual doorbell's sources ring only while the wrapper is bound to the
16238
- * camera, and that binding belongs to `deviceManager.setWrapperActive`.
16239
- * `unknown` means the gate could not be read; it is not "inactive" (D315).
16143
+ * reported read-only, named, never written through this contract (D62) — e.g.
16144
+ * a slot whose sources act only while a wrapper is bound to the host, a
16145
+ * binding that belongs to `deviceManager.setWrapperActive`. No slot reports
16146
+ * one today (`linked-devices` answers `null`). `unknown` means the gate could
16147
+ * not be read; it is not "inactive" (D315).
16240
16148
  */
16241
16149
  var ExtensionSlotActivationSchema = object({
16242
16150
  state: _enum([
@@ -16252,7 +16160,7 @@ var ExtensionSlotRowSchema = discriminatedUnion("state", [object({
16252
16160
  /** `<source>:<slotId>` — the routing key for `listCandidates` / `setSlot`. */
16253
16161
  slotRef: string(),
16254
16162
  slot: ExtensionSlotIdSchema,
16255
- /** Names the store written (D62), e.g. `virtual-doorbell:doorbellSources`. */
16163
+ /** Names the store written (D62), e.g. `device-manager:_linkedDeviceIds`. */
16256
16164
  authority: string(),
16257
16165
  activation: ExtensionSlotActivationSchema.nullable(),
16258
16166
  value: ExtensionSlotValueSchema,
@@ -21404,12 +21312,26 @@ var CameraSensorRefSchema = object({
21404
21312
  function cameraSensorRefKey(ref) {
21405
21313
  return `${ref.addonId}/${ref.stableId}`;
21406
21314
  }
21407
- /** CS-1 accepts exactly one mode; CS-2 (D673) widens it to confirm / replace. */
21408
- var CameraSensorsModeSchema = _enum(["in-addition"]);
21409
- var CameraSensorsConfigSchema = object({
21410
- mode: CameraSensorsModeSchema,
21411
- sensors: array(CameraSensorRefSchema).min(1).max(8)
21412
- }).superRefine((value, ctx) => {
21315
+ /**
21316
+ * A sensor's mode (D673). `in-addition`: its motion is the camera's motion too.
21317
+ * `replace`: its motion is the camera's, and while one is READY the camera's
21318
+ * own motion no longer counts on its own. `confirm`: while one is READY the
21319
+ * camera's own motion counts only while a confirm sensor is active — with or
21320
+ * without a replace sensor (spec C2, the controller's ruling on Q1).
21321
+ */
21322
+ var CameraSensorModeSchema = _enum([
21323
+ "in-addition",
21324
+ "confirm",
21325
+ "replace"
21326
+ ]);
21327
+ /** A stored sensor with no mode — every CS-1 row — is in addition. */
21328
+ var DEFAULT_CAMERA_SENSOR_MODE = "in-addition";
21329
+ /**
21330
+ * A camera's attached sensors. A CS-1 row carried an envelope
21331
+ * `mode: 'in-addition'`: `z.object` drops it on parse, and the PARSED value is
21332
+ * what the write stores (D672 rule 3), so it is never written again.
21333
+ */
21334
+ var CameraSensorsConfigSchema = object({ sensors: array(CameraSensorRefSchema.extend({ mode: CameraSensorModeSchema.default(DEFAULT_CAMERA_SENSOR_MODE) })).min(1).max(8) }).superRefine((value, ctx) => {
21413
21335
  const seen = /* @__PURE__ */ new Set();
21414
21336
  value.sensors.forEach((ref, index) => {
21415
21337
  const key = cameraSensorRefKey(ref);
@@ -21421,39 +21343,41 @@ var CameraSensorsConfigSchema = object({
21421
21343
  seen.add(key);
21422
21344
  });
21423
21345
  });
21424
- var RefFields = {
21346
+ /** Every attachment names its mode; an older orchestrator that does not is in addition. */
21347
+ var AttachmentFields = {
21425
21348
  addonId: string(),
21426
- stableId: string()
21349
+ stableId: string(),
21350
+ mode: CameraSensorModeSchema.default(DEFAULT_CAMERA_SENSOR_MODE)
21427
21351
  };
21428
21352
  var CameraSensorAttachmentSchema = discriminatedUnion("state", [
21429
21353
  object({
21430
- ...RefFields,
21354
+ ...AttachmentFields,
21431
21355
  state: literal("ready"),
21432
21356
  deviceId: number(),
21433
21357
  name: string(),
21434
21358
  caps: array(string()).readonly()
21435
21359
  }),
21436
21360
  object({
21437
- ...RefFields,
21361
+ ...AttachmentFields,
21438
21362
  state: literal("offline"),
21439
21363
  deviceId: number(),
21440
21364
  name: string(),
21441
21365
  reason: _enum(["offline", "disabled"])
21442
21366
  }),
21443
21367
  object({
21444
- ...RefFields,
21368
+ ...AttachmentFields,
21445
21369
  state: literal("missing"),
21446
21370
  reason: string()
21447
21371
  }),
21448
21372
  object({
21449
- ...RefFields,
21373
+ ...AttachmentFields,
21450
21374
  state: literal("unsupported"),
21451
21375
  deviceId: number(),
21452
21376
  name: string(),
21453
21377
  reason: string()
21454
21378
  }),
21455
21379
  object({
21456
- ...RefFields,
21380
+ ...AttachmentFields,
21457
21381
  state: literal("unreadable"),
21458
21382
  reason: string()
21459
21383
  })
@@ -21466,17 +21390,49 @@ var CameraSensorAttachmentSchema = discriminatedUnion("state", [
21466
21390
  * say.
21467
21391
  */
21468
21392
  var CameraSensorsNotForwardedSchema = _enum(["onboard-not-listed", "no-active-detection"]);
21393
+ /** Whether the camera's OWN motion counts on its own (D673 C2), from its READY sensors (C3). */
21394
+ var CameraOwnMotionSchema = _enum([
21395
+ "always",
21396
+ "when-confirmed",
21397
+ "never"
21398
+ ]);
21399
+ /** Confirm / Replace cannot suppress this camera's motion: its provider still emits it directly (D673 C13). */
21400
+ var CameraSensorsNotEnforcedSchema = _enum(["provider-not-split"]);
21401
+ /**
21402
+ * The camera's OWN onboard motion (D696): the raw input the bridge combines,
21403
+ * never the effective value. The camera's `motion` slice is the effective one,
21404
+ * so a view of the camera's own row reads this.
21405
+ * - `atMs`: when the bridge received the camera's last own edge.
21406
+ * - `detected`: evaluated WHEN THE STATUS IS ASKED — the last edge said `true`
21407
+ * AND it is younger than the window the bridge counts the camera's own motion
21408
+ * for (`motionCooldownMs`, floored at two sustain ticks). A camera that never
21409
+ * sends a clear (heartbeats only) therefore reads `false` once no push came
21410
+ * within the window; a status read is a snapshot, so a live view re-asks.
21411
+ * Absent = this orchestrator has not received the camera's own motion since it
21412
+ * started (unknown, never "quiet"), or an orchestrator older than D696.
21413
+ */
21414
+ var CameraRawLevelSchema = object({
21415
+ detected: boolean(),
21416
+ atMs: number()
21417
+ });
21469
21418
  var CameraSensorsStatusSchema = discriminatedUnion("state", [
21470
- object({ state: literal("not-configured") }),
21419
+ object({
21420
+ state: literal("not-configured"),
21421
+ cameraLevel: CameraRawLevelSchema.optional()
21422
+ }),
21471
21423
  object({
21472
21424
  state: literal("unreadable"),
21473
- reason: string()
21425
+ reason: string(),
21426
+ cameraLevel: CameraRawLevelSchema.optional()
21474
21427
  }),
21475
21428
  object({
21476
21429
  state: literal("configured"),
21477
- mode: CameraSensorsModeSchema,
21430
+ cameraLevel: CameraRawLevelSchema.optional(),
21478
21431
  sensors: array(CameraSensorAttachmentSchema).readonly(),
21479
- notForwarded: CameraSensorsNotForwardedSchema.optional()
21432
+ /** Absent = an orchestrator older than CS-2: it does not say (D315). */
21433
+ cameraMotion: CameraOwnMotionSchema.optional(),
21434
+ notForwarded: CameraSensorsNotForwardedSchema.optional(),
21435
+ notEnforced: CameraSensorsNotEnforcedSchema.optional()
21480
21436
  })
21481
21437
  ]);
21482
21438
  Object.freeze({
@@ -24707,8 +24663,10 @@ var RunnerCameraConfigSchema = object({
24707
24663
  * - `analyzer`: ML/frame-diff motion detection (motion-wasm or other
24708
24664
  * analyzer providers) running on decoded frames in this runner.
24709
24665
  * - `onboard`: camera-native motion pushes (Reolink Baichuan, ONVIF
24710
- * analytics). The provider emits ProviderMotion
24711
- * events; the orchestrator forwards to `reportMotion`.
24666
+ * analytics). The provider emits its raw push as `ProviderMotion`
24667
+ * (D673); the orchestrator's camera-sensors bridge re-emits the camera's
24668
+ * effective motion as `MotionOnMotionChanged`, which is what reaches
24669
+ * `reportMotion`.
24712
24670
  */
24713
24671
  motionSources: MotionSourcesSchema.default(["analyzer"]),
24714
24672
  /**
@@ -24885,7 +24843,15 @@ var RunnerLocalLoadSchema = object({
24885
24843
  hasGpu: boolean(),
24886
24844
  inferenceBackend: string().optional(),
24887
24845
  cpuCores: number().optional()
24888
- })
24846
+ }),
24847
+ /**
24848
+ * Who writes a camera's `motion` runtime slice (D696). `'orchestrator'`: this
24849
+ * runner never writes it. ABSENT = a runner older than D696, which still
24850
+ * writes the slice from its phase machine; the orchestrator does not write
24851
+ * while any runner node is absent-or-unanswered, so one slice never has two
24852
+ * writers.
24853
+ */
24854
+ motionSliceWriter: literal("orchestrator").optional()
24889
24855
  });
24890
24856
  /**
24891
24857
  * Aggregate runtime metrics for the runner's whole local pool. Mirrors the
@@ -30495,6 +30461,70 @@ onStatusChanged: { data: object({
30495
30461
  * whether persisting is worth a SQLite commit. */
30496
30462
  volatileStateFields: ["lastChangedAt"]
30497
30463
  };
30464
+ var DoorbellStatusSchema = object({
30465
+ /** Ms epoch of the last press. null = never observed since this provider started. */
30466
+ lastPressedAt: number().nullable(),
30467
+ /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
30468
+ pressCountSinceStart: number()
30469
+ });
30470
+ var DoorbellPressEventSchema = object({
30471
+ deviceId: number(),
30472
+ timestamp: number()
30473
+ });
30474
+ /**
30475
+ * Doorbell button cap. Two kinds of provider serve it, and to every consumer
30476
+ * they are the same cap:
30477
+ *
30478
+ * - **Native** providers, registered per device by a driver addon through
30479
+ * `ctx.registerNativeCap` — a `DeviceType.Button` accessory with
30480
+ * `role: DeviceRole.Doorbell`, or the camera itself (Reolink registers at
30481
+ * camera level). They emit `onPressed` on every firmware ring.
30482
+ * - **A composed doorbell** (D670, D671): a camera's customization gives it
30483
+ * the cap, its `lastPressedAt` rising from the sources the operator
30484
+ * assigned in Customize → Doorbell, and the composer emits `onPressed`
30485
+ * from that field's advance (`fromState`).
30486
+ *
30487
+ * The DeviceEventPropagator re-emits `onPressed` on the camera parent.
30488
+ */
30489
+ var doorbellCapability = {
30490
+ name: "doorbell",
30491
+ scope: "device",
30492
+ deviceNative: true,
30493
+ mode: "singleton",
30494
+ deviceTypes: [DeviceType.Button, DeviceType.Camera],
30495
+ methods: {},
30496
+ events: {
30497
+ /**
30498
+ * Fires once per physical press. Reolink delivers via Baichuan
30499
+ * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
30500
+ * release/duration — it's a pulse.
30501
+ */
30502
+ onPressed: {
30503
+ data: DoorbellPressEventSchema,
30504
+ fromState: {
30505
+ field: "lastPressedAt",
30506
+ on: "advance"
30507
+ }
30508
+ } },
30509
+ status: {
30510
+ schema: DoorbellStatusSchema,
30511
+ kind: "push"
30512
+ },
30513
+ /**
30514
+ * Runtime-state slice — last press timestamp + lifetime press count.
30515
+ * Mirrored by the kernel and readable via
30516
+ * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
30517
+ * without subscribing.
30518
+ */
30519
+ runtimeState: DoorbellStatusSchema,
30520
+ /**
30521
+ * 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.
30522
+ *
30523
+ * See `RuntimeStateDurability`. Enforced by
30524
+ * `scripts/check-runtime-state-durability.ts`.
30525
+ */
30526
+ durability: "restored"
30527
+ };
30498
30528
  /**
30499
30529
  * Enum-state sensor — a string value picked from a finite option set.
30500
30530
  * Drives HA `sensor` entries with `state_class: enum` (HVAC action
@@ -32639,9 +32669,9 @@ var MotionStatusSchema = object({
32639
32669
  /** Ms epoch of the last detected-true observation. Null if never detected. */
32640
32670
  lastDetectedAt: number().nullable(),
32641
32671
  /**
32642
- * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
32643
- * `null` while false and on every `Sensor` device (D475) — see that
32644
- * constant's doc for the one-authority rule.
32672
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device (the
32673
+ * orchestrator writes it, D696), `null` while false and on every `Sensor`
32674
+ * device (D475) — see that constant's doc for the one-authority rule.
32645
32675
  *
32646
32676
  * ## Reading this field still arms nothing
32647
32677
  *
@@ -32659,34 +32689,31 @@ var MotionStatusSchema = object({
32659
32689
  * `addon-export-alexa/src/motion-clear-hold.ts` and
32660
32690
  * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
32661
32691
  *
32662
- * ## Who writes it
32663
- *
32664
- * - **Cameras** — the runner's phase machine, `active → watching` on
32665
- * `cooldown_expired`, which then writes this slice with
32666
- * `detected: false` (`handlePhaseChanged` in
32667
- * `pipeline-runner/index.ts`). It produces the FALLING edge, which
32668
- * matters most for the sources that only ever push a rising one:
32669
- * Reolink emits `MotionOnMotionChanged { detected: true }` and never
32670
- * a false.
32671
- * - **Sensors** (Home Assistant binary sensors, Homematic) — the
32672
- * provider pushes the false itself, from the upstream system's own
32673
- * state change. No phase machine is involved.
32674
- *
32675
- * ### The phase machine is CANONICAL, not sole — and that is a defect
32676
- *
32677
- * An earlier revision of this docblock (mine, 2026-09-12) claimed the
32678
- * phase machine is the sole writer for a camera. It is not.
32679
- * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
32680
- * `setCapSlice(motionCapability, …)` on their own rising edge, and
32681
- * Hikvision's comment says why: it read THIS docblock, agreed the
32682
- * runner is canonical, and wrote anyway to avoid per-tick churn. So
32683
- * two authorities can disagree about one slice, which this repo
32684
- * forbids, and the doc said otherwise — which is worse than saying
32685
- * nothing, because it reads as verification.
32686
- *
32687
- * This predates D475 and is not fixed there: the fix touches every
32688
- * camera provider. Recorded in D475's Consequences. Do not restore the
32689
- * "sole writer" wording without also removing the other writers.
32692
+ * ## Who writes it (D696)
32693
+ *
32694
+ * - **Cameras** — the orchestrator, and nothing else. It writes the camera's
32695
+ * EFFECTIVE motion (`addon-pipeline-orchestrator`
32696
+ * `camera-sensors/motion-slice.ts`), alongside the effective
32697
+ * `MotionOnMotionChanged` it emits or receives: the camera-sensors bridge
32698
+ * for a split camera, an unsplit emitter's direct event, the analyzer and
32699
+ * device activity, as the camera's `motionSources` counts them. A source
32700
+ * that never sends a clear falls one window after its last `true`.
32701
+ * `lastDetectedAt` moves only on an effective rise. No camera provider
32702
+ * writes this slice (not even a boot seed), and neither does the runner's
32703
+ * phase machine: its phase is "a session is attached" for every on-motion
32704
+ * session, not motion, and it now has its own `DetectionPhaseTransition`.
32705
+ * A provider's `isDetected` answers from the hub's slice.
32706
+ * - **Sensors** (Home Assistant binary sensors, Homematic, Matter, Alexa
32707
+ * imports) — the provider pushes both edges itself, from the upstream
32708
+ * system's own state change. That is the sensor's own fact.
32709
+ *
32710
+ * `scripts/check-onboard-motion-emitters.ts` refuses any other writer of a
32711
+ * `motion` slice; each sensor writer is a named exemption.
32712
+ *
32713
+ * This replaces the D475 §4 rule ("the phase machine is the sole writer").
32714
+ * That rule was never true: Hikvision and Amcrest wrote the slice raw beside
32715
+ * it, every provider seeded it at boot, and every session left it
32716
+ * `detected: true` after its detach.
32690
32717
  */
32691
32718
  autoClearAfterMs: number().nullable()
32692
32719
  });
@@ -32758,11 +32785,12 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
32758
32785
  */
32759
32786
  runtimeState: MotionStatusSchema,
32760
32787
  /**
32761
- * Runtime-state durability: **session** — every writer of this slice
32788
+ * Runtime-state durability: **session** — the writer of this slice
32762
32789
  * writes only on an EDGE, so a restored `detected: true` would stay
32763
32790
  * frozen until the next one instead of being corrected. The next edge
32764
- * re-publishes the real state. (On who the writers are, and why there
32765
- * is more than one, see `autoClearAfterMs` above.)
32791
+ * re-publishes the real state, and the orchestrator re-publishes every
32792
+ * camera when it starts writing (D696; on who writes it, see
32793
+ * `autoClearAfterMs` above).
32766
32794
  *
32767
32795
  * See `RuntimeStateDurability`. Enforced by
32768
32796
  * `scripts/check-runtime-state-durability.ts`.
@@ -35145,8 +35173,7 @@ var ptzAutotrackCapability = {
35145
35173
  deviceNative: true,
35146
35174
  mode: "singleton",
35147
35175
  /**
35148
- * Two kinds of provider behind one name, the same shape `snapshot` and
35149
- * `doorbell` use:
35176
+ * Two kinds of provider behind one name, the same shape `snapshot` uses:
35150
35177
  *
35151
35178
  * - **Native**: the camera's own firmware autotrack, registered per device by
35152
35179
  * the driver when the probe says it exists (Reolink: yes; Hikvision:
@@ -35154,7 +35181,7 @@ var ptzAutotrackCapability = {
35154
35181
  * - **Wrapper**: the emulated implementation (`@camstack/system`'s `autotrack` builtin),
35155
35182
  * which follows a subject with `ptz.move` pulses driven by the detection
35156
35183
  * pipeline. `defaultActive: false` — the operator binds it per camera in
35157
- * the bindings UI, exactly as `virtual-doorbell` is bound.
35184
+ * the bindings UI.
35158
35185
  *
35159
35186
  * The binding chooses WHICH implementation answers; `setEnabled` stays the
35160
35187
  * one switch for the function either way. A camera never has both driving its
@@ -52319,6 +52346,7 @@ TimelapseRuleInputSchema.extend({
52319
52346
  createdAt: number(),
52320
52347
  updatedAt: number()
52321
52348
  });
52349
+ MotionOnMotionChangedDataSchema.omit({ triggeredBy: true });
52322
52350
  object({
52323
52351
  /**
52324
52352
  * Fraction of the box's own size added on EACH side before cutting.
@@ -1,4 +1,4 @@
1
- //#region ../types/dist/event-category-C5xZWqz6.mjs
1
+ //#region ../types/dist/event-category-BGmz_oxW.mjs
2
2
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
3
3
  EventCategory["SystemBoot"] = "system.boot";
4
4
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -531,6 +531,15 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
531
531
  */
532
532
  EventCategory["PipelineAudioInferenceResult"] = "pipeline.audio-inference-result";
533
533
  EventCategory["DetectionPhaseTransition"] = "detection.phase-transition";
534
+ /**
535
+ * A camera provider's RAW onboard motion push (D673): the `MotionOnMotionChanged`
536
+ * data shape without `triggeredBy`, built by `providerMotionEvent`. Its one
537
+ * consumer is the orchestrator's camera-sensors bridge, which re-emits the
538
+ * camera's EFFECTIVE onboard motion as `MotionOnMotionChanged` (a pass-through
539
+ * for a camera with no attached sensor). Providers must not emit
540
+ * `MotionOnMotionChanged` themselves; `scripts/check-onboard-motion-emitters.ts`
541
+ * keeps it so (camera-grid is a named, deferred exception).
542
+ */
534
543
  EventCategory["ProviderMotion"] = "provider.motion";
535
544
  EventCategory["ProviderDetection"] = "provider.detection";
536
545
  EventCategory["EnrichmentEmbeddingStored"] = "enrichment.embedding.stored";
@@ -5369,7 +5378,7 @@ var ZodIssueCode = {
5369
5378
  var ZodFirstPartyTypeKind;
5370
5379
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5371
5380
  //#endregion
5372
- //#region ../types/dist/sleep-gU6hqv4_.mjs
5381
+ //#region ../types/dist/sleep-CDCONfkt.mjs
5373
5382
  /**
5374
5383
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5375
5384
  * window to float samples (D455).
@@ -7471,7 +7480,7 @@ function errMsg(err) {
7471
7480
  return String(err);
7472
7481
  }
7473
7482
  //#endregion
7474
- //#region ../types/dist/composition-Dq42XWp0.mjs
7483
+ //#region ../types/dist/composition-43aqsZQj.mjs
7475
7484
  /**
7476
7485
  * The ffmpeg build every CamStack node downloads, per platform and arch.
7477
7486
  *
@@ -7528,13 +7537,12 @@ portable("linux64"), portable("linuxarm64"), portable("macarm64"), portable("mac
7528
7537
  * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
7529
7538
  * valutatore puro del suo FRONTE.
7530
7539
  *
7531
- * Viveva dentro il builtin virtual-doorbell
7532
- * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
7533
- * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
7534
- * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
7535
- * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
7536
- * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
7537
- * SPOSTA qui e il doorbell la ri-esporta.
7540
+ * UNA tabella per tutti quelli che chiedono "questo device è ALTO?": il
7541
+ * trigger `RecordingTriggers.sensorDeviceIds` del recorder, i marker dei
7542
+ * sensori della post-analysis, il bridge camera-sensors dell'orchestratore e
7543
+ * le sorgenti di un campanello composto (`doorbellFeatureSources`, D671).
7544
+ * Una seconda copia divergerebbe alla prima cap aggiunta, e il sintomo — "il
7545
+ * sensore fa suonare il campanello ma non registra" — è esattamente D62.
7538
7546
  *
7539
7547
  * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
7540
7548
  * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
@@ -7560,8 +7568,6 @@ var SOURCE_CAP_ACTIVE_FIELD = {
7560
7568
  vibration: "detected",
7561
7569
  tamper: "tampered"
7562
7570
  };
7563
- /** Cap names whose presence in a device's bindings qualify it as a source. */
7564
- var SOURCE_CAPS = Object.keys(SOURCE_CAP_ACTIVE_FIELD);
7565
7571
  /**
7566
7572
  * Error types for the safe expression engine. Two distinct classes so callers
7567
7573
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
@@ -9415,7 +9421,7 @@ var RecordingTriggersSchema = object({
9415
9421
  *
9416
9422
  * Cosa vuol dire "alto" dipende dal TIPO di device e non è deciso qui:
9417
9423
  * `SOURCE_CAP_ACTIVE_FIELD` (`catalogs/sensor-active-state.ts`) è LA tabella,
9418
- * la stessa che il virtual-doorbell usa dal 2026-08-05. Ed è il FRONTE, non
9424
+ * la stessa del campanello composto (D671). Ed è il FRONTE, non
9419
9425
  * il livello: un contatto trovato già aperto al riavvio del runner non fa
9420
9426
  * registrare.
9421
9427
  */
@@ -16093,109 +16099,10 @@ method(object({
16093
16099
  deviceIds: array(number()).readonly(),
16094
16100
  caps: array(string()).readonly().optional()
16095
16101
  }), record(string(), record(string(), unknown().nullable())));
16096
- /**
16097
- * Doorbell button cap. Two kinds of providers coexist behind this cap
16098
- * name (same pattern as `snapshot`):
16099
- *
16100
- * - **Native** providers: registered per-device by device-driver
16101
- * addons via `ctx.registerNativeCap` — either on a
16102
- * `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
16103
- * or directly on the camera (Reolink registers at camera level).
16104
- * Emits an `onPressed` event every time the firmware pushes a
16105
- * ring; status tracks the last press and a pressCount since start
16106
- * (diagnostic).
16107
- *
16108
- * - **Wrapper** provider: the `virtual-doorbell` system builtin
16109
- * (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
16110
- * device (contact / switch / event-emitter …) into a doorbell for
16111
- * a camera. `defaultActive: false` — the operator explicitly binds
16112
- * it per camera in the device-bindings UI, then picks the source
16113
- * device + trigger in the per-device settings.
16114
- *
16115
- * The DeviceEventPropagator re-emits `onPressed` on the camera parent
16116
- * — subscribers listening at the camera level receive ring events
16117
- * with `via[]` populated. No code on the parent needed.
16118
- */
16119
- var DoorbellStatusSchema = object({
16120
- /** Ms epoch of the last press. null = never observed since this provider started. */
16121
- lastPressedAt: number().nullable(),
16122
- /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
16123
- pressCountSinceStart: number()
16124
- });
16125
- var DoorbellPressEventSchema = object({
16126
- deviceId: number(),
16127
- timestamp: number()
16128
- });
16129
- /**
16130
- * The `doorbell-source` extension slot's editable value (D648): the camera's
16131
- * virtual-doorbell trigger devices, exactly what the wrapper's
16132
- * `doorbellSources` persists (as `{ deviceId }` records).
16133
- */
16134
- var DoorbellSourceSlotValueSchema = object({ deviceIds: array(number().int().positive()) });
16135
- /**
16136
- * The `doorbell-source` slot — which devices ring this camera's VIRTUAL
16137
- * doorbell, owned by the `virtual-doorbell` wrapper over its
16138
- * `doorbellSources` store (D648). A source rings when one of its
16139
- * `SOURCE_CAPS` rises. Whether the wrapper is bound to the camera at all is a
16140
- * different authority (`deviceManager.setWrapperActive`, D62) — the slot
16141
- * reports it, it never writes it.
16142
- */
16143
- var DOORBELL_SOURCE_SLOT = {
16144
- id: "doorbell-source",
16145
- label: "Doorbell trigger devices",
16146
- 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.",
16147
- shape: "association",
16148
- hostDeviceTypes: [DeviceType.Camera],
16149
- sourceCaps: SOURCE_CAPS,
16150
- cardinality: "many",
16151
- value: DoorbellSourceSlotValueSchema
16152
- };
16153
- var doorbellCapability = {
16154
- name: "doorbell",
16155
- scope: "device",
16156
- deviceNative: true,
16157
- mode: "singleton",
16158
- kind: "wrapper",
16159
- defaultActive: false,
16160
- deviceTypes: [DeviceType.Button, DeviceType.Camera],
16161
- extensionSlots: [DOORBELL_SOURCE_SLOT],
16162
- methods: {},
16163
- events: {
16164
- /**
16165
- * Fires once per physical press. Reolink delivers via Baichuan
16166
- * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
16167
- * release/duration — it's a pulse.
16168
- */
16169
- onPressed: {
16170
- data: DoorbellPressEventSchema,
16171
- fromState: {
16172
- field: "lastPressedAt",
16173
- on: "advance"
16174
- }
16175
- } },
16176
- status: {
16177
- schema: DoorbellStatusSchema,
16178
- kind: "push"
16179
- },
16180
- /**
16181
- * Runtime-state slice — last press timestamp + lifetime press count.
16182
- * Mirrored by the kernel and readable via
16183
- * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
16184
- * without subscribing.
16185
- */
16186
- runtimeState: DoorbellStatusSchema,
16187
- /**
16188
- * 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.
16189
- *
16190
- * See `RuntimeStateDurability`. Enforced by
16191
- * `scripts/check-runtime-state-durability.ts`.
16192
- */
16193
- durability: "restored"
16194
- };
16195
- var ExtensionSlotIdSchema = _enum(["doorbell-source", "linked-devices"]);
16196
- DeviceType.Camera, DeviceType.Camera;
16102
+ var ExtensionSlotIdSchema = _enum(["linked-devices"]);
16103
+ DeviceType.Camera;
16197
16104
  /** A slot's editable value, discriminated on `slot`. */
16198
- var ExtensionSlotValueSchema = discriminatedUnion("slot", [DoorbellSourceSlotValueSchema.extend({ slot: literal("doorbell-source") }), LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
16105
+ var ExtensionSlotValueSchema = discriminatedUnion("slot", [LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
16199
16106
  DeviceType.Camera;
16200
16107
  var ExtensionSourceAvailabilitySchema = discriminatedUnion("state", [object({ state: literal("ok") }), object({
16201
16108
  state: literal("unreachable"),
@@ -16232,10 +16139,11 @@ var ExtensionSlotSourceSchema = object({
16232
16139
  });
16233
16140
  /**
16234
16141
  * A DIFFERENT authority that gates whether the slot's sources do anything —
16235
- * reported read-only, named, never written through this contract (D62). The
16236
- * virtual doorbell's sources ring only while the wrapper is bound to the
16237
- * camera, and that binding belongs to `deviceManager.setWrapperActive`.
16238
- * `unknown` means the gate could not be read; it is not "inactive" (D315).
16142
+ * reported read-only, named, never written through this contract (D62) — e.g.
16143
+ * a slot whose sources act only while a wrapper is bound to the host, a
16144
+ * binding that belongs to `deviceManager.setWrapperActive`. No slot reports
16145
+ * one today (`linked-devices` answers `null`). `unknown` means the gate could
16146
+ * not be read; it is not "inactive" (D315).
16239
16147
  */
16240
16148
  var ExtensionSlotActivationSchema = object({
16241
16149
  state: _enum([
@@ -16251,7 +16159,7 @@ var ExtensionSlotRowSchema = discriminatedUnion("state", [object({
16251
16159
  /** `<source>:<slotId>` — the routing key for `listCandidates` / `setSlot`. */
16252
16160
  slotRef: string(),
16253
16161
  slot: ExtensionSlotIdSchema,
16254
- /** Names the store written (D62), e.g. `virtual-doorbell:doorbellSources`. */
16162
+ /** Names the store written (D62), e.g. `device-manager:_linkedDeviceIds`. */
16255
16163
  authority: string(),
16256
16164
  activation: ExtensionSlotActivationSchema.nullable(),
16257
16165
  value: ExtensionSlotValueSchema,
@@ -21403,12 +21311,26 @@ var CameraSensorRefSchema = object({
21403
21311
  function cameraSensorRefKey(ref) {
21404
21312
  return `${ref.addonId}/${ref.stableId}`;
21405
21313
  }
21406
- /** CS-1 accepts exactly one mode; CS-2 (D673) widens it to confirm / replace. */
21407
- var CameraSensorsModeSchema = _enum(["in-addition"]);
21408
- var CameraSensorsConfigSchema = object({
21409
- mode: CameraSensorsModeSchema,
21410
- sensors: array(CameraSensorRefSchema).min(1).max(8)
21411
- }).superRefine((value, ctx) => {
21314
+ /**
21315
+ * A sensor's mode (D673). `in-addition`: its motion is the camera's motion too.
21316
+ * `replace`: its motion is the camera's, and while one is READY the camera's
21317
+ * own motion no longer counts on its own. `confirm`: while one is READY the
21318
+ * camera's own motion counts only while a confirm sensor is active — with or
21319
+ * without a replace sensor (spec C2, the controller's ruling on Q1).
21320
+ */
21321
+ var CameraSensorModeSchema = _enum([
21322
+ "in-addition",
21323
+ "confirm",
21324
+ "replace"
21325
+ ]);
21326
+ /** A stored sensor with no mode — every CS-1 row — is in addition. */
21327
+ var DEFAULT_CAMERA_SENSOR_MODE = "in-addition";
21328
+ /**
21329
+ * A camera's attached sensors. A CS-1 row carried an envelope
21330
+ * `mode: 'in-addition'`: `z.object` drops it on parse, and the PARSED value is
21331
+ * what the write stores (D672 rule 3), so it is never written again.
21332
+ */
21333
+ var CameraSensorsConfigSchema = object({ sensors: array(CameraSensorRefSchema.extend({ mode: CameraSensorModeSchema.default(DEFAULT_CAMERA_SENSOR_MODE) })).min(1).max(8) }).superRefine((value, ctx) => {
21412
21334
  const seen = /* @__PURE__ */ new Set();
21413
21335
  value.sensors.forEach((ref, index) => {
21414
21336
  const key = cameraSensorRefKey(ref);
@@ -21420,39 +21342,41 @@ var CameraSensorsConfigSchema = object({
21420
21342
  seen.add(key);
21421
21343
  });
21422
21344
  });
21423
- var RefFields = {
21345
+ /** Every attachment names its mode; an older orchestrator that does not is in addition. */
21346
+ var AttachmentFields = {
21424
21347
  addonId: string(),
21425
- stableId: string()
21348
+ stableId: string(),
21349
+ mode: CameraSensorModeSchema.default(DEFAULT_CAMERA_SENSOR_MODE)
21426
21350
  };
21427
21351
  var CameraSensorAttachmentSchema = discriminatedUnion("state", [
21428
21352
  object({
21429
- ...RefFields,
21353
+ ...AttachmentFields,
21430
21354
  state: literal("ready"),
21431
21355
  deviceId: number(),
21432
21356
  name: string(),
21433
21357
  caps: array(string()).readonly()
21434
21358
  }),
21435
21359
  object({
21436
- ...RefFields,
21360
+ ...AttachmentFields,
21437
21361
  state: literal("offline"),
21438
21362
  deviceId: number(),
21439
21363
  name: string(),
21440
21364
  reason: _enum(["offline", "disabled"])
21441
21365
  }),
21442
21366
  object({
21443
- ...RefFields,
21367
+ ...AttachmentFields,
21444
21368
  state: literal("missing"),
21445
21369
  reason: string()
21446
21370
  }),
21447
21371
  object({
21448
- ...RefFields,
21372
+ ...AttachmentFields,
21449
21373
  state: literal("unsupported"),
21450
21374
  deviceId: number(),
21451
21375
  name: string(),
21452
21376
  reason: string()
21453
21377
  }),
21454
21378
  object({
21455
- ...RefFields,
21379
+ ...AttachmentFields,
21456
21380
  state: literal("unreadable"),
21457
21381
  reason: string()
21458
21382
  })
@@ -21465,17 +21389,49 @@ var CameraSensorAttachmentSchema = discriminatedUnion("state", [
21465
21389
  * say.
21466
21390
  */
21467
21391
  var CameraSensorsNotForwardedSchema = _enum(["onboard-not-listed", "no-active-detection"]);
21392
+ /** Whether the camera's OWN motion counts on its own (D673 C2), from its READY sensors (C3). */
21393
+ var CameraOwnMotionSchema = _enum([
21394
+ "always",
21395
+ "when-confirmed",
21396
+ "never"
21397
+ ]);
21398
+ /** Confirm / Replace cannot suppress this camera's motion: its provider still emits it directly (D673 C13). */
21399
+ var CameraSensorsNotEnforcedSchema = _enum(["provider-not-split"]);
21400
+ /**
21401
+ * The camera's OWN onboard motion (D696): the raw input the bridge combines,
21402
+ * never the effective value. The camera's `motion` slice is the effective one,
21403
+ * so a view of the camera's own row reads this.
21404
+ * - `atMs`: when the bridge received the camera's last own edge.
21405
+ * - `detected`: evaluated WHEN THE STATUS IS ASKED — the last edge said `true`
21406
+ * AND it is younger than the window the bridge counts the camera's own motion
21407
+ * for (`motionCooldownMs`, floored at two sustain ticks). A camera that never
21408
+ * sends a clear (heartbeats only) therefore reads `false` once no push came
21409
+ * within the window; a status read is a snapshot, so a live view re-asks.
21410
+ * Absent = this orchestrator has not received the camera's own motion since it
21411
+ * started (unknown, never "quiet"), or an orchestrator older than D696.
21412
+ */
21413
+ var CameraRawLevelSchema = object({
21414
+ detected: boolean(),
21415
+ atMs: number()
21416
+ });
21468
21417
  var CameraSensorsStatusSchema = discriminatedUnion("state", [
21469
- object({ state: literal("not-configured") }),
21418
+ object({
21419
+ state: literal("not-configured"),
21420
+ cameraLevel: CameraRawLevelSchema.optional()
21421
+ }),
21470
21422
  object({
21471
21423
  state: literal("unreadable"),
21472
- reason: string()
21424
+ reason: string(),
21425
+ cameraLevel: CameraRawLevelSchema.optional()
21473
21426
  }),
21474
21427
  object({
21475
21428
  state: literal("configured"),
21476
- mode: CameraSensorsModeSchema,
21429
+ cameraLevel: CameraRawLevelSchema.optional(),
21477
21430
  sensors: array(CameraSensorAttachmentSchema).readonly(),
21478
- notForwarded: CameraSensorsNotForwardedSchema.optional()
21431
+ /** Absent = an orchestrator older than CS-2: it does not say (D315). */
21432
+ cameraMotion: CameraOwnMotionSchema.optional(),
21433
+ notForwarded: CameraSensorsNotForwardedSchema.optional(),
21434
+ notEnforced: CameraSensorsNotEnforcedSchema.optional()
21479
21435
  })
21480
21436
  ]);
21481
21437
  Object.freeze({
@@ -24706,8 +24662,10 @@ var RunnerCameraConfigSchema = object({
24706
24662
  * - `analyzer`: ML/frame-diff motion detection (motion-wasm or other
24707
24663
  * analyzer providers) running on decoded frames in this runner.
24708
24664
  * - `onboard`: camera-native motion pushes (Reolink Baichuan, ONVIF
24709
- * analytics). The provider emits ProviderMotion
24710
- * events; the orchestrator forwards to `reportMotion`.
24665
+ * analytics). The provider emits its raw push as `ProviderMotion`
24666
+ * (D673); the orchestrator's camera-sensors bridge re-emits the camera's
24667
+ * effective motion as `MotionOnMotionChanged`, which is what reaches
24668
+ * `reportMotion`.
24711
24669
  */
24712
24670
  motionSources: MotionSourcesSchema.default(["analyzer"]),
24713
24671
  /**
@@ -24884,7 +24842,15 @@ var RunnerLocalLoadSchema = object({
24884
24842
  hasGpu: boolean(),
24885
24843
  inferenceBackend: string().optional(),
24886
24844
  cpuCores: number().optional()
24887
- })
24845
+ }),
24846
+ /**
24847
+ * Who writes a camera's `motion` runtime slice (D696). `'orchestrator'`: this
24848
+ * runner never writes it. ABSENT = a runner older than D696, which still
24849
+ * writes the slice from its phase machine; the orchestrator does not write
24850
+ * while any runner node is absent-or-unanswered, so one slice never has two
24851
+ * writers.
24852
+ */
24853
+ motionSliceWriter: literal("orchestrator").optional()
24888
24854
  });
24889
24855
  /**
24890
24856
  * Aggregate runtime metrics for the runner's whole local pool. Mirrors the
@@ -30494,6 +30460,70 @@ onStatusChanged: { data: object({
30494
30460
  * whether persisting is worth a SQLite commit. */
30495
30461
  volatileStateFields: ["lastChangedAt"]
30496
30462
  };
30463
+ var DoorbellStatusSchema = object({
30464
+ /** Ms epoch of the last press. null = never observed since this provider started. */
30465
+ lastPressedAt: number().nullable(),
30466
+ /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
30467
+ pressCountSinceStart: number()
30468
+ });
30469
+ var DoorbellPressEventSchema = object({
30470
+ deviceId: number(),
30471
+ timestamp: number()
30472
+ });
30473
+ /**
30474
+ * Doorbell button cap. Two kinds of provider serve it, and to every consumer
30475
+ * they are the same cap:
30476
+ *
30477
+ * - **Native** providers, registered per device by a driver addon through
30478
+ * `ctx.registerNativeCap` — a `DeviceType.Button` accessory with
30479
+ * `role: DeviceRole.Doorbell`, or the camera itself (Reolink registers at
30480
+ * camera level). They emit `onPressed` on every firmware ring.
30481
+ * - **A composed doorbell** (D670, D671): a camera's customization gives it
30482
+ * the cap, its `lastPressedAt` rising from the sources the operator
30483
+ * assigned in Customize → Doorbell, and the composer emits `onPressed`
30484
+ * from that field's advance (`fromState`).
30485
+ *
30486
+ * The DeviceEventPropagator re-emits `onPressed` on the camera parent.
30487
+ */
30488
+ var doorbellCapability = {
30489
+ name: "doorbell",
30490
+ scope: "device",
30491
+ deviceNative: true,
30492
+ mode: "singleton",
30493
+ deviceTypes: [DeviceType.Button, DeviceType.Camera],
30494
+ methods: {},
30495
+ events: {
30496
+ /**
30497
+ * Fires once per physical press. Reolink delivers via Baichuan
30498
+ * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
30499
+ * release/duration — it's a pulse.
30500
+ */
30501
+ onPressed: {
30502
+ data: DoorbellPressEventSchema,
30503
+ fromState: {
30504
+ field: "lastPressedAt",
30505
+ on: "advance"
30506
+ }
30507
+ } },
30508
+ status: {
30509
+ schema: DoorbellStatusSchema,
30510
+ kind: "push"
30511
+ },
30512
+ /**
30513
+ * Runtime-state slice — last press timestamp + lifetime press count.
30514
+ * Mirrored by the kernel and readable via
30515
+ * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
30516
+ * without subscribing.
30517
+ */
30518
+ runtimeState: DoorbellStatusSchema,
30519
+ /**
30520
+ * 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.
30521
+ *
30522
+ * See `RuntimeStateDurability`. Enforced by
30523
+ * `scripts/check-runtime-state-durability.ts`.
30524
+ */
30525
+ durability: "restored"
30526
+ };
30497
30527
  /**
30498
30528
  * Enum-state sensor — a string value picked from a finite option set.
30499
30529
  * Drives HA `sensor` entries with `state_class: enum` (HVAC action
@@ -32638,9 +32668,9 @@ var MotionStatusSchema = object({
32638
32668
  /** Ms epoch of the last detected-true observation. Null if never detected. */
32639
32669
  lastDetectedAt: number().nullable(),
32640
32670
  /**
32641
- * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
32642
- * `null` while false and on every `Sensor` device (D475) — see that
32643
- * constant's doc for the one-authority rule.
32671
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device (the
32672
+ * orchestrator writes it, D696), `null` while false and on every `Sensor`
32673
+ * device (D475) — see that constant's doc for the one-authority rule.
32644
32674
  *
32645
32675
  * ## Reading this field still arms nothing
32646
32676
  *
@@ -32658,34 +32688,31 @@ var MotionStatusSchema = object({
32658
32688
  * `addon-export-alexa/src/motion-clear-hold.ts` and
32659
32689
  * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
32660
32690
  *
32661
- * ## Who writes it
32662
- *
32663
- * - **Cameras** — the runner's phase machine, `active → watching` on
32664
- * `cooldown_expired`, which then writes this slice with
32665
- * `detected: false` (`handlePhaseChanged` in
32666
- * `pipeline-runner/index.ts`). It produces the FALLING edge, which
32667
- * matters most for the sources that only ever push a rising one:
32668
- * Reolink emits `MotionOnMotionChanged { detected: true }` and never
32669
- * a false.
32670
- * - **Sensors** (Home Assistant binary sensors, Homematic) — the
32671
- * provider pushes the false itself, from the upstream system's own
32672
- * state change. No phase machine is involved.
32673
- *
32674
- * ### The phase machine is CANONICAL, not sole — and that is a defect
32675
- *
32676
- * An earlier revision of this docblock (mine, 2026-09-12) claimed the
32677
- * phase machine is the sole writer for a camera. It is not.
32678
- * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
32679
- * `setCapSlice(motionCapability, …)` on their own rising edge, and
32680
- * Hikvision's comment says why: it read THIS docblock, agreed the
32681
- * runner is canonical, and wrote anyway to avoid per-tick churn. So
32682
- * two authorities can disagree about one slice, which this repo
32683
- * forbids, and the doc said otherwise — which is worse than saying
32684
- * nothing, because it reads as verification.
32685
- *
32686
- * This predates D475 and is not fixed there: the fix touches every
32687
- * camera provider. Recorded in D475's Consequences. Do not restore the
32688
- * "sole writer" wording without also removing the other writers.
32691
+ * ## Who writes it (D696)
32692
+ *
32693
+ * - **Cameras** — the orchestrator, and nothing else. It writes the camera's
32694
+ * EFFECTIVE motion (`addon-pipeline-orchestrator`
32695
+ * `camera-sensors/motion-slice.ts`), alongside the effective
32696
+ * `MotionOnMotionChanged` it emits or receives: the camera-sensors bridge
32697
+ * for a split camera, an unsplit emitter's direct event, the analyzer and
32698
+ * device activity, as the camera's `motionSources` counts them. A source
32699
+ * that never sends a clear falls one window after its last `true`.
32700
+ * `lastDetectedAt` moves only on an effective rise. No camera provider
32701
+ * writes this slice (not even a boot seed), and neither does the runner's
32702
+ * phase machine: its phase is "a session is attached" for every on-motion
32703
+ * session, not motion, and it now has its own `DetectionPhaseTransition`.
32704
+ * A provider's `isDetected` answers from the hub's slice.
32705
+ * - **Sensors** (Home Assistant binary sensors, Homematic, Matter, Alexa
32706
+ * imports) — the provider pushes both edges itself, from the upstream
32707
+ * system's own state change. That is the sensor's own fact.
32708
+ *
32709
+ * `scripts/check-onboard-motion-emitters.ts` refuses any other writer of a
32710
+ * `motion` slice; each sensor writer is a named exemption.
32711
+ *
32712
+ * This replaces the D475 §4 rule ("the phase machine is the sole writer").
32713
+ * That rule was never true: Hikvision and Amcrest wrote the slice raw beside
32714
+ * it, every provider seeded it at boot, and every session left it
32715
+ * `detected: true` after its detach.
32689
32716
  */
32690
32717
  autoClearAfterMs: number().nullable()
32691
32718
  });
@@ -32757,11 +32784,12 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
32757
32784
  */
32758
32785
  runtimeState: MotionStatusSchema,
32759
32786
  /**
32760
- * Runtime-state durability: **session** — every writer of this slice
32787
+ * Runtime-state durability: **session** — the writer of this slice
32761
32788
  * writes only on an EDGE, so a restored `detected: true` would stay
32762
32789
  * frozen until the next one instead of being corrected. The next edge
32763
- * re-publishes the real state. (On who the writers are, and why there
32764
- * is more than one, see `autoClearAfterMs` above.)
32790
+ * re-publishes the real state, and the orchestrator re-publishes every
32791
+ * camera when it starts writing (D696; on who writes it, see
32792
+ * `autoClearAfterMs` above).
32765
32793
  *
32766
32794
  * See `RuntimeStateDurability`. Enforced by
32767
32795
  * `scripts/check-runtime-state-durability.ts`.
@@ -35144,8 +35172,7 @@ var ptzAutotrackCapability = {
35144
35172
  deviceNative: true,
35145
35173
  mode: "singleton",
35146
35174
  /**
35147
- * Two kinds of provider behind one name, the same shape `snapshot` and
35148
- * `doorbell` use:
35175
+ * Two kinds of provider behind one name, the same shape `snapshot` uses:
35149
35176
  *
35150
35177
  * - **Native**: the camera's own firmware autotrack, registered per device by
35151
35178
  * the driver when the probe says it exists (Reolink: yes; Hikvision:
@@ -35153,7 +35180,7 @@ var ptzAutotrackCapability = {
35153
35180
  * - **Wrapper**: the emulated implementation (`@camstack/system`'s `autotrack` builtin),
35154
35181
  * which follows a subject with `ptz.move` pulses driven by the detection
35155
35182
  * pipeline. `defaultActive: false` — the operator binds it per camera in
35156
- * the bindings UI, exactly as `virtual-doorbell` is bound.
35183
+ * the bindings UI.
35157
35184
  *
35158
35185
  * The binding chooses WHICH implementation answers; `setEnabled` stays the
35159
35186
  * one switch for the function either way. A camera never has both driving its
@@ -52318,6 +52345,7 @@ TimelapseRuleInputSchema.extend({
52318
52345
  createdAt: number(),
52319
52346
  updatedAt: number()
52320
52347
  });
52348
+ MotionOnMotionChangedDataSchema.omit({ triggeredBy: true });
52321
52349
  object({
52322
52350
  /**
52323
52351
  * Fraction of the box's own size added on EACH side before cutting.
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  //#endregion
6
- const require_dist = require("../dist-B-PoT2TH.js");
6
+ const require_dist = require("../dist-Cn_fSOpM.js");
7
7
  let node_crypto = require("node:crypto");
8
8
  //#region src/ha-export/topics.ts
9
9
  /**
@@ -1427,7 +1427,7 @@ function cameraSpecs(device) {
1427
1427
  * `doorbell` cap bound rings, and the operator automates on the ring the same
1428
1428
  * way they automate on `person_detected`. Reolink's own doorbell is exactly
1429
1429
  * this shape (`ReolinkSimpleEvent.type === 'doorbell'` at the camera level),
1430
- * and so is any camera the `virtual-doorbell` wrapper is pointed at.
1430
+ * and so is any camera composed into a doorbell by its customization (D671).
1431
1431
  *
1432
1432
  * Every entity here is fed by the `doorbell` runtime-state slice
1433
1433
  * (`lastPressedAt`, `pressCountSinceStart`) on `device.state-changed` —
@@ -1,4 +1,4 @@
1
- import { C as buildAddonRouteProvider, F as deviceExportCapability, Nt as EventCategory, Q as oauthIntegrationCapability, a as COCO_TO_MACRO, c as FanDirectionSchema, i as CAMERA_SWITCH_ORDER, kt as string, l as HvacModeSchema, o as CameraSwitchIdSchema, p as addonRoutesCapability, t as AlarmArmModeSchema, u as MediaPlayerRepeatSchema, xt as nodePin, yt as BaseAddon } from "../dist-BwAVAaOH.mjs";
1
+ import { C as buildAddonRouteProvider, F as deviceExportCapability, Nt as EventCategory, Q as oauthIntegrationCapability, a as COCO_TO_MACRO, c as FanDirectionSchema, i as CAMERA_SWITCH_ORDER, kt as string, l as HvacModeSchema, o as CameraSwitchIdSchema, p as addonRoutesCapability, t as AlarmArmModeSchema, u as MediaPlayerRepeatSchema, xt as nodePin, yt as BaseAddon } from "../dist-DFsf2z4Q.mjs";
2
2
  import { createHmac, timingSafeEqual } from "node:crypto";
3
3
  //#region src/ha-export/topics.ts
4
4
  /**
@@ -1422,7 +1422,7 @@ function cameraSpecs(device) {
1422
1422
  * `doorbell` cap bound rings, and the operator automates on the ring the same
1423
1423
  * way they automate on `person_detected`. Reolink's own doorbell is exactly
1424
1424
  * this shape (`ReolinkSimpleEvent.type === 'doorbell'` at the camera level),
1425
- * and so is any camera the `virtual-doorbell` wrapper is pointed at.
1425
+ * and so is any camera composed into a doorbell by its customization (D671).
1426
1426
  *
1427
1427
  * Every entity here is fed by the `doorbell` runtime-state slice
1428
1428
  * (`lastPressedAt`, `pressCountSinceStart`) on `device.state-changed` —
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-homeassistant",
3
- "version": "1.2.150",
3
+ "version": "1.2.151",
4
4
  "description": "Home Assistant device provider addon for CamStack",
5
5
  "keywords": [
6
6
  "camstack",