mirror of
https://github.com/koush/scrypted.git
synced 2026-06-20 16:40:30 +01:00
core: Fix notificaiton automation
This commit is contained in:
4
plugins/core/package-lock.json
generated
4
plugins/core/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/core",
|
||||
"version": "0.3.61",
|
||||
"version": "0.3.62",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/core",
|
||||
"version": "0.3.61",
|
||||
"version": "0.3.62",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@scrypted/common": "file:../../common",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scrypted/core",
|
||||
"version": "0.3.61",
|
||||
"version": "0.3.62",
|
||||
"description": "Scrypted Core plugin. Provides the UI, websocket, and engine.io APIs.",
|
||||
"author": "Scrypted",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Brightness, Lock, LockState, Notifier, OnOff, Program, ScryptedDevice, ScryptedInterface, StartStop } from "@scrypted/sdk";
|
||||
import { Brightness, Camera, Lock, LockState, Notifier, OnOff, Program, ScryptedDevice, ScryptedInterface, StartStop, VideoCamera } from "@scrypted/sdk";
|
||||
import { StorageSettingsDict } from "@scrypted/sdk/storage-settings";
|
||||
import sdk from '@scrypted/sdk';
|
||||
|
||||
interface InvokeStorage<T extends string> {
|
||||
settings: StorageSettingsDict<T>;
|
||||
@@ -81,7 +82,23 @@ addAction(ScryptedInterface.Notifier, {
|
||||
deviceFilter: `deviceInterface === '${ScryptedInterface.VideoCamera}' || deviceInterface === '${ScryptedInterface.Camera}'`,
|
||||
},
|
||||
}, async function invoke(device: ScryptedDevice & Notifier, storageSettings) {
|
||||
let { notificationMediaUrl } = storageSettings;
|
||||
if (notificationMediaUrl && !notificationMediaUrl?.includes('://')) {
|
||||
const [id,iface] = notificationMediaUrl.split('#');
|
||||
if (iface === ScryptedInterface.Camera) {
|
||||
const mediaDevice = sdk.systemManager.getDeviceById<Camera>(id);
|
||||
notificationMediaUrl = await mediaDevice.takePicture({
|
||||
reason: 'event',
|
||||
});
|
||||
}
|
||||
else {
|
||||
const mediaDevice = sdk.systemManager.getDeviceById<VideoCamera>(id);
|
||||
notificationMediaUrl = mediaDevice.getVideoStream();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return device.sendNotification(storageSettings.notificationTitle as string, {
|
||||
body: storageSettings.notificationBody as string,
|
||||
});
|
||||
}, notificationMediaUrl);
|
||||
});
|
||||
Reference in New Issue
Block a user