@apocaliss92/scrypted-reolink-native 0.2.14 → 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/main.nodejs.js +1 -1
- package/dist/plugin.zip +0 -0
- package/package.json +1 -1
- package/src/camera.ts +13 -2
- package/src/main.ts +23 -1
package/dist/plugin.zip
CHANGED
|
Binary file
|
package/package.json
CHANGED
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
|
-
|
|
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()}`);
|
package/src/main.ts
CHANGED
|
@@ -32,6 +32,7 @@ class ReolinkNativePlugin extends ScryptedDeviceBase implements DeviceProvider,
|
|
|
32
32
|
nvrDeviceId: string;
|
|
33
33
|
private thumbnailQueue: ThumbnailRequest[] = [];
|
|
34
34
|
private thumbnailProcessing = false;
|
|
35
|
+
private thumbnailPendingRequests = new Map<string, Promise<MediaObject>>();
|
|
35
36
|
|
|
36
37
|
constructor(nativeId: string) {
|
|
37
38
|
super(nativeId);
|
|
@@ -340,12 +341,23 @@ class ReolinkNativePlugin extends ScryptedDeviceBase implements DeviceProvider,
|
|
|
340
341
|
* Add a thumbnail generation request to the queue
|
|
341
342
|
*/
|
|
342
343
|
async generateThumbnail(request: ThumbnailRequestInput): Promise<MediaObject> {
|
|
344
|
+
// Create a unique key for this request (deviceId:fileId)
|
|
345
|
+
const requestKey = `${request.deviceId}:${request.fileId}`;
|
|
346
|
+
|
|
347
|
+
// Check if this thumbnail is already in queue or being processed
|
|
348
|
+
const existingRequest = this.thumbnailPendingRequests.get(requestKey);
|
|
349
|
+
if (existingRequest) {
|
|
350
|
+
const logger = request.device?.getBaichuanLogger?.() || request.logger || console;
|
|
351
|
+
logger.debug(`[Thumbnail] Request already in queue: fileId=${request.fileId}, reusing existing promise`);
|
|
352
|
+
return existingRequest;
|
|
353
|
+
}
|
|
354
|
+
|
|
343
355
|
const queueLength = this.thumbnailQueue.length;
|
|
344
356
|
// Use device logger if available, otherwise fallback to provided logger
|
|
345
357
|
const logger = request.device?.getBaichuanLogger?.() || request.logger || console;
|
|
346
358
|
logger.log(`[Thumbnail] Download start: fileId=${request.fileId}, queuePosition=${queueLength + 1}`);
|
|
347
359
|
|
|
348
|
-
|
|
360
|
+
const promise = new Promise<MediaObject>((resolve, reject) => {
|
|
349
361
|
this.thumbnailQueue.push({
|
|
350
362
|
...request,
|
|
351
363
|
resolve,
|
|
@@ -353,6 +365,16 @@ class ReolinkNativePlugin extends ScryptedDeviceBase implements DeviceProvider,
|
|
|
353
365
|
});
|
|
354
366
|
this.processThumbnailQueue();
|
|
355
367
|
});
|
|
368
|
+
|
|
369
|
+
// Track this request
|
|
370
|
+
this.thumbnailPendingRequests.set(requestKey, promise);
|
|
371
|
+
|
|
372
|
+
// Remove from tracking when the promise resolves or rejects
|
|
373
|
+
promise.finally(() => {
|
|
374
|
+
this.thumbnailPendingRequests.delete(requestKey);
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
return promise;
|
|
356
378
|
}
|
|
357
379
|
|
|
358
380
|
/**
|