@camstack/addon-provider-reolink 1.2.31 → 1.2.33

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
@@ -230964,31 +230964,45 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
230964
230964
  const CONFIRM_TIMEOUT_MS = 1e4;
230965
230965
  const CONFIRM_POLL_MS = 1e3;
230966
230966
  const confirmDeadline = Date.now() + CONFIRM_TIMEOUT_MS;
230967
+ const parent = await this.getParentHub();
230967
230968
  let confirmed = false;
230968
230969
  while (Date.now() < confirmDeadline) {
230969
- let state = null;
230970
- try {
230971
- state = api.getSleepStatus({ channel: this.getChannel() }).state;
230972
- } catch {
230973
- state = null;
230974
- }
230975
- if (state === "awake") {
230976
- confirmed = true;
230977
- break;
230970
+ if (parent !== null) try {
230971
+ if ((await (await parent.getApi()).getNvrChannelsSummary({ channels: [this.getChannel()] })).devices.find((d) => d.channel === this.getChannel())?.sleeping === false) {
230972
+ confirmed = true;
230973
+ break;
230974
+ }
230975
+ } catch {}
230976
+ else {
230977
+ let state = null;
230978
+ try {
230979
+ state = api.getSleepStatus({ channel: this.getChannel() }).state;
230980
+ } catch {
230981
+ state = null;
230982
+ }
230983
+ if (state === "awake") {
230984
+ confirmed = true;
230985
+ break;
230986
+ }
230978
230987
  }
230979
230988
  await sleep$1(CONFIRM_POLL_MS);
230980
230989
  }
230981
- if (confirmed && this.commitSleepState(false, "sleep-poll")) {
230990
+ const confirmSource = parent !== null ? "hub-summary" : "sleep-poll";
230991
+ if (confirmed && this.commitSleepState(false, confirmSource)) {
230982
230992
  this.ctx.logger.info("battery wakeForStream: wake confirmed — driving wake transition", {
230983
230993
  tags: { deviceId: this.id },
230984
- meta: { confirmMs: Date.now() - startedAt }
230994
+ meta: {
230995
+ confirmMs: Date.now() - startedAt,
230996
+ source: confirmSource
230997
+ }
230985
230998
  });
230986
- this.onWakeTransition("sleep-poll").catch(() => {});
230999
+ this.onWakeTransition(confirmSource).catch(() => {});
230987
231000
  } else if (!confirmed) {
230988
231001
  this.ctx.logger.warn("battery wakeForStream: ACK received but no awake evidence inside the confirm window", {
230989
231002
  tags: { deviceId: this.id },
230990
231003
  meta: { confirmTimeoutMs: CONFIRM_TIMEOUT_MS }
230991
231004
  });
231005
+ this.emitWakeSettled();
230992
231006
  return {
230993
231007
  awoke: false,
230994
231008
  durationMs: Date.now() - startedAt
@@ -231006,6 +231020,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
231006
231020
  error: err instanceof Error ? err.message : String(err)
231007
231021
  }
231008
231022
  });
231023
+ this.emitWakeSettled();
231009
231024
  return {
231010
231025
  awoke: false,
231011
231026
  durationMs: Date.now() - startedAt
@@ -231171,6 +231186,26 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
231171
231186
  this.lastProactiveWakeAt = Date.now();
231172
231187
  }
231173
231188
  /**
231189
+ * Close the transient "waking" window on a wake that did NOT produce a
231190
+ * committed transition (ACK with no awake evidence, or a timeout).
231191
+ * `BatteryOnWakeStarted` opens it; normally the `sleeping: false` commit
231192
+ * closes it via `BatteryOnStatusChanged` — but a failed wake changes no
231193
+ * state, so nothing ever closes it, and listeners (the snapshot overlay,
231194
+ * the broker's "WAKING UP" placeholder) kept showing WAKING for the whole
231195
+ * 35 s TTL after the answer was already known (2026-08-15: the overlay
231196
+ * flapped sleeping↔waking on every retry — read as "random"). Re-asserting
231197
+ * the unchanged slice still emits the event (the runtime-state bridge
231198
+ * re-emits per WRITE), which is exactly the "wake is over, nothing came of
231199
+ * it" signal those windows listen for.
231200
+ */
231201
+ emitWakeSettled() {
231202
+ if (!this.isBattery) return;
231203
+ this.ctx.eventBus.emit(createEvent(EventCategory.BatteryOnStatusChanged, this.eventSource(), {
231204
+ deviceId: this.id,
231205
+ status: this.state.battery
231206
+ }));
231207
+ }
231208
+ /**
231174
231209
  * Gate for a PROACTIVE camera read, checked BEFORE `ensureApi()`.
231175
231210
  *
231176
231211
  * The login itself is the wake. On a sleeping UDP/battery camera the
package/dist/addon.mjs CHANGED
@@ -230944,31 +230944,45 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
230944
230944
  const CONFIRM_TIMEOUT_MS = 1e4;
230945
230945
  const CONFIRM_POLL_MS = 1e3;
230946
230946
  const confirmDeadline = Date.now() + CONFIRM_TIMEOUT_MS;
230947
+ const parent = await this.getParentHub();
230947
230948
  let confirmed = false;
230948
230949
  while (Date.now() < confirmDeadline) {
230949
- let state = null;
230950
- try {
230951
- state = api.getSleepStatus({ channel: this.getChannel() }).state;
230952
- } catch {
230953
- state = null;
230954
- }
230955
- if (state === "awake") {
230956
- confirmed = true;
230957
- break;
230950
+ if (parent !== null) try {
230951
+ if ((await (await parent.getApi()).getNvrChannelsSummary({ channels: [this.getChannel()] })).devices.find((d) => d.channel === this.getChannel())?.sleeping === false) {
230952
+ confirmed = true;
230953
+ break;
230954
+ }
230955
+ } catch {}
230956
+ else {
230957
+ let state = null;
230958
+ try {
230959
+ state = api.getSleepStatus({ channel: this.getChannel() }).state;
230960
+ } catch {
230961
+ state = null;
230962
+ }
230963
+ if (state === "awake") {
230964
+ confirmed = true;
230965
+ break;
230966
+ }
230958
230967
  }
230959
230968
  await sleep$1(CONFIRM_POLL_MS);
230960
230969
  }
230961
- if (confirmed && this.commitSleepState(false, "sleep-poll")) {
230970
+ const confirmSource = parent !== null ? "hub-summary" : "sleep-poll";
230971
+ if (confirmed && this.commitSleepState(false, confirmSource)) {
230962
230972
  this.ctx.logger.info("battery wakeForStream: wake confirmed — driving wake transition", {
230963
230973
  tags: { deviceId: this.id },
230964
- meta: { confirmMs: Date.now() - startedAt }
230974
+ meta: {
230975
+ confirmMs: Date.now() - startedAt,
230976
+ source: confirmSource
230977
+ }
230965
230978
  });
230966
- this.onWakeTransition("sleep-poll").catch(() => {});
230979
+ this.onWakeTransition(confirmSource).catch(() => {});
230967
230980
  } else if (!confirmed) {
230968
230981
  this.ctx.logger.warn("battery wakeForStream: ACK received but no awake evidence inside the confirm window", {
230969
230982
  tags: { deviceId: this.id },
230970
230983
  meta: { confirmTimeoutMs: CONFIRM_TIMEOUT_MS }
230971
230984
  });
230985
+ this.emitWakeSettled();
230972
230986
  return {
230973
230987
  awoke: false,
230974
230988
  durationMs: Date.now() - startedAt
@@ -230986,6 +231000,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
230986
231000
  error: err instanceof Error ? err.message : String(err)
230987
231001
  }
230988
231002
  });
231003
+ this.emitWakeSettled();
230989
231004
  return {
230990
231005
  awoke: false,
230991
231006
  durationMs: Date.now() - startedAt
@@ -231151,6 +231166,26 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
231151
231166
  this.lastProactiveWakeAt = Date.now();
231152
231167
  }
231153
231168
  /**
231169
+ * Close the transient "waking" window on a wake that did NOT produce a
231170
+ * committed transition (ACK with no awake evidence, or a timeout).
231171
+ * `BatteryOnWakeStarted` opens it; normally the `sleeping: false` commit
231172
+ * closes it via `BatteryOnStatusChanged` — but a failed wake changes no
231173
+ * state, so nothing ever closes it, and listeners (the snapshot overlay,
231174
+ * the broker's "WAKING UP" placeholder) kept showing WAKING for the whole
231175
+ * 35 s TTL after the answer was already known (2026-08-15: the overlay
231176
+ * flapped sleeping↔waking on every retry — read as "random"). Re-asserting
231177
+ * the unchanged slice still emits the event (the runtime-state bridge
231178
+ * re-emits per WRITE), which is exactly the "wake is over, nothing came of
231179
+ * it" signal those windows listen for.
231180
+ */
231181
+ emitWakeSettled() {
231182
+ if (!this.isBattery) return;
231183
+ this.ctx.eventBus.emit(createEvent(EventCategory.BatteryOnStatusChanged, this.eventSource(), {
231184
+ deviceId: this.id,
231185
+ status: this.state.battery
231186
+ }));
231187
+ }
231188
+ /**
231154
231189
  * Gate for a PROACTIVE camera read, checked BEFORE `ensureApi()`.
231155
231190
  *
231156
231191
  * The login itself is the wake. On a sleeping UDP/battery camera the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-reolink",
3
- "version": "1.2.31",
3
+ "version": "1.2.33",
4
4
  "description": "Reolink camera device provider addon for CamStack — native Baichuan protocol",
5
5
  "keywords": [
6
6
  "camstack",