@camstack/addon-provider-amcrest 0.2.124 → 0.2.126

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 +328 -241
  2. package/dist/addon.mjs +328 -241
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -34,7 +34,7 @@ let node_stream = require("node:stream");
34
34
  let node_stream_promises = require("node:stream/promises");
35
35
  let node_child_process = require("node:child_process");
36
36
  let node_os = require("node:os");
37
- //#region ../types/dist/event-category-C5xZWqz6.mjs
37
+ //#region ../types/dist/event-category-BGmz_oxW.mjs
38
38
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
39
39
  EventCategory["SystemBoot"] = "system.boot";
40
40
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -567,6 +567,15 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
567
567
  */
568
568
  EventCategory["PipelineAudioInferenceResult"] = "pipeline.audio-inference-result";
569
569
  EventCategory["DetectionPhaseTransition"] = "detection.phase-transition";
570
+ /**
571
+ * A camera provider's RAW onboard motion push (D673): the `MotionOnMotionChanged`
572
+ * data shape without `triggeredBy`, built by `providerMotionEvent`. Its one
573
+ * consumer is the orchestrator's camera-sensors bridge, which re-emits the
574
+ * camera's EFFECTIVE onboard motion as `MotionOnMotionChanged` (a pass-through
575
+ * for a camera with no attached sensor). Providers must not emit
576
+ * `MotionOnMotionChanged` themselves; `scripts/check-onboard-motion-emitters.ts`
577
+ * keeps it so (camera-grid is a named, deferred exception).
578
+ */
570
579
  EventCategory["ProviderMotion"] = "provider.motion";
571
580
  EventCategory["ProviderDetection"] = "provider.detection";
572
581
  EventCategory["EnrichmentEmbeddingStored"] = "enrichment.embedding.stored";
