@camstack/addon-provider-reolink 1.2.176 → 1.2.177

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
@@ -19584,6 +19584,8 @@ var NcSystemEventKindSchema = _enum([
19584
19584
  "stream-offline",
19585
19585
  "node-online",
19586
19586
  "node-offline",
19587
+ "node-restarting",
19588
+ "node-updating",
19587
19589
  "node-inference-unavailable",
19588
19590
  "detection-blind",
19589
19591
  "addon-crash-loop",
@@ -33910,7 +33912,8 @@ var MotionStatusSchema = object({
33910
33912
  * writes this slice (not even a boot seed), and neither does the runner's
33911
33913
  * phase machine: its phase is "a session is attached" for every on-motion
33912
33914
  * session, not motion, and it now has its own `DetectionPhaseTransition`.
33913
- * A provider's `isDetected` answers from the hub's slice.
33915
+ * A provider's `isDetected` and `getStatus` answer from the hub's slice
33916
+ * (`hubMotionNativeProvider`).
33914
33917
  * - **Sensors** (Home Assistant binary sensors, Homematic, Matter, Alexa
33915
33918
  * imports) — the provider pushes both edges itself, from the upstream
33916
33919
  * system's own state change. That is the sensor's own fact.
@@ -54128,6 +54131,8 @@ new Map(Object.entries({
54128
54131
  "detection-blind": "device-events",
54129
54132
  "node-online": "system",
54130
54133
  "node-offline": "system",
54134
+ "node-restarting": "system",
54135
+ "node-updating": "system",
54131
54136
  "node-inference-unavailable": "system",
54132
54137
  "addon-crash-loop": "system",
54133
54138
  "addon-update-available": "system",
@@ -54205,6 +54210,7 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
54205
54210
  kinds: [
54206
54211
  "node-offline",
54207
54212
  "node-online",
54213
+ "node-restarting",
54208
54214
  "node-inference-unavailable"
54209
54215
  ]
54210
54216
  },
@@ -54226,6 +54232,7 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
54226
54232
  label: "Server & container updates",
54227
54233
  kinds: [
54228
54234
  "server-update-available",
54235
+ "node-updating",
54229
54236
  "server-updated",
54230
54237
  "wrapper-update-available"
54231
54238
  ]
@@ -54373,6 +54380,7 @@ var STATE_SUMMARY_SECTION_VARS = [
54373
54380
  kinds: [
54374
54381
  "node-offline",
54375
54382
  "node-online",
54383
+ "node-restarting",
54376
54384
  "node-inference-unavailable"
54377
54385
  ]
54378
54386
  },
@@ -54394,6 +54402,7 @@ var STATE_SUMMARY_SECTION_VARS = [
54394
54402
  example: "server 1.2.377 → 1.2.378",
54395
54403
  kinds: [
54396
54404
  "server-update-available",
54405
+ "node-updating",
54397
54406
  "server-updated",
54398
54407
  "wrapper-update-available"
54399
54408
  ]
@@ -54849,10 +54858,9 @@ TimelapseRuleInputSchema.extend({
54849
54858
  createdAt: number(),
54850
54859
  updatedAt: number()
54851
54860
  });
54852
- async function readHubMotionDetected(deviceState, deviceId) {
54853
- let slice;
54861
+ async function readSlice(deviceState, deviceId) {
54854
54862
  try {
54855
- slice = await deviceState.getCapSlice.query({
54863
+ return await deviceState.getCapSlice.query({
54856
54864
  deviceId,
54857
54865
  capName: "motion"
54858
54866
  });
@@ -54860,10 +54868,44 @@ async function readHubMotionDetected(deviceState, deviceId) {
54860
54868
  const reason = err instanceof Error ? err.message : String(err);
54861
54869
  throw new Error(`motion state of device ${deviceId} is unreadable: ${reason}`, { cause: err });
54862
54870
  }
54863
- const detected = slice?.["detected"];
54871
+ }
54872
+ /**
54873
+ * The hub's `motion` slice as a `MotionStatus`, or `null` when nobody has
54874
+ * published it since the hub started. Throws when the hub does not answer or
54875
+ * the slice is malformed — never a made-up "no motion".
54876
+ */
54877
+ async function readHubMotionStatus(deviceState, deviceId) {
54878
+ const slice = await readSlice(deviceState, deviceId);
54879
+ if (slice === null) return null;
54880
+ const parsed = MotionStatusSchema.safeParse(slice);
54881
+ if (!parsed.success) throw new Error(`motion state of device ${deviceId} is malformed on the hub: ${parsed.error.message}`);
54882
+ return parsed.data;
54883
+ }
54884
+ async function readHubMotionDetected(deviceState, deviceId) {
54885
+ const detected = (await readSlice(deviceState, deviceId))?.["detected"];
54864
54886
  if (typeof detected !== "boolean") throw new Error(`motion state of device ${deviceId} is not published yet (unknown)`);
54865
54887
  return detected;
54866
54888
  }
54889
+ /**
54890
+ * The native `motion` provider of a camera whose slice the orchestrator writes
54891
+ * (D696): `isDetected` AND `getStatus`, both from the hub. `owner` names the
54892
+ * provider class in the deviceId-mismatch error.
54893
+ */
54894
+ function hubMotionNativeProvider(deviceState, deviceId, owner) {
54895
+ const ownDevice = (asked) => {
54896
+ if (asked !== deviceId) throw new Error(`${owner}: motion deviceId mismatch, expected ${deviceId}, got ${asked}`);
54897
+ };
54898
+ return {
54899
+ isDetected: async ({ deviceId: asked }) => {
54900
+ ownDevice(asked);
54901
+ return readHubMotionDetected(deviceState, deviceId);
54902
+ },
54903
+ getStatus: async ({ deviceId: asked }) => {
54904
+ ownDevice(asked);
54905
+ return readHubMotionStatus(deviceState, deviceId);
54906
+ }
54907
+ };
54908
+ }
54867
54909
  MotionOnMotionChangedDataSchema.omit({ triggeredBy: true });
54868
54910
  function providerMotionEvent(source, data) {
54869
54911
  return createEvent(EventCategory.ProviderMotion, source, data);
@@ -166983,16 +167025,14 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
166983
167025
  * `handleSimpleEvent` emits its raw push as `ProviderMotion` (`source:
166984
167026
  * 'onboard'`, D673), the orchestrator's camera-sensors bridge turns it into
166985
167027
  * the effective `MotionOnMotionChanged`, and the orchestrator is the slice's
166986
- * only writer, with that effective value, on the hub. `isDetected`
166987
- * therefore answers from the HUB's slice; an unreadable hub, or a slice
166988
- * nobody has published since the hub started, fails the call. It never
166989
- * answers `false` for "unknown" (D49, D393).
167028
+ * only writer, with that effective value, on the hub. `isDetected` AND
167029
+ * `getStatus` therefore answer from the HUB's slice
167030
+ * (`hubMotionNativeProvider`); an unreadable hub fails both. Never `false`
167031
+ * for "unknown" (D49, D393).
166990
167032
  */
166991
167033
  registerMotionCap() {
166992
- this.ctx.registerNativeCap(motionCapability, { isDetected: async ({ deviceId }) => {
166993
- if (deviceId !== this.id) throw new Error(`ReolinkCamera: deviceId mismatch, expected ${this.id}, got ${deviceId}`);
166994
- return readHubMotionDetected(this.ctx.api.deviceState, this.id);
166995
- } });
167034
+ const motionProvider = hubMotionNativeProvider(this.ctx.api.deviceState, this.id, "ReolinkCamera");
167035
+ this.ctx.registerNativeCap(motionCapability, motionProvider);
166996
167036
  }
166997
167037
  registerNetworkLink() {
166998
167038
  this.ctx.registerNativeCap(networkLinkCapability, { getStatus: async ({ deviceId }) => {
package/dist/addon.mjs CHANGED
@@ -19576,6 +19576,8 @@ var NcSystemEventKindSchema = _enum([
19576
19576
  "stream-offline",
19577
19577
  "node-online",
19578
19578
  "node-offline",
19579
+ "node-restarting",
19580
+ "node-updating",
19579
19581
  "node-inference-unavailable",
19580
19582
  "detection-blind",
19581
19583
  "addon-crash-loop",
@@ -33902,7 +33904,8 @@ var MotionStatusSchema = object({
33902
33904
  * writes this slice (not even a boot seed), and neither does the runner's
33903
33905
  * phase machine: its phase is "a session is attached" for every on-motion
33904
33906
  * session, not motion, and it now has its own `DetectionPhaseTransition`.
33905
- * A provider's `isDetected` answers from the hub's slice.
33907
+ * A provider's `isDetected` and `getStatus` answer from the hub's slice
33908
+ * (`hubMotionNativeProvider`).
33906
33909
  * - **Sensors** (Home Assistant binary sensors, Homematic, Matter, Alexa
33907
33910
  * imports) — the provider pushes both edges itself, from the upstream
33908
33911
  * system's own state change. That is the sensor's own fact.
@@ -54120,6 +54123,8 @@ new Map(Object.entries({
54120
54123
  "detection-blind": "device-events",
54121
54124
  "node-online": "system",
54122
54125
  "node-offline": "system",
54126
+ "node-restarting": "system",
54127
+ "node-updating": "system",
54123
54128
  "node-inference-unavailable": "system",
54124
54129
  "addon-crash-loop": "system",
54125
54130
  "addon-update-available": "system",
@@ -54197,6 +54202,7 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
54197
54202
  kinds: [
54198
54203
  "node-offline",
54199
54204
  "node-online",
54205
+ "node-restarting",
54200
54206
  "node-inference-unavailable"
54201
54207
  ]
54202
54208
  },
@@ -54218,6 +54224,7 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
54218
54224
  label: "Server & container updates",
54219
54225
  kinds: [
54220
54226
  "server-update-available",
54227
+ "node-updating",
54221
54228
  "server-updated",
54222
54229
  "wrapper-update-available"
54223
54230
  ]
@@ -54365,6 +54372,7 @@ var STATE_SUMMARY_SECTION_VARS = [
54365
54372
  kinds: [
54366
54373
  "node-offline",
54367
54374
  "node-online",
54375
+ "node-restarting",
54368
54376
  "node-inference-unavailable"
54369
54377
  ]
54370
54378
  },
@@ -54386,6 +54394,7 @@ var STATE_SUMMARY_SECTION_VARS = [
54386
54394
  example: "server 1.2.377 → 1.2.378",
54387
54395
  kinds: [
54388
54396
  "server-update-available",
54397
+ "node-updating",
54389
54398
  "server-updated",
54390
54399
  "wrapper-update-available"
54391
54400
  ]
@@ -54841,10 +54850,9 @@ TimelapseRuleInputSchema.extend({
54841
54850
  createdAt: number(),
54842
54851
  updatedAt: number()
54843
54852
  });
54844
- async function readHubMotionDetected(deviceState, deviceId) {
54845
- let slice;
54853
+ async function readSlice(deviceState, deviceId) {
54846
54854
  try {
54847
- slice = await deviceState.getCapSlice.query({
54855
+ return await deviceState.getCapSlice.query({
54848
54856
  deviceId,
54849
54857
  capName: "motion"
54850
54858
  });
@@ -54852,10 +54860,44 @@ async function readHubMotionDetected(deviceState, deviceId) {
54852
54860
  const reason = err instanceof Error ? err.message : String(err);
54853
54861
  throw new Error(`motion state of device ${deviceId} is unreadable: ${reason}`, { cause: err });
54854
54862
  }
54855
- const detected = slice?.["detected"];
54863
+ }
54864
+ /**
54865
+ * The hub's `motion` slice as a `MotionStatus`, or `null` when nobody has
54866
+ * published it since the hub started. Throws when the hub does not answer or
54867
+ * the slice is malformed — never a made-up "no motion".
54868
+ */
54869
+ async function readHubMotionStatus(deviceState, deviceId) {
54870
+ const slice = await readSlice(deviceState, deviceId);
54871
+ if (slice === null) return null;
54872
+ const parsed = MotionStatusSchema.safeParse(slice);
54873
+ if (!parsed.success) throw new Error(`motion state of device ${deviceId} is malformed on the hub: ${parsed.error.message}`);
54874
+ return parsed.data;
54875
+ }
54876
+ async function readHubMotionDetected(deviceState, deviceId) {
54877
+ const detected = (await readSlice(deviceState, deviceId))?.["detected"];
54856
54878
  if (typeof detected !== "boolean") throw new Error(`motion state of device ${deviceId} is not published yet (unknown)`);
54857
54879
  return detected;
54858
54880
  }
54881
+ /**
54882
+ * The native `motion` provider of a camera whose slice the orchestrator writes
54883
+ * (D696): `isDetected` AND `getStatus`, both from the hub. `owner` names the
54884
+ * provider class in the deviceId-mismatch error.
54885
+ */
54886
+ function hubMotionNativeProvider(deviceState, deviceId, owner) {
54887
+ const ownDevice = (asked) => {
54888
+ if (asked !== deviceId) throw new Error(`${owner}: motion deviceId mismatch, expected ${deviceId}, got ${asked}`);
54889
+ };
54890
+ return {
54891
+ isDetected: async ({ deviceId: asked }) => {
54892
+ ownDevice(asked);
54893
+ return readHubMotionDetected(deviceState, deviceId);
54894
+ },
54895
+ getStatus: async ({ deviceId: asked }) => {
54896
+ ownDevice(asked);
54897
+ return readHubMotionStatus(deviceState, deviceId);
54898
+ }
54899
+ };
54900
+ }
54859
54901
  MotionOnMotionChangedDataSchema.omit({ triggeredBy: true });
54860
54902
  function providerMotionEvent(source, data) {
54861
54903
  return createEvent(EventCategory.ProviderMotion, source, data);
@@ -166975,16 +167017,14 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
166975
167017
  * `handleSimpleEvent` emits its raw push as `ProviderMotion` (`source:
166976
167018
  * 'onboard'`, D673), the orchestrator's camera-sensors bridge turns it into
166977
167019
  * the effective `MotionOnMotionChanged`, and the orchestrator is the slice's
166978
- * only writer, with that effective value, on the hub. `isDetected`
166979
- * therefore answers from the HUB's slice; an unreadable hub, or a slice
166980
- * nobody has published since the hub started, fails the call. It never
166981
- * answers `false` for "unknown" (D49, D393).
167020
+ * only writer, with that effective value, on the hub. `isDetected` AND
167021
+ * `getStatus` therefore answer from the HUB's slice
167022
+ * (`hubMotionNativeProvider`); an unreadable hub fails both. Never `false`
167023
+ * for "unknown" (D49, D393).
166982
167024
  */
166983
167025
  registerMotionCap() {
166984
- this.ctx.registerNativeCap(motionCapability, { isDetected: async ({ deviceId }) => {
166985
- if (deviceId !== this.id) throw new Error(`ReolinkCamera: deviceId mismatch, expected ${this.id}, got ${deviceId}`);
166986
- return readHubMotionDetected(this.ctx.api.deviceState, this.id);
166987
- } });
167026
+ const motionProvider = hubMotionNativeProvider(this.ctx.api.deviceState, this.id, "ReolinkCamera");
167027
+ this.ctx.registerNativeCap(motionCapability, motionProvider);
166988
167028
  }
166989
167029
  registerNetworkLink() {
166990
167030
  this.ctx.registerNativeCap(networkLinkCapability, { getStatus: async ({ deviceId }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-reolink",
3
- "version": "1.2.176",
3
+ "version": "1.2.177",
4
4
  "description": "Reolink camera device provider addon for CamStack — native Baichuan protocol",
5
5
  "keywords": [
6
6
  "camstack",