unifi-protect 0.0.2 → 2.0.0

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.
@@ -1,502 +0,0 @@
1
- /* Copyright(C) 2021, HJD (https://github.com/hjdhjd). All rights reserved.
2
- *
3
- * protect-types.ts: Type definitions for UniFi Protect.
4
- */
5
- // An semi-complete description of the UniFi Protect NVR bootstrap JSON.
6
- export interface ProtectNvrBootstrapInterface {
7
- accessKey: string,
8
- authUserId: string,
9
- bridges: unknown[],
10
- cameras: ProtectCameraConfig[],
11
- cloudPortalUrl: string,
12
- groups: unknown[],
13
- lastUpdateId: string,
14
- lights: unknown[],
15
- liveviews: ProtectNvrLiveviewConfig[],
16
- nvr: ProtectNvrConfig,
17
- sensors: unknown[],
18
- users: ProtectNvrUserConfig[],
19
- viewers: unknown[]
20
- }
21
-
22
- // A semi-complete description of the UniFi Protect NVR configuration JSON.
23
- export interface ProtectNvrConfigInterface {
24
- availableUpdate: string,
25
- canAutoUpdate: boolean,
26
- cloudConnectionError: string,
27
- disableAudio: boolean,
28
- doorbellSettings: {
29
- defaultMessageText: string,
30
- defaultMessageResetTimeoutMs: number,
31
- customMessages: string[],
32
- allMessages: {
33
- type: string,
34
- text: string
35
- }[]
36
- },
37
- enableAutomaticBackups: boolean,
38
- enableCrashReporting: boolean,
39
- enableStatsReporting: boolean,
40
- errorCode: string,
41
- featureFlags: {
42
- beta: boolean,
43
- dev: boolean
44
- },
45
- firmwareVersion: string,
46
- hardwareId: string,
47
- hardwarePlatform: string,
48
- hardwareRevision: string,
49
- host: string,
50
- hostType: string,
51
- hosts: string[],
52
- id: string,
53
- isAdopted: boolean,
54
- isAway: boolean,
55
- isConnectedToCloud: boolean,
56
- isHardware: boolean,
57
- isSetup: boolean,
58
- isSshEnabled: boolean,
59
- isStation: boolean,
60
- isStatsGatheringEnabled: boolean,
61
- isUpdating: boolean,
62
- lastSeen: number,
63
- lastUpdateAt: string,
64
- locationSettings: {
65
- isAway: boolean,
66
- isGeofencingEnabled: boolean,
67
- latitude: number,
68
- longitude: number,
69
- radius: number
70
- },
71
- mac: string,
72
- modelKey: string,
73
- name: string,
74
- network: string,
75
- ports: {
76
- cameraEvents: number,
77
- cameraHttps: number,
78
- cameraTcp: number,
79
- discoveryClient: number,
80
- elementsWss: number,
81
- emsCLI: number,
82
- emsLiveFLV: number,
83
- http: number,
84
- https: number,
85
- liveWs: number,
86
- liveWss: number,
87
- rtmp: number,
88
- rtsp: number,
89
- tcpStreams: number,
90
- ucore: number,
91
- ump: number
92
- },
93
- recordingRetentionDurationMs: string,
94
- releaseChannel: string,
95
- setupCode: string,
96
- storageInfo: unknown,
97
- timeFormat: string,
98
- timezone: string,
99
- type: string,
100
- uiVersion: string,
101
- upSince: number,
102
- uptime: number,
103
- version: string,
104
- wifiSettings: unknown
105
- }
106
-
107
- // A semi-complete description of the UniFi Protect camera JSON.
108
- export interface ProtectCameraConfigInterface {
109
- apMac: string,
110
- apRssi: string,
111
- audioBitrate: number,
112
- canManage: boolean,
113
- channels: ProtectCameraChannelConfigInterface[],
114
- chimeDuration: number,
115
- connectedSince: number,
116
- connectionHost: string,
117
- elementInfo: null,
118
- featureFlags: {
119
- canAdjustIrLedLevel: boolean,
120
- canMagicZoom: boolean,
121
- canOpticalZoom: boolean,
122
- canTouchFocus: boolean,
123
- hasAccelerometer: boolean,
124
- hasAec: boolean,
125
- hasAutoICROnly: boolean,
126
- hasBattery: boolean,
127
- hasBluetooth: boolean,
128
- hasChime: boolean,
129
- hasExternalIr: boolean,
130
- hasHdr: boolean,
131
- hasIcrSensitivity: boolean,
132
- hasLcdScreen: boolean,
133
- hasLdc: boolean,
134
- hasLedIr: boolean,
135
- hasLedStatus: boolean,
136
- hasLineIn: boolean,
137
- hasMic: boolean,
138
- hasMotionZones: boolean,
139
- hasNewMotionAlgorithm: boolean,
140
- hasPrivacyMask: boolean,
141
- hasRtc: boolean,
142
- hasSdCard: boolean,
143
- hasSmartDetect: boolean,
144
- hasSpeaker: boolean,
145
- hasWifi: boolean,
146
- motionAlgorithms: string[],
147
- privacyMaskCapability: {
148
- maxMasks: number,
149
- rectangleOnly: boolean
150
- },
151
- smartDetectTypes: string[],
152
- videoModeMaxFps: number[],
153
- videoModes: string[]
154
- },
155
- firmwareBuild: string,
156
- firmwareVersion: string,
157
- hardwareRevision: string,
158
- hasSpeaker: boolean,
159
- hasWifi: boolean,
160
- hdrMode: boolean,
161
- host: string,
162
- id: string,
163
- isAdopted: boolean,
164
- isAdopting: boolean,
165
- isAttemptingToConnect: boolean,
166
- isConnected: boolean,
167
- isDark: boolean,
168
- isHidden: boolean,
169
- isManaged: boolean,
170
- isMicEnabled: boolean,
171
- isMotionDetected: boolean,
172
- isProbingForWifi: boolean,
173
- isProvisioned: boolean,
174
- isRebooting: boolean,
175
- isRecording: boolean,
176
- isSshEnabled: boolean,
177
- isUpdating: boolean,
178
- ispSettings: {
179
- aeMode: string,
180
- brightness: number,
181
- contrast: number,
182
- dZoomCenterX: number,
183
- dZoomCenterY: number,
184
- dZoomScale: number,
185
- dZoomStreamId: number,
186
- denoise: number,
187
- focusMode: string,
188
- focusPosition: number,
189
- hue: number,
190
- icrSensitivity: number,
191
- irLedLevel: number,
192
- irLedMode: string,
193
- is3dnrEnabled: boolean,
194
- isAggressiveAntiFlickerEnabled: boolean,
195
- isAutoRotateEnabled: boolean,
196
- isExternalIrEnabled: boolean,
197
- isFlippedHorizontal: boolean,
198
- isFlippedVertical: boolean,
199
- isLdcEnabled: boolean,
200
- isPauseMotionEnabled: boolean,
201
- saturation: number,
202
- sharpness: number,
203
- touchFocusX: number,
204
- touchFocusY: number,
205
- wdr: number,
206
- zoomPosition: number
207
- },
208
- lastMotion: number,
209
- lastRing: number | null,
210
- lastSeen: number,
211
- lcdMessage: ProtectCameraLcdMessageConfigInterface,
212
- ledSettings: {
213
- blinkRate: number,
214
- isEnabled: boolean
215
- },
216
- mac: string,
217
- micVolume: number,
218
- modelKey: string
219
- name: string,
220
- osdSettings: {
221
- isDateEnabled: boolean,
222
- isDebugEnabled: boolean,
223
- isLogoEnabled: boolean,
224
- isNameEnabled: boolean
225
- },
226
- phyRate: number,
227
- pirSettings: {
228
- pirMotionClipLength: number,
229
- pirSensitivity: number,
230
- timelapseFrameInterval: number,
231
- timelapseTransferInterval: number
232
- },
233
- platform: string,
234
- recordingSchedule: null,
235
- recordingSettings: {
236
- enablePirTimelapse: boolean,
237
- endMotionEventDelay: number,
238
- geofencing: string,
239
- minMotionEventTrigger: number,
240
- mode: string,
241
- postPaddingSecs: number,
242
- prePaddingSecs: number,
243
- retentionDurationMs: number | null,
244
- suppressIlluminationSurge: boolean,
245
- useNewMotionAlgorithm: boolean
246
- },
247
- smartDetectLines: [],
248
- smartDetectSettings: {
249
- objectTypes: string[]
250
- },
251
- smartDetectZones: {
252
- color: string,
253
- name: string,
254
- objectTypes: string[],
255
- points: [number, number][],
256
- sensitivity: number
257
- }[],
258
- speakerSettings: {
259
- areSystemSoundsEnabled: boolean,
260
- isEnabled: boolean,
261
- volume: number
262
- },
263
- state: string,
264
- stats: {
265
- battery: {
266
- isCharging: boolean,
267
- percentage: number | null,
268
- sleepState: string
269
- },
270
- rxBytes: number,
271
- storage: {
272
- rate: number,
273
- used: number
274
- },
275
- txBytes: number,
276
- video: {
277
- recordingEnd: number,
278
- recordingEndLQ: number,
279
- recordingStart: number,
280
- recordingStartLQ: number,
281
- timelapseEnd: number,
282
- timelapseEndLQ: number,
283
- timelapseStart: number,
284
- timelapseStartLQ: number
285
- },
286
- wifi: {
287
- channel: number | null,
288
- frequency: number | null,
289
- linkSpeedMbps: number | null,
290
- signalQuality: number,
291
- signalStrength: number
292
- },
293
- wifiQuality: number,
294
- wifiStrength: number
295
- },
296
- talkbackSettings: {
297
- bindAddr: string,
298
- bindPort: number,
299
- bitsPerSample: number,
300
- channels: number,
301
- filterAddr: string,
302
- filterPort: number,
303
- typeFmt: string,
304
- typeIn: string,
305
- quality: number,
306
- samplingRate: number
307
- },
308
- type: string,
309
- upSince: number,
310
- wifiConnectionState: {
311
- channel: number | null,
312
- frequency: number | null,
313
- phyRate: number | null,
314
- signalQuality: number | null,
315
- signalStrength: number | null
316
- },
317
- wiredConnectionState: {
318
- phyRate: number
319
- }
320
- }
321
-
322
- // A semi-complete description of the UniFi Protect camera channel JSON.
323
- export interface ProtectCameraChannelConfigInterface {
324
- bitrate: number,
325
- enabled: boolean,
326
- fps: number,
327
- fpsValues: number[],
328
- height: number,
329
- id: string,
330
- idrInterval: number,
331
- isRtspEnabled: boolean,
332
- maxBitrate: number,
333
- minBitrate: number,
334
- minClientAdaptiveBitRate: number,
335
- minMotionAdaptiveBitRate: number,
336
- name: string,
337
- rtspAlias: string,
338
- videoId: string,
339
- width: number
340
- }
341
-
342
- // A semi-complete description of the UniFi Protect LCD message JSON.
343
- export interface ProtectCameraLcdMessageConfigInterface {
344
- duration: number,
345
- resetAt: number | null,
346
- text: string,
347
- type: string
348
- }
349
-
350
- // A semi-complete description of the UniFi Protect NVR liveview JSON.
351
- export interface ProtectNvrLiveviewConfigInterface {
352
- id: string,
353
- isDefault: boolean,
354
- isGlobal: boolean,
355
- layout: number,
356
- modelKey: string,
357
- name: string,
358
- owner: string,
359
- slots: { cameras: string[], cycleInterval: number, cycleMode: string } []
360
- }
361
-
362
- // A semi-complete description of the UniFi Protect NVR user JSON.
363
- export interface ProtectNvrUserConfigInterface {
364
- alertRules: unknown[],
365
- allPermissions: string[],
366
- cloudAccount: string,
367
- email: string,
368
- enableNotifications: boolean,
369
- firstName: string,
370
- groups: string[],
371
- hasAcceptedInvite: boolean,
372
- id: string,
373
- isOwner: boolean,
374
- lastLoginIp: string,
375
- lastLoginTime: number,
376
- lastName: string,
377
- localUsername: string,
378
- location: {
379
- isAway: boolean,
380
- latitude: string,
381
- longitude: string },
382
- modelKey: string,
383
- name: string,
384
- permissions: string[],
385
- role: string,
386
- settings: {
387
- flags: string[]
388
- },
389
- syncSso: boolean
390
- }
391
-
392
- // A semi-complete description of the UniFi Protect system events JSON.
393
- export interface ProtectNvrSystemEventInterface {
394
- apps: {
395
- apps: unknown[],
396
- controllers: ProtectNvrSystemEventController[]
397
- },
398
- system: unknown,
399
- type: string
400
- }
401
-
402
- // A semi-complete description of the UniFi Protect system events controller JSON.
403
- export interface ProtectNvrSystemEventControllerInterface {
404
- harddriveRequired: boolean,
405
- info: {
406
- events: number[],
407
- isAdopted: boolean,
408
- isConnectedToCloud: boolean,
409
- isSetup: boolean,
410
- lastMotion: number,
411
- lastMotionCamera: string,
412
- lastMotionCameraAddress: string,
413
- lastMotionCameraModel: string,
414
- managedCameras: number,
415
- offlineCameras: number,
416
- oldestRecording: number,
417
- onlineCameras: number,
418
- recordingSpaceTotal: number,
419
- recordingSpaceUsed: number,
420
- retentionTime: number,
421
- startedAt: number,
422
- throughput: number,
423
- timeFormat: string,
424
- updateAvailable: boolean,
425
- updateVersion: string
426
- },
427
- installState: string,
428
- isConfigured: boolean,
429
- isInstalled: boolean,
430
- isRunning: boolean,
431
- name: string,
432
- port: number,
433
- required: boolean,
434
- state: string,
435
- status: string,
436
- statusMessage: string,
437
- swaiVersion: number,
438
- type: string,
439
- ui: {
440
- apiPrefix: string,
441
- baseUrl: string,
442
- cdnPublicPaths: string[],
443
- entrypoint: string,
444
- hotkey: string,
445
- icon: string,
446
- publicPath: string,
447
- swaiVersion: number
448
- },
449
- uiNpmPackageName: string,
450
- uiVersion: string,
451
- unadoptedDevices: unknown[],
452
- updateAvailable: string,
453
- version: string
454
- }
455
-
456
- // Plugin configuration options.
457
- export interface ProtectOptions {
458
- controllers: ProtectNvrOptions[],
459
- debugAll: boolean,
460
- ffmpegOptions: string[],
461
- motionDuration: number,
462
- options: string[],
463
- verboseFfmpeg: boolean,
464
- videoProcessor: string
465
- }
466
-
467
- // NVR configuration options.
468
- export interface ProtectNvrOptions {
469
- address: string,
470
- doorbellMessages: {
471
- duration: number,
472
- message: string
473
- }[],
474
- mqttTopic: string,
475
- mqttUrl: string,
476
- name: string,
477
- refreshInterval: number,
478
- username: string,
479
- password: string
480
- }
481
-
482
- // This type declaration make all properties optional recursively including nested objects. This should
483
- // only be used on JSON objects only. Otherwise...you're going to end up with class methods marked as
484
- // optional as well. Credit for this belongs to: https://github.com/joonhocho/tsdef. #Grateful
485
- export type DeepPartial<T> = {
486
- [P in keyof T]?: T[P] extends Array<infer I> ? Array<DeepPartial<I>> : DeepPartial<T[P]>
487
- };
488
-
489
- // We use types instead of interfaces here because we can more easily set the entire thing as readonly.
490
- // Unfortunately, interfaces can't be quickly set as readonly in Typescript without marking each and
491
- // every property as readonly along the way.
492
- export type ProtectNvrBootstrap = Readonly<ProtectNvrBootstrapInterface>;
493
- export type ProtectNvrConfig = Readonly<ProtectNvrConfigInterface>;
494
- export type ProtectCameraConfig = Readonly<ProtectCameraConfigInterface>;
495
- export type ProtectCameraConfigPayload = DeepPartial<ProtectCameraConfigInterface>;
496
- export type ProtectCameraChannelConfig = Readonly<ProtectCameraChannelConfigInterface>;
497
- export type ProtectCameraLcdMessageConfig = Readonly<ProtectCameraLcdMessageConfigInterface>;
498
- export type ProtectCameraLcdMessagePayload = DeepPartial<ProtectCameraLcdMessageConfigInterface>;
499
- export type ProtectNvrLiveviewConfig = Readonly<ProtectNvrLiveviewConfigInterface>;
500
- export type ProtectNvrSystemEvent = Readonly<ProtectNvrSystemEventInterface>;
501
- export type ProtectNvrSystemEventController = Readonly<ProtectNvrSystemEventControllerInterface>;
502
- export type ProtectNvrUserConfig = Readonly<ProtectNvrUserConfigInterface>;
package/src/settings.ts DELETED
@@ -1,20 +0,0 @@
1
- /* Copyright(C) 2017-2021, HJD (https://github.com/hjdhjd). All rights reserved.
2
- *
3
- * settings.ts: Settings and constants for homebridge-unifi-protect.
4
- */
5
-
6
- // Number of API errors to accept before we implement backoff so we don't slam a Protect controller.
7
- export const PROTECT_API_ERROR_LIMIT = 10;
8
-
9
- // Interval, in seconds, to wait before trying to access the API again once we've hit the PROTECT_API_ERROR_LIMIT threshold.
10
- export const PROTECT_API_RETRY_INTERVAL = 300;
11
-
12
- // Protect API response timeout, in seconds. This should never be greater than 5 seconds.
13
- export const PROTECT_API_TIMEOUT = 3.5;
14
-
15
- // Heartbeat interval, in seconds, for the realtime Protect API on UniFI OS devices.
16
- // UniFi OS expects to hear from us every 15 seconds.
17
- export const PROTECT_EVENTS_HEARTBEAT_INTERVAL = 10;
18
-
19
- // How often, in seconds, should we refresh our Protect login credentials.
20
- export const PROTECT_LOGIN_REFRESH_INTERVAL = 1800;
package/tsconfig.json DELETED
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2018",
4
- "module": "commonjs",
5
- "lib": [
6
- "ES2015",
7
- "ES2016",
8
- "ES2017",
9
- "ES2018",
10
- "ES2019",
11
- "dom"
12
- ],
13
- "sourceMap": true,
14
- "rootDir": "src",
15
- "outDir": "dist",
16
- "declaration": true,
17
-
18
- "strict": true,
19
- "esModuleInterop": true,
20
- "forceConsistentCasingInFileNames": true
21
- },
22
- "include": [
23
- "src"
24
- ]
25
- }