@@ -5405,7 +5414,7 @@ var ZodIssueCode = {
5405
5414
  var ZodFirstPartyTypeKind;
5406
5415
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5407
5416
  //#endregion
5408
- //#region ../types/dist/sleep-gU6hqv4_.mjs
5417
+ //#region ../types/dist/sleep-CDCONfkt.mjs
5409
5418
  /**
5410
5419
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5411
5420
  * window to float samples (D455).
@@ -7438,7 +7447,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
7438
7447
  return DeviceRole;
7439
7448
  }({});
7440
7449
  //#endregion
7441
- //#region ../types/dist/composition-Dq42XWp0.mjs
7450
+ //#region ../types/dist/composition-43aqsZQj.mjs
7442
7451
  /**
7443
7452
  * The ffmpeg build every CamStack node downloads, per platform and arch.
7444
7453
  *
@@ -7495,13 +7504,12 @@ portable("linux64"), portable("linuxarm64"), portable("macarm64"), portable("mac
7495
7504
  * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
7496
7505
  * valutatore puro del suo FRONTE.
7497
7506
  *
7498
- * Viveva dentro il builtin virtual-doorbell
7499
- * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
7500
- * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
7501
- * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
7502
- * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
7503
- * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
7504
- * SPOSTA qui e il doorbell la ri-esporta.
7507
+ * UNA tabella per tutti quelli che chiedono "questo device è ALTO?": il
7508
+ * trigger `RecordingTriggers.sensorDeviceIds` del recorder, i marker dei
7509
+ * sensori della post-analysis, il bridge camera-sensors dell'orchestratore e
7510
+ * le sorgenti di un campanello composto (`doorbellFeatureSources`, D671).
7511
+ * Una seconda copia divergerebbe alla prima cap aggiunta, e il sintomo — "il
7512
+ * sensore fa suonare il campanello ma non registra" — è esattamente D62.
7505
7513
  *
7506
7514
  * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
7507
7515
  * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
@@ -7527,8 +7535,6 @@ var SOURCE_CAP_ACTIVE_FIELD = {
7527
7535
  vibration: "detected",
7528
7536
  tamper: "tampered"
7529
7537
  };
7530
- /** Cap names whose presence in a device's bindings qualify it as a source. */
7531
- var SOURCE_CAPS = Object.keys(SOURCE_CAP_ACTIVE_FIELD);
7532
7538
  /**
7533
7539
  * Error types for the safe expression engine. Two distinct classes so callers
7534
7540
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
@@ -9258,7 +9264,7 @@ var RecordingTriggersSchema = object({
9258
9264
  *
9259
9265
  * Cosa vuol dire "alto" dipende dal TIPO di device e non è deciso qui:
9260
9266
  * `SOURCE_CAP_ACTIVE_FIELD` (`catalogs/sensor-active-state.ts`) è LA tabella,
9261
- * la stessa che il virtual-doorbell usa dal 2026-08-05. Ed è il FRONTE, non
9267
+ * la stessa del campanello composto (D671). Ed è il FRONTE, non
9262
9268
  * il livello: un contatto trovato già aperto al riavvio del runner non fa
9263
9269
  * registrare.
9264
9270
  */
@@ -14868,7 +14874,17 @@ var SiteZoneSchema = object({
14868
14874
  var ProviderStatusSchema = object({
14869
14875
  connected: boolean(),
14870
14876
  deviceCount: number(),
14871
- error: string().optional()
14877
+ error: string().optional(),
14878
+ /**
14879
+ * `'orchestrator'`: this provider writes NO camera's `motion` runtime slice
14880
+ * — the orchestrator is its only writer (D696). Set by `BaseDeviceProvider`,
14881
+ * which every provider bundles, so only a provider BUILT from D696-amended
14882
+ * code says it. ABSENT means an older provider that may still write it (raw
14883
+ * VMD writes, a boot seed), and the orchestrator's provider gate keeps that
14884
+ * provider's cameras unwritten (`camera-sensors/motion-slice-provider-gate.ts`)
14885
+ * — the provider twin of the runner's `getLocalLoad().motionSliceWriter`.
14886
+ */
14887
+ motionSliceWriter: literal("orchestrator").optional()
14872
14888
  });
14873
14889
  object({
14874
14890
  externalId: string(),
@@ -15747,109 +15763,10 @@ method(object({
15747
15763
  deviceIds: array(number()).readonly(),
15748
15764
  caps: array(string()).readonly().optional()
15749
15765
  }), record(string(), record(string(), unknown().nullable())));
15750
- /**
15751
- * Doorbell button cap. Two kinds of providers coexist behind this cap
15752
- * name (same pattern as `snapshot`):
15753
- *
15754
- * - **Native** providers: registered per-device by device-driver
15755
- * addons via `ctx.registerNativeCap` — either on a
15756
- * `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
15757
- * or directly on the camera (Reolink registers at camera level).
15758
- * Emits an `onPressed` event every time the firmware pushes a
15759
- * ring; status tracks the last press and a pressCount since start
15760
- * (diagnostic).
15761
- *
15762
- * - **Wrapper** provider: the `virtual-doorbell` system builtin
15763
- * (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
15764
- * device (contact / switch / event-emitter …) into a doorbell for
15765
- * a camera. `defaultActive: false` — the operator explicitly binds
15766
- * it per camera in the device-bindings UI, then picks the source
15767
- * device + trigger in the per-device settings.
15768
- *
15769
- * The DeviceEventPropagator re-emits `onPressed` on the camera parent
15770
- * — subscribers listening at the camera level receive ring events
15771
- * with `via[]` populated. No code on the parent needed.
15772
- */
15773
- var DoorbellStatusSchema = object({
15774
- /** Ms epoch of the last press. null = never observed since this provider started. */
15775
- lastPressedAt: number().nullable(),
15776
- /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
15777
- pressCountSinceStart: number()
15778
- });
15779
- var DoorbellPressEventSchema = object({
15780
- deviceId: number(),
15781
- timestamp: number()
15782
- });
15783
- /**
15784
- * The `doorbell-source` extension slot's editable value (D648): the camera's
15785
- * virtual-doorbell trigger devices, exactly what the wrapper's
15786
- * `doorbellSources` persists (as `{ deviceId }` records).
15787
- */
15788
- var DoorbellSourceSlotValueSchema = object({ deviceIds: array(number().int().positive()) });
15789
- /**
15790
- * The `doorbell-source` slot — which devices ring this camera's VIRTUAL
15791
- * doorbell, owned by the `virtual-doorbell` wrapper over its
15792
- * `doorbellSources` store (D648). A source rings when one of its
15793
- * `SOURCE_CAPS` rises. Whether the wrapper is bound to the camera at all is a
15794
- * different authority (`deviceManager.setWrapperActive`, D62) — the slot
15795
- * reports it, it never writes it.
15796
- */
15797
- var DOORBELL_SOURCE_SLOT = {
15798
- id: "doorbell-source",
15799
- label: "Doorbell trigger devices",
15800
- 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.",
15801
- shape: "association",
15802
- hostDeviceTypes: [DeviceType.Camera],
15803
- sourceCaps: SOURCE_CAPS,
15804
- cardinality: "many",
15805
- value: DoorbellSourceSlotValueSchema
15806
- };
15807
- var doorbellCapability = {
15808
- name: "doorbell",
15809
- scope: "device",
15810
- deviceNative: true,
15811
- mode: "singleton",
15812
- kind: "wrapper",
15813
- defaultActive: false,
15814
- deviceTypes: [DeviceType.Button, DeviceType.Camera],
15815
- extensionSlots: [DOORBELL_SOURCE_SLOT],
15816
- methods: {},
15817
- events: {
15818
- /**
15819
- * Fires once per physical press. Reolink delivers via Baichuan
15820
- * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
15821
- * release/duration — it's a pulse.
15822
- */
15823
- onPressed: {
15824
- data: DoorbellPressEventSchema,
15825
- fromState: {
15826
- field: "lastPressedAt",
15827
- on: "advance"
15828
- }
15829
- } },
15830
- status: {
15831
- schema: DoorbellStatusSchema,
15832
- kind: "push"
15833
- },
15834
- /**
15835
- * Runtime-state slice — last press timestamp + lifetime press count.
15836
- * Mirrored by the kernel and readable via
15837
- * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
15838
- * without subscribing.
15839
- */
15840
- runtimeState: DoorbellStatusSchema,
15841
- /**
15842
- * 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.
15843
- *
15844
- * See `RuntimeStateDurability`. Enforced by
15845
- * `scripts/check-runtime-state-durability.ts`.
15846
- */
15847
- durability: "restored"
15848
- };
15849
- var ExtensionSlotIdSchema = _enum(["doorbell-source", "linked-devices"]);
15850
- DeviceType.Camera, DeviceType.Camera;
15766
+ var ExtensionSlotIdSchema = _enum(["linked-devices"]);
15767
+ DeviceType.Camera;
15851
15768
  /** A slot's editable value, discriminated on `slot`. */
15852
- var ExtensionSlotValueSchema = discriminatedUnion("slot", [DoorbellSourceSlotValueSchema.extend({ slot: literal("doorbell-source") }), LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
15769
+ var ExtensionSlotValueSchema = discriminatedUnion("slot", [LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
15853
15770
  DeviceType.Camera;
15854
15771
  var ExtensionSourceAvailabilitySchema = discriminatedUnion("state", [object({ state: literal("ok") }), object({
15855
15772
  state: literal("unreachable"),
@@ -15886,10 +15803,11 @@ var ExtensionSlotSourceSchema = object({
15886
15803
  });
15887
15804
  /**
15888
15805
  * A DIFFERENT authority that gates whether the slot's sources do anything —
15889
- * reported read-only, named, never written through this contract (D62). The
15890
- * virtual doorbell's sources ring only while the wrapper is bound to the
15891
- * camera, and that binding belongs to `deviceManager.setWrapperActive`.
15892
- * `unknown` means the gate could not be read; it is not "inactive" (D315).
15806
+ * reported read-only, named, never written through this contract (D62) — e.g.
15807
+ * a slot whose sources act only while a wrapper is bound to the host, a
15808
+ * binding that belongs to `deviceManager.setWrapperActive`. No slot reports
15809
+ * one today (`linked-devices` answers `null`). `unknown` means the gate could
15810
+ * not be read; it is not "inactive" (D315).
15893
15811
  */
15894
15812
  var ExtensionSlotActivationSchema = object({
15895
15813
  state: _enum([
@@ -15905,7 +15823,7 @@ var ExtensionSlotRowSchema = discriminatedUnion("state", [object({
15905
15823
  /** `<source>:<slotId>` — the routing key for `listCandidates` / `setSlot`. */
15906
15824
  slotRef: string(),
15907
15825
  slot: ExtensionSlotIdSchema,
15908
- /** Names the store written (D62), e.g. `virtual-doorbell:doorbellSources`. */
15826
+ /** Names the store written (D62), e.g. `device-manager:_linkedDeviceIds`. */
15909
15827
  authority: string(),
15910
15828
  activation: ExtensionSlotActivationSchema.nullable(),
15911
15829
  value: ExtensionSlotValueSchema,
@@ -20428,6 +20346,29 @@ object({
20428
20346
  firstAt: number(),
20429
20347
  lastAt: number()
20430
20348
  });
20349
+ var NC_ALARM_TRIGGERED_MAX_SEC = 3600;
20350
+ var NcAlarmDelaySecSchema = number().int().min(0).max(600);
20351
+ var NcAlarmTriggeredSecSchema = number().int().min(0).max(NC_ALARM_TRIGGERED_MAX_SEC);
20352
+ var uniqueModes = (entries) => new Set(entries.map((e) => e.mode)).size === entries.length;
20353
+ var NcAlarmModeDelaysListSchema = array(object({
20354
+ mode: AlarmArmModeSchema,
20355
+ exitDelaySec: NcAlarmDelaySecSchema.optional(),
20356
+ entryDelaySec: NcAlarmDelaySecSchema.optional(),
20357
+ triggeredDurationSec: NcAlarmTriggeredSecSchema.optional()
20358
+ })).max(8).refine(uniqueModes, { message: "modeDelays: at most one entry per arm mode" });
20359
+ var NcAlarmModeDelaysEditListSchema = array(object({
20360
+ mode: AlarmArmModeSchema,
20361
+ exitDelaySec: NcAlarmDelaySecSchema.nullable().optional(),
20362
+ entryDelaySec: NcAlarmDelaySecSchema.nullable().optional(),
20363
+ triggeredDurationSec: NcAlarmTriggeredSecSchema.nullable().optional()
20364
+ })).max(8).refine(uniqueModes, { message: "modeDelays: at most one edit per arm mode" });
20365
+ /** One switch of the alarm table: put ONE device on, or take it off, ONE mode's list. */
20366
+ var NcAlarmNonBlockingEditSchema = object({
20367
+ mode: AlarmArmModeSchema,
20368
+ deviceId: number().int().positive(),
20369
+ /** true = on the list (may be open, does not block); false = off the list (blocks). */
20370
+ nonBlocking: boolean()
20371
+ });
20431
20372
  /**
20432
20373
  * The per-mode lists, at most one per mode. Two lists for one mode have no
20433
20374
  * meaning a reader could agree on (union? the last one?), so they are refused
@@ -20436,10 +20377,10 @@ object({
20436
20377
  var NcAlarmNonBlockingListSchema = array(object({
20437
20378
  mode: AlarmArmModeSchema,
20438
20379
  deviceIds: array(number().int()).max(200)
20439
- })).max(8).refine((lists) => new Set(lists.map((l) => l.mode)).size === lists.length, { message: "nonBlocking: at most one list per arm mode" });
20380
+ })).max(8).refine(uniqueModes, { message: "nonBlocking: at most one list per arm mode" });
20440
20381
  /**
20441
- * The three durations the panel's state machine runs on, who hears about its
20442
- * transitions, and which openings each mode tolerates.
20382
+ * The three durations — global, and per mode since D697 — the panel's state
20383
+ * machine runs on, who hears about its transitions, and which openings each mode tolerates.
20443
20384
  *
20444
20385
  * They live on the NOTIFICATION-RULES cap, not on `alarm-panel`, on purpose:
20445
20386
  * `alarm-panel` is `deviceNative` and its other provider mirrors somebody
@@ -20449,15 +20390,15 @@ var NcAlarmNonBlockingListSchema = array(object({
20449
20390
  */
20450
20391
  var NcAlarmSettingsSchema = object({
20451
20392
  /** Grace period between arming and the mode taking effect. 0 = immediate. */
20452
- exitDelaySec: number().int().min(0).max(600),
20393
+ exitDelaySec: NcAlarmDelaySecSchema,
20453
20394
  /** Grace period between a trigger and the alarm firing. 0 = immediate. */
20454
- entryDelaySec: number().int().min(0).max(600),
20395
+ entryDelaySec: NcAlarmDelaySecSchema,
20455
20396
  /**
20456
20397
  * How long `triggered` lasts before the panel re-arms itself.
20457
20398
  * **0 = until an operator disarms it** — the behaviour before this field
20458
20399
  * existed, and therefore what an untouched install keeps doing.
20459
20400
  */
20460
- triggeredDurationSec: number().int().min(0).max(3600),
20401
+ triggeredDurationSec: NcAlarmTriggeredSecSchema,
20461
20402
  /**
20462
20403
  * Deprecated by D630 — every transition is announced. Parsed, never read;
20463
20404
  * remove after one release. Optional so an older admin's patch (which still
@@ -20480,17 +20421,30 @@ var NcAlarmSettingsSchema = object({
20480
20421
  * per mode is meaningful. Defaulted to `[]` so a blob stored before D630
20481
20422
  * parses as "every opening blocks" — the behaviour it was written under.
20482
20423
  */
20483
- nonBlocking: NcAlarmNonBlockingListSchema.default([])
20424
+ nonBlocking: NcAlarmNonBlockingListSchema.default([]),
20425
+ /**
20426
+ * Per arm mode, the delays that mode OVERRIDES (D697). A mode with no entry, or an entry
20427
+ * without a field, uses the global value above — so `[]`, the default, is exactly the
20428
+ * behaviour of a blob stored before this field existed. Read through `resolveModeDelays`.
20429
+ */
20430
+ modeDelays: NcAlarmModeDelaysListSchema.default([])
20484
20431
  });
20485
20432
  /**
20486
20433
  * Every field optional — a tab edits one control at a time.
20487
20434
  *
20488
- * `nonBlocking` is re-declared WITHOUT its default: `.partial()` does not
20489
- * remove an inner `.default()`, so a patch that never named the field would
20490
- * parse to `nonBlocking: []` and wipe every mode's list on an unrelated edit
20491
- * (the same trap {@link NcRulePatchSchema} documents).
20435
+ * `nonBlocking` and `modeDelays` are re-declared WITHOUT their defaults:
20436
+ * `.partial()` does not remove an inner `.default()`, so a patch that never
20437
+ * named the field would parse to `[]` and wipe every mode's list on an
20438
+ * unrelated edit (the same trap {@link NcRulePatchSchema} documents). Here
20439
+ * `modeDelays` means EDITS, not the stored overrides.
20492
20440
  */
20493
- var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.extend({ nonBlocking: NcAlarmNonBlockingListSchema }).partial();
20441
+ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.extend({
20442
+ nonBlocking: NcAlarmNonBlockingListSchema,
20443
+ /** Per-mode, per-field edits — NOT the whole list (see NcAlarmModeDelaysEditSchema). */
20444
+ modeDelays: NcAlarmModeDelaysEditListSchema,
20445
+ /** ONE membership change; the panel applies it to the list it holds at its turn. */
20446
+ nonBlockingEdit: NcAlarmNonBlockingEditSchema
20447
+ }).partial().refine((p) => p.nonBlocking === void 0 || p.nonBlockingEdit === void 0, { message: "nonBlocking and nonBlockingEdit are exclusive — send the whole lists or one edit" });
20494
20448
  /**
20495
20449
  * What one arm mode actually arms, DERIVED from the enabled rules gated on it.
20496
20450
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
@@ -20590,6 +20544,28 @@ var NcAlarmConfigSchema = object({
20590
20544
  */
20591
20545
  live: NcAlarmLiveSchema.optional()
20592
20546
  });
20547
+ var NcAlarmSensorReadingSchema = _enum([
20548
+ "open",
20549
+ "closed",
20550
+ "unknown",
20551
+ "not-opening"
20552
+ ]);
20553
+ /** One device's state as the alarm reads it — the classifier the arm check uses. */
20554
+ var NcAlarmSensorStateSchema = object({
20555
+ deviceId: number().int().positive(),
20556
+ reading: NcAlarmSensorReadingSchema,
20557
+ /** The word as read (`open`, `closed`, `unlocked`, `stopped`, …); null when unknown / not an opening. */
20558
+ state: string().nullable(),
20559
+ /** Why `unknown`: the read failed, or the slice holds no word its cap defines (a placeholder included). */
20560
+ unknownWhy: _enum(["read-failed", "unknown-word"]).nullable(),
20561
+ /** The device manager's liveness as the centre mirrors it; null = not known. */
20562
+ online: boolean().nullable()
20563
+ });
20564
+ var NcAlarmSensorsInputSchema = object({ deviceIds: array(number().int().positive()).max(500) });
20565
+ var NcAlarmSensorsSchema = object({
20566
+ sensors: array(NcAlarmSensorStateSchema),
20567
+ readAt: number().int().nonnegative()
20568
+ });
20593
20569
  /**
20594
20570
  * ONE rule's demand on ONE camera's clip ring.
20595
20571
  *
@@ -20680,7 +20656,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
20680
20656
  }), method(object({}), NcAlarmConfigSchema, { auth: "admin" }), method(object({ patch: NcAlarmSettingsPatchSchema }), NcAlarmConfigSchema, {
20681
20657
  kind: "mutation",
20682
20658
  auth: "admin"
20683
- });
20659
+ }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
20684
20660
  /**
20685
20661
  * Zod schemas for persisted record types.
20686
20662
  *
@@ -21027,12 +21003,26 @@ var CameraSensorRefSchema = object({
21027
21003
  function cameraSensorRefKey(ref) {
21028
21004
  return `${ref.addonId}/${ref.stableId}`;
21029
21005
  }
21030
- /** CS-1 accepts exactly one mode; CS-2 (D673) widens it to confirm / replace. */
21031
- var CameraSensorsModeSchema = _enum(["in-addition"]);
21032
- var CameraSensorsConfigSchema = object({
21033
- mode: CameraSensorsModeSchema,
21034
- sensors: array(CameraSensorRefSchema).min(1).max(8)
21035
- }).superRefine((value, ctx) => {
21006
+ /**
21007
+ * A sensor's mode (D673). `in-addition`: its motion is the camera's motion too.
21008
+ * `replace`: its motion is the camera's, and while one is READY the camera's
21009
+ * own motion no longer counts on its own. `confirm`: while one is READY the
21010
+ * camera's own motion counts only while a confirm sensor is active — with or
21011
+ * without a replace sensor (spec C2, the controller's ruling on Q1).
21012
+ */
21013
+ var CameraSensorModeSchema = _enum([
21014
+ "in-addition",
21015
+ "confirm",
21016
+ "replace"
21017
+ ]);
21018
+ /** A stored sensor with no mode — every CS-1 row — is in addition. */
21019
+ var DEFAULT_CAMERA_SENSOR_MODE = "in-addition";
21020
+ /**
21021
+ * A camera's attached sensors. A CS-1 row carried an envelope
21022
+ * `mode: 'in-addition'`: `z.object` drops it on parse, and the PARSED value is
21023
+ * what the write stores (D672 rule 3), so it is never written again.
21024
+ */
21025
+ var CameraSensorsConfigSchema = object({ sensors: array(CameraSensorRefSchema.extend({ mode: CameraSensorModeSchema.default(DEFAULT_CAMERA_SENSOR_MODE) })).min(1).max(8) }).superRefine((value, ctx) => {
21036
21026
  const seen = /* @__PURE__ */ new Set();
21037
21027
  value.sensors.forEach((ref, index) => {
21038
21028
  const key = cameraSensorRefKey(ref);
@@ -21044,39 +21034,41 @@ var CameraSensorsConfigSchema = object({
21044
21034
  seen.add(key);
21045
21035
  });
21046
21036
  });
21047
- var RefFields = {
21037
+ /** Every attachment names its mode; an older orchestrator that does not is in addition. */
21038
+ var AttachmentFields = {
21048
21039
  addonId: string(),
21049
- stableId: string()
21040
+ stableId: string(),
21041
+ mode: CameraSensorModeSchema.default(DEFAULT_CAMERA_SENSOR_MODE)
21050
21042
  };
21051
21043
  var CameraSensorAttachmentSchema = discriminatedUnion("state", [
21052
21044
  object({
21053
- ...RefFields,
21045
+ ...AttachmentFields,
21054
21046
  state: literal("ready"),
21055
21047
  deviceId: number(),
21056
21048
  name: string(),
21057
21049
  caps: array(string()).readonly()
21058
21050
  }),
21059
21051
  object({
21060
- ...RefFields,
21052
+ ...AttachmentFields,
21061
21053
  state: literal("offline"),
21062
21054
  deviceId: number(),
21063
21055
  name: string(),
21064
21056
  reason: _enum(["offline", "disabled"])
21065
21057
  }),
21066
21058
  object({
21067
- ...RefFields,
21059
+ ...AttachmentFields,
21068
21060
  state: literal("missing"),
21069
21061
  reason: string()
21070
21062
  }),
21071
21063
  object({
21072
- ...RefFields,
21064
+ ...AttachmentFields,
21073
21065
  state: literal("unsupported"),
21074
21066
  deviceId: number(),
21075
21067
  name: string(),
21076
21068
  reason: string()
21077
21069
  }),
21078
21070
  object({
21079
- ...RefFields,
21071
+ ...AttachmentFields,
21080
21072
  state: literal("unreadable"),
21081
21073
  reason: string()
21082
21074
  })
@@ -21089,17 +21081,49 @@ var CameraSensorAttachmentSchema = discriminatedUnion("state", [
21089
21081
  * say.
21090
21082
  */
21091
21083
  var CameraSensorsNotForwardedSchema = _enum(["onboard-not-listed", "no-active-detection"]);
21084
+ /** Whether the camera's OWN motion counts on its own (D673 C2), from its READY sensors (C3). */
21085
+ var CameraOwnMotionSchema = _enum([
21086
+ "always",
21087
+ "when-confirmed",
21088
+ "never"
21089
+ ]);
21090
+ /** Confirm / Replace cannot suppress this camera's motion: its provider still emits it directly (D673 C13). */
21091
+ var CameraSensorsNotEnforcedSchema = _enum(["provider-not-split"]);
21092
+ /**
21093
+ * The camera's OWN onboard motion (D696): the raw input the bridge combines,
21094
+ * never the effective value. The camera's `motion` slice is the effective one,
21095
+ * so a view of the camera's own row reads this.
21096
+ * - `atMs`: when the bridge received the camera's last own edge.
21097
+ * - `detected`: evaluated WHEN THE STATUS IS ASKED — the last edge said `true`
21098
+ * AND it is younger than the window the bridge counts the camera's own motion
21099
+ * for (`motionCooldownMs`, floored at two sustain ticks). A camera that never
21100
+ * sends a clear (heartbeats only) therefore reads `false` once no push came
21101
+ * within the window; a status read is a snapshot, so a live view re-asks.
21102
+ * Absent = this orchestrator has not received the camera's own motion since it
21103
+ * started (unknown, never "quiet"), or an orchestrator older than D696.
21104
+ */
21105
+ var CameraRawLevelSchema = object({
21106
+ detected: boolean(),
21107
+ atMs: number()
21108
+ });
21092
21109
  var CameraSensorsStatusSchema = discriminatedUnion("state", [
21093
- object({ state: literal("not-configured") }),
21110
+ object({
21111
+ state: literal("not-configured"),
21112
+ cameraLevel: CameraRawLevelSchema.optional()
21113
+ }),
21094
21114
  object({
21095
21115
  state: literal("unreadable"),
21096
- reason: string()
21116
+ reason: string(),
21117
+ cameraLevel: CameraRawLevelSchema.optional()
21097
21118
  }),
21098
21119
  object({
21099
21120
  state: literal("configured"),
21100
- mode: CameraSensorsModeSchema,
21121
+ cameraLevel: CameraRawLevelSchema.optional(),
21101
21122
  sensors: array(CameraSensorAttachmentSchema).readonly(),
21102
- notForwarded: CameraSensorsNotForwardedSchema.optional()
21123
+ /** Absent = an orchestrator older than CS-2: it does not say (D315). */
21124
+ cameraMotion: CameraOwnMotionSchema.optional(),
21125
+ notForwarded: CameraSensorsNotForwardedSchema.optional(),
21126
+ notEnforced: CameraSensorsNotEnforcedSchema.optional()
21103
21127
  })
21104
21128
  ]);
21105
21129
  Object.freeze({
@@ -24330,8 +24354,10 @@ var RunnerCameraConfigSchema = object({
24330
24354
  * - `analyzer`: ML/frame-diff motion detection (motion-wasm or other
24331
24355
  * analyzer providers) running on decoded frames in this runner.
24332
24356
  * - `onboard`: camera-native motion pushes (Reolink Baichuan, ONVIF
24333
- * analytics). The provider emits ProviderMotion
24334
- * events; the orchestrator forwards to `reportMotion`.
24357
+ * analytics). The provider emits its raw push as `ProviderMotion`
24358
+ * (D673); the orchestrator's camera-sensors bridge re-emits the camera's
24359
+ * effective motion as `MotionOnMotionChanged`, which is what reaches
24360
+ * `reportMotion`.
24335
24361
  */
24336
24362
  motionSources: MotionSourcesSchema.default(["analyzer"]),
24337
24363
  /**
@@ -24508,7 +24534,15 @@ var RunnerLocalLoadSchema = object({
24508
24534
  hasGpu: boolean(),
24509
24535
  inferenceBackend: string().optional(),
24510
24536
  cpuCores: number().optional()
24511
- })
24537
+ }),
24538
+ /**
24539
+ * Who writes a camera's `motion` runtime slice (D696). `'orchestrator'`: this
24540
+ * runner never writes it. ABSENT = a runner older than D696, which still
24541
+ * writes the slice from its phase machine; the orchestrator does not write
24542
+ * while any runner node is absent-or-unanswered, so one slice never has two
24543
+ * writers.
24544
+ */
24545
+ motionSliceWriter: literal("orchestrator").optional()
24512
24546
  });
24513
24547
  /**
24514
24548
  * Aggregate runtime metrics for the runner's whole local pool. Mirrors the
@@ -30542,6 +30576,70 @@ onStatusChanged: { data: object({
30542
30576
  * whether persisting is worth a SQLite commit. */
30543
30577
  volatileStateFields: ["lastChangedAt"]
30544
30578
  };
30579
+ var DoorbellStatusSchema = object({
30580
+ /** Ms epoch of the last press. null = never observed since this provider started. */
30581
+ lastPressedAt: number().nullable(),
30582
+ /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
30583
+ pressCountSinceStart: number()
30584
+ });
30585
+ var DoorbellPressEventSchema = object({
30586
+ deviceId: number(),
30587
+ timestamp: number()
30588
+ });
30589
+ /**
30590
+ * Doorbell button cap. Two kinds of provider serve it, and to every consumer
30591
+ * they are the same cap:
30592
+ *
30593
+ * - **Native** providers, registered per device by a driver addon through
30594
+ * `ctx.registerNativeCap` — a `DeviceType.Button` accessory with
30595
+ * `role: DeviceRole.Doorbell`, or the camera itself (Reolink registers at
30596
+ * camera level). They emit `onPressed` on every firmware ring.
30597
+ * - **A composed doorbell** (D670, D671): a camera's customization gives it
30598
+ * the cap, its `lastPressedAt` rising from the sources the operator
30599
+ * assigned in Customize → Doorbell, and the composer emits `onPressed`
30600
+ * from that field's advance (`fromState`).
30601
+ *
30602
+ * The DeviceEventPropagator re-emits `onPressed` on the camera parent.
30603
+ */
30604
+ var doorbellCapability = {
30605
+ name: "doorbell",
30606
+ scope: "device",
30607
+ deviceNative: true,
30608
+ mode: "singleton",
30609
+ deviceTypes: [DeviceType.Button, DeviceType.Camera],
30610
+ methods: {},
30611
+ events: {
30612
+ /**
30613
+ * Fires once per physical press. Reolink delivers via Baichuan
30614
+ * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
30615
+ * release/duration — it's a pulse.
30616
+ */
30617
+ onPressed: {
30618
+ data: DoorbellPressEventSchema,
30619
+ fromState: {
30620
+ field: "lastPressedAt",
30621
+ on: "advance"
30622
+ }
30623
+ } },
30624
+ status: {
30625
+ schema: DoorbellStatusSchema,
30626
+ kind: "push"
30627
+ },
30628
+ /**
30629
+ * Runtime-state slice — last press timestamp + lifetime press count.
30630
+ * Mirrored by the kernel and readable via
30631
+ * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
30632
+ * without subscribing.
30633
+ */
30634
+ runtimeState: DoorbellStatusSchema,
30635
+ /**
30636
+ * 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.
30637
+ *
30638
+ * See `RuntimeStateDurability`. Enforced by
30639
+ * `scripts/check-runtime-state-durability.ts`.
30640
+ */
30641
+ durability: "restored"
30642
+ };
30545
30643
  /**
30546
30644
  * Enum-state sensor — a string value picked from a finite option set.
30547
30645
  * Drives HA `sensor` entries with `state_class: enum` (HVAC action
@@ -32681,39 +32779,14 @@ authKey: string().optional() }), object({
32681
32779
  /** Human-readable error when `ok: false`. */
32682
32780
  error: string().optional()
32683
32781
  }), { kind: "mutation" });
32684
- /**
32685
- * Hardware / firmware motion sensor cap — binary detected state plus
32686
- * a timestamp of the last observation. Distinct from
32687
- * `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
32688
- * `motion` is the lightweight readout from on-camera motion (Reolink
32689
- * `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
32690
- *
32691
- * Native-motion providers also fan out to `detection.camera-native`
32692
- * with `source: 'onboard'` so cross-cutting system services
32693
- * (alert-center, advanced-notifier) can subscribe once and receive
32694
- * motion from every camera.
32695
- */
32696
- /**
32697
- * How long after a camera's last rising edge `pipeline-analytics` closes the
32698
- * motion EPISODE row it kept open for it (D475) — "il delay della cap", in
32699
- * the operator's words. One authority for the whole system: every provider
32700
- * that seeds `autoClearAfterMs` on a `Camera` device writes this SAME
32701
- * constant while `detected: true` (never its own number — Hikvision used to
32702
- * seed its internal 3 s inactivity timer here, which is a different clock for
32703
- * a different purpose), and `MotionEpisodeTracker` imports it directly rather
32704
- * than reading the live cap value on the hot path. A `Sensor` device (HA
32705
- * binary sensor, Homematic) gets a genuine push both ways and has no episode
32706
- * to close on a timer, so it writes `null`, never this constant.
32707
- */
32708
- var MOTION_CLOSE_AFTER_MS = 15e3;
32709
32782
  var MotionStatusSchema = object({
32710
32783
  detected: boolean(),
32711
32784
  /** Ms epoch of the last detected-true observation. Null if never detected. */
32712
32785
  lastDetectedAt: number().nullable(),
32713
32786
  /**
32714
- * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
32715
- * `null` while false and on every `Sensor` device (D475) — see that
32716
- * constant's doc for the one-authority rule.
32787
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device (the
32788
+ * orchestrator writes it, D696), `null` while false and on every `Sensor`
32789
+ * device (D475) — see that constant's doc for the one-authority rule.
32717
32790
  *
32718
32791
  * ## Reading this field still arms nothing
32719
32792
  *
@@ -32731,34 +32804,31 @@ var MotionStatusSchema = object({
32731
32804
  * `addon-export-alexa/src/motion-clear-hold.ts` and
32732
32805
  * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
32733
32806
  *
32734
- * ## Who writes it
32735
- *
32736
- * - **Cameras** — the runner's phase machine, `active → watching` on
32737
- * `cooldown_expired`, which then writes this slice with
32738
- * `detected: false` (`handlePhaseChanged` in
32739
- * `pipeline-runner/index.ts`). It produces the FALLING edge, which
32740
- * matters most for the sources that only ever push a rising one:
32741
- * Reolink emits `MotionOnMotionChanged { detected: true }` and never
32742
- * a false.
32743
- * - **Sensors** (Home Assistant binary sensors, Homematic) — the
32744
- * provider pushes the false itself, from the upstream system's own
32745
- * state change. No phase machine is involved.
32807
+ * ## Who writes it (D696)
32746
32808
  *
32747
- * ### The phase machine is CANONICAL, not sole — and that is a defect
32809
+ * - **Cameras** — the orchestrator, and nothing else. It writes the camera's
32810
+ * EFFECTIVE motion (`addon-pipeline-orchestrator`
32811
+ * `camera-sensors/motion-slice.ts`), alongside the effective
32812
+ * `MotionOnMotionChanged` it emits or receives: the camera-sensors bridge
32813
+ * for a split camera, an unsplit emitter's direct event, the analyzer and
32814
+ * device activity, as the camera's `motionSources` counts them. A source
32815
+ * that never sends a clear falls one window after its last `true`.
32816
+ * `lastDetectedAt` moves only on an effective rise. No camera provider
32817
+ * writes this slice (not even a boot seed), and neither does the runner's
32818
+ * phase machine: its phase is "a session is attached" for every on-motion
32819
+ * session, not motion, and it now has its own `DetectionPhaseTransition`.
32820
+ * A provider's `isDetected` answers from the hub's slice.
32821
+ * - **Sensors** (Home Assistant binary sensors, Homematic, Matter, Alexa
32822
+ * imports) — the provider pushes both edges itself, from the upstream
32823
+ * system's own state change. That is the sensor's own fact.
32748
32824
  *
32749
- * An earlier revision of this docblock (mine, 2026-09-12) claimed the
32750
- * phase machine is the sole writer for a camera. It is not.
32751
- * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
32752
- * `setCapSlice(motionCapability, …)` on their own rising edge, and
32753
- * Hikvision's comment says why: it read THIS docblock, agreed the
32754
- * runner is canonical, and wrote anyway to avoid per-tick churn. So
32755
- * two authorities can disagree about one slice, which this repo
32756
- * forbids, and the doc said otherwise — which is worse than saying
32757
- * nothing, because it reads as verification.
32825
+ * `scripts/check-onboard-motion-emitters.ts` refuses any other writer of a
32826
+ * `motion` slice; each sensor writer is a named exemption.
32758
32827
  *
32759
- * This predates D475 and is not fixed there: the fix touches every
32760
- * camera provider. Recorded in D475's Consequences. Do not restore the
32761
- * "sole writer" wording without also removing the other writers.
32828
+ * This replaces the D475 §4 rule ("the phase machine is the sole writer").
32829
+ * That rule was never true: Hikvision and Amcrest wrote the slice raw beside
32830
+ * it, every provider seeded it at boot, and every session left it
32831
+ * `detected: true` after its detach.
32762
32832
  */
32763
32833
  autoClearAfterMs: number().nullable()
32764
32834
  });
@@ -32830,11 +32900,12 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
32830
32900
  */
32831
32901
  runtimeState: MotionStatusSchema,
32832
32902
  /**
32833
- * Runtime-state durability: **session** — every writer of this slice
32903
+ * Runtime-state durability: **session** — the writer of this slice
32834
32904
  * writes only on an EDGE, so a restored `detected: true` would stay
32835
32905
  * frozen until the next one instead of being corrected. The next edge
32836
- * re-publishes the real state. (On who the writers are, and why there
32837
- * is more than one, see `autoClearAfterMs` above.)
32906
+ * re-publishes the real state, and the orchestrator re-publishes every
32907
+ * camera when it starts writing (D696; on who writes it, see
32908
+ * `autoClearAfterMs` above).
32838
32909
  *
32839
32910
  * See `RuntimeStateDurability`. Enforced by
32840
32911
  * `scripts/check-runtime-state-durability.ts`.
@@ -35375,8 +35446,7 @@ var ptzAutotrackCapability = {
35375
35446
  deviceNative: true,
35376
35447
  mode: "singleton",
35377
35448
  /**
35378
- * Two kinds of provider behind one name, the same shape `snapshot` and
35379
- * `doorbell` use:
35449
+ * Two kinds of provider behind one name, the same shape `snapshot` uses:
35380
35450
  *
35381
35451
  * - **Native**: the camera's own firmware autotrack, registered per device by
35382
35452
  * the driver when the probe says it exists (Reolink: yes; Hikvision:
@@ -35384,7 +35454,7 @@ var ptzAutotrackCapability = {
35384
35454
  * - **Wrapper**: the emulated implementation (`@camstack/system`'s `autotrack` builtin),
35385
35455
  * which follows a subject with `ptz.move` pulses driven by the detection
35386
35456
  * pipeline. `defaultActive: false` — the operator binds it per camera in
35387
- * the bindings UI, exactly as `virtual-doorbell` is bound.
35457
+ * the bindings UI.
35388
35458
  *
35389
35459
  * The binding chooses WHICH implementation answers; `setEnabled` stays the
35390
35460
  * one switch for the function either way. A camera never has both driving its
@@ -40786,13 +40856,14 @@ var BaseDeviceProvider = class extends BaseAddon {
40786
40856
  async getStatus() {
40787
40857
  const all = await this.ctx.kernel.devices?.getAll() ?? [];
40788
40858
  const summary = this.restoreFailureSummary();
40789
- if (summary === null) return {
40859
+ const base = {
40790
40860
  connected: true,
40791
- deviceCount: all.length
40861
+ deviceCount: all.length,
40862
+ motionSliceWriter: "orchestrator"
40792
40863
  };
40864
+ if (summary === null) return base;
40793
40865
  return {
40794
- connected: true,
40795
- deviceCount: all.length,
40866
+ ...base,
40796
40867
  error: summary
40797
40868
  };
40798
40869
  }
@@ -46434,6 +46505,12 @@ Object.freeze({
46434
46505
  addonId: null,
46435
46506
  access: "view"
46436
46507
  },
46508
+ "notificationRules.getAlarmSensors": {
46509
+ capName: "notification-rules",
46510
+ capScope: "system",
46511
+ addonId: null,
46512
+ access: "view"
46513
+ },
46437
46514
  "notificationRules.getClipRetentionAsks": {
46438
46515
  capName: "notification-rules",
46439
46516
  capScope: "system",
@@ -50917,6 +50994,11 @@ Object.freeze({
50917
50994
  form: "single",
50918
50995
  optional: false
50919
50996
  }],
50997
+ "notificationRules.getAlarmSensors": [{
50998
+ name: "deviceIds",
50999
+ form: "array",
51000
+ optional: false
51001
+ }],
50920
51002
  "notificationRules.setDeviceMuted": [{
50921
51003
  name: "deviceId",
50922
51004
  form: "single",
@@ -52852,6 +52934,25 @@ TimelapseRuleInputSchema.extend({
52852
52934
  createdAt: number(),
52853
52935
  updatedAt: number()
52854
52936
  });
52937
+ async function readHubMotionDetected(deviceState, deviceId) {
52938
+ let slice;
52939
+ try {
52940
+ slice = await deviceState.getCapSlice.query({
52941
+ deviceId,
52942
+ capName: "motion"
52943
+ });
52944
+ } catch (err) {
52945
+ const reason = err instanceof Error ? err.message : String(err);
52946
+ throw new Error(`motion state of device ${deviceId} is unreadable: ${reason}`, { cause: err });
52947
+ }
52948
+ const detected = slice?.["detected"];
52949
+ if (typeof detected !== "boolean") throw new Error(`motion state of device ${deviceId} is not published yet (unknown)`);
52950
+ return detected;
52951
+ }
52952
+ MotionOnMotionChangedDataSchema.omit({ triggeredBy: true });
52953
+ function providerMotionEvent(source, data) {
52954
+ return createEvent(EventCategory.ProviderMotion, source, data);
52955
+ }
52855
52956
  object({
52856
52957
  /**
52857
52958
  * Fraction of the box's own size added on EACH side before cutting.
@@ -55221,17 +55322,14 @@ var AmcrestCamera = class AmcrestCamera extends BaseDevice {
55221
55322
  }
55222
55323
  /** Register the native `motion` cap. Its mere presence (a `kind:'native'`
55223
55324
  * `motion` binding) is what the orchestrator reads to default a
55224
- * freshly-adopted camera to `motionSources:['onboard']`. */
55325
+ * freshly-adopted camera to `motionSources:['onboard']`. `isDetected`
55326
+ * answers from the HUB's slice; an unreadable hub, or a slice nobody has
55327
+ * published yet, fails the call — never `false` for unknown (D49, D393). */
55225
55328
  registerMotionCap() {
55226
55329
  this.ctx.registerNativeCap(motionCapability, { isDetected: async ({ deviceId }) => {
55227
55330
  if (deviceId !== this.id) throw new Error(`AmcrestCamera: motion deviceId mismatch, expected ${this.id}, got ${deviceId}`);
55228
- return this.getCapSlice(motionCapability)?.detected ?? false;
55331
+ return readHubMotionDetected(this.ctx.api.deviceState, this.id);
55229
55332
  } });
55230
- this.setCapSlice(motionCapability, {
55231
- detected: false,
55232
- lastDetectedAt: null,
55233
- autoClearAfterMs: null
55234
- });
55235
55333
  this.ctx.logger.info("amcrest: motion cap registered", { tags: { deviceId: this.id } });
55236
55334
  }
55237
55335
  /** Reusable event-source identity for every emit on this device. */
@@ -55243,10 +55341,12 @@ var AmcrestCamera = class AmcrestCamera extends BaseDevice {
55243
55341
  deviceId: this.id
55244
55342
  };
55245
55343
  }
55246
- /** Emit an onboard motion transition on the bus. The runner subscribes
55247
- * and drives its phase machine via `reportMotion`. */
55344
+ /** Emit the camera's RAW onboard motion transition (`ProviderMotion`,
55345
+ * D673). The orchestrator's camera-sensors bridge re-emits it as
55346
+ * `MotionOnMotionChanged`; the runner subscribes to that and drives its
55347
+ * phase machine via `reportMotion`. */
55248
55348
  emitMotion(detected, timestamp) {
55249
- this.ctx.eventBus.emit(createEvent(EventCategory.MotionOnMotionChanged, this.eventSource(), {
55349
+ this.ctx.eventBus.emit(providerMotionEvent(this.eventSource(), {
55250
55350
  deviceId: this.id,
55251
55351
  detected,
55252
55352
  timestamp,
@@ -55341,14 +55441,7 @@ var AmcrestCamera = class AmcrestCamera extends BaseDevice {
55341
55441
  const wasActive = this.motionActive;
55342
55442
  this.motionActive = true;
55343
55443
  this.emitMotion(true, now);
55344
- if (!wasActive) {
55345
- this.setCapSlice(motionCapability, {
55346
- detected: true,
55347
- lastDetectedAt: now,
55348
- autoClearAfterMs: MOTION_CLOSE_AFTER_MS
55349
- });
55350
- this.ctx.logger.info("amcrest: onboard motion started", { tags: { deviceId: this.id } });
55351
- }
55444
+ if (!wasActive) this.ctx.logger.info("amcrest: onboard motion started", { tags: { deviceId: this.id } });
55352
55445
  if (this.motionKeepaliveTimer === null) this.motionKeepaliveTimer = setInterval(() => {
55353
55446
  this.emitMotion(true, Date.now());
55354
55447
  }, AmcrestCamera.MOTION_KEEPALIVE_MS);
@@ -55358,12 +55451,6 @@ var AmcrestCamera = class AmcrestCamera extends BaseDevice {
55358
55451
  if (!this.motionActive) return;
55359
55452
  this.motionActive = false;
55360
55453
  this.emitMotion(false, now);
55361
- const lastDetectedAt = this.getCapSlice(motionCapability)?.lastDetectedAt ?? now;
55362
- this.setCapSlice(motionCapability, {
55363
- detected: false,
55364
- lastDetectedAt,
55365
- autoClearAfterMs: null
55366
- });
55367
55454
  this.ctx.logger.info("amcrest: onboard motion stopped", { tags: { deviceId: this.id } });
55368
55455
  }
55369
55456
  clearMotionKeepalive() {