@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.
- package/dist/addon.js +338 -247
- package/dist/addon.mjs +338 -247
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -33,7 +33,7 @@ let node_net = require("node:net");
|
|
|
33
33
|
let node_http = require("node:http");
|
|
34
34
|
let node_https = require("node:https");
|
|
35
35
|
let node_os = require("node:os");
|
|
36
|
-
//#region ../types/dist/event-category-
|
|
36
|
+
//#region ../types/dist/event-category-BGmz_oxW.mjs
|
|
37
37
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
38
38
|
EventCategory["SystemBoot"] = "system.boot";
|
|
39
39
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -566,6 +566,15 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
566
566
|
*/
|
|
567
567
|
EventCategory["PipelineAudioInferenceResult"] = "pipeline.audio-inference-result";
|
|
568
568
|
EventCategory["DetectionPhaseTransition"] = "detection.phase-transition";
|
|
569
|
+
/**
|
|
570
|
+
* A camera provider's RAW onboard motion push (D673): the `MotionOnMotionChanged`
|
|
571
|
+
* data shape without `triggeredBy`, built by `providerMotionEvent`. Its one
|
|
572
|
+
* consumer is the orchestrator's camera-sensors bridge, which re-emits the
|
|
573
|
+
* camera's EFFECTIVE onboard motion as `MotionOnMotionChanged` (a pass-through
|
|
574
|
+
* for a camera with no attached sensor). Providers must not emit
|
|
575
|
+
* `MotionOnMotionChanged` themselves; `scripts/check-onboard-motion-emitters.ts`
|
|
576
|
+
* keeps it so (camera-grid is a named, deferred exception).
|
|
577
|
+
*/
|
|
569
578
|
EventCategory["ProviderMotion"] = "provider.motion";
|
|
570
579
|
EventCategory["ProviderDetection"] = "provider.detection";
|
|
571
580
|
EventCategory["EnrichmentEmbeddingStored"] = "enrichment.embedding.stored";
|
|
@@ -5404,7 +5413,7 @@ var ZodIssueCode = {
|
|
|
5404
5413
|
var ZodFirstPartyTypeKind;
|
|
5405
5414
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5406
5415
|
//#endregion
|
|
5407
|
-
//#region ../types/dist/sleep-
|
|
5416
|
+
//#region ../types/dist/sleep-CDCONfkt.mjs
|
|
5408
5417
|
/**
|
|
5409
5418
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5410
5419
|
* window to float samples (D455).
|
|
@@ -7449,7 +7458,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
|
|
|
7449
7458
|
return DeviceRole;
|
|
7450
7459
|
}({});
|
|
7451
7460
|
//#endregion
|
|
7452
|
-
//#region ../types/dist/composition-
|
|
7461
|
+
//#region ../types/dist/composition-43aqsZQj.mjs
|
|
7453
7462
|
/**
|
|
7454
7463
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
7455
7464
|
*
|
|
@@ -7506,13 +7515,12 @@ portable("linux64"), portable("linuxarm64"), portable("macarm64"), portable("mac
|
|
|
7506
7515
|
* LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
|
|
7507
7516
|
* valutatore puro del suo FRONTE.
|
|
7508
7517
|
*
|
|
7509
|
-
*
|
|
7510
|
-
*
|
|
7511
|
-
*
|
|
7512
|
-
*
|
|
7513
|
-
*
|
|
7514
|
-
* fa suonare il campanello ma non registra" — è esattamente D62.
|
|
7515
|
-
* SPOSTA qui e il doorbell la ri-esporta.
|
|
7518
|
+
* UNA tabella per tutti quelli che chiedono "questo device è ALTO?": il
|
|
7519
|
+
* trigger `RecordingTriggers.sensorDeviceIds` del recorder, i marker dei
|
|
7520
|
+
* sensori della post-analysis, il bridge camera-sensors dell'orchestratore e
|
|
7521
|
+
* le sorgenti di un campanello composto (`doorbellFeatureSources`, D671).
|
|
7522
|
+
* Una seconda copia divergerebbe alla prima cap aggiunta, e il sintomo — "il
|
|
7523
|
+
* sensore fa suonare il campanello ma non registra" — è esattamente D62.
|
|
7516
7524
|
*
|
|
7517
7525
|
* ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
|
|
7518
7526
|
* due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
|
|
@@ -7538,8 +7546,6 @@ var SOURCE_CAP_ACTIVE_FIELD = {
|
|
|
7538
7546
|
vibration: "detected",
|
|
7539
7547
|
tamper: "tampered"
|
|
7540
7548
|
};
|
|
7541
|
-
/** Cap names whose presence in a device's bindings qualify it as a source. */
|
|
7542
|
-
var SOURCE_CAPS = Object.keys(SOURCE_CAP_ACTIVE_FIELD);
|
|
7543
7549
|
/**
|
|
7544
7550
|
* Error types for the safe expression engine. Two distinct classes so callers
|
|
7545
7551
|
* can tell a compile-time (grammar) failure from a runtime (evaluation)
|
|
@@ -9269,7 +9275,7 @@ var RecordingTriggersSchema = object({
|
|
|
9269
9275
|
*
|
|
9270
9276
|
* Cosa vuol dire "alto" dipende dal TIPO di device e non è deciso qui:
|
|
9271
9277
|
* `SOURCE_CAP_ACTIVE_FIELD` (`catalogs/sensor-active-state.ts`) è LA tabella,
|
|
9272
|
-
* la stessa
|
|
9278
|
+
* la stessa del campanello composto (D671). Ed è il FRONTE, non
|
|
9273
9279
|
* il livello: un contatto trovato già aperto al riavvio del runner non fa
|
|
9274
9280
|
* registrare.
|
|
9275
9281
|
*/
|
|
@@ -15160,7 +15166,17 @@ var SiteZoneSchema = object({
|
|
|
15160
15166
|
var ProviderStatusSchema = object({
|
|
15161
15167
|
connected: boolean(),
|
|
15162
15168
|
deviceCount: number(),
|
|
15163
|
-
error: string().optional()
|
|
15169
|
+
error: string().optional(),
|
|
15170
|
+
/**
|
|
15171
|
+
* `'orchestrator'`: this provider writes NO camera's `motion` runtime slice
|
|
15172
|
+
* — the orchestrator is its only writer (D696). Set by `BaseDeviceProvider`,
|
|
15173
|
+
* which every provider bundles, so only a provider BUILT from D696-amended
|
|
15174
|
+
* code says it. ABSENT means an older provider that may still write it (raw
|
|
15175
|
+
* VMD writes, a boot seed), and the orchestrator's provider gate keeps that
|
|
15176
|
+
* provider's cameras unwritten (`camera-sensors/motion-slice-provider-gate.ts`)
|
|
15177
|
+
* — the provider twin of the runner's `getLocalLoad().motionSliceWriter`.
|
|
15178
|
+
*/
|
|
15179
|
+
motionSliceWriter: literal("orchestrator").optional()
|
|
15164
15180
|
});
|
|
15165
15181
|
object({
|
|
15166
15182
|
externalId: string(),
|
|
@@ -16039,109 +16055,10 @@ method(object({
|
|
|
16039
16055
|
deviceIds: array(number()).readonly(),
|
|
16040
16056
|
caps: array(string()).readonly().optional()
|
|
16041
16057
|
}), record(string(), record(string(), unknown().nullable())));
|
|
16042
|
-
|
|
16043
|
-
|
|
16044
|
-
* name (same pattern as `snapshot`):
|
|
16045
|
-
*
|
|
16046
|
-
* - **Native** providers: registered per-device by device-driver
|
|
16047
|
-
* addons via `ctx.registerNativeCap` — either on a
|
|
16048
|
-
* `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
|
|
16049
|
-
* or directly on the camera (Reolink registers at camera level).
|
|
16050
|
-
* Emits an `onPressed` event every time the firmware pushes a
|
|
16051
|
-
* ring; status tracks the last press and a pressCount since start
|
|
16052
|
-
* (diagnostic).
|
|
16053
|
-
*
|
|
16054
|
-
* - **Wrapper** provider: the `virtual-doorbell` system builtin
|
|
16055
|
-
* (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
|
|
16056
|
-
* device (contact / switch / event-emitter …) into a doorbell for
|
|
16057
|
-
* a camera. `defaultActive: false` — the operator explicitly binds
|
|
16058
|
-
* it per camera in the device-bindings UI, then picks the source
|
|
16059
|
-
* device + trigger in the per-device settings.
|
|
16060
|
-
*
|
|
16061
|
-
* The DeviceEventPropagator re-emits `onPressed` on the camera parent
|
|
16062
|
-
* — subscribers listening at the camera level receive ring events
|
|
16063
|
-
* with `via[]` populated. No code on the parent needed.
|
|
16064
|
-
*/
|
|
16065
|
-
var DoorbellStatusSchema = object({
|
|
16066
|
-
/** Ms epoch of the last press. null = never observed since this provider started. */
|
|
16067
|
-
lastPressedAt: number().nullable(),
|
|
16068
|
-
/** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
|
|
16069
|
-
pressCountSinceStart: number()
|
|
16070
|
-
});
|
|
16071
|
-
var DoorbellPressEventSchema = object({
|
|
16072
|
-
deviceId: number(),
|
|
16073
|
-
timestamp: number()
|
|
16074
|
-
});
|
|
16075
|
-
/**
|
|
16076
|
-
* The `doorbell-source` extension slot's editable value (D648): the camera's
|
|
16077
|
-
* virtual-doorbell trigger devices, exactly what the wrapper's
|
|
16078
|
-
* `doorbellSources` persists (as `{ deviceId }` records).
|
|
16079
|
-
*/
|
|
16080
|
-
var DoorbellSourceSlotValueSchema = object({ deviceIds: array(number().int().positive()) });
|
|
16081
|
-
/**
|
|
16082
|
-
* The `doorbell-source` slot — which devices ring this camera's VIRTUAL
|
|
16083
|
-
* doorbell, owned by the `virtual-doorbell` wrapper over its
|
|
16084
|
-
* `doorbellSources` store (D648). A source rings when one of its
|
|
16085
|
-
* `SOURCE_CAPS` rises. Whether the wrapper is bound to the camera at all is a
|
|
16086
|
-
* different authority (`deviceManager.setWrapperActive`, D62) — the slot
|
|
16087
|
-
* reports it, it never writes it.
|
|
16088
|
-
*/
|
|
16089
|
-
var DOORBELL_SOURCE_SLOT = {
|
|
16090
|
-
id: "doorbell-source",
|
|
16091
|
-
label: "Doorbell trigger devices",
|
|
16092
|
-
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.",
|
|
16093
|
-
shape: "association",
|
|
16094
|
-
hostDeviceTypes: [DeviceType.Camera],
|
|
16095
|
-
sourceCaps: SOURCE_CAPS,
|
|
16096
|
-
cardinality: "many",
|
|
16097
|
-
value: DoorbellSourceSlotValueSchema
|
|
16098
|
-
};
|
|
16099
|
-
var doorbellCapability = {
|
|
16100
|
-
name: "doorbell",
|
|
16101
|
-
scope: "device",
|
|
16102
|
-
deviceNative: true,
|
|
16103
|
-
mode: "singleton",
|
|
16104
|
-
kind: "wrapper",
|
|
16105
|
-
defaultActive: false,
|
|
16106
|
-
deviceTypes: [DeviceType.Button, DeviceType.Camera],
|
|
16107
|
-
extensionSlots: [DOORBELL_SOURCE_SLOT],
|
|
16108
|
-
methods: {},
|
|
16109
|
-
events: {
|
|
16110
|
-
/**
|
|
16111
|
-
* Fires once per physical press. Reolink delivers via Baichuan
|
|
16112
|
-
* push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
|
|
16113
|
-
* release/duration — it's a pulse.
|
|
16114
|
-
*/
|
|
16115
|
-
onPressed: {
|
|
16116
|
-
data: DoorbellPressEventSchema,
|
|
16117
|
-
fromState: {
|
|
16118
|
-
field: "lastPressedAt",
|
|
16119
|
-
on: "advance"
|
|
16120
|
-
}
|
|
16121
|
-
} },
|
|
16122
|
-
status: {
|
|
16123
|
-
schema: DoorbellStatusSchema,
|
|
16124
|
-
kind: "push"
|
|
16125
|
-
},
|
|
16126
|
-
/**
|
|
16127
|
-
* Runtime-state slice — last press timestamp + lifetime press count.
|
|
16128
|
-
* Mirrored by the kernel and readable via
|
|
16129
|
-
* `device.state.doorbell.value`. UIs can show "last ring 5m ago"
|
|
16130
|
-
* without subscribing.
|
|
16131
|
-
*/
|
|
16132
|
-
runtimeState: DoorbellStatusSchema,
|
|
16133
|
-
/**
|
|
16134
|
-
* 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.
|
|
16135
|
-
*
|
|
16136
|
-
* See `RuntimeStateDurability`. Enforced by
|
|
16137
|
-
* `scripts/check-runtime-state-durability.ts`.
|
|
16138
|
-
*/
|
|
16139
|
-
durability: "restored"
|
|
16140
|
-
};
|
|
16141
|
-
var ExtensionSlotIdSchema = _enum(["doorbell-source", "linked-devices"]);
|
|
16142
|
-
DeviceType.Camera, DeviceType.Camera;
|
|
16058
|
+
var ExtensionSlotIdSchema = _enum(["linked-devices"]);
|
|
16059
|
+
DeviceType.Camera;
|
|
16143
16060
|
/** A slot's editable value, discriminated on `slot`. */
|
|
16144
|
-
var ExtensionSlotValueSchema = discriminatedUnion("slot", [
|
|
16061
|
+
var ExtensionSlotValueSchema = discriminatedUnion("slot", [LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
|
|
16145
16062
|
DeviceType.Camera;
|
|
16146
16063
|
var ExtensionSourceAvailabilitySchema = discriminatedUnion("state", [object({ state: literal("ok") }), object({
|
|
16147
16064
|
state: literal("unreachable"),
|
|
@@ -16178,10 +16095,11 @@ var ExtensionSlotSourceSchema = object({
|
|
|
16178
16095
|
});
|
|
16179
16096
|
/**
|
|
16180
16097
|
* A DIFFERENT authority that gates whether the slot's sources do anything —
|
|
16181
|
-
* reported read-only, named, never written through this contract (D62).
|
|
16182
|
-
*
|
|
16183
|
-
*
|
|
16184
|
-
* `unknown` means the gate could
|
|
16098
|
+
* reported read-only, named, never written through this contract (D62) — e.g.
|
|
16099
|
+
* a slot whose sources act only while a wrapper is bound to the host, a
|
|
16100
|
+
* binding that belongs to `deviceManager.setWrapperActive`. No slot reports
|
|
16101
|
+
* one today (`linked-devices` answers `null`). `unknown` means the gate could
|
|
16102
|
+
* not be read; it is not "inactive" (D315).
|
|
16185
16103
|
*/
|
|
16186
16104
|
var ExtensionSlotActivationSchema = object({
|
|
16187
16105
|
state: _enum([
|
|
@@ -16197,7 +16115,7 @@ var ExtensionSlotRowSchema = discriminatedUnion("state", [object({
|
|
|
16197
16115
|
/** `<source>:<slotId>` — the routing key for `listCandidates` / `setSlot`. */
|
|
16198
16116
|
slotRef: string(),
|
|
16199
16117
|
slot: ExtensionSlotIdSchema,
|
|
16200
|
-
/** Names the store written (D62), e.g. `
|
|
16118
|
+
/** Names the store written (D62), e.g. `device-manager:_linkedDeviceIds`. */
|
|
16201
16119
|
authority: string(),
|
|
16202
16120
|
activation: ExtensionSlotActivationSchema.nullable(),
|
|
16203
16121
|
value: ExtensionSlotValueSchema,
|
|
@@ -20739,6 +20657,29 @@ object({
|
|
|
20739
20657
|
firstAt: number(),
|
|
20740
20658
|
lastAt: number()
|
|
20741
20659
|
});
|
|
20660
|
+
var NC_ALARM_TRIGGERED_MAX_SEC = 3600;
|
|
20661
|
+
var NcAlarmDelaySecSchema = number().int().min(0).max(600);
|
|
20662
|
+
var NcAlarmTriggeredSecSchema = number().int().min(0).max(NC_ALARM_TRIGGERED_MAX_SEC);
|
|
20663
|
+
var uniqueModes = (entries) => new Set(entries.map((e) => e.mode)).size === entries.length;
|
|
20664
|
+
var NcAlarmModeDelaysListSchema = array(object({
|
|
20665
|
+
mode: AlarmArmModeSchema,
|
|
20666
|
+
exitDelaySec: NcAlarmDelaySecSchema.optional(),
|
|
20667
|
+
entryDelaySec: NcAlarmDelaySecSchema.optional(),
|
|
20668
|
+
triggeredDurationSec: NcAlarmTriggeredSecSchema.optional()
|
|
20669
|
+
})).max(8).refine(uniqueModes, { message: "modeDelays: at most one entry per arm mode" });
|
|
20670
|
+
var NcAlarmModeDelaysEditListSchema = array(object({
|
|
20671
|
+
mode: AlarmArmModeSchema,
|
|
20672
|
+
exitDelaySec: NcAlarmDelaySecSchema.nullable().optional(),
|
|
20673
|
+
entryDelaySec: NcAlarmDelaySecSchema.nullable().optional(),
|
|
20674
|
+
triggeredDurationSec: NcAlarmTriggeredSecSchema.nullable().optional()
|
|
20675
|
+
})).max(8).refine(uniqueModes, { message: "modeDelays: at most one edit per arm mode" });
|
|
20676
|
+
/** One switch of the alarm table: put ONE device on, or take it off, ONE mode's list. */
|
|
20677
|
+
var NcAlarmNonBlockingEditSchema = object({
|
|
20678
|
+
mode: AlarmArmModeSchema,
|
|
20679
|
+
deviceId: number().int().positive(),
|
|
20680
|
+
/** true = on the list (may be open, does not block); false = off the list (blocks). */
|
|
20681
|
+
nonBlocking: boolean()
|
|
20682
|
+
});
|
|
20742
20683
|
/**
|
|
20743
20684
|
* The per-mode lists, at most one per mode. Two lists for one mode have no
|
|
20744
20685
|
* meaning a reader could agree on (union? the last one?), so they are refused
|
|
@@ -20747,10 +20688,10 @@ object({
|
|
|
20747
20688
|
var NcAlarmNonBlockingListSchema = array(object({
|
|
20748
20689
|
mode: AlarmArmModeSchema,
|
|
20749
20690
|
deviceIds: array(number().int()).max(200)
|
|
20750
|
-
})).max(8).refine(
|
|
20691
|
+
})).max(8).refine(uniqueModes, { message: "nonBlocking: at most one list per arm mode" });
|
|
20751
20692
|
/**
|
|
20752
|
-
* The three durations
|
|
20753
|
-
* transitions, and which openings each mode tolerates.
|
|
20693
|
+
* The three durations — global, and per mode since D697 — the panel's state
|
|
20694
|
+
* machine runs on, who hears about its transitions, and which openings each mode tolerates.
|
|
20754
20695
|
*
|
|
20755
20696
|
* They live on the NOTIFICATION-RULES cap, not on `alarm-panel`, on purpose:
|
|
20756
20697
|
* `alarm-panel` is `deviceNative` and its other provider mirrors somebody
|
|
@@ -20760,15 +20701,15 @@ var NcAlarmNonBlockingListSchema = array(object({
|
|
|
20760
20701
|
*/
|
|
20761
20702
|
var NcAlarmSettingsSchema = object({
|
|
20762
20703
|
/** Grace period between arming and the mode taking effect. 0 = immediate. */
|
|
20763
|
-
exitDelaySec:
|
|
20704
|
+
exitDelaySec: NcAlarmDelaySecSchema,
|
|
20764
20705
|
/** Grace period between a trigger and the alarm firing. 0 = immediate. */
|
|
20765
|
-
entryDelaySec:
|
|
20706
|
+
entryDelaySec: NcAlarmDelaySecSchema,
|
|
20766
20707
|
/**
|
|
20767
20708
|
* How long `triggered` lasts before the panel re-arms itself.
|
|
20768
20709
|
* **0 = until an operator disarms it** — the behaviour before this field
|
|
20769
20710
|
* existed, and therefore what an untouched install keeps doing.
|
|
20770
20711
|
*/
|
|
20771
|
-
triggeredDurationSec:
|
|
20712
|
+
triggeredDurationSec: NcAlarmTriggeredSecSchema,
|
|
20772
20713
|
/**
|
|
20773
20714
|
* Deprecated by D630 — every transition is announced. Parsed, never read;
|
|
20774
20715
|
* remove after one release. Optional so an older admin's patch (which still
|
|
@@ -20791,17 +20732,30 @@ var NcAlarmSettingsSchema = object({
|
|
|
20791
20732
|
* per mode is meaningful. Defaulted to `[]` so a blob stored before D630
|
|
20792
20733
|
* parses as "every opening blocks" — the behaviour it was written under.
|
|
20793
20734
|
*/
|
|
20794
|
-
nonBlocking: NcAlarmNonBlockingListSchema.default([])
|
|
20735
|
+
nonBlocking: NcAlarmNonBlockingListSchema.default([]),
|
|
20736
|
+
/**
|
|
20737
|
+
* Per arm mode, the delays that mode OVERRIDES (D697). A mode with no entry, or an entry
|
|
20738
|
+
* without a field, uses the global value above — so `[]`, the default, is exactly the
|
|
20739
|
+
* behaviour of a blob stored before this field existed. Read through `resolveModeDelays`.
|
|
20740
|
+
*/
|
|
20741
|
+
modeDelays: NcAlarmModeDelaysListSchema.default([])
|
|
20795
20742
|
});
|
|
20796
20743
|
/**
|
|
20797
20744
|
* Every field optional — a tab edits one control at a time.
|
|
20798
20745
|
*
|
|
20799
|
-
* `nonBlocking`
|
|
20800
|
-
* remove an inner `.default()`, so a patch that never
|
|
20801
|
-
* parse to `
|
|
20802
|
-
* (the same trap {@link NcRulePatchSchema} documents).
|
|
20746
|
+
* `nonBlocking` and `modeDelays` are re-declared WITHOUT their defaults:
|
|
20747
|
+
* `.partial()` does not remove an inner `.default()`, so a patch that never
|
|
20748
|
+
* named the field would parse to `[]` and wipe every mode's list on an
|
|
20749
|
+
* unrelated edit (the same trap {@link NcRulePatchSchema} documents). Here
|
|
20750
|
+
* `modeDelays` means EDITS, not the stored overrides.
|
|
20803
20751
|
*/
|
|
20804
|
-
var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.extend({
|
|
20752
|
+
var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.extend({
|
|
20753
|
+
nonBlocking: NcAlarmNonBlockingListSchema,
|
|
20754
|
+
/** Per-mode, per-field edits — NOT the whole list (see NcAlarmModeDelaysEditSchema). */
|
|
20755
|
+
modeDelays: NcAlarmModeDelaysEditListSchema,
|
|
20756
|
+
/** ONE membership change; the panel applies it to the list it holds at its turn. */
|
|
20757
|
+
nonBlockingEdit: NcAlarmNonBlockingEditSchema
|
|
20758
|
+
}).partial().refine((p) => p.nonBlocking === void 0 || p.nonBlockingEdit === void 0, { message: "nonBlocking and nonBlockingEdit are exclusive — send the whole lists or one edit" });
|
|
20805
20759
|
/**
|
|
20806
20760
|
* What one arm mode actually arms, DERIVED from the enabled rules gated on it.
|
|
20807
20761
|
* Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
|
|
@@ -20901,6 +20855,28 @@ var NcAlarmConfigSchema = object({
|
|
|
20901
20855
|
*/
|
|
20902
20856
|
live: NcAlarmLiveSchema.optional()
|
|
20903
20857
|
});
|
|
20858
|
+
var NcAlarmSensorReadingSchema = _enum([
|
|
20859
|
+
"open",
|
|
20860
|
+
"closed",
|
|
20861
|
+
"unknown",
|
|
20862
|
+
"not-opening"
|
|
20863
|
+
]);
|
|
20864
|
+
/** One device's state as the alarm reads it — the classifier the arm check uses. */
|
|
20865
|
+
var NcAlarmSensorStateSchema = object({
|
|
20866
|
+
deviceId: number().int().positive(),
|
|
20867
|
+
reading: NcAlarmSensorReadingSchema,
|
|
20868
|
+
/** The word as read (`open`, `closed`, `unlocked`, `stopped`, …); null when unknown / not an opening. */
|
|
20869
|
+
state: string().nullable(),
|
|
20870
|
+
/** Why `unknown`: the read failed, or the slice holds no word its cap defines (a placeholder included). */
|
|
20871
|
+
unknownWhy: _enum(["read-failed", "unknown-word"]).nullable(),
|
|
20872
|
+
/** The device manager's liveness as the centre mirrors it; null = not known. */
|
|
20873
|
+
online: boolean().nullable()
|
|
20874
|
+
});
|
|
20875
|
+
var NcAlarmSensorsInputSchema = object({ deviceIds: array(number().int().positive()).max(500) });
|
|
20876
|
+
var NcAlarmSensorsSchema = object({
|
|
20877
|
+
sensors: array(NcAlarmSensorStateSchema),
|
|
20878
|
+
readAt: number().int().nonnegative()
|
|
20879
|
+
});
|
|
20904
20880
|
/**
|
|
20905
20881
|
* ONE rule's demand on ONE camera's clip ring.
|
|
20906
20882
|
*
|
|
@@ -20991,7 +20967,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
|
|
|
20991
20967
|
}), method(object({}), NcAlarmConfigSchema, { auth: "admin" }), method(object({ patch: NcAlarmSettingsPatchSchema }), NcAlarmConfigSchema, {
|
|
20992
20968
|
kind: "mutation",
|
|
20993
20969
|
auth: "admin"
|
|
20994
|
-
});
|
|
20970
|
+
}), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
|
|
20995
20971
|
/**
|
|
20996
20972
|
* Zod schemas for persisted record types.
|
|
20997
20973
|
*
|
|
@@ -21338,12 +21314,26 @@ var CameraSensorRefSchema = object({
|
|
|
21338
21314
|
function cameraSensorRefKey(ref) {
|
|
21339
21315
|
return `${ref.addonId}/${ref.stableId}`;
|
|
21340
21316
|
}
|
|
21341
|
-
/**
|
|
21342
|
-
|
|
21343
|
-
|
|
21344
|
-
|
|
21345
|
-
|
|
21346
|
-
|
|
21317
|
+
/**
|
|
21318
|
+
* A sensor's mode (D673). `in-addition`: its motion is the camera's motion too.
|
|
21319
|
+
* `replace`: its motion is the camera's, and while one is READY the camera's
|
|
21320
|
+
* own motion no longer counts on its own. `confirm`: while one is READY the
|
|
21321
|
+
* camera's own motion counts only while a confirm sensor is active — with or
|
|
21322
|
+
* without a replace sensor (spec C2, the controller's ruling on Q1).
|
|
21323
|
+
*/
|
|
21324
|
+
var CameraSensorModeSchema = _enum([
|
|
21325
|
+
"in-addition",
|
|
21326
|
+
"confirm",
|
|
21327
|
+
"replace"
|
|
21328
|
+
]);
|
|
21329
|
+
/** A stored sensor with no mode — every CS-1 row — is in addition. */
|
|
21330
|
+
var DEFAULT_CAMERA_SENSOR_MODE = "in-addition";
|
|
21331
|
+
/**
|
|
21332
|
+
* A camera's attached sensors. A CS-1 row carried an envelope
|
|
21333
|
+
* `mode: 'in-addition'`: `z.object` drops it on parse, and the PARSED value is
|
|
21334
|
+
* what the write stores (D672 rule 3), so it is never written again.
|
|
21335
|
+
*/
|
|
21336
|
+
var CameraSensorsConfigSchema = object({ sensors: array(CameraSensorRefSchema.extend({ mode: CameraSensorModeSchema.default(DEFAULT_CAMERA_SENSOR_MODE) })).min(1).max(8) }).superRefine((value, ctx) => {
|
|
21347
21337
|
const seen = /* @__PURE__ */ new Set();
|
|
21348
21338
|
value.sensors.forEach((ref, index) => {
|
|
21349
21339
|
const key = cameraSensorRefKey(ref);
|
|
@@ -21355,39 +21345,41 @@ var CameraSensorsConfigSchema = object({
|
|
|
21355
21345
|
seen.add(key);
|
|
21356
21346
|
});
|
|
21357
21347
|
});
|
|
21358
|
-
|
|
21348
|
+
/** Every attachment names its mode; an older orchestrator that does not is in addition. */
|
|
21349
|
+
var AttachmentFields = {
|
|
21359
21350
|
addonId: string(),
|
|
21360
|
-
stableId: string()
|
|
21351
|
+
stableId: string(),
|
|
21352
|
+
mode: CameraSensorModeSchema.default(DEFAULT_CAMERA_SENSOR_MODE)
|
|
21361
21353
|
};
|
|
21362
21354
|
var CameraSensorAttachmentSchema = discriminatedUnion("state", [
|
|
21363
21355
|
object({
|
|
21364
|
-
...
|
|
21356
|
+
...AttachmentFields,
|
|
21365
21357
|
state: literal("ready"),
|
|
21366
21358
|
deviceId: number(),
|
|
21367
21359
|
name: string(),
|
|
21368
21360
|
caps: array(string()).readonly()
|
|
21369
21361
|
}),
|
|
21370
21362
|
object({
|
|
21371
|
-
...
|
|
21363
|
+
...AttachmentFields,
|
|
21372
21364
|
state: literal("offline"),
|
|
21373
21365
|
deviceId: number(),
|
|
21374
21366
|
name: string(),
|
|
21375
21367
|
reason: _enum(["offline", "disabled"])
|
|
21376
21368
|
}),
|
|
21377
21369
|
object({
|
|
21378
|
-
...
|
|
21370
|
+
...AttachmentFields,
|
|
21379
21371
|
state: literal("missing"),
|
|
21380
21372
|
reason: string()
|
|
21381
21373
|
}),
|
|
21382
21374
|
object({
|
|
21383
|
-
...
|
|
21375
|
+
...AttachmentFields,
|
|
21384
21376
|
state: literal("unsupported"),
|
|
21385
21377
|
deviceId: number(),
|
|
21386
21378
|
name: string(),
|
|
21387
21379
|
reason: string()
|
|
21388
21380
|
}),
|
|
21389
21381
|
object({
|
|
21390
|
-
...
|
|
21382
|
+
...AttachmentFields,
|
|
21391
21383
|
state: literal("unreadable"),
|
|
21392
21384
|
reason: string()
|
|
21393
21385
|
})
|
|
@@ -21400,17 +21392,49 @@ var CameraSensorAttachmentSchema = discriminatedUnion("state", [
|
|
|
21400
21392
|
* say.
|
|
21401
21393
|
*/
|
|
21402
21394
|
var CameraSensorsNotForwardedSchema = _enum(["onboard-not-listed", "no-active-detection"]);
|
|
21395
|
+
/** Whether the camera's OWN motion counts on its own (D673 C2), from its READY sensors (C3). */
|
|
21396
|
+
var CameraOwnMotionSchema = _enum([
|
|
21397
|
+
"always",
|
|
21398
|
+
"when-confirmed",
|
|
21399
|
+
"never"
|
|
21400
|
+
]);
|
|
21401
|
+
/** Confirm / Replace cannot suppress this camera's motion: its provider still emits it directly (D673 C13). */
|
|
21402
|
+
var CameraSensorsNotEnforcedSchema = _enum(["provider-not-split"]);
|
|
21403
|
+
/**
|
|
21404
|
+
* The camera's OWN onboard motion (D696): the raw input the bridge combines,
|
|
21405
|
+
* never the effective value. The camera's `motion` slice is the effective one,
|
|
21406
|
+
* so a view of the camera's own row reads this.
|
|
21407
|
+
* - `atMs`: when the bridge received the camera's last own edge.
|
|
21408
|
+
* - `detected`: evaluated WHEN THE STATUS IS ASKED — the last edge said `true`
|
|
21409
|
+
* AND it is younger than the window the bridge counts the camera's own motion
|
|
21410
|
+
* for (`motionCooldownMs`, floored at two sustain ticks). A camera that never
|
|
21411
|
+
* sends a clear (heartbeats only) therefore reads `false` once no push came
|
|
21412
|
+
* within the window; a status read is a snapshot, so a live view re-asks.
|
|
21413
|
+
* Absent = this orchestrator has not received the camera's own motion since it
|
|
21414
|
+
* started (unknown, never "quiet"), or an orchestrator older than D696.
|
|
21415
|
+
*/
|
|
21416
|
+
var CameraRawLevelSchema = object({
|
|
21417
|
+
detected: boolean(),
|
|
21418
|
+
atMs: number()
|
|
21419
|
+
});
|
|
21403
21420
|
var CameraSensorsStatusSchema = discriminatedUnion("state", [
|
|
21404
|
-
object({
|
|
21421
|
+
object({
|
|
21422
|
+
state: literal("not-configured"),
|
|
21423
|
+
cameraLevel: CameraRawLevelSchema.optional()
|
|
21424
|
+
}),
|
|
21405
21425
|
object({
|
|
21406
21426
|
state: literal("unreadable"),
|
|
21407
|
-
reason: string()
|
|
21427
|
+
reason: string(),
|
|
21428
|
+
cameraLevel: CameraRawLevelSchema.optional()
|
|
21408
21429
|
}),
|
|
21409
21430
|
object({
|
|
21410
21431
|
state: literal("configured"),
|
|
21411
|
-
|
|
21432
|
+
cameraLevel: CameraRawLevelSchema.optional(),
|
|
21412
21433
|
sensors: array(CameraSensorAttachmentSchema).readonly(),
|
|
21413
|
-
|
|
21434
|
+
/** Absent = an orchestrator older than CS-2: it does not say (D315). */
|
|
21435
|
+
cameraMotion: CameraOwnMotionSchema.optional(),
|
|
21436
|
+
notForwarded: CameraSensorsNotForwardedSchema.optional(),
|
|
21437
|
+
notEnforced: CameraSensorsNotEnforcedSchema.optional()
|
|
21414
21438
|
})
|
|
21415
21439
|
]);
|
|
21416
21440
|
Object.freeze({
|
|
@@ -24641,8 +24665,10 @@ var RunnerCameraConfigSchema = object({
|
|
|
24641
24665
|
* - `analyzer`: ML/frame-diff motion detection (motion-wasm or other
|
|
24642
24666
|
* analyzer providers) running on decoded frames in this runner.
|
|
24643
24667
|
* - `onboard`: camera-native motion pushes (Reolink Baichuan, ONVIF
|
|
24644
|
-
* analytics). The provider emits ProviderMotion
|
|
24645
|
-
*
|
|
24668
|
+
* analytics). The provider emits its raw push as `ProviderMotion`
|
|
24669
|
+
* (D673); the orchestrator's camera-sensors bridge re-emits the camera's
|
|
24670
|
+
* effective motion as `MotionOnMotionChanged`, which is what reaches
|
|
24671
|
+
* `reportMotion`.
|
|
24646
24672
|
*/
|
|
24647
24673
|
motionSources: MotionSourcesSchema.default(["analyzer"]),
|
|
24648
24674
|
/**
|
|
@@ -24819,7 +24845,15 @@ var RunnerLocalLoadSchema = object({
|
|
|
24819
24845
|
hasGpu: boolean(),
|
|
24820
24846
|
inferenceBackend: string().optional(),
|
|
24821
24847
|
cpuCores: number().optional()
|
|
24822
|
-
})
|
|
24848
|
+
}),
|
|
24849
|
+
/**
|
|
24850
|
+
* Who writes a camera's `motion` runtime slice (D696). `'orchestrator'`: this
|
|
24851
|
+
* runner never writes it. ABSENT = a runner older than D696, which still
|
|
24852
|
+
* writes the slice from its phase machine; the orchestrator does not write
|
|
24853
|
+
* while any runner node is absent-or-unanswered, so one slice never has two
|
|
24854
|
+
* writers.
|
|
24855
|
+
*/
|
|
24856
|
+
motionSliceWriter: literal("orchestrator").optional()
|
|
24823
24857
|
});
|
|
24824
24858
|
/**
|
|
24825
24859
|
* Aggregate runtime metrics for the runner's whole local pool. Mirrors the
|
|
@@ -30862,6 +30896,70 @@ onStatusChanged: { data: object({
|
|
|
30862
30896
|
* whether persisting is worth a SQLite commit. */
|
|
30863
30897
|
volatileStateFields: ["lastChangedAt"]
|
|
30864
30898
|
};
|
|
30899
|
+
var DoorbellStatusSchema = object({
|
|
30900
|
+
/** Ms epoch of the last press. null = never observed since this provider started. */
|
|
30901
|
+
lastPressedAt: number().nullable(),
|
|
30902
|
+
/** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
|
|
30903
|
+
pressCountSinceStart: number()
|
|
30904
|
+
});
|
|
30905
|
+
var DoorbellPressEventSchema = object({
|
|
30906
|
+
deviceId: number(),
|
|
30907
|
+
timestamp: number()
|
|
30908
|
+
});
|
|
30909
|
+
/**
|
|
30910
|
+
* Doorbell button cap. Two kinds of provider serve it, and to every consumer
|
|
30911
|
+
* they are the same cap:
|
|
30912
|
+
*
|
|
30913
|
+
* - **Native** providers, registered per device by a driver addon through
|
|
30914
|
+
* `ctx.registerNativeCap` — a `DeviceType.Button` accessory with
|
|
30915
|
+
* `role: DeviceRole.Doorbell`, or the camera itself (Reolink registers at
|
|
30916
|
+
* camera level). They emit `onPressed` on every firmware ring.
|
|
30917
|
+
* - **A composed doorbell** (D670, D671): a camera's customization gives it
|
|
30918
|
+
* the cap, its `lastPressedAt` rising from the sources the operator
|
|
30919
|
+
* assigned in Customize → Doorbell, and the composer emits `onPressed`
|
|
30920
|
+
* from that field's advance (`fromState`).
|
|
30921
|
+
*
|
|
30922
|
+
* The DeviceEventPropagator re-emits `onPressed` on the camera parent.
|
|
30923
|
+
*/
|
|
30924
|
+
var doorbellCapability = {
|
|
30925
|
+
name: "doorbell",
|
|
30926
|
+
scope: "device",
|
|
30927
|
+
deviceNative: true,
|
|
30928
|
+
mode: "singleton",
|
|
30929
|
+
deviceTypes: [DeviceType.Button, DeviceType.Camera],
|
|
30930
|
+
methods: {},
|
|
30931
|
+
events: {
|
|
30932
|
+
/**
|
|
30933
|
+
* Fires once per physical press. Reolink delivers via Baichuan
|
|
30934
|
+
* push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
|
|
30935
|
+
* release/duration — it's a pulse.
|
|
30936
|
+
*/
|
|
30937
|
+
onPressed: {
|
|
30938
|
+
data: DoorbellPressEventSchema,
|
|
30939
|
+
fromState: {
|
|
30940
|
+
field: "lastPressedAt",
|
|
30941
|
+
on: "advance"
|
|
30942
|
+
}
|
|
30943
|
+
} },
|
|
30944
|
+
status: {
|
|
30945
|
+
schema: DoorbellStatusSchema,
|
|
30946
|
+
kind: "push"
|
|
30947
|
+
},
|
|
30948
|
+
/**
|
|
30949
|
+
* Runtime-state slice — last press timestamp + lifetime press count.
|
|
30950
|
+
* Mirrored by the kernel and readable via
|
|
30951
|
+
* `device.state.doorbell.value`. UIs can show "last ring 5m ago"
|
|
30952
|
+
* without subscribing.
|
|
30953
|
+
*/
|
|
30954
|
+
runtimeState: DoorbellStatusSchema,
|
|
30955
|
+
/**
|
|
30956
|
+
* 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.
|
|
30957
|
+
*
|
|
30958
|
+
* See `RuntimeStateDurability`. Enforced by
|
|
30959
|
+
* `scripts/check-runtime-state-durability.ts`.
|
|
30960
|
+
*/
|
|
30961
|
+
durability: "restored"
|
|
30962
|
+
};
|
|
30865
30963
|
/**
|
|
30866
30964
|
* Enum-state sensor — a string value picked from a finite option set.
|
|
30867
30965
|
* Drives HA `sensor` entries with `state_class: enum` (HVAC action
|
|
@@ -33001,39 +33099,14 @@ authKey: string().optional() }), object({
|
|
|
33001
33099
|
/** Human-readable error when `ok: false`. */
|
|
33002
33100
|
error: string().optional()
|
|
33003
33101
|
}), { kind: "mutation" });
|
|
33004
|
-
/**
|
|
33005
|
-
* Hardware / firmware motion sensor cap — binary detected state plus
|
|
33006
|
-
* a timestamp of the last observation. Distinct from
|
|
33007
|
-
* `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
|
|
33008
|
-
* `motion` is the lightweight readout from on-camera motion (Reolink
|
|
33009
|
-
* `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
|
|
33010
|
-
*
|
|
33011
|
-
* Native-motion providers also fan out to `detection.camera-native`
|
|
33012
|
-
* with `source: 'onboard'` so cross-cutting system services
|
|
33013
|
-
* (alert-center, advanced-notifier) can subscribe once and receive
|
|
33014
|
-
* motion from every camera.
|
|
33015
|
-
*/
|
|
33016
|
-
/**
|
|
33017
|
-
* How long after a camera's last rising edge `pipeline-analytics` closes the
|
|
33018
|
-
* motion EPISODE row it kept open for it (D475) — "il delay della cap", in
|
|
33019
|
-
* the operator's words. One authority for the whole system: every provider
|
|
33020
|
-
* that seeds `autoClearAfterMs` on a `Camera` device writes this SAME
|
|
33021
|
-
* constant while `detected: true` (never its own number — Hikvision used to
|
|
33022
|
-
* seed its internal 3 s inactivity timer here, which is a different clock for
|
|
33023
|
-
* a different purpose), and `MotionEpisodeTracker` imports it directly rather
|
|
33024
|
-
* than reading the live cap value on the hot path. A `Sensor` device (HA
|
|
33025
|
-
* binary sensor, Homematic) gets a genuine push both ways and has no episode
|
|
33026
|
-
* to close on a timer, so it writes `null`, never this constant.
|
|
33027
|
-
*/
|
|
33028
|
-
var MOTION_CLOSE_AFTER_MS = 15e3;
|
|
33029
33102
|
var MotionStatusSchema = object({
|
|
33030
33103
|
detected: boolean(),
|
|
33031
33104
|
/** Ms epoch of the last detected-true observation. Null if never detected. */
|
|
33032
33105
|
lastDetectedAt: number().nullable(),
|
|
33033
33106
|
/**
|
|
33034
|
-
* `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device
|
|
33035
|
-
* `null` while false and on every `Sensor`
|
|
33036
|
-
* constant's doc for the one-authority rule.
|
|
33107
|
+
* `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device (the
|
|
33108
|
+
* orchestrator writes it, D696), `null` while false and on every `Sensor`
|
|
33109
|
+
* device (D475) — see that constant's doc for the one-authority rule.
|
|
33037
33110
|
*
|
|
33038
33111
|
* ## Reading this field still arms nothing
|
|
33039
33112
|
*
|
|
@@ -33051,34 +33124,31 @@ var MotionStatusSchema = object({
|
|
|
33051
33124
|
* `addon-export-alexa/src/motion-clear-hold.ts` and
|
|
33052
33125
|
* `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
|
|
33053
33126
|
*
|
|
33054
|
-
* ## Who writes it
|
|
33055
|
-
*
|
|
33056
|
-
* - **Cameras** — the
|
|
33057
|
-
*
|
|
33058
|
-
* `
|
|
33059
|
-
* `
|
|
33060
|
-
*
|
|
33061
|
-
*
|
|
33062
|
-
* a
|
|
33063
|
-
*
|
|
33064
|
-
*
|
|
33065
|
-
*
|
|
33066
|
-
*
|
|
33067
|
-
*
|
|
33068
|
-
*
|
|
33069
|
-
*
|
|
33070
|
-
*
|
|
33071
|
-
*
|
|
33072
|
-
* `
|
|
33073
|
-
*
|
|
33074
|
-
*
|
|
33075
|
-
*
|
|
33076
|
-
*
|
|
33077
|
-
*
|
|
33078
|
-
*
|
|
33079
|
-
* This predates D475 and is not fixed there: the fix touches every
|
|
33080
|
-
* camera provider. Recorded in D475's Consequences. Do not restore the
|
|
33081
|
-
* "sole writer" wording without also removing the other writers.
|
|
33127
|
+
* ## Who writes it (D696)
|
|
33128
|
+
*
|
|
33129
|
+
* - **Cameras** — the orchestrator, and nothing else. It writes the camera's
|
|
33130
|
+
* EFFECTIVE motion (`addon-pipeline-orchestrator`
|
|
33131
|
+
* `camera-sensors/motion-slice.ts`), alongside the effective
|
|
33132
|
+
* `MotionOnMotionChanged` it emits or receives: the camera-sensors bridge
|
|
33133
|
+
* for a split camera, an unsplit emitter's direct event, the analyzer and
|
|
33134
|
+
* device activity, as the camera's `motionSources` counts them. A source
|
|
33135
|
+
* that never sends a clear falls one window after its last `true`.
|
|
33136
|
+
* `lastDetectedAt` moves only on an effective rise. No camera provider
|
|
33137
|
+
* writes this slice (not even a boot seed), and neither does the runner's
|
|
33138
|
+
* phase machine: its phase is "a session is attached" for every on-motion
|
|
33139
|
+
* session, not motion, and it now has its own `DetectionPhaseTransition`.
|
|
33140
|
+
* A provider's `isDetected` answers from the hub's slice.
|
|
33141
|
+
* - **Sensors** (Home Assistant binary sensors, Homematic, Matter, Alexa
|
|
33142
|
+
* imports) — the provider pushes both edges itself, from the upstream
|
|
33143
|
+
* system's own state change. That is the sensor's own fact.
|
|
33144
|
+
*
|
|
33145
|
+
* `scripts/check-onboard-motion-emitters.ts` refuses any other writer of a
|
|
33146
|
+
* `motion` slice; each sensor writer is a named exemption.
|
|
33147
|
+
*
|
|
33148
|
+
* This replaces the D475 §4 rule ("the phase machine is the sole writer").
|
|
33149
|
+
* That rule was never true: Hikvision and Amcrest wrote the slice raw beside
|
|
33150
|
+
* it, every provider seeded it at boot, and every session left it
|
|
33151
|
+
* `detected: true` after its detach.
|
|
33082
33152
|
*/
|
|
33083
33153
|
autoClearAfterMs: number().nullable()
|
|
33084
33154
|
});
|
|
@@ -33150,11 +33220,12 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
|
|
|
33150
33220
|
*/
|
|
33151
33221
|
runtimeState: MotionStatusSchema,
|
|
33152
33222
|
/**
|
|
33153
|
-
* Runtime-state durability: **session** —
|
|
33223
|
+
* Runtime-state durability: **session** — the writer of this slice
|
|
33154
33224
|
* writes only on an EDGE, so a restored `detected: true` would stay
|
|
33155
33225
|
* frozen until the next one instead of being corrected. The next edge
|
|
33156
|
-
* re-publishes the real state
|
|
33157
|
-
*
|
|
33226
|
+
* re-publishes the real state, and the orchestrator re-publishes every
|
|
33227
|
+
* camera when it starts writing (D696; on who writes it, see
|
|
33228
|
+
* `autoClearAfterMs` above).
|
|
33158
33229
|
*
|
|
33159
33230
|
* See `RuntimeStateDurability`. Enforced by
|
|
33160
33231
|
* `scripts/check-runtime-state-durability.ts`.
|
|
@@ -35695,8 +35766,7 @@ var ptzAutotrackCapability = {
|
|
|
35695
35766
|
deviceNative: true,
|
|
35696
35767
|
mode: "singleton",
|
|
35697
35768
|
/**
|
|
35698
|
-
* Two kinds of provider behind one name, the same shape `snapshot`
|
|
35699
|
-
* `doorbell` use:
|
|
35769
|
+
* Two kinds of provider behind one name, the same shape `snapshot` uses:
|
|
35700
35770
|
*
|
|
35701
35771
|
* - **Native**: the camera's own firmware autotrack, registered per device by
|
|
35702
35772
|
* the driver when the probe says it exists (Reolink: yes; Hikvision:
|
|
@@ -35704,7 +35774,7 @@ var ptzAutotrackCapability = {
|
|
|
35704
35774
|
* - **Wrapper**: the emulated implementation (`@camstack/system`'s `autotrack` builtin),
|
|
35705
35775
|
* which follows a subject with `ptz.move` pulses driven by the detection
|
|
35706
35776
|
* pipeline. `defaultActive: false` — the operator binds it per camera in
|
|
35707
|
-
* the bindings UI
|
|
35777
|
+
* the bindings UI.
|
|
35708
35778
|
*
|
|
35709
35779
|
* The binding chooses WHICH implementation answers; `setEnabled` stays the
|
|
35710
35780
|
* one switch for the function either way. A camera never has both driving its
|
|
@@ -41220,13 +41290,14 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
41220
41290
|
async getStatus() {
|
|
41221
41291
|
const all = await this.ctx.kernel.devices?.getAll() ?? [];
|
|
41222
41292
|
const summary = this.restoreFailureSummary();
|
|
41223
|
-
|
|
41293
|
+
const base = {
|
|
41224
41294
|
connected: true,
|
|
41225
|
-
deviceCount: all.length
|
|
41295
|
+
deviceCount: all.length,
|
|
41296
|
+
motionSliceWriter: "orchestrator"
|
|
41226
41297
|
};
|
|
41298
|
+
if (summary === null) return base;
|
|
41227
41299
|
return {
|
|
41228
|
-
|
|
41229
|
-
deviceCount: all.length,
|
|
41300
|
+
...base,
|
|
41230
41301
|
error: summary
|
|
41231
41302
|
};
|
|
41232
41303
|
}
|
|
@@ -46880,6 +46951,12 @@ Object.freeze({
|
|
|
46880
46951
|
addonId: null,
|
|
46881
46952
|
access: "view"
|
|
46882
46953
|
},
|
|
46954
|
+
"notificationRules.getAlarmSensors": {
|
|
46955
|
+
capName: "notification-rules",
|
|
46956
|
+
capScope: "system",
|
|
46957
|
+
addonId: null,
|
|
46958
|
+
access: "view"
|
|
46959
|
+
},
|
|
46883
46960
|
"notificationRules.getClipRetentionAsks": {
|
|
46884
46961
|
capName: "notification-rules",
|
|
46885
46962
|
capScope: "system",
|
|
@@ -51363,6 +51440,11 @@ Object.freeze({
|
|
|
51363
51440
|
form: "single",
|
|
51364
51441
|
optional: false
|
|
51365
51442
|
}],
|
|
51443
|
+
"notificationRules.getAlarmSensors": [{
|
|
51444
|
+
name: "deviceIds",
|
|
51445
|
+
form: "array",
|
|
51446
|
+
optional: false
|
|
51447
|
+
}],
|
|
51366
51448
|
"notificationRules.setDeviceMuted": [{
|
|
51367
51449
|
name: "deviceId",
|
|
51368
51450
|
form: "single",
|
|
@@ -53298,6 +53380,25 @@ TimelapseRuleInputSchema.extend({
|
|
|
53298
53380
|
createdAt: number(),
|
|
53299
53381
|
updatedAt: number()
|
|
53300
53382
|
});
|
|
53383
|
+
async function readHubMotionDetected(deviceState, deviceId) {
|
|
53384
|
+
let slice;
|
|
53385
|
+
try {
|
|
53386
|
+
slice = await deviceState.getCapSlice.query({
|
|
53387
|
+
deviceId,
|
|
53388
|
+
capName: "motion"
|
|
53389
|
+
});
|
|
53390
|
+
} catch (err) {
|
|
53391
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
53392
|
+
throw new Error(`motion state of device ${deviceId} is unreadable: ${reason}`, { cause: err });
|
|
53393
|
+
}
|
|
53394
|
+
const detected = slice?.["detected"];
|
|
53395
|
+
if (typeof detected !== "boolean") throw new Error(`motion state of device ${deviceId} is not published yet (unknown)`);
|
|
53396
|
+
return detected;
|
|
53397
|
+
}
|
|
53398
|
+
MotionOnMotionChangedDataSchema.omit({ triggeredBy: true });
|
|
53399
|
+
function providerMotionEvent(source, data) {
|
|
53400
|
+
return createEvent(EventCategory.ProviderMotion, source, data);
|
|
53401
|
+
}
|
|
53301
53402
|
object({
|
|
53302
53403
|
/**
|
|
53303
53404
|
* Fraction of the box's own size added on EACH side before cutting.
|
|
@@ -63110,15 +63211,7 @@ var HikvisionCamera = class HikvisionCamera extends BaseDevice {
|
|
|
63110
63211
|
host
|
|
63111
63212
|
};
|
|
63112
63213
|
} });
|
|
63113
|
-
this.
|
|
63114
|
-
if (deviceId !== this.id) throw new Error(`HikvisionCamera: deviceId mismatch, expected ${this.id}, got ${deviceId}`);
|
|
63115
|
-
return this.state.motion?.detected ?? false;
|
|
63116
|
-
} });
|
|
63117
|
-
this.setCapSlice(motionCapability, {
|
|
63118
|
-
detected: false,
|
|
63119
|
-
lastDetectedAt: null,
|
|
63120
|
-
autoClearAfterMs: null
|
|
63121
|
-
});
|
|
63214
|
+
this.registerMotionCap();
|
|
63122
63215
|
this.registerIntercomIfSupported();
|
|
63123
63216
|
this.registerOsdCap(1);
|
|
63124
63217
|
this.registerStreamParamsCap(1);
|
|
@@ -65587,43 +65680,41 @@ var HikvisionCamera = class HikvisionCamera extends BaseDevice {
|
|
|
65587
65680
|
deviceId: this.id
|
|
65588
65681
|
};
|
|
65589
65682
|
}
|
|
65683
|
+
/**
|
|
65684
|
+
* The native `motion` cap. Its presence is what defaults the camera to
|
|
65685
|
+
* `motionSources: ['onboard']`. This provider writes NO `motion` slice (D696):
|
|
65686
|
+
* the orchestrator is its only writer, with the EFFECTIVE motion, on the hub.
|
|
65687
|
+
* `isDetected` therefore answers from the hub's slice; an unreadable hub, or
|
|
65688
|
+
* a slice nobody has published since the hub started, makes the call fail.
|
|
65689
|
+
* It never answers `false` for "unknown" (D49, D393).
|
|
65690
|
+
*/
|
|
65691
|
+
registerMotionCap() {
|
|
65692
|
+
this.ctx.registerNativeCap(motionCapability, { isDetected: async ({ deviceId }) => {
|
|
65693
|
+
if (deviceId !== this.id) throw new Error(`HikvisionCamera: deviceId mismatch, expected ${this.id}, got ${deviceId}`);
|
|
65694
|
+
return readHubMotionDetected(this.ctx.api.deviceState, this.id);
|
|
65695
|
+
} });
|
|
65696
|
+
}
|
|
65590
65697
|
handleMotionEvent(ev, camStreamId) {
|
|
65591
65698
|
const now = ev.observedAt;
|
|
65592
|
-
const wasInactive = (this.lastMotionAt.get(camStreamId) ?? 0) === 0;
|
|
65593
65699
|
this.lastMotionAt.set(camStreamId, now);
|
|
65594
|
-
this.ctx.eventBus.emit(
|
|
65700
|
+
this.ctx.eventBus.emit(providerMotionEvent(this.eventSource, {
|
|
65595
65701
|
deviceId: this.id,
|
|
65596
65702
|
detected: true,
|
|
65597
65703
|
timestamp: now,
|
|
65598
65704
|
source: "onboard"
|
|
65599
65705
|
}));
|
|
65600
|
-
if (wasInactive) try {
|
|
65601
|
-
this.setCapSlice(motionCapability, {
|
|
65602
|
-
detected: true,
|
|
65603
|
-
lastDetectedAt: now,
|
|
65604
|
-
autoClearAfterMs: MOTION_CLOSE_AFTER_MS
|
|
65605
|
-
});
|
|
65606
|
-
} catch {}
|
|
65607
65706
|
const existing = this.motionInactiveTimers.get(camStreamId);
|
|
65608
65707
|
if (existing) clearTimeout(existing);
|
|
65609
65708
|
const timer = setTimeout(() => {
|
|
65610
65709
|
const clearedAt = Date.now();
|
|
65611
65710
|
this.lastMotionAt.set(camStreamId, 0);
|
|
65612
65711
|
this.motionInactiveTimers.delete(camStreamId);
|
|
65613
|
-
this.ctx.eventBus.emit(
|
|
65712
|
+
this.ctx.eventBus.emit(providerMotionEvent(this.eventSource, {
|
|
65614
65713
|
deviceId: this.id,
|
|
65615
65714
|
detected: false,
|
|
65616
65715
|
timestamp: clearedAt,
|
|
65617
65716
|
source: "onboard"
|
|
65618
65717
|
}));
|
|
65619
|
-
try {
|
|
65620
|
-
const lastDetectedAt = this.state.motion?.lastDetectedAt ?? clearedAt;
|
|
65621
|
-
this.setCapSlice(motionCapability, {
|
|
65622
|
-
detected: false,
|
|
65623
|
-
lastDetectedAt,
|
|
65624
|
-
autoClearAfterMs: null
|
|
65625
|
-
});
|
|
65626
|
-
} catch {}
|
|
65627
65718
|
}, HikvisionCamera.MOTION_INACTIVE_AFTER_MS);
|
|
65628
65719
|
this.motionInactiveTimers.set(camStreamId, timer);
|
|
65629
65720
|
}
|