@apocaliss92/scrypted-reolink-native 0.5.49 → 0.5.51

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/plugin.zip CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apocaliss92/scrypted-reolink-native",
3
- "version": "0.5.49",
3
+ "version": "0.5.51",
4
4
  "description": "Use any reolink camera with Scrypted, even older/unsupported models without HTTP protocol support",
5
5
  "author": "@apocaliss92",
6
6
  "license": "Apache",
@@ -44,7 +44,7 @@
44
44
  ]
45
45
  },
46
46
  "dependencies": {
47
- "@apocaliss92/nodelink-js": "^0.6.4",
47
+ "@apocaliss92/nodelink-js": "^0.6.6",
48
48
  "@scrypted/common": "file:../../scrypted/common",
49
49
  "@scrypted/rtsp": "file:../../scrypted/plugins/rtsp",
50
50
  "@scrypted/sdk": "^0.3.118"
package/src/camera.ts CHANGED
@@ -4169,7 +4169,7 @@ export class ReolinkCamera
4169
4169
 
4170
4170
  const { hasPtz } = await this.getAbilities();
4171
4171
 
4172
- if (hasPtz && !this.multiFocalDevice) {
4172
+ if (hasPtz) {
4173
4173
  const choices = (this.presets || []).map(
4174
4174
  (preset: any) => preset.id + "=" + preset.name,
4175
4175
  );
package/src/nvr.ts CHANGED
@@ -453,22 +453,43 @@ export class ReolinkNativeNvrDevice
453
453
  ];
454
454
  }
455
455
 
456
- async syncEntitiesFromRemote() {
456
+ async syncEntitiesFromRemote(attempt = 0) {
457
457
  const logger = this.getBaichuanLogger();
458
458
  // const { ipAddress } = this.storageSettings.values;
459
459
 
460
460
  const api = await this.ensureBaichuanClient();
461
- // source:"cgi" uses HTTP GetChannelstatus which returns the channel list immediately,
462
- // without depending on the async cmd_id 145 Baichuan push. This avoids the race
463
- // condition where getNvrChannelsSummary returns empty right after login.
464
- const { devices, channels } = await api.getNvrChannelsSummary({ source: "cgi" });
461
+ // Prefer CGI (HTTP GetChannelstatus): it returns the channel list
462
+ // immediately, without depending on the async cmd_id 145 Baichuan push.
463
+ // But some Home Hub models expose no HTTP API at all (issue #15): CGI
464
+ // then fails fast (connection refused), so we fall back to HTTP-free
465
+ // Baichuan discovery, which probes the Support-advertised channel slots.
466
+ let result: Awaited<ReturnType<typeof api.getNvrChannelsSummary>>;
467
+ try {
468
+ result = await api.getNvrChannelsSummary({ source: "cgi" });
469
+ if (!result.channels.length) {
470
+ throw new Error("CGI returned no channels");
471
+ }
472
+ } catch (e) {
473
+ logger.debug(
474
+ `CGI channel discovery unavailable (${(e as Error)?.message}); falling back to Baichuan`,
475
+ );
476
+ result = await api.getNvrChannelsSummary({ source: "baichuan" });
477
+ }
478
+ const { devices, channels } = result;
465
479
 
466
480
  if (!channels.length) {
481
+ const maxAttempts = 5;
482
+ if (attempt >= maxAttempts) {
483
+ logger.warn(
484
+ `No channels found after ${attempt + 1} attempts; giving up for now`,
485
+ );
486
+ return;
487
+ }
467
488
  logger.debug(
468
- `No channels found, retrying in 1s. ${JSON.stringify({ channels, devices })}`,
489
+ `No channels found, retrying in 1s (attempt ${attempt + 1}/${maxAttempts}). ${JSON.stringify({ channels, devices })}`,
469
490
  );
470
491
  await new Promise((resolve) => setTimeout(resolve, 1000));
471
- await this.syncEntitiesFromRemote();
492
+ await this.syncEntitiesFromRemote(attempt + 1);
472
493
  return;
473
494
  }
474
495