@camstack/addon-provider-hikvision 1.2.135 → 1.2.137

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 +338 -247
  2. package/dist/addon.mjs +338 -247
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -12,7 +12,7 @@ import { networkInterfaces } from "node:os";
12
12
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
13
13
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
14
14
  //#endregion
15
- //#region ../types/dist/event-category-C5xZWqz6.mjs
15
+ //#region ../types/dist/event-category-BGmz_oxW.mjs
16
16
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
17
17
  EventCategory["SystemBoot"] = "system.boot";
18
18
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -545,6 +545,15 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
545
545
  */
546
546
  EventCategory["PipelineAudioInferenceResult"] = "pipeline.audio-inference-result";
547
547
  EventCategory["DetectionPhaseTransition"] = "detection.phase-transition";
548
+ /**
549
+ * A camera provider's RAW onboard motion push (D673): the `MotionOnMotionChanged`
550
+ * data shape without `triggeredBy`, built by `providerMotionEvent`. Its one
551
+ * consumer is the orchestrator's camera-sensors bridge, which re-emits the
552
+ * camera's EFFECTIVE onboard motion as `MotionOnMotionChanged` (a pass-through
553
+ * for a camera with no attached sensor). Providers must not emit
554
+ * `MotionOnMotionChanged` themselves; `scripts/check-onboard-motion-emitters.ts`
555
+ * keeps it so (camera-grid is a named, deferred exception).
556
+ */
548
557
  EventCategory["ProviderMotion"] = "provider.motion";
549
558
  EventCategory["ProviderDetection"] = "provider.detection";
550
559
  EventCategory["EnrichmentEmbeddingStored"] = "enrichment.embedding.stored";
