@apocaliss92/scrypted-reolink-native 0.2.15 → 0.2.16

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.2.15",
3
+ "version": "0.2.16",
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
@@ -787,7 +787,6 @@ export class ReolinkCamera extends BaseBaichuanClass implements VideoCamera, Cam
787
787
  const api = await this.ensureClient();
788
788
 
789
789
  if (useNvr) {
790
- // Fetch from NVR using VOD listing so clip.id/fileId is a real file path (e.g. /mnt/sda/...)
791
790
  const channel = this.storageSettings.values.rtspChannel ?? 0;
792
791
 
793
792
  logger.debug(`[NVR VOD] Listing recordings: channel=${channel}, start=${start.toISOString()}, end=${end.toISOString()}`);
@@ -2098,7 +2097,18 @@ export class ReolinkCamera extends BaseBaichuanClass implements VideoCamera, Cam
2098
2097
  }
2099
2098
  } else {
2100
2099
  const logger = this.getBaichuanLogger();
2101
- const shouldTakeNewSnapshot = this.forceNewSnapshot;
2100
+ let shouldTakeNewSnapshot = this.forceNewSnapshot;
2101
+
2102
+ if (this.lastPicture) {
2103
+ const batteryUpdateIntervalMinutes = this.storageSettings.values.batteryUpdateIntervalMinutes ?? 60;
2104
+ const updateIntervalMs = batteryUpdateIntervalMinutes * 60_000;
2105
+ const timeSinceLastSnapshot = Date.now() - this.lastPicture.atMs;
2106
+
2107
+ if (timeSinceLastSnapshot >= updateIntervalMs) {
2108
+ shouldTakeNewSnapshot = true;
2109
+ logger.log(`Snapshot expired: ${Math.round(timeSinceLastSnapshot / 60_000)} minutes since last snapshot (interval: ${batteryUpdateIntervalMinutes} minutes)`);
2110
+ }
2111
+ }
2102
2112
 
2103
2113
  if (!shouldTakeNewSnapshot && this.lastPicture) {
2104
2114
  logger.log(`Returning cached snapshot, taken at ${new Date(this.lastPicture.atMs).toLocaleString()}`);
@@ -2112,6 +2122,7 @@ export class ReolinkCamera extends BaseBaichuanClass implements VideoCamera, Cam
2112
2122
 
2113
2123
  this.takePictureInFlight = (async () => {
2114
2124
  const client = await this.ensureClient();
2125
+ await client.wakeUp();
2115
2126
  const mo = await this.takePictureInternal(client);
2116
2127
  this.lastPicture = { mo, atMs: Date.now() };
2117
2128
  logger.log(`Snapshot taken at ${new Date(this.lastPicture.atMs).toLocaleString()}`);