mirror of
https://github.com/koush/scrypted.git
synced 2026-02-16 03:32:15 +00:00
unifi-protect: added new smart event and updated snapshot to use login (#595)
This commit is contained in:
@@ -200,11 +200,17 @@ export class UnifiCamera extends ScryptedDeviceBase implements Notifier, Interco
|
||||
await input.promise;
|
||||
}
|
||||
const url = `https://${this.protect.getSetting('ip')}/proxy/protect/api/events/${detectionId}/thumbnail`;
|
||||
const response = await this.protect.api.fetch(url);
|
||||
if (!response) {
|
||||
throw new Error('Event snapshot unavailable.');
|
||||
}
|
||||
const data = await response.arrayBuffer();
|
||||
|
||||
const abort = new AbortController();
|
||||
const timeout = setTimeout(() => abort.abort('Unifi Protect Snapshot timed out after 10 seconds. Aborted.'), 10000);
|
||||
const response = await this.protect.loginFetch(url, {
|
||||
signal: abort.signal,
|
||||
responseType: 'arraybuffer',
|
||||
});
|
||||
clearTimeout(timeout);
|
||||
if (!response)
|
||||
throw new Error('event snapshot unavailable.');
|
||||
const data = Buffer.from(response.data);
|
||||
return this.createMediaObject(Buffer.from(data), 'image/jpeg');
|
||||
}
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ export class UnifiProtect extends ScryptedDeviceBase implements Settings, Device
|
||||
|
||||
let detections: ObjectDetectionResult[] = [];
|
||||
|
||||
if (payload.type === 'smartDetectZone') {
|
||||
if (payload.type === 'smartDetectZone' || payload.type === 'smartDetectLine') {
|
||||
unifiCamera.resetDetectionTimeout();
|
||||
|
||||
detections = payload.smartDetectTypes.map(type => ({
|
||||
|
||||
Reference in New Issue
Block a user