@apocaliss92/scrypted-reolink-native 0.4.1 → 0.4.2

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.4.1",
3
+ "version": "0.4.2",
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",
package/src/camera.ts CHANGED
@@ -2446,6 +2446,14 @@ export class ReolinkCamera
2446
2446
  const pirNativeId = `${this.nativeId}${pirSuffix}`;
2447
2447
  const autotrackingNativeId = `${this.nativeId}${autotrackingSuffix}`;
2448
2448
 
2449
+ // Helper to safely remove a device only if it exists
2450
+ const safeRemoveDevice = (nativeId: string) => {
2451
+ const existingIds = sdk.deviceManager.getNativeIds();
2452
+ if (existingIds.includes(nativeId)) {
2453
+ sdk.deviceManager.onDeviceRemoved(nativeId);
2454
+ }
2455
+ };
2456
+
2449
2457
  // Create motion-siren device (motion detection alarm)
2450
2458
  if (hasSiren) {
2451
2459
  const device: Device = {
@@ -2461,7 +2469,7 @@ export class ReolinkCamera
2461
2469
  sdk.deviceManager.onDeviceDiscovered(device);
2462
2470
  } else {
2463
2471
  // Remove motion-siren device if capability is no longer available
2464
- sdk.deviceManager.onDeviceRemoved(motionSirenNativeId);
2472
+ safeRemoveDevice(motionSirenNativeId);
2465
2473
  this.motionSiren = undefined;
2466
2474
  }
2467
2475
 
@@ -2480,7 +2488,7 @@ export class ReolinkCamera
2480
2488
  sdk.deviceManager.onDeviceDiscovered(device);
2481
2489
  } else {
2482
2490
  // Remove siren device if capability is no longer available
2483
- sdk.deviceManager.onDeviceRemoved(sirenNativeId);
2491
+ safeRemoveDevice(sirenNativeId);
2484
2492
  this.siren = undefined;
2485
2493
  }
2486
2494
 
@@ -2503,7 +2511,7 @@ export class ReolinkCamera
2503
2511
  sdk.deviceManager.onDeviceDiscovered(device);
2504
2512
  } else {
2505
2513
  // Remove motion-floodlight device if capability is no longer available
2506
- sdk.deviceManager.onDeviceRemoved(motionFloodlightNativeId);
2514
+ safeRemoveDevice(motionFloodlightNativeId);
2507
2515
  this.motionFloodlight = undefined;
2508
2516
  }
2509
2517
 
@@ -2526,7 +2534,7 @@ export class ReolinkCamera
2526
2534
  sdk.deviceManager.onDeviceDiscovered(device);
2527
2535
  } else {
2528
2536
  // Remove floodlight device if capability is no longer available
2529
- sdk.deviceManager.onDeviceRemoved(floodlightNativeId);
2537
+ safeRemoveDevice(floodlightNativeId);
2530
2538
  this.floodlight = undefined;
2531
2539
  }
2532
2540
 
@@ -2544,7 +2552,7 @@ export class ReolinkCamera
2544
2552
  sdk.deviceManager.onDeviceDiscovered(device);
2545
2553
  } else {
2546
2554
  // Remove PIR device if capability is no longer available
2547
- sdk.deviceManager.onDeviceRemoved(pirNativeId);
2555
+ safeRemoveDevice(pirNativeId);
2548
2556
  this.pirSensor = undefined;
2549
2557
  }
2550
2558
 
@@ -2563,7 +2571,7 @@ export class ReolinkCamera
2563
2571
  sdk.deviceManager.onDeviceDiscovered(device);
2564
2572
  } else {
2565
2573
  // Remove autotracking device if capability is no longer available
2566
- sdk.deviceManager.onDeviceRemoved(autotrackingNativeId);
2574
+ safeRemoveDevice(autotrackingNativeId);
2567
2575
  this.autotracking = undefined;
2568
2576
  }
2569
2577
  }