@camstack/addon-provider-reolink 1.2.36 → 1.2.37

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
@@ -231012,6 +231012,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
231012
231012
  durationMs: Date.now() - startedAt
231013
231013
  };
231014
231014
  }
231015
+ if (confirmed && !observedAwake && parent !== null) this.watchHubChildAwake(parent).catch(() => {});
231015
231016
  return {
231016
231017
  awoke: true,
231017
231018
  durationMs: Date.now() - startedAt
@@ -231190,6 +231191,29 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
231190
231191
  this.lastProactiveWakeAt = Date.now();
231191
231192
  }
231192
231193
  /**
231194
+ * Post-confirm watch for a hub child whose wake lands on the consumer's
231195
+ * relay dial: re-read the parent's channel summary a few times over the
231196
+ * dial's wake window and commit `sleeping: false` the moment the firmware
231197
+ * reports it. Ends EARLY once committed; bounded hard so a dead link can't
231198
+ * leak a timer. Costs the camera nothing — the summary is the hub's own
231199
+ * mains-powered read.
231200
+ */
231201
+ async watchHubChildAwake(parent) {
231202
+ const deadline = Date.now() + 45e3;
231203
+ while (Date.now() < deadline) {
231204
+ await sleep$1(5e3);
231205
+ try {
231206
+ if ((await (await parent.getApi()).getNvrChannelsSummary({ channels: [this.getChannel()] })).devices.find((d) => d.channel === this.getChannel())?.sleeping === false) {
231207
+ if (this.commitSleepState(false, "hub-summary")) {
231208
+ this.ctx.logger.info("battery wakeForStream: hub child observed awake after the dial", { tags: { deviceId: this.id } });
231209
+ this.onWakeTransition("hub-summary").catch(() => {});
231210
+ }
231211
+ return;
231212
+ }
231213
+ } catch {}
231214
+ }
231215
+ }
231216
+ /**
231193
231217
  * Close the transient "waking" window on a wake that did NOT produce a
231194
231218
  * committed transition (ACK with no awake evidence, or a timeout).
231195
231219
  * `BatteryOnWakeStarted` opens it; normally the `sleeping: false` commit
@@ -236651,6 +236675,14 @@ function computeHealthCheckBackoffMs(consecutive) {
236651
236675
  //#endregion
236652
236676
  //#region src/reolink-hub.ts
236653
236677
  var HUB_DISCOVERY_REFRESH_TIMEOUT_MS = 8e3;
236678
+ /**
236679
+ * How often the hub re-reads its own channels summary to reconcile the
236680
+ * adopted children's sleep slices. 60 s: a naturally-waking camera (PIR,
236681
+ * schedule) is caught within a minute, and the play path has its own
236682
+ * faster confirm + post-dial watch, so this only ever carries background
236683
+ * drift. Never wakes a child — the summary is answered by the hub itself.
236684
+ */
236685
+ var HUB_CHILD_SLEEP_RECONCILE_MS = 6e4;
236654
236686
  var HUB_RECONNECT_BASE_MS = 2e3;
236655
236687
  var HUB_RECONNECT_MAX_MS = 3e4;
236656
236688
  /**
@@ -236684,6 +236716,8 @@ var ReolinkHub = class ReolinkHub extends BaseDevice {
236684
236716
  connectInFlight = null;
236685
236717
  reconnectAttempts = 0;
236686
236718
  reconnectTimer = null;
236719
+ /** Periodic child-sleep reconcile timer (armed in `onActivate`). */
236720
+ sleepReconcileTimer = null;
236687
236721
  shutdownRequested = false;
236688
236722
  /** Diagnostic Sessions snapshot — same shape as the camera's. */
236689
236723
  sessionsSnapshot = null;
@@ -236768,6 +236802,10 @@ var ReolinkHub = class ReolinkHub extends BaseDevice {
236768
236802
  this.ctx.logger.info("Reolink Hub: child unregistered externally — refreshing discovery", cid !== null ? { tags: { deviceId: cid } } : {});
236769
236803
  this.refreshDiscoveryFromCamera().catch(() => {});
236770
236804
  }));
236805
+ this.sleepReconcileTimer = setInterval(() => {
236806
+ this.refreshDiscoveryFromCamera().catch(() => {});
236807
+ }, HUB_CHILD_SLEEP_RECONCILE_MS);
236808
+ if (typeof this.sleepReconcileTimer.unref === "function") this.sleepReconcileTimer.unref();
236771
236809
  }
236772
236810
  eventUnsubscribers = [];