@@ -5383,7 +5392,7 @@ var ZodIssueCode = {
5383
5392
  var ZodFirstPartyTypeKind;
5384
5393
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5385
5394
  //#endregion
5386
- //#region ../types/dist/sleep-gU6hqv4_.mjs
5395
+ //#region ../types/dist/sleep-CDCONfkt.mjs
5387
5396
  /**
5388
5397
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5389
5398
  * window to float samples (D455).
@@ -7428,7 +7437,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
7428
7437
  return DeviceRole;
7429
7438
  }({});
7430
7439
  //#endregion
7431
- //#region ../types/dist/composition-Dq42XWp0.mjs
7440
+ //#region ../types/dist/composition-43aqsZQj.mjs
7432
7441
  /**
7433
7442
  * The ffmpeg build every CamStack node downloads, per platform and arch.
7434
7443
  *
@@ -7485,13 +7494,12 @@ portable("linux64"), portable("linuxarm64"), portable("macarm64"), portable("mac
7485
7494
  * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
7486
7495
  * valutatore puro del suo FRONTE.
7487
7496
  *
7488
- * Viveva dentro il builtin virtual-doorbell
7489
- * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
7490
- * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
7491
- * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
7492
- * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
7493
- * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
7494
- * SPOSTA qui e il doorbell la ri-esporta.
7497
+ * UNA tabella per tutti quelli che chiedono "questo device è ALTO?": il
7498
+ * trigger `RecordingTriggers.sensorDeviceIds` del recorder, i marker dei
7499
+ * sensori della post-analysis, il bridge camera-sensors dell'orchestratore e
7500
+ * le sorgenti di un campanello composto (`doorbellFeatureSources`, D671).
7501
+ * Una seconda copia divergerebbe alla prima cap aggiunta, e il sintomo — "il
7502
+ * sensore fa suonare il campanello ma non registra" — è esattamente D62.
7495
7503
  *
7496
7504
  * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
7497
7505
  * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
@@ -7517,8 +7525,6 @@ var SOURCE_CAP_ACTIVE_FIELD = {
7517
7525
  vibration: "detected",
7518
7526
  tamper: "tampered"
7519
7527
  };
7520
- /** Cap names whose presence in a device's bindings qualify it as a source. */
7521
- var SOURCE_CAPS = Object.keys(SOURCE_CAP_ACTIVE_FIELD);
7522
7528
  /**
7523
7529
  * Error types for the safe expression engine. Two distinct classes so callers
7524
7530
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
@@ -9248,7 +9254,7 @@ var RecordingTriggersSchema = object({
9248
9254
  *
9249
9255
  * Cosa vuol dire "alto" dipende dal TIPO di device e non è deciso qui:
9250
9256
  * `SOURCE_CAP_ACTIVE_FIELD` (`catalogs/sensor-active-state.ts`) è LA tabella,
9251
- * la stessa che il virtual-doorbell usa dal 2026-08-05. Ed è il FRONTE, non
9257
+ * la stessa del campanello composto (D671). Ed è il FRONTE, non
9252
9258
  * il livello: un contatto trovato già aperto al riavvio del runner non fa
9253
9259
  * registrare.
9254
9260
  */
@@ -15139,7 +15145,17 @@ var SiteZoneSchema = object({
15139
15145
  var ProviderStatusSchema = object({
15140
15146
  connected: boolean(),
15141
15147
  deviceCount: number(),
15142
- error: string().optional()
15148
+ error: string().optional(),
15149
+ /**
15150
+ * `'orchestrator'`: this provider writes NO camera's `motion` runtime slice
15151
+ * — the orchestrator is its only writer (D696). Set by `BaseDeviceProvider`,
15152
+ * which every provider bundles, so only a provider BUILT from D696-amended
15153
+ * code says it. ABSENT means an older provider that may still write it (raw
15154
+ * VMD writes, a boot seed), and the orchestrator's provider gate keeps that
15155
+ * provider's cameras unwritten (`camera-sensors/motion-slice-provider-gate.ts`)
15156
+ * — the provider twin of the runner's `getLocalLoad().motionSliceWriter`.
15157
+ */
15158
+ motionSliceWriter: literal("orchestrator").optional()
15143
15159
  });
15144
15160
  object({
15145
15161
  externalId: string(),
@@ -16018,109 +16034,10 @@ method(object({
16018
16034
  deviceIds: array(number()).readonly(),
16019
16035
  caps: array(string()).readonly().optional()
16020
16036
  }), record(string(), record(string(), unknown().nullable())));
16021
- /**
16022
- * Doorbell button cap. Two kinds of providers coexist behind this cap
16023
- * name (same pattern as `snapshot`):
16024
- *
16025
- * - **Native** providers: registered per-device by device-driver
16026
- * addons via `ctx.registerNativeCap` — either on a
16027
- * `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
16028
- * or directly on the camera (Reolink registers at camera level).
16029
- * Emits an `onPressed` event every time the firmware pushes a
16030
- * ring; status tracks the last press and a pressCount since start
16031
- * (diagnostic).
16032
- *
16033
- * - **Wrapper** provider: the `virtual-doorbell` system builtin
16034
- * (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
16035
- * device (contact / switch / event-emitter …) into a doorbell for
16036
- * a camera. `defaultActive: false` — the operator explicitly binds
16037
- * it per camera in the device-bindings UI, then picks the source
16038
- * device + trigger in the per-device settings.
16039
- *
16040
- * The DeviceEventPropagator re-emits `onPressed` on the camera parent
16041
- * — subscribers listening at the camera level receive ring events
16042
- * with `via[]` populated. No code on the parent needed.
16043
- */
16044
- var DoorbellStatusSchema = object({
16045
- /** Ms epoch of the last press. null = never observed since this provider started. */
16046
- lastPressedAt: number().nullable(),
16047
- /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
16048
- pressCountSinceStart: number()
16049
- });
16050
- var DoorbellPressEventSchema = object({
16051
- deviceId: number(),
16052
- timestamp: number()
16053
- });
16054
- /**
16055
- * The `doorbell-source` extension slot's editable value (D648): the camera's
16056
- * virtual-doorbell trigger devices, exactly what the wrapper's
16057
- * `doorbellSources` persists (as `{ deviceId }` records).
16058
- */
16059
- var DoorbellSourceSlotValueSchema = object({ deviceIds: array(number().int().positive()) });
16060
- /**
16061
- * The `doorbell-source` slot — which devices ring this camera's VIRTUAL
16062
- * doorbell, owned by the `virtual-doorbell` wrapper over its
16063
- * `doorbellSources` store (D648). A source rings when one of its
16064
- * `SOURCE_CAPS` rises. Whether the wrapper is bound to the camera at all is a
16065
- * different authority (`deviceManager.setWrapperActive`, D62) — the slot
16066
- * reports it, it never writes it.
16067
- */
16068
- var DOORBELL_SOURCE_SLOT = {
16069
- id: "doorbell-source",
16070
- label: "Doorbell trigger devices",
16071
- 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.",
16072
- shape: "association",
16073
- hostDeviceTypes: [DeviceType.Camera],
16074
- sourceCaps: SOURCE_CAPS,
16075
- cardinality: "many",
16076
- value: DoorbellSourceSlotValueSchema
16077
- };
16078
- var doorbellCapability = {
16079
- name: "doorbell",
16080
- scope: "device",
16081
- deviceNative: true,
16082
- mode: "singleton",
16083
- kind: "wrapper",
16084
- defaultActive: false,
16085
- deviceTypes: [DeviceType.Button, DeviceType.Camera],
16086
- extensionSlots: [DOORBELL_SOURCE_SLOT],
16087
- methods: {},
16088
- events: {
16089
- /**
16090
- * Fires once per physical press. Reolink delivers via Baichuan
16091
- * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
16092
- * release/duration — it's a pulse.
16093
- */
16094
- onPressed: {
16095
- data: DoorbellPressEventSchema,
16096
- fromState: {
16097
- field: "lastPressedAt",
16098
- on: "advance"
16099
- }
16100
- } },
16101
- status: {
16102
- schema: DoorbellStatusSchema,
16103
- kind: "push"
16104
- },
16105
- /**
16106
- * Runtime-state slice — last press timestamp + lifetime press count.
16107
- * Mirrored by the kernel and readable via
16108
- * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
16109
- * without subscribing.
16110
- */
16111
- runtimeState: DoorbellStatusSchema,
16112
- /**
16113
- * 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.
16114
- *
16115
- * See `RuntimeStateDurability`. Enforced by
16116
- * `scripts/check-runtime-state-durability.ts`.
16117
- */
16118
- durability: "restored"
16119
- };
16120
- var ExtensionSlotIdSchema = _enum(["doorbell-source", "linked-devices"]);
16121
- DeviceType.Camera, DeviceType.Camera;
16037
+ var ExtensionSlotIdSchema = _enum(["linked-devices"]);
16038
+ DeviceType.Camera;
16122
16039
  /** A slot's editable value, discriminated on `slot`. */
16123
- var ExtensionSlotValueSchema = discriminatedUnion("slot", [DoorbellSourceSlotValueSchema.extend({ slot: literal("doorbell-source") }), LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
16040
+ var ExtensionSlotValueSchema = discriminatedUnion("slot", [LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
16124
16041
  DeviceType.Camera;
16125
16042
  var ExtensionSourceAvailabilitySchema = discriminatedUnion("state", [object({ state: literal("ok") }), object({
16126
16043
  state: literal("unreachable"),
@@ -16157,10 +16074,11 @@ var ExtensionSlotSourceSchema = object({
16157
16074
  });
16158
16075
  /**
16159
16076
  * A DIFFERENT authority that gates whether the slot's sources do anything —
16160
- * reported read-only, named, never written through this contract (D62). The
16161
- * virtual doorbell's sources ring only while the wrapper is bound to the
16162
- * camera, and that binding belongs to `deviceManager.setWrapperActive`.
16163
- * `unknown` means the gate could not be read; it is not "inactive" (D315).
16077
+ * reported read-only, named, never written through this contract (D62) — e.g.
16078
+ * a slot whose sources act only while a wrapper is bound to the host, a
16079
+ * binding that belongs to `deviceManager.setWrapperActive`. No slot reports
16080
+ * one today (`linked-devices` answers `null`). `unknown` means the gate could
16081
+ * not be read; it is not "inactive" (D315).
16164
16082
  */
16165
16083
  var ExtensionSlotActivationSchema = object({
16166
16084
  state: _enum([
@@ -16176,7 +16094,7 @@ var ExtensionSlotRowSchema = discriminatedUnion("state", [object({
16176
16094
  /** `<source>:<slotId>` — the routing key for `listCandidates` / `setSlot`. */
16177
16095
  slotRef: string(),
16178
16096
  slot: ExtensionSlotIdSchema,
16179
- /** Names the store written (D62), e.g. `virtual-doorbell:doorbellSources`. */
16097
+ /** Names the store written (D62), e.g. `device-manager:_linkedDeviceIds`. */
16180
16098
  authority: string(),
16181
16099
  activation: ExtensionSlotActivationSchema.nullable(),
16182
16100
  value: ExtensionSlotValueSchema,
@@ -20718,6 +20636,29 @@ object({
20718
20636
  firstAt: number(),
20719
20637
  lastAt: number()
20720
20638
  });
20639
+ var NC_ALARM_TRIGGERED_MAX_SEC = 3600;
20640
+ var NcAlarmDelaySecSchema = number().int().min(0).max(600);
20641
+ var NcAlarmTriggeredSecSchema = number().int().min(0).max(NC_ALARM_TRIGGERED_MAX_SEC);
20642
+ var uniqueModes = (entries) => new Set(entries.map((e) => e.mode)).size === entries.length;
20643
+ var NcAlarmModeDelaysListSchema = array(object({
20644
+ mode: AlarmArmModeSchema,
20645
+ exitDelaySec: NcAlarmDelaySecSchema.optional(),
20646
+ entryDelaySec: NcAlarmDelaySecSchema.optional(),
20647
+ triggeredDurationSec: NcAlarmTriggeredSecSchema.optional()
20648
+ })).max(8).refine(uniqueModes, { message: "modeDelays: at most one entry per arm mode" });
20649
+ var NcAlarmModeDelaysEditListSchema = array(object({
20650
+ mode: AlarmArmModeSchema,
20651
+ exitDelaySec: NcAlarmDelaySecSchema.nullable().optional(),
20652
+ entryDelaySec: NcAlarmDelaySecSchema.nullable().optional(),
20653
+ triggeredDurationSec: NcAlarmTriggeredSecSchema.nullable().optional()
20654
+ })).max(8).refine(uniqueModes, { message: "modeDelays: at most one edit per arm mode" });
20655
+ /** One switch of the alarm table: put ONE device on, or take it off, ONE mode's list. */
20656
+ var NcAlarmNonBlockingEditSchema = object({
20657
+ mode: AlarmArmModeSchema,
20658
+ deviceId: number().int().positive(),
20659
+ /** true = on the list (may be open, does not block); false = off the list (blocks). */
20660
+ nonBlocking: boolean()
20661
+ });
20721
20662
  /**
20722
20663
  * The per-mode lists, at most one per mode. Two lists for one mode have no
20723
20664
  * meaning a reader could agree on (union? the last one?), so they are refused
@@ -20726,10 +20667,10 @@ object({
20726
20667
  var NcAlarmNonBlockingListSchema = array(object({
20727
20668
  mode: AlarmArmModeSchema,
20728
20669
  deviceIds: array(number().int()).max(200)
20729
- })).max(8).refine((lists) => new Set(lists.map((l) => l.mode)).size === lists.length, { message: "nonBlocking: at most one list per arm mode" });
20670
+ })).max(8).refine(uniqueModes, { message: "nonBlocking: at most one list per arm mode" });
20730
20671
  /**
20731
- * The three durations the panel's state machine runs on, who hears about its
20732
- * transitions, and which openings each mode tolerates.
20672
+ * The three durations — global, and per mode since D697 — the panel's state
20673
+ * machine runs on, who hears about its transitions, and which openings each mode tolerates.
20733
20674
  *
20734
20675
  * They live on the NOTIFICATION-RULES cap, not on `alarm-panel`, on purpose:
20735
20676
  * `alarm-panel` is `deviceNative` and its other provider mirrors somebody
@@ -20739,15 +20680,15 @@ var NcAlarmNonBlockingListSchema = array(object({
20739
20680
  */
20740
20681
  var NcAlarmSettingsSchema = object({
20741
20682
  /** Grace period between arming and the mode taking effect. 0 = immediate. */
20742
- exitDelaySec: number().int().min(0).max(600),
20683
+ exitDelaySec: NcAlarmDelaySecSchema,
20743
20684
  /** Grace period between a trigger and the alarm firing. 0 = immediate. */
20744
- entryDelaySec: number().int().min(0).max(600),
20685
+ entryDelaySec: NcAlarmDelaySecSchema,
20745
20686
  /**
20746
20687
  * How long `triggered` lasts before the panel re-arms itself.
20747
20688
  * **0 = until an operator disarms it** — the behaviour before this field
20748
20689
  * existed, and therefore what an untouched install keeps doing.
20749
20690
  */
20750
- triggeredDurationSec: number().int().min(0).max(3600),
20691
+ triggeredDurationSec: NcAlarmTriggeredSecSchema,
20751
20692
  /**
20752
20693
  * Deprecated by D630 — every transition is announced. Parsed, never read;
20753
20694
  * remove after one release. Optional so an older admin's patch (which still
@@ -20770,17 +20711,30 @@ var NcAlarmSettingsSchema = object({
20770
20711
  * per mode is meaningful. Defaulted to `[]` so a blob stored before D630
20771
20712
  * parses as "every opening blocks" — the behaviour it was written under.
20772
20713
  */
20773
- nonBlocking: NcAlarmNonBlockingListSchema.default([])
20714
+ nonBlocking: NcAlarmNonBlockingListSchema.default([]),
20715
+ /**
20716
+ * Per arm mode, the delays that mode OVERRIDES (D697). A mode with no entry, or an entry
20717
+ * without a field, uses the global value above — so `[]`, the default, is exactly the
20718
+ * behaviour of a blob stored before this field existed. Read through `resolveModeDelays`.
20719
+ */
20720
+ modeDelays: NcAlarmModeDelaysListSchema.default([])
20774
20721
  });
20775
20722
  /**
20776
20723
  * Every field optional — a tab edits one control at a time.
20777
20724
  *
20778
- * `nonBlocking` is re-declared WITHOUT its default: `.partial()` does not
20779
- * remove an inner `.default()`, so a patch that never named the field would
20780
- * parse to `nonBlocking: []` and wipe every mode's list on an unrelated edit
20781
- * (the same trap {@link NcRulePatchSchema} documents).
20725
+ * `nonBlocking` and `modeDelays` are re-declared WITHOUT their defaults:
20726
+ * `.partial()` does not remove an inner `.default()`, so a patch that never
20727
+ * named the field would parse to `[]` and wipe every mode's list on an
20728
+ * unrelated edit (the same trap {@link NcRulePatchSchema} documents). Here
20729
+ * `modeDelays` means EDITS, not the stored overrides.
20782
20730
  */
20783
- var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.extend({ nonBlocking: NcAlarmNonBlockingListSchema }).partial();
20731
+ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.extend({
20732
+ nonBlocking: NcAlarmNonBlockingListSchema,
20733
+ /** Per-mode, per-field edits — NOT the whole list (see NcAlarmModeDelaysEditSchema). */
20734
+ modeDelays: NcAlarmModeDelaysEditListSchema,
20735
+ /** ONE membership change; the panel applies it to the list it holds at its turn. */
20736
+ nonBlockingEdit: NcAlarmNonBlockingEditSchema
20737
+ }).partial().refine((p) => p.nonBlocking === void 0 || p.nonBlockingEdit === void 0, { message: "nonBlocking and nonBlockingEdit are exclusive — send the whole lists or one edit" });
20784
20738
  /**
20785
20739
  * What one arm mode actually arms, DERIVED from the enabled rules gated on it.
20786
20740
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
@@ -20880,6 +20834,28 @@ var NcAlarmConfigSchema = object({
20880
20834
  */
20881
20835
  live: NcAlarmLiveSchema.optional()
20882
20836
  });
20837
+ var NcAlarmSensorReadingSchema = _enum([
20838
+ "open",
20839
+ "closed",
20840
+ "unknown",
20841
+ "not-opening"
20842
+ ]);
20843
+ /** One device's state as the alarm reads it — the classifier the arm check uses. */
20844
+ var NcAlarmSensorStateSchema = object({
20845
+ deviceId: number().int().positive(),
20846
+ reading: NcAlarmSensorReadingSchema,
20847
+ /** The word as read (`open`, `closed`, `unlocked`, `stopped`, …); null when unknown / not an opening. */
20848
+ state: string().nullable(),
20849
+ /** Why `unknown`: the read failed, or the slice holds no word its cap defines (a placeholder included). */
20850
+ unknownWhy: _enum(["read-failed", "unknown-word"]).nullable(),
20851
+ /** The device manager's liveness as the centre mirrors it; null = not known. */
20852
+ online: boolean().nullable()
20853
+ });
20854
+ var NcAlarmSensorsInputSchema = object({ deviceIds: array(number().int().positive()).max(500) });
20855
+ var NcAlarmSensorsSchema = object({
20856
+ sensors: array(NcAlarmSensorStateSchema),
20857
+ readAt: number().int().nonnegative()
20858
+ });
20883
20859
  /**
20884
20860
  * ONE rule's demand on ONE camera's clip ring.
20885
20861
  *
@@ -20970,7 +20946,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
20970
20946
  }), method(object({}), NcAlarmConfigSchema, { auth: "admin" }), method(object({ patch: NcAlarmSettingsPatchSchema }), NcAlarmConfigSchema, {
20971
20947
  kind: "mutation",
20972
20948
  auth: "admin"
20973
- });
20949
+ }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
20974
20950
  /**
20975
20951
  * Zod schemas for persisted record types.
20976
20952
  *
@@ -21317,12 +21293,26 @@ var CameraSensorRefSchema = object({
21317
21293
  function cameraSensorRefKey(ref) {
21318
21294
  return `${ref.addonId}/${ref.stableId}`;
21319
21295
  }
21320
- /** CS-1 accepts exactly one mode; CS-2 (D673) widens it to confirm / replace. */
21321
- var CameraSensorsModeSchema = _enum(["in-addition"]);
21322
- var CameraSensorsConfigSchema = object({
21323
- mode: CameraSensorsModeSchema,
21324
- sensors: array(CameraSensorRefSchema).min(1).max(8)
21325
- }).superRefine((value, ctx) => {
21296
+ /**
21297
+ * A sensor's mode (D673). `in-addition`: its motion is the camera's motion too.
21298
+ * `replace`: its motion is the camera's, and while one is READY the camera's
21299
+ * own motion no longer counts on its own. `confirm`: while one is READY the
21300
+ * camera's own motion counts only while a confirm sensor is active — with or
21301
+ * without a replace sensor (spec C2, the controller's ruling on Q1).
21302
+ */
21303
+ var CameraSensorModeSchema = _enum([
21304
+ "in-addition",
21305
+ "confirm",
21306
+ "replace"
21307
+ ]);
21308
+ /** A stored sensor with no mode — every CS-1 row — is in addition. */
21309
+ var DEFAULT_CAMERA_SENSOR_MODE = "in-addition";
21310
+ /**
21311
+ * A camera's attached sensors. A CS-1 row carried an envelope
21312
+ * `mode: 'in-addition'`: `z.object` drops it on parse, and the PARSED value is
21313
+ * what the write stores (D672 rule 3), so it is never written again.
21314
+ */
21315
+ var CameraSensorsConfigSchema = object({ sensors: array(CameraSensorRefSchema.extend({ mode: CameraSensorModeSchema.default(DEFAULT_CAMERA_SENSOR_MODE) })).min(1).max(8) }).superRefine((value, ctx) => {
21326
21316
  const seen = /* @__PURE__ */ new Set();
21327
21317
  value.sensors.forEach((ref, index) => {
21328
21318
  const key = cameraSensorRefKey(ref);
@@ -21334,39 +21324,41 @@ var CameraSensorsConfigSchema = object({
21334
21324
  seen.add(key);
21335
21325
  });
21336
21326
  });
21337
- var RefFields = {
21327
+ /** Every attachment names its mode; an older orchestrator that does not is in addition. */
21328
+ var AttachmentFields = {
21338
21329
  addonId: string(),
21339
- stableId: string()
21330
+ stableId: string(),
21331
+ mode: CameraSensorModeSchema.default(DEFAULT_CAMERA_SENSOR_MODE)
21340
21332
  };
21341
21333
  var CameraSensorAttachmentSchema = discriminatedUnion("state", [
21342
21334
  object({
21343
- ...RefFields,
21335
+ ...AttachmentFields,
21344
21336
  state: literal("ready"),
21345
21337
  deviceId: number(),
21346
21338
  name: string(),
21347
21339
  caps: array(string()).readonly()
21348
21340
  }),
21349
21341
  object({
21350
- ...RefFields,
21342
+ ...AttachmentFields,
21351
21343
  state: literal("offline"),
21352
21344
  deviceId: number(),
21353
21345
  name: string(),
21354
21346
  reason: _enum(["offline", "disabled"])
21355
21347
  }),
21356
21348
  object({
21357
- ...RefFields,
21349
+ ...AttachmentFields,
21358
21350
  state: literal("missing"),
21359
21351
  reason: string()
21360
21352
  }),
21361
21353
  object({
21362
- ...RefFields,
21354
+ ...AttachmentFields,
21363
21355
  state: literal("unsupported"),
21364
21356
  deviceId: number(),
21365
21357
  name: string(),
21366
21358
  reason: string()
21367
21359
  }),
21368
21360
  object({
21369
- ...RefFields,
21361
+ ...AttachmentFields,
21370
21362
  state: literal("unreadable"),
21371
21363
  reason: string()
21372
21364
  })
@@ -21379,17 +21371,49 @@ var CameraSensorAttachmentSchema = discriminatedUnion("state", [
21379
21371
  * say.
21380
21372
  */
21381
21373
  var CameraSensorsNotForwardedSchema = _enum(["onboard-not-listed", "no-active-detection"]);
21374
+ /** Whether the camera's OWN motion counts on its own (D673 C2), from its READY sensors (C3). */
21375
+ var CameraOwnMotionSchema = _enum([
21376
+ "always",
21377
+ "when-confirmed",
21378
+ "never"
21379
+ ]);
21380
+ /** Confirm / Replace cannot suppress this camera's motion: its provider still emits it directly (D673 C13). */
21381
+ var CameraSensorsNotEnforcedSchema = _enum(["provider-not-split"]);
21382
+ /**
21383
+ * The camera's OWN onboard motion (D696): the raw input the bridge combines,
21384
+ * never the effective value. The camera's `motion` slice is the effective one,
21385
+ * so a view of the camera's own row reads this.
21386
+ * - `atMs`: when the bridge received the camera's last own edge.
21387
+ * - `detected`: evaluated WHEN THE STATUS IS ASKED — the last edge said `true`
21388
+ * AND it is younger than the window the bridge counts the camera's own motion
21389
+ * for (`motionCooldownMs`, floored at two sustain ticks). A camera that never
21390
+ * sends a clear (heartbeats only) therefore reads `false` once no push came
21391
+ * within the window; a status read is a snapshot, so a live view re-asks.
21392
+ * Absent = this orchestrator has not received the camera's own motion since it
21393
+ * started (unknown, never "quiet"), or an orchestrator older than D696.
21394
+ */
21395
+ var CameraRawLevelSchema = object({
21396
+ detected: boolean(),
21397
+ atMs: number()
21398
+ });
21382
21399
  var CameraSensorsStatusSchema = discriminatedUnion("state", [
21383
- object({ state: literal("not-configured") }),
21400
+ object({
21401
+ state: literal("not-configured"),
21402
+ cameraLevel: CameraRawLevelSchema.optional()
21403
+ }),
21384
21404
  object({
21385
21405
  state: literal("unreadable"),
21386
- reason: string()
21406
+ reason: string(),
21407
+ cameraLevel: CameraRawLevelSchema.optional()
21387
21408
  }),
21388
21409
  object({
21389
21410
  state: literal("configured"),
21390
- mode: CameraSensorsModeSchema,
21411
+ cameraLevel: CameraRawLevelSchema.optional(),
21391
21412
  sensors: array(CameraSensorAttachmentSchema).readonly(),
21392
- notForwarded: CameraSensorsNotForwardedSchema.optional()
21413
+ /** Absent = an orchestrator older than CS-2: it does not say (D315). */
21414
+ cameraMotion: CameraOwnMotionSchema.optional(),
21415
+ notForwarded: CameraSensorsNotForwardedSchema.optional(),
21416
+ notEnforced: CameraSensorsNotEnforcedSchema.optional()
21393
21417
  })
21394
21418
  ]);
21395
21419
  Object.freeze({
@@ -24620,8 +24644,10 @@ var RunnerCameraConfigSchema = object({
24620
24644
  * - `analyzer`: ML/frame-diff motion detection (motion-wasm or other
24621
24645
  * analyzer providers) running on decoded frames in this runner.
24622
24646
  * - `onboard`: camera-native motion pushes (Reolink Baichuan, ONVIF
24623
- * analytics). The provider emits ProviderMotion
24624
- * events; the orchestrator forwards to `reportMotion`.
24647
+ * analytics). The provider emits its raw push as `ProviderMotion`
24648
+ * (D673); the orchestrator's camera-sensors bridge re-emits the camera's
24649
+ * effective motion as `MotionOnMotionChanged`, which is what reaches
24650
+ * `reportMotion`.
24625
24651
  */
24626
24652
  motionSources: MotionSourcesSchema.default(["analyzer"]),
24627
24653
  /**
@@ -24798,7 +24824,15 @@ var RunnerLocalLoadSchema = object({
24798
24824
  hasGpu: boolean(),
24799
24825
  inferenceBackend: string().optional(),
24800
24826
  cpuCores: number().optional()
24801
- })
24827
+ }),
24828
+ /**
24829
+ * Who writes a camera's `motion` runtime slice (D696). `'orchestrator'`: this
24830
+ * runner never writes it. ABSENT = a runner older than D696, which still
24831
+ * writes the slice from its phase machine; the orchestrator does not write
24832
+ * while any runner node is absent-or-unanswered, so one slice never has two
24833
+ * writers.
24834
+ */
24835
+ motionSliceWriter: literal("orchestrator").optional()
24802
24836
  });
24803
24837
  /**
24804
24838
  * Aggregate runtime metrics for the runner's whole local pool. Mirrors the
@@ -30841,6 +30875,70 @@ onStatusChanged: { data: object({
30841
30875
  * whether persisting is worth a SQLite commit. */
30842
30876
  volatileStateFields: ["lastChangedAt"]
30843
30877
  };
30878
+ var DoorbellStatusSchema = object({
30879
+ /** Ms epoch of the last press. null = never observed since this provider started. */
30880
+ lastPressedAt: number().nullable(),
30881
+ /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
30882
+ pressCountSinceStart: number()
30883
+ });
30884
+ var DoorbellPressEventSchema = object({
30885
+ deviceId: number(),
30886
+ timestamp: number()
30887
+ });
30888
+ /**
30889
+ * Doorbell button cap. Two kinds of provider serve it, and to every consumer
30890
+ * they are the same cap:
30891
+ *
30892
+ * - **Native** providers, registered per device by a driver addon through
30893
+ * `ctx.registerNativeCap` — a `DeviceType.Button` accessory with
30894
+ * `role: DeviceRole.Doorbell`, or the camera itself (Reolink registers at
30895
+ * camera level). They emit `onPressed` on every firmware ring.
30896
+ * - **A composed doorbell** (D670, D671): a camera's customization gives it
30897
+ * the cap, its `lastPressedAt` rising from the sources the operator
30898
+ * assigned in Customize → Doorbell, and the composer emits `onPressed`
30899
+ * from that field's advance (`fromState`).
30900
+ *
30901
+ * The DeviceEventPropagator re-emits `onPressed` on the camera parent.
30902
+ */
30903
+ var doorbellCapability = {
30904
+ name: "doorbell",
30905
+ scope: "device",
30906
+ deviceNative: true,
30907
+ mode: "singleton",
30908
+ deviceTypes: [DeviceType.Button, DeviceType.Camera],
30909
+ methods: {},
30910
+ events: {
30911
+ /**
30912
+ * Fires once per physical press. Reolink delivers via Baichuan
30913
+ * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
30914
+ * release/duration — it's a pulse.
30915
+ */
30916
+ onPressed: {
30917
+ data: DoorbellPressEventSchema,
30918
+ fromState: {
30919
+ field: "lastPressedAt",
30920
+ on: "advance"
30921
+ }
30922
+ } },
30923
+ status: {
30924
+ schema: DoorbellStatusSchema,
30925
+ kind: "push"
30926
+ },
30927
+ /**
30928
+ * Runtime-state slice — last press timestamp + lifetime press count.
30929
+ * Mirrored by the kernel and readable via
30930
+ * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
30931
+ * without subscribing.
30932
+ */
30933
+ runtimeState: DoorbellStatusSchema,
30934
+ /**
30935
+ * 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.
30936
+ *
30937
+ * See `RuntimeStateDurability`. Enforced by
30938
+ * `scripts/check-runtime-state-durability.ts`.
30939
+ */
30940
+ durability: "restored"
30941
+ };
30844
30942
  /**
30845
30943
  * Enum-state sensor — a string value picked from a finite option set.
30846
30944
  * Drives HA `sensor` entries with `state_class: enum` (HVAC action
@@ -32980,39 +33078,14 @@ authKey: string().optional() }), object({
32980
33078
  /** Human-readable error when `ok: false`. */
32981
33079
  error: string().optional()
32982
33080
  }), { kind: "mutation" });
32983
- /**
32984
- * Hardware / firmware motion sensor cap — binary detected state plus
32985
- * a timestamp of the last observation. Distinct from
32986
- * `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
32987
- * `motion` is the lightweight readout from on-camera motion (Reolink
32988
- * `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
32989
- *
32990
- * Native-motion providers also fan out to `detection.camera-native`
32991
- * with `source: 'onboard'` so cross-cutting system services
32992
- * (alert-center, advanced-notifier) can subscribe once and receive
32993
- * motion from every camera.
32994
- */
32995
- /**
32996
- * How long after a camera's last rising edge `pipeline-analytics` closes the
32997
- * motion EPISODE row it kept open for it (D475) — "il delay della cap", in
32998
- * the operator's words. One authority for the whole system: every provider
32999
- * that seeds `autoClearAfterMs` on a `Camera` device writes this SAME
33000
- * constant while `detected: true` (never its own number — Hikvision used to
33001
- * seed its internal 3 s inactivity timer here, which is a different clock for
33002
- * a different purpose), and `MotionEpisodeTracker` imports it directly rather
33003
- * than reading the live cap value on the hot path. A `Sensor` device (HA
33004
- * binary sensor, Homematic) gets a genuine push both ways and has no episode
33005
- * to close on a timer, so it writes `null`, never this constant.
33006
- */
33007
- var MOTION_CLOSE_AFTER_MS = 15e3;
33008
33081
  var MotionStatusSchema = object({
33009
33082
  detected: boolean(),
33010
33083
  /** Ms epoch of the last detected-true observation. Null if never detected. */
33011
33084
  lastDetectedAt: number().nullable(),
33012
33085
  /**
33013
- * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
33014
- * `null` while false and on every `Sensor` device (D475) — see that
33015
- * constant's doc for the one-authority rule.
33086
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device (the
33087
+ * orchestrator writes it, D696), `null` while false and on every `Sensor`
33088
+ * device (D475) — see that constant's doc for the one-authority rule.
33016
33089
  *
33017
33090
  * ## Reading this field still arms nothing
33018
33091
  *
@@ -33030,34 +33103,31 @@ var MotionStatusSchema = object({
33030
33103
  * `addon-export-alexa/src/motion-clear-hold.ts` and
33031
33104
  * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
33032
33105
  *
33033
- * ## Who writes it
33034
- *
33035
- * - **Cameras** — the runner's phase machine, `active → watching` on
33036
- * `cooldown_expired`, which then writes this slice with
33037
- * `detected: false` (`handlePhaseChanged` in
33038
- * `pipeline-runner/index.ts`). It produces the FALLING edge, which
33039
- * matters most for the sources that only ever push a rising one:
33040
- * Reolink emits `MotionOnMotionChanged { detected: true }` and never
33041
- * a false.
33042
- * - **Sensors** (Home Assistant binary sensors, Homematic) — the
33043
- * provider pushes the false itself, from the upstream system's own
33044
- * state change. No phase machine is involved.
33045
- *
33046
- * ### The phase machine is CANONICAL, not sole — and that is a defect
33047
- *
33048
- * An earlier revision of this docblock (mine, 2026-09-12) claimed the
33049
- * phase machine is the sole writer for a camera. It is not.
33050
- * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
33051
- * `setCapSlice(motionCapability, …)` on their own rising edge, and
33052
- * Hikvision's comment says why: it read THIS docblock, agreed the
33053
- * runner is canonical, and wrote anyway to avoid per-tick churn. So
33054
- * two authorities can disagree about one slice, which this repo
33055
- * forbids, and the doc said otherwise — which is worse than saying
33056
- * nothing, because it reads as verification.
33057
- *
33058
- * This predates D475 and is not fixed there: the fix touches every
33059
- * camera provider. Recorded in D475's Consequences. Do not restore the
33060
- * "sole writer" wording without also removing the other writers.
33106
+ * ## Who writes it (D696)
33107
+ *
33108
+ * - **Cameras** — the orchestrator, and nothing else. It writes the camera's
33109
+ * EFFECTIVE motion (`addon-pipeline-orchestrator`
33110
+ * `camera-sensors/motion-slice.ts`), alongside the effective
33111
+ * `MotionOnMotionChanged` it emits or receives: the camera-sensors bridge
33112
+ * for a split camera, an unsplit emitter's direct event, the analyzer and
33113
+ * device activity, as the camera's `motionSources` counts them. A source
33114
+ * that never sends a clear falls one window after its last `true`.
33115
+ * `lastDetectedAt` moves only on an effective rise. No camera provider
33116
+ * writes this slice (not even a boot seed), and neither does the runner's
33117
+ * phase machine: its phase is "a session is attached" for every on-motion
33118
+ * session, not motion, and it now has its own `DetectionPhaseTransition`.
33119
+ * A provider's `isDetected` answers from the hub's slice.
33120
+ * - **Sensors** (Home Assistant binary sensors, Homematic, Matter, Alexa
33121
+ * imports) — the provider pushes both edges itself, from the upstream
33122
+ * system's own state change. That is the sensor's own fact.
33123
+ *
33124
+ * `scripts/check-onboard-motion-emitters.ts` refuses any other writer of a
33125
+ * `motion` slice; each sensor writer is a named exemption.
33126
+ *
33127
+ * This replaces the D475 §4 rule ("the phase machine is the sole writer").
33128
+ * That rule was never true: Hikvision and Amcrest wrote the slice raw beside
33129
+ * it, every provider seeded it at boot, and every session left it
33130
+ * `detected: true` after its detach.
33061
33131
  */
33062
33132
  autoClearAfterMs: number().nullable()
33063
33133
  });
@@ -33129,11 +33199,12 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
33129
33199
  */
33130
33200
  runtimeState: MotionStatusSchema,
33131
33201
  /**
33132
- * Runtime-state durability: **session** — every writer of this slice
33202
+ * Runtime-state durability: **session** — the writer of this slice
33133
33203
  * writes only on an EDGE, so a restored `detected: true` would stay
33134
33204
  * frozen until the next one instead of being corrected. The next edge
33135
- * re-publishes the real state. (On who the writers are, and why there
33136
- * is more than one, see `autoClearAfterMs` above.)
33205
+ * re-publishes the real state, and the orchestrator re-publishes every
33206
+ * camera when it starts writing (D696; on who writes it, see
33207
+ * `autoClearAfterMs` above).
33137
33208
  *
33138
33209
  * See `RuntimeStateDurability`. Enforced by
33139
33210
  * `scripts/check-runtime-state-durability.ts`.
@@ -35674,8 +35745,7 @@ var ptzAutotrackCapability = {
35674
35745
  deviceNative: true,
35675
35746
  mode: "singleton",
35676
35747
  /**
35677
- * Two kinds of provider behind one name, the same shape `snapshot` and
35678
- * `doorbell` use:
35748
+ * Two kinds of provider behind one name, the same shape `snapshot` uses:
35679
35749
  *
35680
35750
  * - **Native**: the camera's own firmware autotrack, registered per device by
35681
35751
  * the driver when the probe says it exists (Reolink: yes; Hikvision:
@@ -35683,7 +35753,7 @@ var ptzAutotrackCapability = {
35683
35753
  * - **Wrapper**: the emulated implementation (`@camstack/system`'s `autotrack` builtin),
35684
35754
  * which follows a subject with `ptz.move` pulses driven by the detection
35685
35755
  * pipeline. `defaultActive: false` — the operator binds it per camera in
35686
- * the bindings UI, exactly as `virtual-doorbell` is bound.
35756
+ * the bindings UI.
35687
35757
  *
35688
35758
  * The binding chooses WHICH implementation answers; `setEnabled` stays the
35689
35759
  * one switch for the function either way. A camera never has both driving its
@@ -41199,13 +41269,14 @@ var BaseDeviceProvider = class extends BaseAddon {
41199
41269
  async getStatus() {
41200
41270
  const all = await this.ctx.kernel.devices?.getAll() ?? [];
41201
41271
  const summary = this.restoreFailureSummary();
41202
- if (summary === null) return {
41272
+ const base = {
41203
41273
  connected: true,
41204
- deviceCount: all.length
41274
+ deviceCount: all.length,
41275
+ motionSliceWriter: "orchestrator"
41205
41276
  };
41277
+ if (summary === null) return base;
41206
41278
  return {
41207
- connected: true,
41208
- deviceCount: all.length,
41279
+ ...base,
41209
41280
  error: summary
41210
41281
  };
41211
41282
  }
@@ -46859,6 +46930,12 @@ Object.freeze({
46859
46930
  addonId: null,
46860
46931
  access: "view"
46861
46932
  },
46933
+ "notificationRules.getAlarmSensors": {
46934
+ capName: "notification-rules",
46935
+ capScope: "system",
46936
+ addonId: null,
46937
+ access: "view"
46938
+ },
46862
46939
  "notificationRules.getClipRetentionAsks": {
46863
46940
  capName: "notification-rules",
46864
46941
  capScope: "system",
@@ -51342,6 +51419,11 @@ Object.freeze({
51342
51419
  form: "single",
51343
51420
  optional: false
51344
51421
  }],
51422
+ "notificationRules.getAlarmSensors": [{
51423
+ name: "deviceIds",
51424
+ form: "array",
51425
+ optional: false
51426
+ }],
51345
51427
  "notificationRules.setDeviceMuted": [{
51346
51428
  name: "deviceId",
51347
51429
  form: "single",
@@ -53277,6 +53359,25 @@ TimelapseRuleInputSchema.extend({
53277
53359
  createdAt: number(),
53278
53360
  updatedAt: number()
53279
53361
  });
53362
+ async function readHubMotionDetected(deviceState, deviceId) {
53363
+ let slice;
53364
+ try {
53365
+ slice = await deviceState.getCapSlice.query({
53366
+ deviceId,
53367
+ capName: "motion"
53368
+ });
53369
+ } catch (err) {
53370
+ const reason = err instanceof Error ? err.message : String(err);
53371
+ throw new Error(`motion state of device ${deviceId} is unreadable: ${reason}`, { cause: err });
53372
+ }
53373
+ const detected = slice?.["detected"];
53374
+ if (typeof detected !== "boolean") throw new Error(`motion state of device ${deviceId} is not published yet (unknown)`);
53375
+ return detected;
53376
+ }
53377
+ MotionOnMotionChangedDataSchema.omit({ triggeredBy: true });
53378
+ function providerMotionEvent(source, data) {
53379
+ return createEvent(EventCategory.ProviderMotion, source, data);
53380
+ }
53280
53381
  object({
53281
53382
  /**
53282
53383
  * Fraction of the box's own size added on EACH side before cutting.
@@ -63089,15 +63190,7 @@ var HikvisionCamera = class HikvisionCamera extends BaseDevice {
63089
63190
  host
63090
63191
  };
63091
63192
  } });
63092
- this.ctx.registerNativeCap(motionCapability, { isDetected: async ({ deviceId }) => {
63093
- if (deviceId !== this.id) throw new Error(`HikvisionCamera: deviceId mismatch, expected ${this.id}, got ${deviceId}`);
63094
- return this.state.motion?.detected ?? false;
63095
- } });
63096
- this.setCapSlice(motionCapability, {
63097
- detected: false,
63098
- lastDetectedAt: null,
63099
- autoClearAfterMs: null
63100
- });
63193
+ this.registerMotionCap();
63101
63194
  this.registerIntercomIfSupported();
63102
63195
  this.registerOsdCap(1);
63103
63196
  this.registerStreamParamsCap(1);
@@ -65566,43 +65659,41 @@ var HikvisionCamera = class HikvisionCamera extends BaseDevice {
65566
65659
  deviceId: this.id
65567
65660
  };
65568
65661
  }
65662
+ /**
65663
+ * The native `motion` cap. Its presence is what defaults the camera to
65664
+ * `motionSources: ['onboard']`. This provider writes NO `motion` slice (D696):
65665
+ * the orchestrator is its only writer, with the EFFECTIVE motion, on the hub.
65666
+ * `isDetected` therefore answers from the hub's slice; an unreadable hub, or
65667
+ * a slice nobody has published since the hub started, makes the call fail.
65668
+ * It never answers `false` for "unknown" (D49, D393).
65669
+ */
65670
+ registerMotionCap() {
65671
+ this.ctx.registerNativeCap(motionCapability, { isDetected: async ({ deviceId }) => {
65672
+ if (deviceId !== this.id) throw new Error(`HikvisionCamera: deviceId mismatch, expected ${this.id}, got ${deviceId}`);
65673
+ return readHubMotionDetected(this.ctx.api.deviceState, this.id);
65674
+ } });
65675
+ }
65569
65676
  handleMotionEvent(ev, camStreamId) {
65570
65677
  const now = ev.observedAt;
65571
- const wasInactive = (this.lastMotionAt.get(camStreamId) ?? 0) === 0;
65572
65678
  this.lastMotionAt.set(camStreamId, now);
65573
- this.ctx.eventBus.emit(createEvent(EventCategory.MotionOnMotionChanged, this.eventSource, {
65679
+ this.ctx.eventBus.emit(providerMotionEvent(this.eventSource, {
65574
65680
  deviceId: this.id,
65575
65681
  detected: true,
65576
65682
  timestamp: now,
65577
65683
  source: "onboard"
65578
65684
  }));
65579
- if (wasInactive) try {
65580
- this.setCapSlice(motionCapability, {
65581
- detected: true,
65582
- lastDetectedAt: now,
65583
- autoClearAfterMs: MOTION_CLOSE_AFTER_MS
65584
- });
65585
- } catch {}
65586
65685
  const existing = this.motionInactiveTimers.get(camStreamId);
65587
65686
  if (existing) clearTimeout(existing);
65588
65687
  const timer = setTimeout(() => {
65589
65688
  const clearedAt = Date.now();
65590
65689
  this.lastMotionAt.set(camStreamId, 0);
65591
65690
  this.motionInactiveTimers.delete(camStreamId);
65592
- this.ctx.eventBus.emit(createEvent(EventCategory.MotionOnMotionChanged, this.eventSource, {
65691
+ this.ctx.eventBus.emit(providerMotionEvent(this.eventSource, {
65593
65692
  deviceId: this.id,
65594
65693
  detected: false,
65595
65694
  timestamp: clearedAt,
65596
65695
  source: "onboard"
65597
65696
  }));
65598
- try {
65599
- const lastDetectedAt = this.state.motion?.lastDetectedAt ?? clearedAt;
65600
- this.setCapSlice(motionCapability, {
65601
- detected: false,
65602
- lastDetectedAt,
65603
- autoClearAfterMs: null
65604
- });
65605
- } catch {}
65606
65697
  }, HikvisionCamera.MOTION_INACTIVE_AFTER_MS);
65607
65698
  this.motionInactiveTimers.set(camStreamId, timer);
65608
65699
  }