@camstack/addon-provider-reolink 1.2.33 → 1.2.34

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
@@ -230953,6 +230953,8 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
230953
230953
  });
230954
230954
  this.ctx.eventBus.emit(createEvent(EventCategory.BatteryOnWakeStarted, this.eventSource(), { deviceId: this.id }));
230955
230955
  const channel = this.getChannel();
230956
+ const isHubChild = this.isHubChild();
230957
+ const wakeTimeoutMs = isHubChild ? Math.max(timeoutMs, 2e4) : timeoutMs;
230956
230958
  try {
230957
230959
  await Promise.race([(async () => {
230958
230960
  await api.wakeUp(channel, {
@@ -230960,7 +230962,11 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
230960
230962
  attempts: 2
230961
230963
  });
230962
230964
  await sleep$1(1500);
230963
- })(), new Promise((_, rej) => setTimeout(() => rej(/* @__PURE__ */ new Error("wakeForStream timeout")), timeoutMs))]);
230965
+ if (isHubChild) {
230966
+ const dialId = buildCamStreamId("native", channel, "main", 1);
230967
+ await Promise.race([this.ensureRfc4571Server(dialId, channel, "main"), sleep$1(1e4)]);
230968
+ }
230969
+ })(), new Promise((_, rej) => setTimeout(() => rej(/* @__PURE__ */ new Error("wakeForStream timeout")), wakeTimeoutMs))]);
230964
230970
  const CONFIRM_TIMEOUT_MS = 1e4;
230965
230971
  const CONFIRM_POLL_MS = 1e3;
230966
230972
  const confirmDeadline = Date.now() + CONFIRM_TIMEOUT_MS;
