@camstack/addon-provider-hikvision 1.2.143 → 1.2.144

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/addon.js CHANGED
@@ -19264,6 +19264,8 @@ var NcSystemEventKindSchema = _enum([
19264
19264
  "stream-offline",
19265
19265
  "node-online",
19266
19266
  "node-offline",
19267
+ "node-restarting",
19268
+ "node-updating",
19267
19269
  "node-inference-unavailable",
19268
19270
  "detection-blind",
19269
19271
  "addon-crash-loop",
@@ -33590,7 +33592,8 @@ var MotionStatusSchema = object({
33590
33592
  * writes this slice (not even a boot seed), and neither does the runner's
33591
33593
  * phase machine: its phase is "a session is attached" for every on-motion
33592
33594
  * session, not motion, and it now has its own `DetectionPhaseTransition`.
33593
- * A provider's `isDetected` answers from the hub's slice.
33595
+ * A provider's `isDetected` and `getStatus` answer from the hub's slice
33596
+ * (`hubMotionNativeProvider`).
33594
33597
  * - **Sensors** (Home Assistant binary sensors, Homematic, Matter, Alexa
33595
33598
  * imports) — the provider pushes both edges itself, from the upstream
33596
33599
  * system's own state change. That is the sensor's own fact.
@@ -53854,6 +53857,8 @@ new Map(Object.entries({
53854
53857
  "detection-blind": "device-events",
53855
53858
  "node-online": "system",
53856
53859
  "node-offline": "system",
53860
+ "node-restarting": "system",
53861
+ "node-updating": "system",
53857
53862
  "node-inference-unavailable": "system",
53858
53863
  "addon-crash-loop": "system",
53859
53864
  "addon-update-available": "system",
@@ -53931,6 +53936,7 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
53931
53936
  kinds: [
53932
53937
  "node-offline",
53933
53938
  "node-online",
53939
+ "node-restarting",
53934
53940
  "node-inference-unavailable"
53935
53941
  ]
53936
53942
  },
@@ -53952,6 +53958,7 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
53952
53958
  label: "Server & container updates",
53953
53959
  kinds: [
53954
53960
  "server-update-available",
53961
+ "node-updating",
53955
53962
  "server-updated",
53956
53963
  "wrapper-update-available"
53957
53964
  ]
@@ -54099,6 +54106,7 @@ var STATE_SUMMARY_SECTION_VARS = [
54099
54106
  kinds: [
54100
54107
  "node-offline",
54101
54108
  "node-online",
54109
+ "node-restarting",
54102
54110
  "node-inference-unavailable"
54103
54111
  ]
54104
54112
  },
@@ -54120,6 +54128,7 @@ var STATE_SUMMARY_SECTION_VARS = [
54120
54128
  example: "server 1.2.377 → 1.2.378",
54121
54129
  kinds: [
54122
54130
  "server-update-available",
54131
+ "node-updating",
54123
54132
  "server-updated",
54124
54133
  "wrapper-update-available"
54125
54134
  ]
@@ -54575,10 +54584,9 @@ TimelapseRuleInputSchema.extend({
54575
54584
  createdAt: number(),
54576
54585
  updatedAt: number()
54577
54586
  });
54578
- async function readHubMotionDetected(deviceState, deviceId) {
54579
- let slice;
54587
+ async function readSlice(deviceState, deviceId) {
54580
54588
  try {
54581
- slice = await deviceState.getCapSlice.query({
54589
+ return await deviceState.getCapSlice.query({
54582
54590
  deviceId,
54583
54591
  capName: "motion"
54584
54592
  });
@@ -54586,10 +54594,44 @@ async function readHubMotionDetected(deviceState, deviceId) {
54586
54594
  const reason = err instanceof Error ? err.message : String(err);
54587
54595
  throw new Error(`motion state of device ${deviceId} is unreadable: ${reason}`, { cause: err });
54588
54596
  }
54589
- const detected = slice?.["detected"];
54597
+ }
54598
+ /**
54599
+ * The hub's `motion` slice as a `MotionStatus`, or `null` when nobody has
54600
+ * published it since the hub started. Throws when the hub does not answer or
54601
+ * the slice is malformed — never a made-up "no motion".
54602
+ */
54603
+ async function readHubMotionStatus(deviceState, deviceId) {
54604
+ const slice = await readSlice(deviceState, deviceId);
54605
+ if (slice === null) return null;
54606
+ const parsed = MotionStatusSchema.safeParse(slice);
54607
+ if (!parsed.success) throw new Error(`motion state of device ${deviceId} is malformed on the hub: ${parsed.error.message}`);
54608
+ return parsed.data;
54609
+ }
54610
+ async function readHubMotionDetected(deviceState, deviceId) {
54611
+ const detected = (await readSlice(deviceState, deviceId))?.["detected"];
54590
54612
  if (typeof detected !== "boolean") throw new Error(`motion state of device ${deviceId} is not published yet (unknown)`);
54591
54613
  return detected;
54592
54614
  }
54615
+ /**
54616
+ * The native `motion` provider of a camera whose slice the orchestrator writes
54617
+ * (D696): `isDetected` AND `getStatus`, both from the hub. `owner` names the
54618
+ * provider class in the deviceId-mismatch error.
54619
+ */
54620
+ function hubMotionNativeProvider(deviceState, deviceId, owner) {
54621
+ const ownDevice = (asked) => {
54622
+ if (asked !== deviceId) throw new Error(`${owner}: motion deviceId mismatch, expected ${deviceId}, got ${asked}`);
54623
+ };
54624
+ return {
54625
+ isDetected: async ({ deviceId: asked }) => {
54626
+ ownDevice(asked);
54627
+ return readHubMotionDetected(deviceState, deviceId);
54628
+ },
54629
+ getStatus: async ({ deviceId: asked }) => {
54630
+ ownDevice(asked);
54631
+ return readHubMotionStatus(deviceState, deviceId);
54632
+ }
54633
+ };
54634
+ }
54593
54635
  MotionOnMotionChangedDataSchema.omit({ triggeredBy: true });
54594
54636
  function providerMotionEvent(source, data) {
54595
54637
  return createEvent(EventCategory.ProviderMotion, source, data);
@@ -66965,15 +67007,14 @@ var HikvisionCamera = class HikvisionCamera extends BaseDevice {
66965
67007
  * The native `motion` cap. Its presence is what defaults the camera to
66966
67008
  * `motionSources: ['onboard']`. This provider writes NO `motion` slice (D696):
66967
67009
  * the orchestrator is its only writer, with the EFFECTIVE motion, on the hub.
66968
- * `isDetected` therefore answers from the hub's slice; an unreadable hub, or
66969
- * a slice nobody has published since the hub started, makes the call fail.
66970
- * It never answers `false` for "unknown" (D49, D393).
67010
+ * `isDetected` AND `getStatus` therefore answer from the hub's slice
67011
+ * (`hubMotionNativeProvider`; without its own `getStatus` the framework's
67012
+ * default reads this process's empty local state and answers `null`). An
67013
+ * unreadable hub fails both; never `false` for "unknown" (D49, D393).
66971
67014
  */
66972
67015
  registerMotionCap() {
66973
- this.ctx.registerNativeCap(motionCapability, { isDetected: async ({ deviceId }) => {
66974
- if (deviceId !== this.id) throw new Error(`HikvisionCamera: deviceId mismatch, expected ${this.id}, got ${deviceId}`);
66975
- return readHubMotionDetected(this.ctx.api.deviceState, this.id);
66976
- } });
67016
+ const motionProvider = hubMotionNativeProvider(this.ctx.api.deviceState, this.id, "HikvisionCamera");
67017
+ this.ctx.registerNativeCap(motionCapability, motionProvider);
66977
67018
  }
66978
67019
  handleMotionEvent(ev, camStreamId) {
66979
67020
  const now = ev.observedAt;
package/dist/addon.mjs CHANGED
@@ -19243,6 +19243,8 @@ var NcSystemEventKindSchema = _enum([
19243
19243
  "stream-offline",
19244
19244
  "node-online",
19245
19245
  "node-offline",
19246
+ "node-restarting",
19247
+ "node-updating",
19246
19248
  "node-inference-unavailable",
19247
19249
  "detection-blind",
19248
19250
  "addon-crash-loop",
@@ -33569,7 +33571,8 @@ var MotionStatusSchema = object({
33569
33571
  * writes this slice (not even a boot seed), and neither does the runner's
33570
33572
  * phase machine: its phase is "a session is attached" for every on-motion
33571
33573
  * session, not motion, and it now has its own `DetectionPhaseTransition`.
33572
- * A provider's `isDetected` answers from the hub's slice.
33574
+ * A provider's `isDetected` and `getStatus` answer from the hub's slice
33575
+ * (`hubMotionNativeProvider`).
33573
33576
  * - **Sensors** (Home Assistant binary sensors, Homematic, Matter, Alexa
33574
33577
  * imports) — the provider pushes both edges itself, from the upstream
33575
33578
  * system's own state change. That is the sensor's own fact.
@@ -53833,6 +53836,8 @@ new Map(Object.entries({
53833
53836
  "detection-blind": "device-events",
53834
53837
  "node-online": "system",
53835
53838
  "node-offline": "system",
53839
+ "node-restarting": "system",
53840
+ "node-updating": "system",
53836
53841
  "node-inference-unavailable": "system",
53837
53842
  "addon-crash-loop": "system",
53838
53843
  "addon-update-available": "system",
@@ -53910,6 +53915,7 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
53910
53915
  kinds: [
53911
53916
  "node-offline",
53912
53917
  "node-online",
53918
+ "node-restarting",
53913
53919
  "node-inference-unavailable"
53914
53920
  ]
53915
53921
  },
@@ -53931,6 +53937,7 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
53931
53937
  label: "Server & container updates",
53932
53938
  kinds: [
53933
53939
  "server-update-available",
53940
+ "node-updating",
53934
53941
  "server-updated",
53935
53942
  "wrapper-update-available"
53936
53943
  ]
@@ -54078,6 +54085,7 @@ var STATE_SUMMARY_SECTION_VARS = [
54078
54085
  kinds: [
54079
54086
  "node-offline",
54080
54087
  "node-online",
54088
+ "node-restarting",
54081
54089
  "node-inference-unavailable"
54082
54090
  ]
54083
54091
  },
@@ -54099,6 +54107,7 @@ var STATE_SUMMARY_SECTION_VARS = [
54099
54107
  example: "server 1.2.377 → 1.2.378",
54100
54108
  kinds: [
54101
54109
  "server-update-available",
54110
+ "node-updating",
54102
54111
  "server-updated",
54103
54112
  "wrapper-update-available"
54104
54113
  ]
@@ -54554,10 +54563,9 @@ TimelapseRuleInputSchema.extend({
54554
54563
  createdAt: number(),
54555
54564
  updatedAt: number()
54556
54565
  });
54557
- async function readHubMotionDetected(deviceState, deviceId) {
54558
- let slice;
54566
+ async function readSlice(deviceState, deviceId) {
54559
54567
  try {
54560
- slice = await deviceState.getCapSlice.query({
54568
+ return await deviceState.getCapSlice.query({
54561
54569
  deviceId,
54562
54570
  capName: "motion"
54563
54571
  });
@@ -54565,10 +54573,44 @@ async function readHubMotionDetected(deviceState, deviceId) {
54565
54573
  const reason = err instanceof Error ? err.message : String(err);
54566
54574
  throw new Error(`motion state of device ${deviceId} is unreadable: ${reason}`, { cause: err });
54567
54575
  }
54568
- const detected = slice?.["detected"];
54576
+ }
54577
+ /**
54578
+ * The hub's `motion` slice as a `MotionStatus`, or `null` when nobody has
54579
+ * published it since the hub started. Throws when the hub does not answer or
54580
+ * the slice is malformed — never a made-up "no motion".
54581
+ */
54582
+ async function readHubMotionStatus(deviceState, deviceId) {
54583
+ const slice = await readSlice(deviceState, deviceId);
54584
+ if (slice === null) return null;
54585
+ const parsed = MotionStatusSchema.safeParse(slice);
54586
+ if (!parsed.success) throw new Error(`motion state of device ${deviceId} is malformed on the hub: ${parsed.error.message}`);
54587
+ return parsed.data;
54588
+ }
54589
+ async function readHubMotionDetected(deviceState, deviceId) {
54590
+ const detected = (await readSlice(deviceState, deviceId))?.["detected"];
54569
54591
  if (typeof detected !== "boolean") throw new Error(`motion state of device ${deviceId} is not published yet (unknown)`);
54570
54592
  return detected;
54571
54593
  }
54594
+ /**
54595
+ * The native `motion` provider of a camera whose slice the orchestrator writes
54596
+ * (D696): `isDetected` AND `getStatus`, both from the hub. `owner` names the
54597
+ * provider class in the deviceId-mismatch error.
54598
+ */
54599
+ function hubMotionNativeProvider(deviceState, deviceId, owner) {
54600
+ const ownDevice = (asked) => {
54601
+ if (asked !== deviceId) throw new Error(`${owner}: motion deviceId mismatch, expected ${deviceId}, got ${asked}`);
54602
+ };
54603
+ return {
54604
+ isDetected: async ({ deviceId: asked }) => {
54605
+ ownDevice(asked);
54606
+ return readHubMotionDetected(deviceState, deviceId);
54607
+ },
54608
+ getStatus: async ({ deviceId: asked }) => {
54609
+ ownDevice(asked);
54610
+ return readHubMotionStatus(deviceState, deviceId);
54611
+ }
54612
+ };
54613
+ }
54572
54614
  MotionOnMotionChangedDataSchema.omit({ triggeredBy: true });
54573
54615
  function providerMotionEvent(source, data) {
54574
54616
  return createEvent(EventCategory.ProviderMotion, source, data);
@@ -66944,15 +66986,14 @@ var HikvisionCamera = class HikvisionCamera extends BaseDevice {
66944
66986
  * The native `motion` cap. Its presence is what defaults the camera to
66945
66987
  * `motionSources: ['onboard']`. This provider writes NO `motion` slice (D696):
66946
66988
  * the orchestrator is its only writer, with the EFFECTIVE motion, on the hub.
66947
- * `isDetected` therefore answers from the hub's slice; an unreadable hub, or
66948
- * a slice nobody has published since the hub started, makes the call fail.
66949
- * It never answers `false` for "unknown" (D49, D393).
66989
+ * `isDetected` AND `getStatus` therefore answer from the hub's slice
66990
+ * (`hubMotionNativeProvider`; without its own `getStatus` the framework's
66991
+ * default reads this process's empty local state and answers `null`). An
66992
+ * unreadable hub fails both; never `false` for "unknown" (D49, D393).
66950
66993
  */
66951
66994
  registerMotionCap() {
66952
- this.ctx.registerNativeCap(motionCapability, { isDetected: async ({ deviceId }) => {
66953
- if (deviceId !== this.id) throw new Error(`HikvisionCamera: deviceId mismatch, expected ${this.id}, got ${deviceId}`);
66954
- return readHubMotionDetected(this.ctx.api.deviceState, this.id);
66955
- } });
66995
+ const motionProvider = hubMotionNativeProvider(this.ctx.api.deviceState, this.id, "HikvisionCamera");
66996
+ this.ctx.registerNativeCap(motionCapability, motionProvider);
66956
66997
  }
66957
66998
  handleMotionEvent(ev, camStreamId) {
66958
66999
  const now = ev.observedAt;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-hikvision",
3
- "version": "1.2.143",
3
+ "version": "1.2.144",
4
4
  "description": "Hikvision camera device provider addon for CamStack — ISAPI over HTTP(S) with digest auth (snapshot, alarm stream, RTSP discovery)",
5
5
  "keywords": [
6
6
  "camstack",