@apocaliss92/scrypted-reolink-native 0.5.23 → 0.5.24

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.23",
3
+ "version": "0.5.24",
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.4.30",
47
+ "@apocaliss92/nodelink-js": "^0.4.31",
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
@@ -2745,37 +2745,32 @@ export class ReolinkCamera
2745
2745
 
2746
2746
  /**
2747
2747
  * Called from `baichuan-base.subscribeToEvents` when a per-camera
2748
- * email-push event lands on the bus. If the camera attached the
2749
- * trigger-frame JPEG (the common case for `attachmentType=picture`),
2750
- * we wrap it in a Scrypted MediaObject and overwrite `lastPicture`
2751
- * so the next `takePicture()` returns the fresh snapshot which is
2752
- * what the Snapshot mixin MQTT/HA image entity republishes off the
2753
- * back of the motion event. Without this hook, battery cams have
2754
- * nothing fresh to give and HA shows the previous cached frame.
2748
+ * email-push event lands on the bus. We don't use the e-mail's image
2749
+ * attachment Reolink firmwares vary on quality/encoding and we'd
2750
+ * be reimplementing the snapshot pipeline. Instead we leverage the
2751
+ * fact that the camera is *guaranteed awake* right now (it just
2752
+ * pushed an e-mail) and call the live Baichuan snapshot API: it
2753
+ * returns a fresh frame in milliseconds without forcing an extra
2754
+ * wake-up cycle. The result is stashed in `lastPicture` so the
2755
+ * Snapshot mixin → MQTT image entity (and any other consumer that
2756
+ * calls `takePicture()` on the back of the motion event) serves the
2757
+ * trigger frame instead of the previous cached one.
2755
2758
  */
2756
2759
  private async handleEmailPushSnapshot(
2757
2760
  event: EmailPushEvent,
2758
2761
  ): Promise<void> {
2759
2762
  const logger = this.getBaichuanLogger();
2760
- if (!event.attachment) {
2761
- logger.debug(
2762
- `E-mail Push event without attachment (type=${event.inferredType}); skipping snapshot cache update`,
2763
- );
2764
- return;
2765
- }
2766
2763
  try {
2767
- const mo = await this.createMediaObject(
2768
- event.attachment.data,
2769
- event.attachment.contentType,
2770
- );
2764
+ const client = await this.ensureClient();
2765
+ const mo = await this.takePictureInternal(client);
2771
2766
  this.lastPicture = { mo, atMs: event.receivedAtMs };
2772
2767
  this.forceNewSnapshot = false;
2773
2768
  logger.log(
2774
- `E-mail Push snapshot cached (${event.attachment.data.length}B, ${event.attachment.contentType}) — next takePicture will serve it`,
2769
+ `E-mail Push snapshot fetched live (type=${event.inferredType}) — next takePicture will serve it`,
2775
2770
  );
2776
2771
  } catch (e) {
2777
2772
  logger.warn(
2778
- `E-mail Push: failed to wrap attachment as MediaObject: ${e?.message || String(e)}`,
2773
+ `E-mail Push: live snapshot fetch failed: ${e?.message || String(e)}`,
2779
2774
  );
2780
2775
  }
2781
2776
  }