@apocaliss92/scrypted-reolink-native 0.3.7 → 0.3.8

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.3.7",
3
+ "version": "0.3.8",
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",
@@ -640,16 +640,16 @@ export abstract class BaseBaichuanClass extends ScryptedDeviceBase {
640
640
  if (this.lastEventTime > 0 && timeSinceLastEvent > fiveMinutesMs) {
641
641
  logger.log(`No events received in the last ${Math.round(timeSinceLastEvent / 60_000)} minutes, restarting event listener`);
642
642
  // Restart event subscription
643
- await this.unsubscribeFromEvents();
644
- await this.subscribeToEvents();
643
+ await this.unsubscribeFromEvents(true);
644
+ await this.subscribeToEvents(true);
645
645
  } else if (this.lastEventTime === 0) {
646
646
  // If lastEventTime is 0, it means we just subscribed but haven't received any events yet
647
647
  // Wait a bit longer before considering it a problem
648
648
  const timeSinceSubscription = now - (this.connectionTime || now);
649
649
  if (timeSinceSubscription > fiveMinutesMs) {
650
650
  logger.log(`No events received since subscription (${Math.round(timeSinceSubscription / 60_000)} minutes ago), restarting event listener`);
651
- await this.unsubscribeFromEvents();
652
- await this.subscribeToEvents();
651
+ await this.unsubscribeFromEvents(true);
652
+ await this.subscribeToEvents(true);
653
653
  }
654
654
  }
655
655
  } catch (e) {
@@ -672,7 +672,7 @@ export abstract class BaseBaichuanClass extends ScryptedDeviceBase {
672
672
  /**
673
673
  * Subscribe to Baichuan simple events
674
674
  */
675
- async subscribeToEvents(): Promise<void> {
675
+ async subscribeToEvents(silent: boolean = false): Promise<void> {
676
676
  const logger = this.getBaichuanLogger();
677
677
  const callbacks = this.getConnectionCallbacks();
678
678
 
@@ -691,7 +691,7 @@ export abstract class BaseBaichuanClass extends ScryptedDeviceBase {
691
691
  }
692
692
 
693
693
  // Unsubscribe first if handler exists (idempotent)
694
- await this.unsubscribeFromEvents();
694
+ await this.unsubscribeFromEvents(silent);
695
695
 
696
696
  // Get Baichuan client connection
697
697
  const api = await this.ensureBaichuanClient();
@@ -721,7 +721,9 @@ export abstract class BaseBaichuanClass extends ScryptedDeviceBase {
721
721
  await api.onSimpleEvent(wrappedHandler);
722
722
  this.eventSubscriptionActive = true;
723
723
  this.lastEventTime = Date.now(); // Initialize on subscription
724
- logger.log('Subscribed to Baichuan events');
724
+ if (!silent) {
725
+ logger.debug('Subscribed to Baichuan events');
726
+ }
725
727
  }
726
728
  catch (e) {
727
729
  logger.warn('Failed to subscribe to events', e?.message || String(e));
@@ -731,8 +733,9 @@ export abstract class BaseBaichuanClass extends ScryptedDeviceBase {
731
733
 
732
734
  /**
733
735
  * Unsubscribe from Baichuan simple events
736
+ * @param silent If true, don't log unsubscription messages
734
737
  */
735
- async unsubscribeFromEvents(): Promise<void> {
738
+ async unsubscribeFromEvents(silent: boolean = false): Promise<void> {
736
739
  const logger = this.getBaichuanLogger();
737
740
  const callbacks = this.getConnectionCallbacks();
738
741
 
@@ -740,10 +743,14 @@ export abstract class BaseBaichuanClass extends ScryptedDeviceBase {
740
743
  if (this.eventSubscriptionActive && this.baichuanApi && callbacks.onSimpleEvent) {
741
744
  try {
742
745
  this.baichuanApi.offSimpleEvent(callbacks.onSimpleEvent);
743
- logger.debug('Unsubscribed from Baichuan events');
746
+ if (!silent) {
747
+ logger.debug('Unsubscribed from Baichuan events');
748
+ }
744
749
  }
745
750
  catch (e) {
746
- logger.warn('Error unsubscribing from events', e?.message || String(e));
751
+ if (!silent) {
752
+ logger.warn('Error unsubscribing from events', e?.message || String(e));
753
+ }
747
754
  }
748
755
  }
749
756