236773
236811
  /** Per-channel throttle for the unrouted-event warning (see
@@ -236779,6 +236817,10 @@ var ReolinkHub = class ReolinkHub extends BaseDevice {
236779
236817
  clearTimeout(this.reconnectTimer);
236780
236818
  this.reconnectTimer = null;
236781
236819
  }
236820
+ if (this.sleepReconcileTimer) {
236821
+ clearInterval(this.sleepReconcileTimer);
236822
+ this.sleepReconcileTimer = null;
236823
+ }
236782
236824
  for (const unsub of this.eventUnsubscribers) try {
236783
236825
  unsub();
236784
236826
  } catch {}
package/dist/addon.mjs CHANGED
@@ -230992,6 +230992,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
230992
230992
  durationMs: Date.now() - startedAt
230993
230993
  };
230994
230994
  }
230995
+ if (confirmed && !observedAwake && parent !== null) this.watchHubChildAwake(parent).catch(() => {});
230995
230996
  return {
230996
230997
  awoke: true,
230997
230998
  durationMs: Date.now() - startedAt
@@ -231170,6 +231171,29 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
231170
231171
  this.lastProactiveWakeAt = Date.now();
231171
231172
  }
231172
231173
  /**
231174
+ * Post-confirm watch for a hub child whose wake lands on the consumer's
231175
+ * relay dial: re-read the parent's channel summary a few times over the
231176
+ * dial's wake window and commit `sleeping: false` the moment the firmware
231177
+ * reports it. Ends EARLY once committed; bounded hard so a dead link can't
231178
+ * leak a timer. Costs the camera nothing — the summary is the hub's own
231179
+ * mains-powered read.
231180
+ */
231181
+ async watchHubChildAwake(parent) {
231182
+ const deadline = Date.now() + 45e3;
231183
+ while (Date.now() < deadline) {
231184
+ await sleep$1(5e3);
231185
+ try {
231186
+ if ((await (await parent.getApi()).getNvrChannelsSummary({ channels: [this.getChannel()] })).devices.find((d) => d.channel === this.getChannel())?.sleeping === false) {
231187
+ if (this.commitSleepState(false, "hub-summary")) {
231188
+ this.ctx.logger.info("battery wakeForStream: hub child observed awake after the dial", { tags: { deviceId: this.id } });
231189
+ this.onWakeTransition("hub-summary").catch(() => {});
231190
+ }
231191
+ return;
231192
+ }
231193
+ } catch {}
231194
+ }
231195
+ }
231196
+ /**
231173
231197
  * Close the transient "waking" window on a wake that did NOT produce a
231174
231198
  * committed transition (ACK with no awake evidence, or a timeout).
231175
231199
  * `BatteryOnWakeStarted` opens it; normally the `sleeping: false` commit
@@ -236631,6 +236655,14 @@ function computeHealthCheckBackoffMs(consecutive) {
236631
236655
  //#endregion
236632
236656
  //#region src/reolink-hub.ts
236633
236657
  var HUB_DISCOVERY_REFRESH_TIMEOUT_MS = 8e3;
236658
+ /**
236659
+ * How often the hub re-reads its own channels summary to reconcile the
236660
+ * adopted children's sleep slices. 60 s: a naturally-waking camera (PIR,
236661
+ * schedule) is caught within a minute, and the play path has its own
236662
+ * faster confirm + post-dial watch, so this only ever carries background
236663
+ * drift. Never wakes a child — the summary is answered by the hub itself.
236664
+ */
236665
+ var HUB_CHILD_SLEEP_RECONCILE_MS = 6e4;
236634
236666
  var HUB_RECONNECT_BASE_MS = 2e3;
236635
236667
  var HUB_RECONNECT_MAX_MS = 3e4;
236636
236668
  /**
@@ -236664,6 +236696,8 @@ var ReolinkHub = class ReolinkHub extends BaseDevice {
236664
236696
  connectInFlight = null;
236665
236697
  reconnectAttempts = 0;
236666
236698
  reconnectTimer = null;
236699
+ /** Periodic child-sleep reconcile timer (armed in `onActivate`). */
236700
+ sleepReconcileTimer = null;
236667
236701
  shutdownRequested = false;
236668
236702
  /** Diagnostic Sessions snapshot — same shape as the camera's. */
236669
236703
  sessionsSnapshot = null;
@@ -236748,6 +236782,10 @@ var ReolinkHub = class ReolinkHub extends BaseDevice {
236748
236782
  this.ctx.logger.info("Reolink Hub: child unregistered externally — refreshing discovery", cid !== null ? { tags: { deviceId: cid } } : {});
236749
236783
  this.refreshDiscoveryFromCamera().catch(() => {});
236750
236784
  }));
236785
+ this.sleepReconcileTimer = setInterval(() => {
236786
+ this.refreshDiscoveryFromCamera().catch(() => {});
236787
+ }, HUB_CHILD_SLEEP_RECONCILE_MS);
236788
+ if (typeof this.sleepReconcileTimer.unref === "function") this.sleepReconcileTimer.unref();
236751
236789
  }
236752
236790
  eventUnsubscribers = [];
236753
236791
  /** Per-channel throttle for the unrouted-event warning (see
@@ -236759,6 +236797,10 @@ var ReolinkHub = class ReolinkHub extends BaseDevice {
236759
236797
  clearTimeout(this.reconnectTimer);
236760
236798
  this.reconnectTimer = null;
236761
236799
  }
236800
+ if (this.sleepReconcileTimer) {
236801
+ clearInterval(this.sleepReconcileTimer);
236802
+ this.sleepReconcileTimer = null;
236803
+ }
236762
236804
  for (const unsub of this.eventUnsubscribers) try {
236763
236805
  unsub();
236764
236806
  } catch {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-reolink",
3
- "version": "1.2.36",
3
+ "version": "1.2.37",
4
4
  "description": "Reolink camera device provider addon for CamStack — native Baichuan protocol",
5
5
  "keywords": [
6
6
  "camstack",