@camstack/addon-provider-amcrest 0.2.124 → 0.2.125
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 +230 -223
- package/dist/addon.mjs +230 -223
- package/package.json +1 -1
package/dist/addon.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import { networkInterfaces } from "node:os";
|
|
|
13
13
|
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
14
14
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
15
15
|
//#endregion
|
|
16
|
-
//#region ../types/dist/event-category-
|
|
16
|
+
//#region ../types/dist/event-category-BGmz_oxW.mjs
|
|
17
17
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
18
18
|
EventCategory["SystemBoot"] = "system.boot";
|
|
19
19
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -546,6 +546,15 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
546
546
|
*/
|
|
547
547
|
EventCategory["PipelineAudioInferenceResult"] = "pipeline.audio-inference-result";
|
|
548
548
|
EventCategory["DetectionPhaseTransition"] = "detection.phase-transition";
|
|
549
|
+
/**
|
|
550
|
+
* A camera provider's RAW onboard motion push (D673): the `MotionOnMotionChanged`
|
|
551
|
+
* data shape without `triggeredBy`, built by `providerMotionEvent`. Its one
|
|
552
|
+
* consumer is the orchestrator's camera-sensors bridge, which re-emits the
|
|
553
|
+
* camera's EFFECTIVE onboard motion as `MotionOnMotionChanged` (a pass-through
|
|
554
|
+
* for a camera with no attached sensor). Providers must not emit
|
|
555
|
+
* `MotionOnMotionChanged` themselves; `scripts/check-onboard-motion-emitters.ts`
|
|
556
|
+
* keeps it so (camera-grid is a named, deferred exception).
|
|
557
|
+
*/
|
|
549
558
|
EventCategory["ProviderMotion"] = "provider.motion";
|
|
550
559
|
EventCategory["ProviderDetection"] = "provider.detection";
|
|
551
560
|
EventCategory["EnrichmentEmbeddingStored"] = "enrichment.embedding.stored";
|
|
@@ -5384,7 +5393,7 @@ var ZodIssueCode = {
|
|
|
5384
5393
|
var ZodFirstPartyTypeKind;
|
|
5385
5394
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5386
5395
|
//#endregion
|
|
5387
|
-
//#region ../types/dist/sleep-
|
|
5396
|
+
//#region ../types/dist/sleep-CDCONfkt.mjs
|
|
5388
5397
|
/**
|
|
5389
5398
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5390
5399
|
* window to float samples (D455).
|
|
@@ -7417,7 +7426,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
|
|
|
7417
7426
|
return DeviceRole;
|
|
7418
7427
|
}({});
|
|
7419
7428
|
//#endregion
|
|
7420
|
-
//#region ../types/dist/composition-
|
|
7429
|
+
//#region ../types/dist/composition-43aqsZQj.mjs
|
|
7421
7430
|
/**
|
|
7422
7431
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
7423
7432
|
*
|
|
@@ -7474,13 +7483,12 @@ portable("linux64"), portable("linuxarm64"), portable("macarm64"), portable("mac
|
|
|
7474
7483
|
* LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
|
|
7475
7484
|
* valutatore puro del suo FRONTE.
|
|
7476
7485
|
*
|
|
7477
|
-
*
|
|
7478
|
-
*
|
|
7479
|
-
*
|
|
7480
|
-
*
|
|
7481
|
-
*
|
|
7482
|
-
* fa suonare il campanello ma non registra" — è esattamente D62.
|
|
7483
|
-
* SPOSTA qui e il doorbell la ri-esporta.
|
|
7486
|
+
* UNA tabella per tutti quelli che chiedono "questo device è ALTO?": il
|
|
7487
|
+
* trigger `RecordingTriggers.sensorDeviceIds` del recorder, i marker dei
|
|
7488
|
+
* sensori della post-analysis, il bridge camera-sensors dell'orchestratore e
|
|
7489
|
+
* le sorgenti di un campanello composto (`doorbellFeatureSources`, D671).
|
|
7490
|
+
* Una seconda copia divergerebbe alla prima cap aggiunta, e il sintomo — "il
|
|
7491
|
+
* sensore fa suonare il campanello ma non registra" — è esattamente D62.
|
|
7484
7492
|
*
|
|
7485
7493
|
* ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
|
|
7486
7494
|
* due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
|
|
@@ -7506,8 +7514,6 @@ var SOURCE_CAP_ACTIVE_FIELD = {
|
|
|
7506
7514
|
vibration: "detected",
|
|
7507
7515
|
tamper: "tampered"
|
|
7508
7516
|
};
|
|
7509
|
-
/** Cap names whose presence in a device's bindings qualify it as a source. */
|
|
7510
|
-
var SOURCE_CAPS = Object.keys(SOURCE_CAP_ACTIVE_FIELD);
|
|
7511
7517
|
/**
|
|
7512
7518
|
* Error types for the safe expression engine. Two distinct classes so callers
|
|
7513
7519
|
* can tell a compile-time (grammar) failure from a runtime (evaluation)
|
|
@@ -9237,7 +9243,7 @@ var RecordingTriggersSchema = object({
|
|
|
9237
9243
|
*
|
|
9238
9244
|
* Cosa vuol dire "alto" dipende dal TIPO di device e non è deciso qui:
|
|
9239
9245
|
* `SOURCE_CAP_ACTIVE_FIELD` (`catalogs/sensor-active-state.ts`) è LA tabella,
|
|
9240
|
-
* la stessa
|
|
9246
|
+
* la stessa del campanello composto (D671). Ed è il FRONTE, non
|
|
9241
9247
|
* il livello: un contatto trovato già aperto al riavvio del runner non fa
|
|
9242
9248
|
* registrare.
|
|
9243
9249
|
*/
|
|
@@ -15726,109 +15732,10 @@ method(object({
|
|
|
15726
15732
|
deviceIds: array(number()).readonly(),
|
|
15727
15733
|
caps: array(string()).readonly().optional()
|
|
15728
15734
|
}), record(string(), record(string(), unknown().nullable())));
|
|
15729
|
-
|
|
15730
|
-
|
|
15731
|
-
* name (same pattern as `snapshot`):
|
|
15732
|
-
*
|
|
15733
|
-
* - **Native** providers: registered per-device by device-driver
|
|
15734
|
-
* addons via `ctx.registerNativeCap` — either on a
|
|
15735
|
-
* `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
|
|
15736
|
-
* or directly on the camera (Reolink registers at camera level).
|
|
15737
|
-
* Emits an `onPressed` event every time the firmware pushes a
|
|
15738
|
-
* ring; status tracks the last press and a pressCount since start
|
|
15739
|
-
* (diagnostic).
|
|
15740
|
-
*
|
|
15741
|
-
* - **Wrapper** provider: the `virtual-doorbell` system builtin
|
|
15742
|
-
* (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
|
|
15743
|
-
* device (contact / switch / event-emitter …) into a doorbell for
|
|
15744
|
-
* a camera. `defaultActive: false` — the operator explicitly binds
|
|
15745
|
-
* it per camera in the device-bindings UI, then picks the source
|
|
15746
|
-
* device + trigger in the per-device settings.
|
|
15747
|
-
*
|
|
15748
|
-
* The DeviceEventPropagator re-emits `onPressed` on the camera parent
|
|
15749
|
-
* — subscribers listening at the camera level receive ring events
|
|
15750
|
-
* with `via[]` populated. No code on the parent needed.
|
|
15751
|
-
*/
|
|
15752
|
-
var DoorbellStatusSchema = object({
|
|
15753
|
-
/** Ms epoch of the last press. null = never observed since this provider started. */
|
|
15754
|
-
lastPressedAt: number().nullable(),
|
|
15755
|
-
/** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
|
|
15756
|
-
pressCountSinceStart: number()
|
|
15757
|
-
});
|
|
15758
|
-
var DoorbellPressEventSchema = object({
|
|
15759
|
-
deviceId: number(),
|
|
15760
|
-
timestamp: number()
|
|
15761
|
-
});
|
|
15762
|
-
/**
|
|
15763
|
-
* The `doorbell-source` extension slot's editable value (D648): the camera's
|
|
15764
|
-
* virtual-doorbell trigger devices, exactly what the wrapper's
|
|
15765
|
-
* `doorbellSources` persists (as `{ deviceId }` records).
|
|
15766
|
-
*/
|
|
15767
|
-
var DoorbellSourceSlotValueSchema = object({ deviceIds: array(number().int().positive()) });
|
|
15768
|
-
/**
|
|
15769
|
-
* The `doorbell-source` slot — which devices ring this camera's VIRTUAL
|
|
15770
|
-
* doorbell, owned by the `virtual-doorbell` wrapper over its
|
|
15771
|
-
* `doorbellSources` store (D648). A source rings when one of its
|
|
15772
|
-
* `SOURCE_CAPS` rises. Whether the wrapper is bound to the camera at all is a
|
|
15773
|
-
* different authority (`deviceManager.setWrapperActive`, D62) — the slot
|
|
15774
|
-
* reports it, it never writes it.
|
|
15775
|
-
*/
|
|
15776
|
-
var DOORBELL_SOURCE_SLOT = {
|
|
15777
|
-
id: "doorbell-source",
|
|
15778
|
-
label: "Doorbell trigger devices",
|
|
15779
|
-
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.",
|
|
15780
|
-
shape: "association",
|
|
15781
|
-
hostDeviceTypes: [DeviceType.Camera],
|
|
15782
|
-
sourceCaps: SOURCE_CAPS,
|
|
15783
|
-
cardinality: "many",
|
|
15784
|
-
value: DoorbellSourceSlotValueSchema
|
|
15785
|
-
};
|
|
15786
|
-
var doorbellCapability = {
|
|
15787
|
-
name: "doorbell",
|
|
15788
|
-
scope: "device",
|
|
15789
|
-
deviceNative: true,
|
|
15790
|
-
mode: "singleton",
|
|
15791
|
-
kind: "wrapper",
|
|
15792
|
-
defaultActive: false,
|
|
15793
|
-
deviceTypes: [DeviceType.Button, DeviceType.Camera],
|
|
15794
|
-
extensionSlots: [DOORBELL_SOURCE_SLOT],
|
|
15795
|
-
methods: {},
|
|
15796
|
-
events: {
|
|
15797
|
-
/**
|
|
15798
|
-
* Fires once per physical press. Reolink delivers via Baichuan
|
|
15799
|
-
* push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
|
|
15800
|
-
* release/duration — it's a pulse.
|
|
15801
|
-
*/
|
|
15802
|
-
onPressed: {
|
|
15803
|
-
data: DoorbellPressEventSchema,
|
|
15804
|
-
fromState: {
|
|
15805
|
-
field: "lastPressedAt",
|
|
15806
|
-
on: "advance"
|
|
15807
|
-
}
|
|
15808
|
-
} },
|
|
15809
|
-
status: {
|
|
15810
|
-
schema: DoorbellStatusSchema,
|
|
15811
|
-
kind: "push"
|
|
15812
|
-
},
|
|
15813
|
-
/**
|
|
15814
|
-
* Runtime-state slice — last press timestamp + lifetime press count.
|
|
15815
|
-
* Mirrored by the kernel and readable via
|
|
15816
|
-
* `device.state.doorbell.value`. UIs can show "last ring 5m ago"
|
|
15817
|
-
* without subscribing.
|
|
15818
|
-
*/
|
|
15819
|
-
runtimeState: DoorbellStatusSchema,
|
|
15820
|
-
/**
|
|
15821
|
-
* 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.
|
|
15822
|
-
*
|
|
15823
|
-
* See `RuntimeStateDurability`. Enforced by
|
|
15824
|
-
* `scripts/check-runtime-state-durability.ts`.
|
|
15825
|
-
*/
|
|
15826
|
-
durability: "restored"
|
|
15827
|
-
};
|
|
15828
|
-
var ExtensionSlotIdSchema = _enum(["doorbell-source", "linked-devices"]);
|
|
15829
|
-
DeviceType.Camera, DeviceType.Camera;
|
|
15735
|
+
var ExtensionSlotIdSchema = _enum(["linked-devices"]);
|
|
15736
|
+
DeviceType.Camera;
|
|
15830
15737
|
/** A slot's editable value, discriminated on `slot`. */
|
|
15831
|
-
var ExtensionSlotValueSchema = discriminatedUnion("slot", [
|
|
15738
|
+
var ExtensionSlotValueSchema = discriminatedUnion("slot", [LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
|
|
15832
15739
|
DeviceType.Camera;
|
|
15833
15740
|
var ExtensionSourceAvailabilitySchema = discriminatedUnion("state", [object({ state: literal("ok") }), object({
|
|
15834
15741
|
state: literal("unreachable"),
|
|
@@ -15865,10 +15772,11 @@ var ExtensionSlotSourceSchema = object({
|
|
|
15865
15772
|
});
|
|
15866
15773
|
/**
|
|
15867
15774
|
* A DIFFERENT authority that gates whether the slot's sources do anything —
|
|
15868
|
-
* reported read-only, named, never written through this contract (D62).
|
|
15869
|
-
*
|
|
15870
|
-
*
|
|
15871
|
-
* `unknown` means the gate could
|
|
15775
|
+
* reported read-only, named, never written through this contract (D62) — e.g.
|
|
15776
|
+
* a slot whose sources act only while a wrapper is bound to the host, a
|
|
15777
|
+
* binding that belongs to `deviceManager.setWrapperActive`. No slot reports
|
|
15778
|
+
* one today (`linked-devices` answers `null`). `unknown` means the gate could
|
|
15779
|
+
* not be read; it is not "inactive" (D315).
|
|
15872
15780
|
*/
|
|
15873
15781
|
var ExtensionSlotActivationSchema = object({
|
|
15874
15782
|
state: _enum([
|
|
@@ -15884,7 +15792,7 @@ var ExtensionSlotRowSchema = discriminatedUnion("state", [object({
|
|
|
15884
15792
|
/** `<source>:<slotId>` — the routing key for `listCandidates` / `setSlot`. */
|
|
15885
15793
|
slotRef: string(),
|
|
15886
15794
|
slot: ExtensionSlotIdSchema,
|
|
15887
|
-
/** Names the store written (D62), e.g. `
|
|
15795
|
+
/** Names the store written (D62), e.g. `device-manager:_linkedDeviceIds`. */
|
|
15888
15796
|
authority: string(),
|
|
15889
15797
|
activation: ExtensionSlotActivationSchema.nullable(),
|
|
15890
15798
|
value: ExtensionSlotValueSchema,
|
|
@@ -21006,12 +20914,26 @@ var CameraSensorRefSchema = object({
|
|
|
21006
20914
|
function cameraSensorRefKey(ref) {
|
|
21007
20915
|
return `${ref.addonId}/${ref.stableId}`;
|
|
21008
20916
|
}
|
|
21009
|
-
/**
|
|
21010
|
-
|
|
21011
|
-
|
|
21012
|
-
|
|
21013
|
-
|
|
21014
|
-
|
|
20917
|
+
/**
|
|
20918
|
+
* A sensor's mode (D673). `in-addition`: its motion is the camera's motion too.
|
|
20919
|
+
* `replace`: its motion is the camera's, and while one is READY the camera's
|
|
20920
|
+
* own motion no longer counts on its own. `confirm`: while one is READY the
|
|
20921
|
+
* camera's own motion counts only while a confirm sensor is active — with or
|
|
20922
|
+
* without a replace sensor (spec C2, the controller's ruling on Q1).
|
|
20923
|
+
*/
|
|
20924
|
+
var CameraSensorModeSchema = _enum([
|
|
20925
|
+
"in-addition",
|
|
20926
|
+
"confirm",
|
|
20927
|
+
"replace"
|
|
20928
|
+
]);
|
|
20929
|
+
/** A stored sensor with no mode — every CS-1 row — is in addition. */
|
|
20930
|
+
var DEFAULT_CAMERA_SENSOR_MODE = "in-addition";
|
|
20931
|
+
/**
|
|
20932
|
+
* A camera's attached sensors. A CS-1 row carried an envelope
|
|
20933
|
+
* `mode: 'in-addition'`: `z.object` drops it on parse, and the PARSED value is
|
|
20934
|
+
* what the write stores (D672 rule 3), so it is never written again.
|
|
20935
|
+
*/
|
|
20936
|
+
var CameraSensorsConfigSchema = object({ sensors: array(CameraSensorRefSchema.extend({ mode: CameraSensorModeSchema.default(DEFAULT_CAMERA_SENSOR_MODE) })).min(1).max(8) }).superRefine((value, ctx) => {
|
|
21015
20937
|
const seen = /* @__PURE__ */ new Set();
|
|
21016
20938
|
value.sensors.forEach((ref, index) => {
|
|
21017
20939
|
const key = cameraSensorRefKey(ref);
|
|
@@ -21023,39 +20945,41 @@ var CameraSensorsConfigSchema = object({
|
|
|
21023
20945
|
seen.add(key);
|
|
21024
20946
|
});
|
|
21025
20947
|
});
|
|
21026
|
-
|
|
20948
|
+
/** Every attachment names its mode; an older orchestrator that does not is in addition. */
|
|
20949
|
+
var AttachmentFields = {
|
|
21027
20950
|
addonId: string(),
|
|
21028
|
-
stableId: string()
|
|
20951
|
+
stableId: string(),
|
|
20952
|
+
mode: CameraSensorModeSchema.default(DEFAULT_CAMERA_SENSOR_MODE)
|
|
21029
20953
|
};
|
|
21030
20954
|
var CameraSensorAttachmentSchema = discriminatedUnion("state", [
|
|
21031
20955
|
object({
|
|
21032
|
-
...
|
|
20956
|
+
...AttachmentFields,
|
|
21033
20957
|
state: literal("ready"),
|
|
21034
20958
|
deviceId: number(),
|
|
21035
20959
|
name: string(),
|
|
21036
20960
|
caps: array(string()).readonly()
|
|
21037
20961
|
}),
|
|
21038
20962
|
object({
|
|
21039
|
-
...
|
|
20963
|
+
...AttachmentFields,
|
|
21040
20964
|
state: literal("offline"),
|
|
21041
20965
|
deviceId: number(),
|
|
21042
20966
|
name: string(),
|
|
21043
20967
|
reason: _enum(["offline", "disabled"])
|
|
21044
20968
|
}),
|
|
21045
20969
|
object({
|
|
21046
|
-
...
|
|
20970
|
+
...AttachmentFields,
|
|
21047
20971
|
state: literal("missing"),
|
|
21048
20972
|
reason: string()
|
|
21049
20973
|
}),
|
|
21050
20974
|
object({
|
|
21051
|
-
...
|
|
20975
|
+
...AttachmentFields,
|
|
21052
20976
|
state: literal("unsupported"),
|
|
21053
20977
|
deviceId: number(),
|
|
21054
20978
|
name: string(),
|
|
21055
20979
|
reason: string()
|
|
21056
20980
|
}),
|
|
21057
20981
|
object({
|
|
21058
|
-
...
|
|
20982
|
+
...AttachmentFields,
|
|
21059
20983
|
state: literal("unreadable"),
|
|
21060
20984
|
reason: string()
|
|
21061
20985
|
})
|
|
@@ -21068,17 +20992,49 @@ var CameraSensorAttachmentSchema = discriminatedUnion("state", [
|
|
|
21068
20992
|
* say.
|
|
21069
20993
|
*/
|
|
21070
20994
|
var CameraSensorsNotForwardedSchema = _enum(["onboard-not-listed", "no-active-detection"]);
|
|
20995
|
+
/** Whether the camera's OWN motion counts on its own (D673 C2), from its READY sensors (C3). */
|
|
20996
|
+
var CameraOwnMotionSchema = _enum([
|
|
20997
|
+
"always",
|
|
20998
|
+
"when-confirmed",
|
|
20999
|
+
"never"
|
|
21000
|
+
]);
|
|
21001
|
+
/** Confirm / Replace cannot suppress this camera's motion: its provider still emits it directly (D673 C13). */
|
|
21002
|
+
var CameraSensorsNotEnforcedSchema = _enum(["provider-not-split"]);
|
|
21003
|
+
/**
|
|
21004
|
+
* The camera's OWN onboard motion (D696): the raw input the bridge combines,
|
|
21005
|
+
* never the effective value. The camera's `motion` slice is the effective one,
|
|
21006
|
+
* so a view of the camera's own row reads this.
|
|
21007
|
+
* - `atMs`: when the bridge received the camera's last own edge.
|
|
21008
|
+
* - `detected`: evaluated WHEN THE STATUS IS ASKED — the last edge said `true`
|
|
21009
|
+
* AND it is younger than the window the bridge counts the camera's own motion
|
|
21010
|
+
* for (`motionCooldownMs`, floored at two sustain ticks). A camera that never
|
|
21011
|
+
* sends a clear (heartbeats only) therefore reads `false` once no push came
|
|
21012
|
+
* within the window; a status read is a snapshot, so a live view re-asks.
|
|
21013
|
+
* Absent = this orchestrator has not received the camera's own motion since it
|
|
21014
|
+
* started (unknown, never "quiet"), or an orchestrator older than D696.
|
|
21015
|
+
*/
|
|
21016
|
+
var CameraRawLevelSchema = object({
|
|
21017
|
+
detected: boolean(),
|
|
21018
|
+
atMs: number()
|
|
21019
|
+
});
|
|
21071
21020
|
var CameraSensorsStatusSchema = discriminatedUnion("state", [
|
|
21072
|
-
object({
|
|
21021
|
+
object({
|
|
21022
|
+
state: literal("not-configured"),
|
|
21023
|
+
cameraLevel: CameraRawLevelSchema.optional()
|
|
21024
|
+
}),
|
|
21073
21025
|
object({
|
|
21074
21026
|
state: literal("unreadable"),
|
|
21075
|
-
reason: string()
|
|
21027
|
+
reason: string(),
|
|
21028
|
+
cameraLevel: CameraRawLevelSchema.optional()
|
|
21076
21029
|
}),
|
|
21077
21030
|
object({
|
|
21078
21031
|
state: literal("configured"),
|
|
21079
|
-
|
|
21032
|
+
cameraLevel: CameraRawLevelSchema.optional(),
|
|
21080
21033
|
sensors: array(CameraSensorAttachmentSchema).readonly(),
|
|
21081
|
-
|
|
21034
|
+
/** Absent = an orchestrator older than CS-2: it does not say (D315). */
|
|
21035
|
+
cameraMotion: CameraOwnMotionSchema.optional(),
|
|
21036
|
+
notForwarded: CameraSensorsNotForwardedSchema.optional(),
|
|
21037
|
+
notEnforced: CameraSensorsNotEnforcedSchema.optional()
|
|
21082
21038
|
})
|
|
21083
21039
|
]);
|
|
21084
21040
|
Object.freeze({
|
|
@@ -24309,8 +24265,10 @@ var RunnerCameraConfigSchema = object({
|
|
|
24309
24265
|
* - `analyzer`: ML/frame-diff motion detection (motion-wasm or other
|
|
24310
24266
|
* analyzer providers) running on decoded frames in this runner.
|
|
24311
24267
|
* - `onboard`: camera-native motion pushes (Reolink Baichuan, ONVIF
|
|
24312
|
-
* analytics). The provider emits ProviderMotion
|
|
24313
|
-
*
|
|
24268
|
+
* analytics). The provider emits its raw push as `ProviderMotion`
|
|
24269
|
+
* (D673); the orchestrator's camera-sensors bridge re-emits the camera's
|
|
24270
|
+
* effective motion as `MotionOnMotionChanged`, which is what reaches
|
|
24271
|
+
* `reportMotion`.
|
|
24314
24272
|
*/
|
|
24315
24273
|
motionSources: MotionSourcesSchema.default(["analyzer"]),
|
|
24316
24274
|
/**
|
|
@@ -24487,7 +24445,15 @@ var RunnerLocalLoadSchema = object({
|
|
|
24487
24445
|
hasGpu: boolean(),
|
|
24488
24446
|
inferenceBackend: string().optional(),
|
|
24489
24447
|
cpuCores: number().optional()
|
|
24490
|
-
})
|
|
24448
|
+
}),
|
|
24449
|
+
/**
|
|
24450
|
+
* Who writes a camera's `motion` runtime slice (D696). `'orchestrator'`: this
|
|
24451
|
+
* runner never writes it. ABSENT = a runner older than D696, which still
|
|
24452
|
+
* writes the slice from its phase machine; the orchestrator does not write
|
|
24453
|
+
* while any runner node is absent-or-unanswered, so one slice never has two
|
|
24454
|
+
* writers.
|
|
24455
|
+
*/
|
|
24456
|
+
motionSliceWriter: literal("orchestrator").optional()
|
|
24491
24457
|
});
|
|
24492
24458
|
/**
|
|
24493
24459
|
* Aggregate runtime metrics for the runner's whole local pool. Mirrors the
|
|
@@ -30521,6 +30487,70 @@ onStatusChanged: { data: object({
|
|
|
30521
30487
|
* whether persisting is worth a SQLite commit. */
|
|
30522
30488
|
volatileStateFields: ["lastChangedAt"]
|
|
30523
30489
|
};
|
|
30490
|
+
var DoorbellStatusSchema = object({
|
|
30491
|
+
/** Ms epoch of the last press. null = never observed since this provider started. */
|
|
30492
|
+
lastPressedAt: number().nullable(),
|
|
30493
|
+
/** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
|
|
30494
|
+
pressCountSinceStart: number()
|
|
30495
|
+
});
|
|
30496
|
+
var DoorbellPressEventSchema = object({
|
|
30497
|
+
deviceId: number(),
|
|
30498
|
+
timestamp: number()
|
|
30499
|
+
});
|
|
30500
|
+
/**
|
|
30501
|
+
* Doorbell button cap. Two kinds of provider serve it, and to every consumer
|
|
30502
|
+
* they are the same cap:
|
|
30503
|
+
*
|
|
30504
|
+
* - **Native** providers, registered per device by a driver addon through
|
|
30505
|
+
* `ctx.registerNativeCap` — a `DeviceType.Button` accessory with
|
|
30506
|
+
* `role: DeviceRole.Doorbell`, or the camera itself (Reolink registers at
|
|
30507
|
+
* camera level). They emit `onPressed` on every firmware ring.
|
|
30508
|
+
* - **A composed doorbell** (D670, D671): a camera's customization gives it
|
|
30509
|
+
* the cap, its `lastPressedAt` rising from the sources the operator
|
|
30510
|
+
* assigned in Customize → Doorbell, and the composer emits `onPressed`
|
|
30511
|
+
* from that field's advance (`fromState`).
|
|
30512
|
+
*
|
|
30513
|
+
* The DeviceEventPropagator re-emits `onPressed` on the camera parent.
|
|
30514
|
+
*/
|
|
30515
|
+
var doorbellCapability = {
|
|
30516
|
+
name: "doorbell",
|
|
30517
|
+
scope: "device",
|
|
30518
|
+
deviceNative: true,
|
|
30519
|
+
mode: "singleton",
|
|
30520
|
+
deviceTypes: [DeviceType.Button, DeviceType.Camera],
|
|
30521
|
+
methods: {},
|
|
30522
|
+
events: {
|
|
30523
|
+
/**
|
|
30524
|
+
* Fires once per physical press. Reolink delivers via Baichuan
|
|
30525
|
+
* push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
|
|
30526
|
+
* release/duration — it's a pulse.
|
|
30527
|
+
*/
|
|
30528
|
+
onPressed: {
|
|
30529
|
+
data: DoorbellPressEventSchema,
|
|
30530
|
+
fromState: {
|
|
30531
|
+
field: "lastPressedAt",
|
|
30532
|
+
on: "advance"
|
|
30533
|
+
}
|
|
30534
|
+
} },
|
|
30535
|
+
status: {
|
|
30536
|
+
schema: DoorbellStatusSchema,
|
|
30537
|
+
kind: "push"
|
|
30538
|
+
},
|
|
30539
|
+
/**
|
|
30540
|
+
* Runtime-state slice — last press timestamp + lifetime press count.
|
|
30541
|
+
* Mirrored by the kernel and readable via
|
|
30542
|
+
* `device.state.doorbell.value`. UIs can show "last ring 5m ago"
|
|
30543
|
+
* without subscribing.
|
|
30544
|
+
*/
|
|
30545
|
+
runtimeState: DoorbellStatusSchema,
|
|
30546
|
+
/**
|
|
30547
|
+
* 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.
|
|
30548
|
+
*
|
|
30549
|
+
* See `RuntimeStateDurability`. Enforced by
|
|
30550
|
+
* `scripts/check-runtime-state-durability.ts`.
|
|
30551
|
+
*/
|
|
30552
|
+
durability: "restored"
|
|
30553
|
+
};
|
|
30524
30554
|
/**
|
|
30525
30555
|
* Enum-state sensor — a string value picked from a finite option set.
|
|
30526
30556
|
* Drives HA `sensor` entries with `state_class: enum` (HVAC action
|
|
@@ -32660,39 +32690,14 @@ authKey: string().optional() }), object({
|
|
|
32660
32690
|
/** Human-readable error when `ok: false`. */
|
|
32661
32691
|
error: string().optional()
|
|
32662
32692
|
}), { kind: "mutation" });
|
|
32663
|
-
/**
|
|
32664
|
-
* Hardware / firmware motion sensor cap — binary detected state plus
|
|
32665
|
-
* a timestamp of the last observation. Distinct from
|
|
32666
|
-
* `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
|
|
32667
|
-
* `motion` is the lightweight readout from on-camera motion (Reolink
|
|
32668
|
-
* `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
|
|
32669
|
-
*
|
|
32670
|
-
* Native-motion providers also fan out to `detection.camera-native`
|
|
32671
|
-
* with `source: 'onboard'` so cross-cutting system services
|
|
32672
|
-
* (alert-center, advanced-notifier) can subscribe once and receive
|
|
32673
|
-
* motion from every camera.
|
|
32674
|
-
*/
|
|
32675
|
-
/**
|
|
32676
|
-
* How long after a camera's last rising edge `pipeline-analytics` closes the
|
|
32677
|
-
* motion EPISODE row it kept open for it (D475) — "il delay della cap", in
|
|
32678
|
-
* the operator's words. One authority for the whole system: every provider
|
|
32679
|
-
* that seeds `autoClearAfterMs` on a `Camera` device writes this SAME
|
|
32680
|
-
* constant while `detected: true` (never its own number — Hikvision used to
|
|
32681
|
-
* seed its internal 3 s inactivity timer here, which is a different clock for
|
|
32682
|
-
* a different purpose), and `MotionEpisodeTracker` imports it directly rather
|
|
32683
|
-
* than reading the live cap value on the hot path. A `Sensor` device (HA
|
|
32684
|
-
* binary sensor, Homematic) gets a genuine push both ways and has no episode
|
|
32685
|
-
* to close on a timer, so it writes `null`, never this constant.
|
|
32686
|
-
*/
|
|
32687
|
-
var MOTION_CLOSE_AFTER_MS = 15e3;
|
|
32688
32693
|
var MotionStatusSchema = object({
|
|
32689
32694
|
detected: boolean(),
|
|
32690
32695
|
/** Ms epoch of the last detected-true observation. Null if never detected. */
|
|
32691
32696
|
lastDetectedAt: number().nullable(),
|
|
32692
32697
|
/**
|
|
32693
|
-
* `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device
|
|
32694
|
-
* `null` while false and on every `Sensor`
|
|
32695
|
-
* constant's doc for the one-authority rule.
|
|
32698
|
+
* `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device (the
|
|
32699
|
+
* orchestrator writes it, D696), `null` while false and on every `Sensor`
|
|
32700
|
+
* device (D475) — see that constant's doc for the one-authority rule.
|
|
32696
32701
|
*
|
|
32697
32702
|
* ## Reading this field still arms nothing
|
|
32698
32703
|
*
|
|
@@ -32710,34 +32715,31 @@ var MotionStatusSchema = object({
|
|
|
32710
32715
|
* `addon-export-alexa/src/motion-clear-hold.ts` and
|
|
32711
32716
|
* `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
|
|
32712
32717
|
*
|
|
32713
|
-
* ## Who writes it
|
|
32714
|
-
*
|
|
32715
|
-
* - **Cameras** — the runner's phase machine, `active → watching` on
|
|
32716
|
-
* `cooldown_expired`, which then writes this slice with
|
|
32717
|
-
* `detected: false` (`handlePhaseChanged` in
|
|
32718
|
-
* `pipeline-runner/index.ts`). It produces the FALLING edge, which
|
|
32719
|
-
* matters most for the sources that only ever push a rising one:
|
|
32720
|
-
* Reolink emits `MotionOnMotionChanged { detected: true }` and never
|
|
32721
|
-
* a false.
|
|
32722
|
-
* - **Sensors** (Home Assistant binary sensors, Homematic) — the
|
|
32723
|
-
* provider pushes the false itself, from the upstream system's own
|
|
32724
|
-
* state change. No phase machine is involved.
|
|
32718
|
+
* ## Who writes it (D696)
|
|
32725
32719
|
*
|
|
32726
|
-
*
|
|
32720
|
+
* - **Cameras** — the orchestrator, and nothing else. It writes the camera's
|
|
32721
|
+
* EFFECTIVE motion (`addon-pipeline-orchestrator`
|
|
32722
|
+
* `camera-sensors/motion-slice.ts`), alongside the effective
|
|
32723
|
+
* `MotionOnMotionChanged` it emits or receives: the camera-sensors bridge
|
|
32724
|
+
* for a split camera, an unsplit emitter's direct event, the analyzer and
|
|
32725
|
+
* device activity, as the camera's `motionSources` counts them. A source
|
|
32726
|
+
* that never sends a clear falls one window after its last `true`.
|
|
32727
|
+
* `lastDetectedAt` moves only on an effective rise. No camera provider
|
|
32728
|
+
* writes this slice (not even a boot seed), and neither does the runner's
|
|
32729
|
+
* phase machine: its phase is "a session is attached" for every on-motion
|
|
32730
|
+
* session, not motion, and it now has its own `DetectionPhaseTransition`.
|
|
32731
|
+
* A provider's `isDetected` answers from the hub's slice.
|
|
32732
|
+
* - **Sensors** (Home Assistant binary sensors, Homematic, Matter, Alexa
|
|
32733
|
+
* imports) — the provider pushes both edges itself, from the upstream
|
|
32734
|
+
* system's own state change. That is the sensor's own fact.
|
|
32727
32735
|
*
|
|
32728
|
-
*
|
|
32729
|
-
*
|
|
32730
|
-
* `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
|
|
32731
|
-
* `setCapSlice(motionCapability, …)` on their own rising edge, and
|
|
32732
|
-
* Hikvision's comment says why: it read THIS docblock, agreed the
|
|
32733
|
-
* runner is canonical, and wrote anyway to avoid per-tick churn. So
|
|
32734
|
-
* two authorities can disagree about one slice, which this repo
|
|
32735
|
-
* forbids, and the doc said otherwise — which is worse than saying
|
|
32736
|
-
* nothing, because it reads as verification.
|
|
32736
|
+
* `scripts/check-onboard-motion-emitters.ts` refuses any other writer of a
|
|
32737
|
+
* `motion` slice; each sensor writer is a named exemption.
|
|
32737
32738
|
*
|
|
32738
|
-
* This
|
|
32739
|
-
*
|
|
32740
|
-
*
|
|
32739
|
+
* This replaces the D475 §4 rule ("the phase machine is the sole writer").
|
|
32740
|
+
* That rule was never true: Hikvision and Amcrest wrote the slice raw beside
|
|
32741
|
+
* it, every provider seeded it at boot, and every session left it
|
|
32742
|
+
* `detected: true` after its detach.
|
|
32741
32743
|
*/
|
|
32742
32744
|
autoClearAfterMs: number().nullable()
|
|
32743
32745
|
});
|
|
@@ -32809,11 +32811,12 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
|
|
|
32809
32811
|
*/
|
|
32810
32812
|
runtimeState: MotionStatusSchema,
|
|
32811
32813
|
/**
|
|
32812
|
-
* Runtime-state durability: **session** —
|
|
32814
|
+
* Runtime-state durability: **session** — the writer of this slice
|
|
32813
32815
|
* writes only on an EDGE, so a restored `detected: true` would stay
|
|
32814
32816
|
* frozen until the next one instead of being corrected. The next edge
|
|
32815
|
-
* re-publishes the real state
|
|
32816
|
-
*
|
|
32817
|
+
* re-publishes the real state, and the orchestrator re-publishes every
|
|
32818
|
+
* camera when it starts writing (D696; on who writes it, see
|
|
32819
|
+
* `autoClearAfterMs` above).
|
|
32817
32820
|
*
|
|
32818
32821
|
* See `RuntimeStateDurability`. Enforced by
|
|
32819
32822
|
* `scripts/check-runtime-state-durability.ts`.
|
|
@@ -35354,8 +35357,7 @@ var ptzAutotrackCapability = {
|
|
|
35354
35357
|
deviceNative: true,
|
|
35355
35358
|
mode: "singleton",
|
|
35356
35359
|
/**
|
|
35357
|
-
* Two kinds of provider behind one name, the same shape `snapshot`
|
|
35358
|
-
* `doorbell` use:
|
|
35360
|
+
* Two kinds of provider behind one name, the same shape `snapshot` uses:
|
|
35359
35361
|
*
|
|
35360
35362
|
* - **Native**: the camera's own firmware autotrack, registered per device by
|
|
35361
35363
|
* the driver when the probe says it exists (Reolink: yes; Hikvision:
|
|
@@ -35363,7 +35365,7 @@ var ptzAutotrackCapability = {
|
|
|
35363
35365
|
* - **Wrapper**: the emulated implementation (`@camstack/system`'s `autotrack` builtin),
|
|
35364
35366
|
* which follows a subject with `ptz.move` pulses driven by the detection
|
|
35365
35367
|
* pipeline. `defaultActive: false` — the operator binds it per camera in
|
|
35366
|
-
* the bindings UI
|
|
35368
|
+
* the bindings UI.
|
|
35367
35369
|
*
|
|
35368
35370
|
* The binding chooses WHICH implementation answers; `setEnabled` stays the
|
|
35369
35371
|
* one switch for the function either way. A camera never has both driving its
|
|
@@ -52831,6 +52833,25 @@ TimelapseRuleInputSchema.extend({
|
|
|
52831
52833
|
createdAt: number(),
|
|
52832
52834
|
updatedAt: number()
|
|
52833
52835
|
});
|
|
52836
|
+
async function readHubMotionDetected(deviceState, deviceId) {
|
|
52837
|
+
let slice;
|
|
52838
|
+
try {
|
|
52839
|
+
slice = await deviceState.getCapSlice.query({
|
|
52840
|
+
deviceId,
|
|
52841
|
+
capName: "motion"
|
|
52842
|
+
});
|
|
52843
|
+
} catch (err) {
|
|
52844
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
52845
|
+
throw new Error(`motion state of device ${deviceId} is unreadable: ${reason}`, { cause: err });
|
|
52846
|
+
}
|
|
52847
|
+
const detected = slice?.["detected"];
|
|
52848
|
+
if (typeof detected !== "boolean") throw new Error(`motion state of device ${deviceId} is not published yet (unknown)`);
|
|
52849
|
+
return detected;
|
|
52850
|
+
}
|
|
52851
|
+
MotionOnMotionChangedDataSchema.omit({ triggeredBy: true });
|
|
52852
|
+
function providerMotionEvent(source, data) {
|
|
52853
|
+
return createEvent(EventCategory.ProviderMotion, source, data);
|
|
52854
|
+
}
|
|
52834
52855
|
object({
|
|
52835
52856
|
/**
|
|
52836
52857
|
* Fraction of the box's own size added on EACH side before cutting.
|
|
@@ -55200,17 +55221,14 @@ var AmcrestCamera = class AmcrestCamera extends BaseDevice {
|
|
|
55200
55221
|
}
|
|
55201
55222
|
/** Register the native `motion` cap. Its mere presence (a `kind:'native'`
|
|
55202
55223
|
* `motion` binding) is what the orchestrator reads to default a
|
|
55203
|
-
* freshly-adopted camera to `motionSources:['onboard']`.
|
|
55224
|
+
* freshly-adopted camera to `motionSources:['onboard']`. `isDetected`
|
|
55225
|
+
* answers from the HUB's slice; an unreadable hub, or a slice nobody has
|
|
55226
|
+
* published yet, fails the call — never `false` for unknown (D49, D393). */
|
|
55204
55227
|
registerMotionCap() {
|
|
55205
55228
|
this.ctx.registerNativeCap(motionCapability, { isDetected: async ({ deviceId }) => {
|
|
55206
55229
|
if (deviceId !== this.id) throw new Error(`AmcrestCamera: motion deviceId mismatch, expected ${this.id}, got ${deviceId}`);
|
|
55207
|
-
return this.
|
|
55230
|
+
return readHubMotionDetected(this.ctx.api.deviceState, this.id);
|
|
55208
55231
|
} });
|
|
55209
|
-
this.setCapSlice(motionCapability, {
|
|
55210
|
-
detected: false,
|
|
55211
|
-
lastDetectedAt: null,
|
|
55212
|
-
autoClearAfterMs: null
|
|
55213
|
-
});
|
|
55214
55232
|
this.ctx.logger.info("amcrest: motion cap registered", { tags: { deviceId: this.id } });
|
|
55215
55233
|
}
|
|
55216
55234
|
/** Reusable event-source identity for every emit on this device. */
|
|
@@ -55222,10 +55240,12 @@ var AmcrestCamera = class AmcrestCamera extends BaseDevice {
|
|
|
55222
55240
|
deviceId: this.id
|
|
55223
55241
|
};
|
|
55224
55242
|
}
|
|
55225
|
-
/** Emit
|
|
55226
|
-
*
|
|
55243
|
+
/** Emit the camera's RAW onboard motion transition (`ProviderMotion`,
|
|
55244
|
+
* D673). The orchestrator's camera-sensors bridge re-emits it as
|
|
55245
|
+
* `MotionOnMotionChanged`; the runner subscribes to that and drives its
|
|
55246
|
+
* phase machine via `reportMotion`. */
|
|
55227
55247
|
emitMotion(detected, timestamp) {
|
|
55228
|
-
this.ctx.eventBus.emit(
|
|
55248
|
+
this.ctx.eventBus.emit(providerMotionEvent(this.eventSource(), {
|
|
55229
55249
|
deviceId: this.id,
|
|
55230
55250
|
detected,
|
|
55231
55251
|
timestamp,
|
|
@@ -55320,14 +55340,7 @@ var AmcrestCamera = class AmcrestCamera extends BaseDevice {
|
|
|
55320
55340
|
const wasActive = this.motionActive;
|
|
55321
55341
|
this.motionActive = true;
|
|
55322
55342
|
this.emitMotion(true, now);
|
|
55323
|
-
if (!wasActive) {
|
|
55324
|
-
this.setCapSlice(motionCapability, {
|
|
55325
|
-
detected: true,
|
|
55326
|
-
lastDetectedAt: now,
|
|
55327
|
-
autoClearAfterMs: MOTION_CLOSE_AFTER_MS
|
|
55328
|
-
});
|
|
55329
|
-
this.ctx.logger.info("amcrest: onboard motion started", { tags: { deviceId: this.id } });
|
|
55330
|
-
}
|
|
55343
|
+
if (!wasActive) this.ctx.logger.info("amcrest: onboard motion started", { tags: { deviceId: this.id } });
|
|
55331
55344
|
if (this.motionKeepaliveTimer === null) this.motionKeepaliveTimer = setInterval(() => {
|
|
55332
55345
|
this.emitMotion(true, Date.now());
|
|
55333
55346
|
}, AmcrestCamera.MOTION_KEEPALIVE_MS);
|
|
@@ -55337,12 +55350,6 @@ var AmcrestCamera = class AmcrestCamera extends BaseDevice {
|
|
|
55337
55350
|
if (!this.motionActive) return;
|
|
55338
55351
|
this.motionActive = false;
|
|
55339
55352
|
this.emitMotion(false, now);
|
|
55340
|
-
const lastDetectedAt = this.getCapSlice(motionCapability)?.lastDetectedAt ?? now;
|
|
55341
|
-
this.setCapSlice(motionCapability, {
|
|
55342
|
-
detected: false,
|
|
55343
|
-
lastDetectedAt,
|
|
55344
|
-
autoClearAfterMs: null
|
|
55345
|
-
});
|
|
55346
55353
|
this.ctx.logger.info("amcrest: onboard motion stopped", { tags: { deviceId: this.id } });
|
|
55347
55354
|
}
|
|
55348
55355
|
clearMotionKeepalive() {
|