@scrypted/server 0.0.7 → 0.0.8

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.

Potentially problematic release.


This version of @scrypted/server might be problematic. Click here for more details.

@@ -0,0 +1,1093 @@
1
+ /// <reference types="node" />
2
+ export declare type ScryptedNativeId = string | undefined;
3
+ /**
4
+ * DeviceState is returned by DeviceManager.getDeviceState, and allows getting/setting of a device provided by a DeviceProvider.
5
+ */
6
+ export interface DeviceState {
7
+ id?: string;
8
+ interfaces?: string[];
9
+ mixins?: string[];
10
+ info?: DeviceInformation;
11
+ name?: string;
12
+ providedInterfaces?: string[];
13
+ providedName?: ScryptedDeviceType;
14
+ providedRoom?: string;
15
+ providedType?: ScryptedDeviceType;
16
+ providerId?: string;
17
+ room?: string;
18
+ type?: ScryptedDeviceType;
19
+ on?: boolean;
20
+ brightness?: number;
21
+ colorTemperature?: number;
22
+ rgb?: ColorRgb;
23
+ hsv?: ColorHsv;
24
+ running?: boolean;
25
+ paused?: boolean;
26
+ docked?: boolean;
27
+ /**
28
+ * Get the ambient temperature in Celsius.
29
+ */
30
+ temperature?: number;
31
+ /**
32
+ * Get the user facing unit of measurement for this thermometer. Note that while this may be Fahrenheit, getTemperatureAmbient will return the temperature in Celsius.
33
+ */
34
+ temperatureUnit?: TemperatureUnit;
35
+ humidity?: number;
36
+ thermostatAvailableModes?: ThermostatMode[];
37
+ thermostatMode?: ThermostatMode;
38
+ thermostatSetpoint?: number;
39
+ thermostatSetpointHigh?: number;
40
+ thermostatSetpointLow?: number;
41
+ lockState?: LockState;
42
+ entryOpen?: boolean;
43
+ batteryLevel?: number;
44
+ online?: boolean;
45
+ updateAvailable?: boolean;
46
+ fromMimeType?: string;
47
+ toMimeType?: string;
48
+ binaryState?: boolean;
49
+ intrusionDetected?: boolean;
50
+ powerDetected?: boolean;
51
+ motionDetected?: boolean;
52
+ audioDetected?: boolean;
53
+ occupied?: boolean;
54
+ flooded?: boolean;
55
+ ultraviolet?: number;
56
+ luminance?: number;
57
+ position?: Position;
58
+ }
59
+ /**
60
+ * All devices in Scrypted implement ScryptedDevice, which contains the id, name, and type. Add listeners to subscribe to events from that device.
61
+ */
62
+ export interface ScryptedDevice {
63
+ /**
64
+ * Subscribe to events from a specific interface on a device, such as 'OnOff' or 'Brightness'.
65
+ */
66
+ listen(event: ScryptedInterface | string | EventListenerOptions, callback: EventListener): EventListenerRegister;
67
+ setName(name: string): Promise<void>;
68
+ setRoom(room: string): Promise<void>;
69
+ setType(type: ScryptedDeviceType): Promise<void>;
70
+ id?: string;
71
+ interfaces?: string[];
72
+ mixins?: string[];
73
+ name?: string;
74
+ info?: DeviceInformation;
75
+ providedInterfaces?: string[];
76
+ providedName?: ScryptedDeviceType;
77
+ providedRoom?: string;
78
+ providedType?: ScryptedDeviceType;
79
+ providerId?: string;
80
+ room?: string;
81
+ type?: ScryptedDeviceType;
82
+ }
83
+ export interface EventListenerOptions {
84
+ /**
85
+ * This EventListener will denoise events, and will not be called unless the state changes.
86
+ */
87
+ denoise?: boolean;
88
+ /**
89
+ * The EventListener will subscribe to this event interface.
90
+ */
91
+ event?: ScryptedInterface | string;
92
+ /**
93
+ * This EventListener will passively watch for events, and not initiate polling.
94
+ */
95
+ watch?: boolean;
96
+ }
97
+ export interface EventListener {
98
+ /**
99
+ * This device type can be hooked by Automation actions to handle events. The event source, event details (interface, time, property), and event data are all passed to the listener as arguments.
100
+ */
101
+ (eventSource: ScryptedDevice | undefined, eventDetails: EventDetails, eventData: any): void;
102
+ }
103
+ export interface EventDetails {
104
+ changed?: boolean;
105
+ eventInterface?: string;
106
+ eventTime?: number;
107
+ property?: string;
108
+ }
109
+ /**
110
+ * Returned when an event listener is attached to an EventEmitter. Call removeListener to unregister from events.
111
+ */
112
+ export interface EventListenerRegister {
113
+ removeListener(): void;
114
+ }
115
+ export declare enum ScryptedDeviceType {
116
+ Builtin = "Builtin",
117
+ Camera = "Camera",
118
+ Fan = "Fan",
119
+ Light = "Light",
120
+ Switch = "Switch",
121
+ Outlet = "Outlet",
122
+ Sensor = "Sensor",
123
+ Scene = "Scene",
124
+ Program = "Program",
125
+ Automation = "Automation",
126
+ Vacuum = "Vacuum",
127
+ Notifier = "Notifier",
128
+ Thermostat = "Thermostat",
129
+ Lock = "Lock",
130
+ PasswordControl = "PasswordControl",
131
+ Display = "Display",
132
+ Speaker = "Speaker",
133
+ Event = "Event",
134
+ Entry = "Entry",
135
+ Garage = "Garage",
136
+ DeviceProvider = "DeviceProvider",
137
+ DataSource = "DataSource",
138
+ API = "API",
139
+ Doorbell = "Doorbell",
140
+ Irrigation = "Irrigation",
141
+ Valve = "Valve",
142
+ Person = "Person",
143
+ Unknown = "Unknown"
144
+ }
145
+ /**
146
+ * OnOff is a basic binary switch.
147
+ */
148
+ export interface OnOff {
149
+ turnOff(): Promise<void>;
150
+ turnOn(): Promise<void>;
151
+ on?: boolean;
152
+ }
153
+ /**
154
+ * Brightness is a lighting device that can be dimmed/lit between 0 to 100.
155
+ */
156
+ export interface Brightness {
157
+ setBrightness(brightness: number): Promise<void>;
158
+ brightness?: number;
159
+ }
160
+ /**
161
+ * ColorSettingTemperature sets the color temperature of a light in Kelvin.
162
+ */
163
+ export interface ColorSettingTemperature {
164
+ getTemperatureMaxK(): Promise<number>;
165
+ getTemperatureMinK(): Promise<number>;
166
+ setColorTemperature(kelvin: number): Promise<void>;
167
+ colorTemperature?: number;
168
+ }
169
+ /**
170
+ * ColorSettingRgb sets the color of a colored light using the RGB representation.
171
+ */
172
+ export interface ColorSettingRgb {
173
+ setRgb(r: number, g: number, b: number): Promise<void>;
174
+ rgb?: ColorRgb;
175
+ }
176
+ /**
177
+ * Represents an RGB color with component values between 0 and 255.
178
+ */
179
+ export interface ColorRgb {
180
+ b?: number;
181
+ g?: number;
182
+ r?: number;
183
+ }
184
+ /**
185
+ * ColorSettingHsv sets the color of a colored light using the HSV representation.
186
+ */
187
+ export interface ColorSettingHsv {
188
+ setHsv(hue: number, saturation: number, value: number): Promise<void>;
189
+ hsv?: ColorHsv;
190
+ }
191
+ /**
192
+ * Represents an HSV color value component.
193
+ */
194
+ export interface ColorHsv {
195
+ /**
196
+ * Hue. 0 to 360.
197
+ */
198
+ h?: number;
199
+ /**
200
+ * Saturation. 0 to 1.
201
+ */
202
+ s?: number;
203
+ /**
204
+ * Value. 0 to 1.
205
+ */
206
+ v?: number;
207
+ }
208
+ /**
209
+ * Notifier can be any endpoint that can receive messages, such as speakers, phone numbers, messaging clients, etc. The messages may optionally contain media.
210
+ */
211
+ export interface Notifier {
212
+ /**
213
+ * If a the media parameter is supplied, the mime type denotes how to send the media within notification. For example, specify 'image/*' to send a video MediaObject as an image.
214
+ Passing null uses the native type of the MediaObject. If that is not supported by the notifier, the media will be converted to a compatible type.
215
+ */
216
+ sendNotification(title: string, body: string, media: string | MediaObject, mimeType?: string): Promise<void>;
217
+ }
218
+ /**
219
+ * MediaObject is an intermediate object within Scrypted to represent all media objects. Plugins should use the MediaConverter to convert the Scrypted MediaObject into a desired type, whether it is a externally accessible URL, a Buffer, etc.
220
+ */
221
+ export interface MediaObject {
222
+ mimeType?: string;
223
+ }
224
+ /**
225
+ * StartStop represents a device that can be started, stopped, and possibly paused and resumed. Typically vacuum cleaners or washers.
226
+ */
227
+ export interface StartStop {
228
+ start(): Promise<void>;
229
+ stop(): Promise<void>;
230
+ running?: boolean;
231
+ }
232
+ export interface Pause {
233
+ pause(): Promise<void>;
234
+ resume(): Promise<void>;
235
+ paused?: boolean;
236
+ }
237
+ /**
238
+ * Dock instructs devices that have a base station or charger, to return to their home.
239
+ */
240
+ export interface Dock {
241
+ dock(): Promise<void>;
242
+ docked?: boolean;
243
+ }
244
+ /**
245
+ * TemperatureSetting represents a thermostat device.
246
+ */
247
+ export interface TemperatureSetting extends Thermometer, HumiditySensor {
248
+ setThermostatMode(mode: ThermostatMode): Promise<void>;
249
+ setThermostatSetpoint(degrees: number): Promise<void>;
250
+ setThermostatSetpointHigh(high: number): Promise<void>;
251
+ setThermostatSetpointLow(low: number): Promise<void>;
252
+ thermostatAvailableModes?: ThermostatMode[];
253
+ thermostatMode?: ThermostatMode;
254
+ thermostatSetpoint?: number;
255
+ thermostatSetpointHigh?: number;
256
+ thermostatSetpointLow?: number;
257
+ }
258
+ export interface Thermometer {
259
+ /**
260
+ * Get the ambient temperature in Celsius.
261
+ */
262
+ temperature?: number;
263
+ /**
264
+ * Get the user facing unit of measurement for this thermometer. Note that while this may be Fahrenheit, getTemperatureAmbient will return the temperature in Celsius.
265
+ */
266
+ temperatureUnit?: TemperatureUnit;
267
+ }
268
+ export declare enum TemperatureUnit {
269
+ C = "C",
270
+ F = "F"
271
+ }
272
+ export interface HumiditySensor {
273
+ humidity?: number;
274
+ }
275
+ export declare enum ThermostatMode {
276
+ Off = "Off",
277
+ Cool = "Cool",
278
+ Heat = "Heat",
279
+ HeatCool = "HeatCool",
280
+ Auto = "Auto",
281
+ FanOnly = "FanOnly",
282
+ Purifier = "Purifier",
283
+ Eco = "Eco",
284
+ Dry = "Dry",
285
+ On = "On"
286
+ }
287
+ export interface PictureOptions {
288
+ id?: string;
289
+ name?: string;
290
+ picture?: {
291
+ width?: number;
292
+ height?: number;
293
+ };
294
+ }
295
+ /**
296
+ * Camera devices can take still photos.
297
+ */
298
+ export interface Camera {
299
+ takePicture(options?: PictureOptions): Promise<MediaObject>;
300
+ getPictureOptions(): Promise<PictureOptions[]>;
301
+ }
302
+ /**
303
+ * Options passed to VideoCamera.getVideoStream to
304
+ * request specific media formats.
305
+ * The audio/video properties may be omitted
306
+ * to indicate no audio/video is available when
307
+ * calling getVideoStreamOptions or no audio/video
308
+ * is requested when calling getVideoStream.
309
+ */
310
+ export interface MediaStreamOptions {
311
+ /**
312
+ * Prebuffer time in milliseconds.
313
+ */
314
+ id?: string;
315
+ name?: string;
316
+ prebuffer?: number;
317
+ container?: string;
318
+ video?: {
319
+ codec?: string;
320
+ width?: number;
321
+ height?: number;
322
+ bitrate?: number;
323
+ minBitrate?: number;
324
+ maxBitrate?: number;
325
+ fps?: number;
326
+ idrIntervalMillis?: number;
327
+ };
328
+ audio?: {
329
+ codec?: string;
330
+ bitrate?: number;
331
+ };
332
+ }
333
+ /**
334
+ * VideoCamera devices can capture video streams.
335
+ */
336
+ export interface VideoCamera {
337
+ getVideoStream(options?: MediaStreamOptions): Promise<MediaObject>;
338
+ /**
339
+ * Get the available video streaming options.
340
+ */
341
+ getVideoStreamOptions(): Promise<MediaStreamOptions[]>;
342
+ }
343
+ /**
344
+ * Intercom devices can play back
345
+ */
346
+ export interface Intercom {
347
+ startIntercom(media: MediaObject): Promise<void>;
348
+ stopIntercom(): Promise<void>;
349
+ }
350
+ /**
351
+ * Lock controls devices that can lock or unlock entries. Often works in tandem with PasswordControl.
352
+ */
353
+ export interface Lock {
354
+ lock(): Promise<void>;
355
+ unlock(): Promise<void>;
356
+ lockState?: LockState;
357
+ }
358
+ export declare enum LockState {
359
+ Locked = "Locked",
360
+ Unlocked = "Unlocked",
361
+ Jammed = "Jammed"
362
+ }
363
+ /**
364
+ * PasswordControl represents devices that authorize users via a passcode or pin code.
365
+ */
366
+ export interface PasswordStore extends Authenticator {
367
+ addPassword(password: string): Promise<void>;
368
+ getPasswords(): Promise<string[]>;
369
+ removePassword(password: string): Promise<void>;
370
+ }
371
+ /**
372
+ * Authenticator can be used to require a password before allowing interaction with a security device.
373
+ */
374
+ export interface Authenticator {
375
+ checkPassword(password: string): Promise<boolean>;
376
+ }
377
+ /**
378
+ * Scenes control multiple different devices into a given state.
379
+ */
380
+ export interface Scene {
381
+ activate(): Promise<void>;
382
+ deactivate(): Promise<void>;
383
+ /**
384
+ * If a scene can be reversed, isReversible should return true. Otherwise deactivate will not be called.
385
+ */
386
+ isReversible(): boolean;
387
+ }
388
+ /**
389
+ * Entry represents devices that can open and close barriers, such as garage doors.
390
+ */
391
+ export interface Entry extends EntrySensor {
392
+ closeEntry(): Promise<void>;
393
+ openEntry(): Promise<void>;
394
+ }
395
+ export interface EntrySensor {
396
+ entryOpen?: boolean;
397
+ }
398
+ /**
399
+ * DeviceProvider acts as a controller/hub and exposes multiple devices to Scrypted Device Manager.
400
+ */
401
+ export interface DeviceProvider {
402
+ /**
403
+ * Perform device discovery for the specified duration in seconds.
404
+ */
405
+ discoverDevices(duration: number): Promise<void>;
406
+ /**
407
+ * Get an instance of a previously discovered device that was reported to the device manager.
408
+ */
409
+ getDevice(nativeId: ScryptedNativeId): any;
410
+ }
411
+ /**
412
+ * Battery retrieves the battery level of battery powered devices.
413
+ */
414
+ export interface Battery {
415
+ batteryLevel?: number;
416
+ }
417
+ /**
418
+ * Refresh indicates that this device has properties that are not automatically updated, and must be periodically refreshed via polling. Device implementations should never implement their own underlying polling algorithm, and instead implement Refresh to allow Scrypted to manage polling intelligently.
419
+ */
420
+ export interface Refresh {
421
+ /**
422
+ * Get the recommended refresh/poll frequency in seconds for this device.
423
+ */
424
+ getRefreshFrequency(): Promise<number>;
425
+ /**
426
+ * This method is called by Scrypted when the properties of the device need to be refreshed. When the device has completed the refresh, the appropriate DeviceState properties should be set. The parameters provide the specific interface that needs to be refreshed and whether it was user initiated (via UI or voice).
427
+ */
428
+ refresh(refreshInterface: string, userInitiated: boolean): Promise<void>;
429
+ }
430
+ /**
431
+ * MediaPlayer allows media playback on screen or speaker devices, such as Chromecasts or TVs.
432
+ */
433
+ export interface MediaPlayer extends StartStop, Pause {
434
+ getMediaStatus(): Promise<MediaStatus>;
435
+ load(media: string | MediaObject, options?: MediaPlayerOptions): Promise<void>;
436
+ seek(milliseconds: number): Promise<void>;
437
+ skipNext(): Promise<void>;
438
+ skipPrevious(): Promise<void>;
439
+ }
440
+ export interface MediaPlayerOptions {
441
+ autoplay?: boolean;
442
+ mimeType?: string;
443
+ title?: string;
444
+ }
445
+ /**
446
+ * Online denotes whether the device is online or unresponsive. It may be unresponsive due to being unplugged, network error, etc.
447
+ */
448
+ export interface Online {
449
+ online?: boolean;
450
+ }
451
+ export interface Program {
452
+ /**
453
+ * Asynchronously run a script given the provided arguments.
454
+ */
455
+ run(variables?: {
456
+ [name: string]: any;
457
+ }): Promise<any>;
458
+ }
459
+ export interface ScriptSource {
460
+ name?: string;
461
+ script?: string;
462
+ language?: string;
463
+ monacoEvalDefaults?: string;
464
+ }
465
+ export interface Scriptable {
466
+ saveScript(script: ScriptSource): Promise<void>;
467
+ loadScripts(): Promise<{
468
+ [filename: string]: ScriptSource;
469
+ }>;
470
+ eval(source: ScriptSource, variables?: {
471
+ [name: string]: any;
472
+ }): Promise<any>;
473
+ }
474
+ /**
475
+ * SoftwareUpdate provides a way to check for updates and install them. This may be a Scrypted Plugin or device firmware.
476
+ */
477
+ export interface SoftwareUpdate {
478
+ checkForUpdate(): Promise<void>;
479
+ installUpdate(): Promise<void>;
480
+ updateAvailable?: boolean;
481
+ }
482
+ /**
483
+ * Add a converter to be used by Scrypted to convert buffers from one mime type to another mime type. May optionally accept string urls if accept-url is a fromMimeType parameter.
484
+ */
485
+ export interface BufferConverter {
486
+ convert(data: string | Buffer, fromMimeType: string): Promise<Buffer | string>;
487
+ fromMimeType?: string;
488
+ toMimeType?: string;
489
+ }
490
+ /**
491
+ * Settings viewing and editing of device configurations that describe or modify behavior.
492
+ */
493
+ export interface Settings {
494
+ getSettings(): Promise<Setting[]>;
495
+ putSetting(key: string, value: SettingValue): Promise<void>;
496
+ }
497
+ export interface BinarySensor {
498
+ binaryState?: boolean;
499
+ }
500
+ export interface IntrusionSensor {
501
+ intrusionDetected?: boolean;
502
+ }
503
+ export interface PowerSensor {
504
+ powerDetected?: boolean;
505
+ }
506
+ export interface AudioSensor {
507
+ audioDetected?: boolean;
508
+ }
509
+ export interface MotionSensor {
510
+ motionDetected?: boolean;
511
+ }
512
+ export interface OccupancySensor {
513
+ occupied?: boolean;
514
+ }
515
+ export interface FloodSensor {
516
+ flooded?: boolean;
517
+ }
518
+ export interface UltravioletSensor {
519
+ ultraviolet?: number;
520
+ }
521
+ export interface LuminanceSensor {
522
+ luminance?: number;
523
+ }
524
+ export interface PositionSensor {
525
+ position?: Position;
526
+ }
527
+ export interface Position {
528
+ /**
529
+ * The accuracy radius of this position in meters.
530
+ */
531
+ accuracyRadius?: number;
532
+ latitude?: number;
533
+ longitude?: number;
534
+ }
535
+ export interface ObjectDetectionResult {
536
+ className: string;
537
+ score: number;
538
+ boundingBox?: [number, number, number, number];
539
+ }
540
+ export interface FaceRecognition {
541
+ id: string;
542
+ label: string;
543
+ score?: number;
544
+ boundingBox?: [number, number, number, number];
545
+ }
546
+ export interface ObjectDetection {
547
+ detections?: ObjectDetectionResult[];
548
+ faces?: ObjectDetectionResult[];
549
+ people?: FaceRecognition[];
550
+ detectionId?: any;
551
+ inputDimensions?: [number, number];
552
+ timestamp: number;
553
+ }
554
+ export interface ObjectDetectionTypes {
555
+ detections?: string[];
556
+ faces?: boolean;
557
+ people?: FaceRecognition[];
558
+ }
559
+ export interface ObjectDetector {
560
+ /**
561
+ * Get the media (image or video) that contains this detection.
562
+ * @param detectionId
563
+ */
564
+ getDetectionInput(detectionId: any): Promise<MediaObject>;
565
+ getObjectTypes(): Promise<ObjectDetectionTypes>;
566
+ }
567
+ /**
568
+ * Logger is exposed via log.* to allow writing to the Scrypted log.
569
+ */
570
+ export interface Logger {
571
+ /**
572
+ * Alert. Alert level logs will be displayed as a notification in the management console.
573
+ */
574
+ a(msg: string): void;
575
+ /**
576
+ * Clear the log
577
+ */
578
+ clear(): void;
579
+ /**
580
+ * Clear a specific alert
581
+ */
582
+ clearAlert(msg: string): void;
583
+ /**
584
+ * Clear all alerts
585
+ */
586
+ clearAlerts(): void;
587
+ /**
588
+ * Debug
589
+ */
590
+ d(msg: string): void;
591
+ /**
592
+ * Error
593
+ */
594
+ e(msg: string): void;
595
+ /**
596
+ * Info
597
+ */
598
+ i(msg: string): void;
599
+ /**
600
+ * Verbose
601
+ */
602
+ v(msg: string): void;
603
+ /**
604
+ * Warn
605
+ */
606
+ w(msg: string): void;
607
+ }
608
+ export interface MediaSource {
609
+ /**
610
+ * Get a MediaObject that will be automatically converted for playback on other devices.
611
+ */
612
+ getMedia(): MediaObject;
613
+ }
614
+ export interface MessagingEndpoint {
615
+ }
616
+ /**
617
+ * The OauthClient can be implemented to perform the browser based Oauth process from within a plugin.
618
+ */
619
+ export interface OauthClient {
620
+ /**
621
+ * Get the Oauth URL to navigate to in the browser. The redirect_uri parameter is not needed and will be automatically set by Scrypted.
622
+ */
623
+ getOauthUrl(): Promise<string>;
624
+ /**
625
+ * When an oauth request by a plugin completes, the callback url, with the code/token, will be passed to this method.
626
+ */
627
+ onOauthCallback(callbackUrl: string): Promise<void>;
628
+ }
629
+ export interface MediaManager {
630
+ /**
631
+ * Additional plugin provided convertors to consider for use when converting MediaObjects.
632
+ */
633
+ builtinConverters: BufferConverter[];
634
+ /**
635
+ * Convert a media object to a Buffer of the given mime type.
636
+ */
637
+ convertMediaObjectToBuffer(mediaObject: string | MediaObject, toMimeType: string): Promise<Buffer>;
638
+ /**
639
+ * Convert a media object to a locally accessible URL that serves a media file of the given mime type. If the media object is an externally accessible URL, that will be returned.
640
+ */
641
+ convertMediaObjectToInsecureLocalUrl(mediaObject: string | MediaObject, toMimeType: string): Promise<string>;
642
+ /**
643
+ * Convert a media object to a locally accessible URL that serves a media file of the given mime type. If the media object is an externally accessible URL, that will be returned.
644
+ */
645
+ convertMediaObjectToLocalUrl(mediaObject: string | MediaObject, toMimeType: string): Promise<string>;
646
+ /**
647
+ * Convert a media object to a publically accessible URL that serves a media file of the given mime type.
648
+ */
649
+ convertMediaObjectToUrl(mediaObject: string | MediaObject, toMimeType: string): Promise<string>;
650
+ /**
651
+ * Create a MediaObject. The media will be created from the provided FFmpeg input arguments.
652
+ */
653
+ createFFmpegMediaObject(ffmpegInput: FFMpegInput): MediaObject;
654
+ /**
655
+ * Create a MediaObject. The mime type needs to be provided up front, but the data can be a URL string, Buffer, or a Promise for a URL string or Buffer.
656
+ */
657
+ createMediaObject(data: string | Buffer | Promise<string | Buffer>, mimeType: string): MediaObject;
658
+ /**
659
+ * Get the path to ffmpeg on the host system.
660
+ */
661
+ getFFmpegPath(): Promise<string>;
662
+ }
663
+ export interface FFMpegInput {
664
+ inputArguments?: string[];
665
+ mediaStreamOptions?: MediaStreamOptions;
666
+ }
667
+ /**
668
+ * DeviceManager is the interface used by DeviceProvider to report new devices, device states, and device events to Scrypted.
669
+ */
670
+ export interface DeviceManager {
671
+ /**
672
+ * Get the logger for a device given a native id.
673
+ */
674
+ getDeviceLogger(nativeId?: ScryptedNativeId): Logger;
675
+ /**
676
+ * Get the console for the device given a native id.
677
+ */
678
+ getDeviceConsole?(nativeId?: ScryptedNativeId): Console;
679
+ /**
680
+ * Get the console for the device given a native id.
681
+ */
682
+ getMixinConsole?(mixinId: string, nativeId?: ScryptedNativeId): Console;
683
+ /**
684
+ * Get the device state maintained by Scrypted. Setting properties on this state will update the state in Scrypted.
685
+ */
686
+ getDeviceState(nativeId?: ScryptedNativeId): DeviceState;
687
+ /**
688
+ * Get the per script Storage object.
689
+ */
690
+ getDeviceStorage(): Storage;
691
+ /**
692
+ * Get the storage for a mixin.
693
+ * @param id The id of the device being mixined.
694
+ * @param nativeId The nativeId of the MixinProvider.
695
+ */
696
+ getMixinStorage(id: string, nativeId?: ScryptedNativeId): Storage;
697
+ /**
698
+ * Fire an event for a mixin provided by this plugin.
699
+ */
700
+ onMixinEvent(id: string, nativeId: ScryptedNativeId, eventInterface: string, eventData: any): Promise<void>;
701
+ /**
702
+ * Get the per device Storage object.
703
+ */
704
+ getDeviceStorage(nativeId?: ScryptedNativeId): Storage;
705
+ getNativeIds(): string[];
706
+ /**
707
+ * onDeviceDiscovered is used to report new devices that are trickle discovered, one by one, such as via a network broadcast.
708
+ */
709
+ onDeviceDiscovered(device: Device): Promise<void>;
710
+ /**
711
+ * Fire an event for a device provided by this plugin.
712
+ */
713
+ onDeviceEvent(nativeId: ScryptedNativeId, eventInterface: string, eventData: any): Promise<void>;
714
+ /**
715
+ * onDeviceRemoved is used to report when discovered devices are removed.
716
+ */
717
+ onDeviceRemoved(nativeId: string): Promise<void>;
718
+ /**
719
+ * onDevicesChanged is used to sync Scrypted with devices that are attached to a hub, such as Hue or SmartThings. All the devices should be reported at once.
720
+ */
721
+ onDevicesChanged(devices: DeviceManifest): Promise<void>;
722
+ /**
723
+ * Restart the plugin. May not happen immediately.
724
+ */
725
+ requestRestart(): Promise<void>;
726
+ }
727
+ export interface DeviceInformation {
728
+ model?: string;
729
+ manufacturer?: string;
730
+ version?: string;
731
+ firmware?: string;
732
+ serialNumber?: string;
733
+ metadata?: any;
734
+ }
735
+ /**
736
+ * Device objects are created by DeviceProviders when new devices are discover and synced to Scrypted via the DeviceManager.
737
+ */
738
+ export interface Device {
739
+ name: string;
740
+ /**
741
+ * The native id that is used by the DeviceProvider used to internally identify provided devices.
742
+ */
743
+ nativeId: string;
744
+ type: ScryptedDeviceType;
745
+ interfaces: string[];
746
+ info?: DeviceInformation;
747
+ /**
748
+ * The native id of the hub or discovery DeviceProvider that manages this device.
749
+ */
750
+ providerNativeId?: ScryptedNativeId;
751
+ room?: string;
752
+ }
753
+ /**
754
+ * DeviceManifest is passed to DeviceManager.onDevicesChanged to sync a full list of devices from the controller/hub (Hue, SmartThings, etc)
755
+ */
756
+ export interface DeviceManifest {
757
+ /**
758
+ * The native id of the hub or discovery DeviceProvider that manages these devices.
759
+ */
760
+ providerNativeId?: ScryptedNativeId;
761
+ devices?: Device[];
762
+ }
763
+ /**
764
+ * EndpointManager provides publicly accessible URLs that can be used to contact your Scrypted Plugin.
765
+ */
766
+ export interface EndpointManager {
767
+ /**
768
+ * Get an URL pathname that can be accessed on your local network or cloud while authenticated. This is an absolute path that requires cookie authentication, and generally used only in browser contexts.
769
+ */
770
+ getAuthenticatedPath(): Promise<string>;
771
+ /**
772
+ * Get an URL pathname that can be accessed on your local network or cloud while authenticated. This is an absolute path that requires cookie authentication, and generally used only in browser contexts.
773
+ */
774
+ getAuthenticatedPath(nativeId?: ScryptedNativeId): Promise<string>;
775
+ /**
776
+ * Get an URL that can only be accessed on your local network by anyone with the link. HTTP requests and responses are without any encryption. Plugin implementation is responsible for authentication.
777
+ */
778
+ getInsecurePublicLocalEndpoint(): Promise<string>;
779
+ /**
780
+ * Get an URL that can only be accessed on your local network by anyone with the link. HTTP requests and responses are without any encryption. Plugin implementation is responsible for authentication.
781
+ */
782
+ getInsecurePublicLocalEndpoint(nativeId?: ScryptedNativeId): Promise<string>;
783
+ /**
784
+ * Get an URL that can be externally accessed by anyone with the link. Plugin implementation is responsible for authentication.
785
+ */
786
+ getPublicCloudEndpoint(): Promise<string>;
787
+ /**
788
+ * Get an URL that can be externally accessed by anyone with the link. Plugin implementation is responsible for authentication.
789
+ */
790
+ getPublicCloudEndpoint(nativeId?: ScryptedNativeId): Promise<string>;
791
+ /**
792
+ * Get an URL that can only be accessed on your local network by anyone with the link. HTTP requests and responses are over SSL with a self signed certificate. Plugin implementation is responsible for authentication.
793
+ */
794
+ getPublicLocalEndpoint(): Promise<string>;
795
+ /**
796
+ * Get an URL that can only be accessed on your local network by anyone with the link. HTTP requests and responses are over SSL with a self signed certificate. Plugin implementation is responsible for authentication.
797
+ */
798
+ getPublicLocalEndpoint(nativeId?: ScryptedNativeId): Promise<string>;
799
+ /**
800
+ * Get an URL that can be used to send a push message to the client. This differs from a cloud endpoint, in that, the Plugin does not send a response back. Plugin implementation is responsible for authentication.
801
+ */
802
+ getPublicPushEndpoint(): Promise<string>;
803
+ /**
804
+ * Get an URL that can be used to send a push message to the client. This differs from a cloud endpoint, in that, the Plugin does not send a response back. Plugin implementation is responsible for authentication.
805
+ */
806
+ getPublicPushEndpoint(nativeId?: ScryptedNativeId): Promise<string>;
807
+ /**
808
+ * Deliver a push notification to the system.
809
+ */
810
+ deliverPush(endpoint: string, request: HttpRequest): Promise<void>;
811
+ }
812
+ /**
813
+ * SystemManager is used by scripts to query device state and access devices.
814
+ */
815
+ export interface SystemManager {
816
+ /**
817
+ * Retrieve a system service.
818
+ */
819
+ getComponent(id: string): Promise<any>;
820
+ /**
821
+ * Find a Scrypted device by id.
822
+ */
823
+ getDeviceById(id: string): ScryptedDevice;
824
+ /**
825
+ * Find a Scrypted device by id.
826
+ */
827
+ getDeviceById<T>(id: string): ScryptedDevice & T;
828
+ /**
829
+ * Find a Scrypted device by name.
830
+ */
831
+ getDeviceByName(name: string): ScryptedDevice;
832
+ /**
833
+ * Find a Scrypted device by name.
834
+ */
835
+ getDeviceByName<T>(name: string): ScryptedDevice & T;
836
+ /**
837
+ * Get the current state of a device.
838
+ */
839
+ getDeviceState(id: string): any;
840
+ /**
841
+ * Get the current state of every device.
842
+ */
843
+ getSystemState(): {
844
+ [id: string]: {
845
+ [property: string]: SystemDeviceState;
846
+ };
847
+ };
848
+ /**
849
+ * Passively (without polling) listen to property changed events.
850
+ */
851
+ listen(EventListener: EventListener): EventListenerRegister;
852
+ /**
853
+ * Subscribe to events from a specific interface on a device id, such as 'OnOff' or 'Brightness'. This is a convenience method for ScryptedDevice.listen.
854
+ */
855
+ listenDevice(id: string, event: ScryptedInterface | string | EventListenerOptions, callback: EventListener): EventListenerRegister;
856
+ /**
857
+ * Remove a device from Scrypted. Plugins should use DeviceManager.onDevicesChanged or DeviceManager.onDeviceRemoved to remove their own devices
858
+ */
859
+ removeDevice(id: string): Promise<void>;
860
+ }
861
+ /**
862
+ * MixinProviders can add and intercept interfaces to other devices to add or augment their behavior.
863
+ */
864
+ export interface MixinProvider {
865
+ /**
866
+ * Called by the system to determine if this provider can create a mixin for the supplied device. Returns null if a mixin can not be created, otherwise returns a list of new interfaces (which may be an empty list) that are provided by the mixin.
867
+ */
868
+ canMixin(type: ScryptedDeviceType, interfaces: string[]): Promise<string[]>;
869
+ /**
870
+ * Create a mixin that can be applied to the supplied device.
871
+ */
872
+ getMixin(mixinDevice: any, mixinDeviceInterfaces: ScryptedInterface[], mixinDeviceState: {
873
+ [key: string]: any;
874
+ }): Promise<any>;
875
+ /**
876
+ * Release a mixin device that was previously returned from getMixin.
877
+ */
878
+ releaseMixin(id: string, mixinDevice: any): Promise<void>;
879
+ }
880
+ /**
881
+ * The HttpRequestHandler allows handling of web requests under the endpoint path: /endpoint/npm-package-name/*.
882
+ */
883
+ export interface HttpRequestHandler {
884
+ /**
885
+ * Callback to handle an incoming request.
886
+ */
887
+ onRequest(request: HttpRequest, response: HttpResponse): Promise<void>;
888
+ }
889
+ export interface HttpRequest {
890
+ body?: string;
891
+ headers?: object;
892
+ isPublicEndpoint?: boolean;
893
+ method?: string;
894
+ rootPath?: string;
895
+ url?: string;
896
+ username?: string;
897
+ }
898
+ /**
899
+ * Response object provided by the HttpRequestHandler.
900
+ */
901
+ export interface HttpResponse {
902
+ send(body: string): void;
903
+ send(body: string, options: HttpResponseOptions): void;
904
+ send(body: Buffer): void;
905
+ send(body: Buffer, options: HttpResponseOptions): void;
906
+ sendFile(path: string): void;
907
+ sendFile(path: string, options: HttpResponseOptions): void;
908
+ }
909
+ export interface HttpResponseOptions {
910
+ code?: number;
911
+ headers?: object;
912
+ }
913
+ export interface EngineIOHandler {
914
+ onConnection(request: HttpRequest, webSocketUrl: string): Promise<void>;
915
+ }
916
+ export interface PushHandler {
917
+ /**
918
+ * Callback to handle an incoming push.
919
+ */
920
+ onPush(request: HttpRequest): Promise<void>;
921
+ }
922
+ export interface SystemDeviceState {
923
+ /**
924
+ * The last time the state was updated, even if it did not change.
925
+ */
926
+ lastEventTime?: number;
927
+ /**
928
+ * The last time the state changed.
929
+ */
930
+ stateTime?: number;
931
+ value?: any;
932
+ }
933
+ export interface MediaStatus {
934
+ duration?: number;
935
+ mediaPlayerState?: MediaPlayerState;
936
+ metadata?: any;
937
+ position?: number;
938
+ }
939
+ export declare enum MediaPlayerState {
940
+ Idle = "Idle",
941
+ Playing = "Playing",
942
+ Paused = "Paused",
943
+ Buffering = "Buffering"
944
+ }
945
+ export declare type SettingValue = string | number | boolean | string[] | number[];
946
+ export interface Setting {
947
+ key?: string;
948
+ title?: string;
949
+ group?: string;
950
+ description?: string;
951
+ placeholder?: string;
952
+ type?: 'string' | 'password' | 'number' | 'boolean' | 'device';
953
+ readonly?: boolean;
954
+ choices?: string[];
955
+ combobox?: boolean;
956
+ deviceFilter?: string;
957
+ multiple?: boolean;
958
+ value?: SettingValue;
959
+ }
960
+ export declare enum ScryptedInterface {
961
+ ScryptedDevice = "ScryptedDevice",
962
+ OnOff = "OnOff",
963
+ Brightness = "Brightness",
964
+ ColorSettingTemperature = "ColorSettingTemperature",
965
+ ColorSettingRgb = "ColorSettingRgb",
966
+ ColorSettingHsv = "ColorSettingHsv",
967
+ Notifier = "Notifier",
968
+ StartStop = "StartStop",
969
+ Pause = "Pause",
970
+ Dock = "Dock",
971
+ TemperatureSetting = "TemperatureSetting",
972
+ Thermometer = "Thermometer",
973
+ HumiditySensor = "HumiditySensor",
974
+ Camera = "Camera",
975
+ VideoCamera = "VideoCamera",
976
+ Intercom = "Intercom",
977
+ Lock = "Lock",
978
+ PasswordStore = "PasswordStore",
979
+ Authenticator = "Authenticator",
980
+ Scene = "Scene",
981
+ Entry = "Entry",
982
+ EntrySensor = "EntrySensor",
983
+ DeviceProvider = "DeviceProvider",
984
+ Battery = "Battery",
985
+ Refresh = "Refresh",
986
+ MediaPlayer = "MediaPlayer",
987
+ Online = "Online",
988
+ SoftwareUpdate = "SoftwareUpdate",
989
+ BufferConverter = "BufferConverter",
990
+ Settings = "Settings",
991
+ BinarySensor = "BinarySensor",
992
+ IntrusionSensor = "IntrusionSensor",
993
+ PowerSensor = "PowerSensor",
994
+ AudioSensor = "AudioSensor",
995
+ MotionSensor = "MotionSensor",
996
+ OccupancySensor = "OccupancySensor",
997
+ FloodSensor = "FloodSensor",
998
+ UltravioletSensor = "UltravioletSensor",
999
+ LuminanceSensor = "LuminanceSensor",
1000
+ PositionSensor = "PositionSensor",
1001
+ MediaSource = "MediaSource",
1002
+ MessagingEndpoint = "MessagingEndpoint",
1003
+ OauthClient = "OauthClient",
1004
+ MixinProvider = "MixinProvider",
1005
+ HttpRequestHandler = "HttpRequestHandler",
1006
+ EngineIOHandler = "EngineIOHandler",
1007
+ PushHandler = "PushHandler",
1008
+ Program = "Program",
1009
+ Scriptable = "Scriptable",
1010
+ ObjectDetector = "ObjectDetector"
1011
+ }
1012
+ export declare enum ScryptedInterfaceProperty {
1013
+ id = "id",
1014
+ interfaces = "interfaces",
1015
+ mixins = "mixins",
1016
+ info = "info",
1017
+ name = "name",
1018
+ providedInterfaces = "providedInterfaces",
1019
+ providedName = "providedName",
1020
+ providedRoom = "providedRoom",
1021
+ providedType = "providedType",
1022
+ providerId = "providerId",
1023
+ room = "room",
1024
+ type = "type",
1025
+ on = "on",
1026
+ brightness = "brightness",
1027
+ colorTemperature = "colorTemperature",
1028
+ rgb = "rgb",
1029
+ hsv = "hsv",
1030
+ running = "running",
1031
+ paused = "paused",
1032
+ docked = "docked",
1033
+ thermostatAvailableModes = "thermostatAvailableModes",
1034
+ thermostatMode = "thermostatMode",
1035
+ thermostatSetpoint = "thermostatSetpoint",
1036
+ thermostatSetpointHigh = "thermostatSetpointHigh",
1037
+ thermostatSetpointLow = "thermostatSetpointLow",
1038
+ temperature = "temperature",
1039
+ temperatureUnit = "temperatureUnit",
1040
+ humidity = "humidity",
1041
+ lockState = "lockState",
1042
+ entryOpen = "entryOpen",
1043
+ batteryLevel = "batteryLevel",
1044
+ online = "online",
1045
+ updateAvailable = "updateAvailable",
1046
+ fromMimeType = "fromMimeType",
1047
+ toMimeType = "toMimeType",
1048
+ binaryState = "binaryState",
1049
+ intrusionDetected = "intrusionDetected",
1050
+ powerDetected = "powerDetected",
1051
+ motionDetected = "motionDetected",
1052
+ audioDetected = "audioDetected",
1053
+ occupied = "occupied",
1054
+ flooded = "flooded",
1055
+ ultraviolet = "ultraviolet",
1056
+ luminance = "luminance",
1057
+ position = "position"
1058
+ }
1059
+ export interface RTCAVMessage {
1060
+ id: string;
1061
+ description: RTCSessionDescriptionInit;
1062
+ candidates: RTCIceCandidateInit[];
1063
+ configuration: RTCConfiguration;
1064
+ }
1065
+ export declare enum ScryptedMimeTypes {
1066
+ AcceptUrlParameter = "accept-url",
1067
+ Url = "text/x-uri",
1068
+ InsecureLocalUrl = "text/x-insecure-local-uri",
1069
+ LocalUrl = "text/x-local-uri",
1070
+ PushEndpoint = "text/x-push-endpoint",
1071
+ FFmpegInput = "x-scrypted/x-ffmpeg-input",
1072
+ RTCAVOffer = "x-scrypted/x-rtc-av-offer",
1073
+ RTCAVAnswer = "x-scrypted/x-rtc-av-answer"
1074
+ }
1075
+ export interface ScryptedInterfaceDescriptor {
1076
+ name: string;
1077
+ properties: ScryptedInterfaceProperty[];
1078
+ methods: string[];
1079
+ }
1080
+ export declare const ScryptedInterfaceDescriptors: {
1081
+ [scryptedInterface: string]: ScryptedInterfaceDescriptor;
1082
+ };
1083
+ export interface ScryptedStatic {
1084
+ /**
1085
+ * @deprecated
1086
+ */
1087
+ log?: Logger;
1088
+ deviceManager?: DeviceManager;
1089
+ endpointManager?: EndpointManager;
1090
+ mediaManager?: MediaManager;
1091
+ systemManager: SystemManager;
1092
+ pluginHostAPI?: any;
1093
+ }