@@ -236705,6 +236711,13 @@ var ReolinkHub = class ReolinkHub extends BaseDevice {
236705
236711
  this.ensureApi().catch((err) => {
236706
236712
  this.ctx.logger.warn("Reolink Hub initial connect failed — will retry", { meta: { error: err instanceof Error ? err.message : String(err) } });
236707
236713
  });
236714
+ this.eventUnsubscribers.push(this.ctx.eventBus.subscribe({ category: EventCategory.DeviceRegistered }, (event) => {
236715
+ if (event.data.parentDeviceId !== this.id) return;
236716
+ (async () => {
236717
+ const byChannel = await this.loadAdoptedChildrenByChannel();
236718
+ for (const [ch, did] of byChannel) this.channelToDeviceId.set(ch, did);
236719
+ })().catch(() => {});
236720
+ }));
236708
236721
  this.eventUnsubscribers.push(this.ctx.eventBus.subscribe({ category: EventCategory.DeviceUnregistered }, (event) => {
236709
236722
  const data = event.data;
236710
236723
  if (data.parentDeviceId !== this.id) return;
@@ -236717,6 +236730,9 @@ var ReolinkHub = class ReolinkHub extends BaseDevice {
236717
236730
  }));
236718
236731
  }
236719
236732
  eventUnsubscribers = [];
236733
+ /** Per-channel throttle for the unrouted-event warning (see
236734
+ * `routeSimpleEvent`) — a chatty unmapped channel must not flood. */
236735
+ unroutedChannelLoggedAt = /* @__PURE__ */ new Map();
236720
236736
  async removeDevice() {
236721
236737
  this.shutdownRequested = true;
236722
236738
  if (this.reconnectTimer) {
@@ -237273,7 +237289,18 @@ var ReolinkHub = class ReolinkHub extends BaseDevice {
237273
237289
  const channel = ev?.channel;
237274
237290
  if (typeof channel !== "number") return;
237275
237291
  const deviceId = this.channelToDeviceId.get(channel);
237276
- if (deviceId === void 0) return;
237292
+ if (deviceId === void 0) {
237293
+ const last = this.unroutedChannelLoggedAt.get(channel) ?? 0;
237294
+ const now = Date.now();
237295
+ if (now - last > 6e4) {
237296
+ this.unroutedChannelLoggedAt.set(channel, now);
237297
+ this.ctx.logger.warn("Reolink Hub: simpleEvent for an unmapped channel dropped", { meta: {
237298
+ channel,
237299
+ type: ev?.type ?? "unknown"
237300
+ } });
237301
+ }
237302
+ return;
237303
+ }
237277
237304
  this.ctx.devices.getAll().then((all) => all.find((d) => d.id === deviceId)).then((child) => {
237278
237305
  if (!(child instanceof ReolinkCamera)) return;
237279
237306
  child.handleSimpleEvent(ev);
package/dist/addon.mjs CHANGED
@@ -230933,6 +230933,8 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
230933
230933
  });
230934
230934
  this.ctx.eventBus.emit(createEvent(EventCategory.BatteryOnWakeStarted, this.eventSource(), { deviceId: this.id }));
230935
230935
  const channel = this.getChannel();
230936
+ const isHubChild = this.isHubChild();
230937
+ const wakeTimeoutMs = isHubChild ? Math.max(timeoutMs, 2e4) : timeoutMs;
230936
230938
  try {
230937
230939
  await Promise.race([(async () => {
230938
230940
  await api.wakeUp(channel, {
@@ -230940,7 +230942,11 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
230940
230942
  attempts: 2
230941
230943
  });
230942
230944
  await sleep$1(1500);
230943
- })(), new Promise((_, rej) => setTimeout(() => rej(/* @__PURE__ */ new Error("wakeForStream timeout")), timeoutMs))]);
230945
+ if (isHubChild) {
230946
+ const dialId = buildCamStreamId("native", channel, "main", 1);
230947
+ await Promise.race([this.ensureRfc4571Server(dialId, channel, "main"), sleep$1(1e4)]);
230948
+ }
230949
+ })(), new Promise((_, rej) => setTimeout(() => rej(/* @__PURE__ */ new Error("wakeForStream timeout")), wakeTimeoutMs))]);
230944
230950
  const CONFIRM_TIMEOUT_MS = 1e4;
230945
230951
  const CONFIRM_POLL_MS = 1e3;
230946
230952
  const confirmDeadline = Date.now() + CONFIRM_TIMEOUT_MS;
@@ -236685,6 +236691,13 @@ var ReolinkHub = class ReolinkHub extends BaseDevice {
236685
236691
  this.ensureApi().catch((err) => {
236686
236692
  this.ctx.logger.warn("Reolink Hub initial connect failed — will retry", { meta: { error: err instanceof Error ? err.message : String(err) } });
236687
236693
  });
236694
+ this.eventUnsubscribers.push(this.ctx.eventBus.subscribe({ category: EventCategory.DeviceRegistered }, (event) => {
236695
+ if (event.data.parentDeviceId !== this.id) return;
236696
+ (async () => {
236697
+ const byChannel = await this.loadAdoptedChildrenByChannel();
236698
+ for (const [ch, did] of byChannel) this.channelToDeviceId.set(ch, did);
236699
+ })().catch(() => {});
236700
+ }));
236688
236701
  this.eventUnsubscribers.push(this.ctx.eventBus.subscribe({ category: EventCategory.DeviceUnregistered }, (event) => {
236689
236702
  const data = event.data;
236690
236703
  if (data.parentDeviceId !== this.id) return;
@@ -236697,6 +236710,9 @@ var ReolinkHub = class ReolinkHub extends BaseDevice {
236697
236710
  }));
236698
236711
  }
236699
236712
  eventUnsubscribers = [];
236713
+ /** Per-channel throttle for the unrouted-event warning (see
236714
+ * `routeSimpleEvent`) — a chatty unmapped channel must not flood. */
236715
+ unroutedChannelLoggedAt = /* @__PURE__ */ new Map();
236700
236716
  async removeDevice() {
236701
236717
  this.shutdownRequested = true;
236702
236718
  if (this.reconnectTimer) {
@@ -237253,7 +237269,18 @@ var ReolinkHub = class ReolinkHub extends BaseDevice {
237253
237269
  const channel = ev?.channel;
237254
237270
  if (typeof channel !== "number") return;
237255
237271
  const deviceId = this.channelToDeviceId.get(channel);
237256
- if (deviceId === void 0) return;
237272
+ if (deviceId === void 0) {
237273
+ const last = this.unroutedChannelLoggedAt.get(channel) ?? 0;
237274
+ const now = Date.now();
237275
+ if (now - last > 6e4) {
237276
+ this.unroutedChannelLoggedAt.set(channel, now);
237277
+ this.ctx.logger.warn("Reolink Hub: simpleEvent for an unmapped channel dropped", { meta: {
237278
+ channel,
237279
+ type: ev?.type ?? "unknown"
237280
+ } });
237281
+ }
237282
+ return;
237283
+ }
237257
237284
  this.ctx.devices.getAll().then((all) => all.find((d) => d.id === deviceId)).then((child) => {
237258
237285
  if (!(child instanceof ReolinkCamera)) return;
237259
237286
  child.handleSimpleEvent(ev);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-reolink",
3
- "version": "1.2.33",
3
+ "version": "1.2.34",
4
4
  "description": "Reolink camera device provider addon for CamStack — native Baichuan protocol",
5
5
  "keywords": [
6
6
  "camstack",