diff --git a/plugins/ring/src/main.ts b/plugins/ring/src/main.ts index 77bd907ea..8f42c91f0 100644 --- a/plugins/ring/src/main.ts +++ b/plugins/ring/src/main.ts @@ -1,4 +1,4 @@ -import { BinarySensor, Device, DeviceDiscovery, DeviceProvider, FFMpegInput, MediaObject, MediaStreamOptions, MotionSensor, ScryptedDeviceBase, ScryptedDeviceType, ScryptedInterface, ScryptedMimeTypes, Setting, Settings, SettingValue, VideoCamera } from '@scrypted/sdk'; +import { BinarySensor, Camera, Device, DeviceDiscovery, DeviceProvider, FFMpegInput, MediaObject, MediaStreamOptions, MotionSensor, PictureOptions, ScryptedDeviceBase, ScryptedDeviceType, ScryptedInterface, ScryptedMimeTypes, Setting, Settings, SettingValue, VideoCamera } from '@scrypted/sdk'; import sdk from '@scrypted/sdk'; import ring, { RingApi, RingCamera } from 'ring-client-api'; import { StorageSettings } from '../../../common/src/settings'; @@ -8,11 +8,22 @@ import { randomBytes } from 'crypto'; const { log, deviceManager, mediaManager } = sdk; -class RingCameraDevice extends ScryptedDeviceBase implements VideoCamera, MotionSensor, BinarySensor { +class RingCameraDevice extends ScryptedDeviceBase implements Camera, VideoCamera, MotionSensor, BinarySensor { sessions = new Map(); constructor(public plugin: RingPlugin, nativeId: string) { super(nativeId); } + + async takePicture(options?: PictureOptions): Promise { + const camera = this.findCamera(); + const snapshot = await camera.getSnapshot(); + return mediaManager.createMediaObject(snapshot, 'image/jpeg'); + } + + async getPictureOptions(): Promise { + return; + } + async getVideoStream(options?: MediaStreamOptions): Promise { // the ring-api-client can negotiate the sip connection and output the stream // to a ffmpeg output target. @@ -173,6 +184,7 @@ class RingPlugin extends ScryptedDeviceBase implements DeviceProvider, DeviceDis const nativeId = camera.id.toString(); const isDoorbell = camera.model.toLowerCase().includes('doorbell'); const interfaces = [ + ScryptedInterface.Camera, ScryptedInterface.VideoCamera, ScryptedInterface.MotionSensor, ];