eufy-security-client 2.4.2 → 2.4.4
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.
- package/README.md +12 -0
- package/build/error.d.ts +57 -57
- package/build/error.js +155 -155
- package/build/eufysecurity.d.ts +162 -161
- package/build/eufysecurity.js +2104 -2091
- package/build/eufysecurity.js.map +1 -1
- package/build/http/api.d.ts +90 -90
- package/build/http/api.js +1407 -1407
- package/build/http/api.js.map +1 -1
- package/build/http/cache.d.ts +8 -8
- package/build/http/cache.js +33 -33
- package/build/http/const.d.ts +3 -3
- package/build/http/const.js +8545 -8545
- package/build/http/device.d.ts +360 -360
- package/build/http/device.js +2793 -2793
- package/build/http/device.js.map +1 -1
- package/build/http/error.d.ts +28 -28
- package/build/http/error.js +76 -76
- package/build/http/index.d.ts +10 -10
- package/build/http/index.js +29 -29
- package/build/http/interfaces.d.ts +202 -202
- package/build/http/interfaces.js +2 -2
- package/build/http/models.d.ts +561 -561
- package/build/http/models.js +2 -2
- package/build/http/parameter.d.ts +5 -5
- package/build/http/parameter.js +75 -75
- package/build/http/station.d.ts +292 -292
- package/build/http/station.js +6780 -6780
- package/build/http/station.js.map +1 -1
- package/build/http/types.d.ts +945 -945
- package/build/http/types.js +6070 -6070
- package/build/http/utils.d.ts +37 -37
- package/build/http/utils.js +370 -370
- package/build/index.d.ts +7 -7
- package/build/index.js +25 -25
- package/build/interfaces.d.ts +113 -113
- package/build/interfaces.js +2 -2
- package/build/mqtt/interface.d.ts +6 -6
- package/build/mqtt/interface.js +2 -2
- package/build/mqtt/model.d.ts +24 -24
- package/build/mqtt/model.js +2 -2
- package/build/mqtt/service.d.ts +30 -30
- package/build/mqtt/service.js +168 -168
- package/build/mqtt/service.js.map +1 -1
- package/build/p2p/ble.d.ts +47 -47
- package/build/p2p/ble.js +188 -188
- package/build/p2p/ble.js.map +1 -1
- package/build/p2p/error.d.ts +24 -24
- package/build/p2p/error.js +67 -67
- package/build/p2p/index.d.ts +8 -8
- package/build/p2p/index.js +27 -27
- package/build/p2p/interfaces.d.ts +162 -162
- package/build/p2p/interfaces.js +2 -2
- package/build/p2p/models.d.ts +146 -146
- package/build/p2p/models.js +2 -2
- package/build/p2p/session.d.ts +168 -168
- package/build/p2p/session.js +2087 -2087
- package/build/p2p/session.js.map +1 -1
- package/build/p2p/talkback.d.ts +10 -10
- package/build/p2p/talkback.js +22 -22
- package/build/p2p/types.d.ts +923 -923
- package/build/p2p/types.js +957 -957
- package/build/p2p/utils.d.ts +56 -56
- package/build/p2p/utils.js +653 -653
- package/build/push/client.d.ts +51 -51
- package/build/push/client.js +311 -311
- package/build/push/client.js.map +1 -1
- package/build/push/index.d.ts +5 -5
- package/build/push/index.js +24 -24
- package/build/push/interfaces.d.ts +19 -19
- package/build/push/interfaces.js +2 -2
- package/build/push/models.d.ts +292 -292
- package/build/push/models.js +30 -30
- package/build/push/parser.d.ts +28 -28
- package/build/push/parser.js +215 -215
- package/build/push/parser.js.map +1 -1
- package/build/push/service.d.ts +45 -45
- package/build/push/service.js +643 -643
- package/build/push/service.js.map +1 -1
- package/build/push/types.d.ts +176 -176
- package/build/push/types.js +192 -192
- package/build/push/utils.d.ts +7 -7
- package/build/push/utils.js +102 -102
- package/build/utils.d.ts +16 -13
- package/build/utils.js +207 -191
- package/build/utils.js.map +1 -1
- package/package.json +10 -10
package/build/eufysecurity.js
CHANGED
|
@@ -1,2092 +1,2105 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
this.
|
|
53
|
-
this.
|
|
54
|
-
this.
|
|
55
|
-
this.
|
|
56
|
-
this.
|
|
57
|
-
this.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
this.
|
|
72
|
-
this.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
this.api.
|
|
153
|
-
this.api.
|
|
154
|
-
this.api.
|
|
155
|
-
this.api.on("
|
|
156
|
-
this.api.on("
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
this.persistentData.
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
this.
|
|
179
|
-
this.
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
this.persistentData.cloud_token_expiration
|
|
185
|
-
this.persistentData.
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
this.log.debug("
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
this.
|
|
199
|
-
|
|
200
|
-
this.
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
this.
|
|
223
|
-
|
|
224
|
-
this.
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
this.
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
station.
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
this.
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
this.
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
this.
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
device.
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
this.
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
337
|
-
async
|
|
338
|
-
if (this.
|
|
339
|
-
await this.
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
station.on("
|
|
409
|
-
station.on("
|
|
410
|
-
station.on("
|
|
411
|
-
station.on("
|
|
412
|
-
station.on("
|
|
413
|
-
station.on("
|
|
414
|
-
station.on("
|
|
415
|
-
station.on("
|
|
416
|
-
station.on("
|
|
417
|
-
station.on("
|
|
418
|
-
station.on("
|
|
419
|
-
station.on("
|
|
420
|
-
station.on("
|
|
421
|
-
station.on("
|
|
422
|
-
station.on("
|
|
423
|
-
station.on("
|
|
424
|
-
station.on("
|
|
425
|
-
station.on("
|
|
426
|
-
station.on("
|
|
427
|
-
station.on("
|
|
428
|
-
station.on("
|
|
429
|
-
station.on("
|
|
430
|
-
station.on("
|
|
431
|
-
station.on("
|
|
432
|
-
station.on("
|
|
433
|
-
station.on("
|
|
434
|
-
station.on("
|
|
435
|
-
station.on("
|
|
436
|
-
station.on("
|
|
437
|
-
this.
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
device.on("
|
|
552
|
-
device.on("
|
|
553
|
-
device.on("
|
|
554
|
-
device.on("
|
|
555
|
-
device.on("
|
|
556
|
-
device.on("
|
|
557
|
-
device.on("
|
|
558
|
-
device.on("
|
|
559
|
-
device.on("
|
|
560
|
-
device.on("
|
|
561
|
-
device.on("
|
|
562
|
-
device.on("
|
|
563
|
-
device.on("
|
|
564
|
-
device.on("
|
|
565
|
-
device.on("
|
|
566
|
-
device.on("
|
|
567
|
-
device.on("
|
|
568
|
-
device.on("
|
|
569
|
-
device.on("
|
|
570
|
-
this.
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
this.
|
|
596
|
-
})
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
this.
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
});
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
this.
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
this.
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
this.
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
this.
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
this.
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
this.
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
const
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
});
|
|
862
|
-
if (
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
const
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
case types_1.PropertyName.
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
case types_1.PropertyName.
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
case types_1.PropertyName.
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
case types_1.PropertyName.
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
case types_1.PropertyName.
|
|
1360
|
-
case types_1.PropertyName.
|
|
1361
|
-
case types_1.PropertyName.
|
|
1362
|
-
case types_1.PropertyName.
|
|
1363
|
-
case types_1.PropertyName.
|
|
1364
|
-
case types_1.PropertyName.
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
case types_1.PropertyName.
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
case types_1.PropertyName.
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
case types_1.PropertyName.
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
case types_1.PropertyName.
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
this.
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
}
|
|
1627
|
-
|
|
1628
|
-
}
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
this.
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
}
|
|
1804
|
-
})
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
}
|
|
1821
|
-
|
|
1822
|
-
this.getStationDevice(station.getSerial(), channel).then((device) => {
|
|
1823
|
-
if (device.hasProperty(types_1.PropertyName.
|
|
1824
|
-
const
|
|
1825
|
-
device.updateRawProperty(
|
|
1826
|
-
}
|
|
1827
|
-
}).catch((error) => {
|
|
1828
|
-
this.log.error(`Station
|
|
1829
|
-
});
|
|
1830
|
-
}
|
|
1831
|
-
|
|
1832
|
-
this.
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
this.
|
|
1842
|
-
})
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
this.
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
if (
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
if (
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
}
|
|
2089
|
-
|
|
2090
|
-
}
|
|
2091
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.EufySecurity = void 0;
|
|
30
|
+
const tiny_typed_emitter_1 = require("tiny-typed-emitter");
|
|
31
|
+
const ts_log_1 = require("ts-log");
|
|
32
|
+
const fse = __importStar(require("fs-extra"));
|
|
33
|
+
const path = __importStar(require("path"));
|
|
34
|
+
const events_1 = __importDefault(require("events"));
|
|
35
|
+
const api_1 = require("./http/api");
|
|
36
|
+
const station_1 = require("./http/station");
|
|
37
|
+
const types_1 = require("./http/types");
|
|
38
|
+
const service_1 = require("./push/service");
|
|
39
|
+
const device_1 = require("./http/device");
|
|
40
|
+
const types_2 = require("./p2p/types");
|
|
41
|
+
const utils_1 = require("./utils");
|
|
42
|
+
const error_1 = require("./error");
|
|
43
|
+
const _1 = require(".");
|
|
44
|
+
const error_2 = require("./http/error");
|
|
45
|
+
const types_3 = require("./push/types");
|
|
46
|
+
const service_2 = require("./mqtt/service");
|
|
47
|
+
const const_1 = require("./http/const");
|
|
48
|
+
const utils_2 = require("./http/utils");
|
|
49
|
+
class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
50
|
+
constructor(config, log = ts_log_1.dummyLogger) {
|
|
51
|
+
super();
|
|
52
|
+
this.houses = {};
|
|
53
|
+
this.stations = {};
|
|
54
|
+
this.devices = {};
|
|
55
|
+
this.P2P_REFRESH_INTERVAL_MIN = 720;
|
|
56
|
+
this.cameraMaxLivestreamSeconds = 30;
|
|
57
|
+
this.cameraStationLivestreamTimeout = new Map();
|
|
58
|
+
this.cameraCloudLivestreamTimeout = new Map();
|
|
59
|
+
this.pushCloudRegistered = false;
|
|
60
|
+
this.pushCloudChecked = false;
|
|
61
|
+
this.persistentData = {
|
|
62
|
+
country: "",
|
|
63
|
+
openudid: "",
|
|
64
|
+
serial_number: "",
|
|
65
|
+
push_credentials: undefined,
|
|
66
|
+
push_persistentIds: [],
|
|
67
|
+
login_hash: "",
|
|
68
|
+
version: "",
|
|
69
|
+
httpApi: undefined
|
|
70
|
+
};
|
|
71
|
+
this.connected = false;
|
|
72
|
+
this.retries = 0;
|
|
73
|
+
this.refreshEufySecurityP2PTimeout = {};
|
|
74
|
+
this.deviceSnoozeTimeout = {};
|
|
75
|
+
this.stationsLoaded = false;
|
|
76
|
+
this.devicesLoaded = false;
|
|
77
|
+
this.loadingEmitter = new events_1.default();
|
|
78
|
+
this.config = config;
|
|
79
|
+
this.log = log;
|
|
80
|
+
}
|
|
81
|
+
static async initialize(config, log = ts_log_1.dummyLogger) {
|
|
82
|
+
const eufySecurity = new EufySecurity(config, log);
|
|
83
|
+
await eufySecurity._initializeInternals();
|
|
84
|
+
return eufySecurity;
|
|
85
|
+
}
|
|
86
|
+
async _initializeInternals() {
|
|
87
|
+
if (this.config.country === undefined) {
|
|
88
|
+
this.config.country = "US";
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
this.config.country = this.config.country.toUpperCase();
|
|
92
|
+
}
|
|
93
|
+
if (this.config.language === undefined) {
|
|
94
|
+
this.config.language = "en";
|
|
95
|
+
}
|
|
96
|
+
if (this.config.eventDurationSeconds === undefined) {
|
|
97
|
+
this.config.eventDurationSeconds = 10;
|
|
98
|
+
}
|
|
99
|
+
if (this.config.p2pConnectionSetup === undefined) {
|
|
100
|
+
this.config.p2pConnectionSetup = types_2.P2PConnectionType.QUICKEST;
|
|
101
|
+
}
|
|
102
|
+
else if (!Object.values(types_2.P2PConnectionType).includes(this.config.p2pConnectionSetup)) {
|
|
103
|
+
this.config.p2pConnectionSetup = types_2.P2PConnectionType.QUICKEST;
|
|
104
|
+
}
|
|
105
|
+
if (this.config.pollingIntervalMinutes === undefined) {
|
|
106
|
+
this.config.pollingIntervalMinutes = 10;
|
|
107
|
+
}
|
|
108
|
+
if (this.config.acceptInvitations === undefined) {
|
|
109
|
+
this.config.acceptInvitations = false;
|
|
110
|
+
}
|
|
111
|
+
if (this.config.persistentDir === undefined) {
|
|
112
|
+
this.config.persistentDir = path.resolve(__dirname, "../../..");
|
|
113
|
+
}
|
|
114
|
+
else if (!fse.existsSync(this.config.persistentDir)) {
|
|
115
|
+
this.config.persistentDir = path.resolve(__dirname, "../../..");
|
|
116
|
+
}
|
|
117
|
+
this.persistentFile = path.join(this.config.persistentDir, "persistent.json");
|
|
118
|
+
try {
|
|
119
|
+
if (fse.statSync(this.persistentFile).isFile()) {
|
|
120
|
+
const fileContent = fse.readFileSync(this.persistentFile, "utf8");
|
|
121
|
+
this.persistentData = JSON.parse(fileContent);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
catch (err) {
|
|
125
|
+
this.log.debug("No stored data from last exit found");
|
|
126
|
+
}
|
|
127
|
+
try {
|
|
128
|
+
if (this.persistentData.version !== _1.libVersion) {
|
|
129
|
+
const currentVersion = Number.parseFloat((0, utils_1.removeLastChar)(_1.libVersion, "."));
|
|
130
|
+
const previousVersion = this.persistentData.version !== "" && this.persistentData.version !== undefined ? Number.parseFloat((0, utils_1.removeLastChar)(this.persistentData.version, ".")) : 0;
|
|
131
|
+
this.log.debug("Handling of driver update", { currentVersion: currentVersion, previousVersion: previousVersion });
|
|
132
|
+
if (previousVersion < currentVersion) {
|
|
133
|
+
this.persistentData = (0, utils_1.handleUpdate)(this.persistentData, this.log, previousVersion);
|
|
134
|
+
this.persistentData.version = _1.libVersion;
|
|
135
|
+
this.writePersistentData();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
this.log.error("Handling update - Error:", error);
|
|
141
|
+
}
|
|
142
|
+
if (this.config.trustedDeviceName === undefined || this.config.trustedDeviceName === "") {
|
|
143
|
+
if (this.persistentData.fallbackTrustedDeviceName !== undefined) {
|
|
144
|
+
this.config.trustedDeviceName = this.persistentData.fallbackTrustedDeviceName;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
const rnd = (0, utils_2.randomNumber)(0, const_1.PhoneModels.length);
|
|
148
|
+
this.persistentData.fallbackTrustedDeviceName = const_1.PhoneModels[rnd];
|
|
149
|
+
this.config.trustedDeviceName = this.persistentData.fallbackTrustedDeviceName;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
this.api = await api_1.HTTPApi.initialize(this.config.country, this.config.username, this.config.password, this.log, this.persistentData.httpApi);
|
|
153
|
+
this.api.setLanguage(this.config.language);
|
|
154
|
+
this.api.setPhoneModel(this.config.trustedDeviceName);
|
|
155
|
+
this.api.on("houses", (houses) => this.handleHouses(houses));
|
|
156
|
+
this.api.on("hubs", (hubs) => this.handleHubs(hubs));
|
|
157
|
+
this.api.on("devices", (devices) => this.handleDevices(devices));
|
|
158
|
+
this.api.on("close", () => this.onAPIClose());
|
|
159
|
+
this.api.on("connect", () => this.onAPIConnect());
|
|
160
|
+
this.api.on("captcha request", (id, captcha) => this.onCaptchaRequest(id, captcha));
|
|
161
|
+
this.api.on("auth token invalidated", () => this.onAuthTokenInvalidated());
|
|
162
|
+
this.api.on("tfa request", () => this.onTfaRequest());
|
|
163
|
+
this.api.on("connection error", (error) => this.onAPIConnectionError(error));
|
|
164
|
+
if (this.persistentData.login_hash && this.persistentData.login_hash != "") {
|
|
165
|
+
this.log.debug("Load previous login_hash:", this.persistentData.login_hash);
|
|
166
|
+
if ((0, utils_1.md5)(`${this.config.username}:${this.config.password}`) != this.persistentData.login_hash) {
|
|
167
|
+
this.log.info("Authentication properties changed, invalidate saved cloud token.");
|
|
168
|
+
this.persistentData.cloud_token = "";
|
|
169
|
+
this.persistentData.cloud_token_expiration = 0;
|
|
170
|
+
this.persistentData.httpApi = undefined;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
this.persistentData.cloud_token = "";
|
|
175
|
+
this.persistentData.cloud_token_expiration = 0;
|
|
176
|
+
}
|
|
177
|
+
if (this.persistentData.country !== undefined && this.persistentData.country !== "" && this.persistentData.country !== this.config.country) {
|
|
178
|
+
this.log.info("Country property changed, invalidate saved cloud token.");
|
|
179
|
+
this.persistentData.cloud_token = "";
|
|
180
|
+
this.persistentData.cloud_token_expiration = 0;
|
|
181
|
+
this.persistentData.httpApi = undefined;
|
|
182
|
+
}
|
|
183
|
+
if (this.persistentData.cloud_token && this.persistentData.cloud_token != "" && this.persistentData.cloud_token_expiration) {
|
|
184
|
+
this.log.debug("Load previous token:", { token: this.persistentData.cloud_token, tokenExpiration: this.persistentData.cloud_token_expiration });
|
|
185
|
+
this.api.setToken(this.persistentData.cloud_token);
|
|
186
|
+
this.api.setTokenExpiration(new Date(this.persistentData.cloud_token_expiration));
|
|
187
|
+
}
|
|
188
|
+
if (this.persistentData.httpApi !== undefined && (this.persistentData.httpApi.clientPrivateKey === undefined || this.persistentData.httpApi.clientPrivateKey === "" || this.persistentData.httpApi.serverPublicKey === undefined || this.persistentData.httpApi.serverPublicKey === "")) {
|
|
189
|
+
this.log.debug("Incomplete persistent data for v2 encrypted cloud api communication. Invalidate authenticated session data.");
|
|
190
|
+
this.persistentData.cloud_token = "";
|
|
191
|
+
this.persistentData.cloud_token_expiration = 0;
|
|
192
|
+
this.persistentData.httpApi = undefined;
|
|
193
|
+
}
|
|
194
|
+
if (!this.persistentData.openudid || this.persistentData.openudid == "") {
|
|
195
|
+
this.persistentData.openudid = (0, utils_1.generateUDID)();
|
|
196
|
+
this.log.debug("Generated new openudid:", this.persistentData.openudid);
|
|
197
|
+
}
|
|
198
|
+
this.api.setOpenUDID(this.persistentData.openudid);
|
|
199
|
+
if (!this.persistentData.serial_number || this.persistentData.serial_number == "") {
|
|
200
|
+
this.persistentData.serial_number = (0, utils_1.generateSerialnumber)(12);
|
|
201
|
+
this.log.debug("Generated new serial_number:", this.persistentData.serial_number);
|
|
202
|
+
}
|
|
203
|
+
this.api.setSerialNumber(this.persistentData.serial_number);
|
|
204
|
+
this.pushService = new service_1.PushNotificationService(this.log);
|
|
205
|
+
this.pushService.on("connect", async (token) => {
|
|
206
|
+
this.pushCloudRegistered = await this.api.registerPushToken(token);
|
|
207
|
+
this.pushCloudChecked = await this.api.checkPushToken();
|
|
208
|
+
//TODO: Retry if failed with max retry to not lock account
|
|
209
|
+
if (this.pushCloudRegistered && this.pushCloudChecked) {
|
|
210
|
+
this.log.info("Push notification connection successfully established");
|
|
211
|
+
this.emit("push connect");
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
this.log.info("Push notification connection closed");
|
|
215
|
+
this.emit("push close");
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
this.pushService.on("credential", (credentials) => {
|
|
219
|
+
this.savePushCredentials(credentials);
|
|
220
|
+
});
|
|
221
|
+
this.pushService.on("message", (message) => this.onPushMessage(message));
|
|
222
|
+
this.pushService.on("close", () => {
|
|
223
|
+
this.log.info("Push notification connection closed");
|
|
224
|
+
this.emit("push close");
|
|
225
|
+
});
|
|
226
|
+
await this.initMQTT();
|
|
227
|
+
}
|
|
228
|
+
async initMQTT() {
|
|
229
|
+
this.mqttService = await service_2.MQTTService.init(this.log);
|
|
230
|
+
this.mqttService.on("connect", () => {
|
|
231
|
+
this.log.info("MQTT connection successfully established");
|
|
232
|
+
this.emit("mqtt connect");
|
|
233
|
+
});
|
|
234
|
+
this.mqttService.on("close", () => {
|
|
235
|
+
this.log.info("MQTT connection closed");
|
|
236
|
+
this.emit("mqtt close");
|
|
237
|
+
});
|
|
238
|
+
this.mqttService.on("lock message", (message) => {
|
|
239
|
+
this.getDevice(message.data.data.deviceSn).then((device) => {
|
|
240
|
+
device.processMQTTNotification(message.data.data, this.config.eventDurationSeconds);
|
|
241
|
+
}).catch((error) => {
|
|
242
|
+
if (error instanceof error_1.DeviceNotFoundError) {
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
this.log.error("Lock MQTT Message Error", error);
|
|
246
|
+
}
|
|
247
|
+
}).finally(() => {
|
|
248
|
+
this.emit("mqtt lock message", message);
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
getPushService() {
|
|
253
|
+
return this.pushService;
|
|
254
|
+
}
|
|
255
|
+
addStation(station) {
|
|
256
|
+
const serial = station.getSerial();
|
|
257
|
+
if (serial && !Object.keys(this.stations).includes(serial)) {
|
|
258
|
+
this.stations[serial] = station;
|
|
259
|
+
this.getStorageInfo(serial);
|
|
260
|
+
this.emit("station added", station);
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
this.log.debug(`Station with this serial ${station.getSerial()} exists already and couldn't be added again!`);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
removeStation(station) {
|
|
267
|
+
const serial = station.getSerial();
|
|
268
|
+
if (serial && Object.keys(this.stations).includes(serial)) {
|
|
269
|
+
delete this.stations[serial];
|
|
270
|
+
station.removeAllListeners();
|
|
271
|
+
if (station.isConnected())
|
|
272
|
+
station.close();
|
|
273
|
+
this.emit("station removed", station);
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
this.log.debug(`Station with this serial ${station.getSerial()} doesn't exists and couldn't be removed!`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
async updateStation(hub) {
|
|
280
|
+
if (!this.stationsLoaded)
|
|
281
|
+
await (0, utils_1.waitForEvent)(this.loadingEmitter, "stations loaded");
|
|
282
|
+
if (Object.keys(this.stations).includes(hub.station_sn)) {
|
|
283
|
+
this.stations[hub.station_sn].update(hub, this.stations[hub.station_sn] !== undefined && !this.stations[hub.station_sn].isIntegratedDevice() && this.stations[hub.station_sn].isConnected());
|
|
284
|
+
if (!this.stations[hub.station_sn].isConnected() && !this.stations[hub.station_sn].isEnergySavingDevice()) {
|
|
285
|
+
this.stations[hub.station_sn].setConnectionType(this.config.p2pConnectionSetup);
|
|
286
|
+
this.stations[hub.station_sn].connect();
|
|
287
|
+
}
|
|
288
|
+
this.getStorageInfo(hub.station_sn);
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
this.log.debug(`Station with this serial ${hub.station_sn} doesn't exists and couldn't be updated!`);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
async getStorageInfo(stationSerial) {
|
|
295
|
+
await this.stations[stationSerial].getStorageInfoEx();
|
|
296
|
+
}
|
|
297
|
+
addDevice(device) {
|
|
298
|
+
const serial = device.getSerial();
|
|
299
|
+
if (serial && !Object.keys(this.devices).includes(serial)) {
|
|
300
|
+
this.devices[serial] = device;
|
|
301
|
+
this.emit("device added", device);
|
|
302
|
+
if (device.isLock())
|
|
303
|
+
this.mqttService.subscribeLock(device.getSerial());
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
this.log.debug(`Device with this serial ${device.getSerial()} exists already and couldn't be added again!`);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
removeDevice(device) {
|
|
310
|
+
const serial = device.getSerial();
|
|
311
|
+
if (serial && Object.keys(this.devices).includes(serial)) {
|
|
312
|
+
delete this.devices[serial];
|
|
313
|
+
device.removeAllListeners();
|
|
314
|
+
this.emit("device removed", device);
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
this.log.debug(`Device with this serial ${device.getSerial()} doesn't exists and couldn't be removed!`);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
async updateDevice(device) {
|
|
321
|
+
if (!this.devicesLoaded)
|
|
322
|
+
await (0, utils_1.waitForEvent)(this.loadingEmitter, "devices loaded");
|
|
323
|
+
if (Object.keys(this.devices).includes(device.device_sn))
|
|
324
|
+
this.devices[device.device_sn].update(device, this.stations[device.station_sn] !== undefined && !this.stations[device.station_sn].isIntegratedDevice() && this.stations[device.station_sn].isConnected());
|
|
325
|
+
else
|
|
326
|
+
this.log.debug(`Device with this serial ${device.device_sn} doesn't exists and couldn't be updated!`);
|
|
327
|
+
}
|
|
328
|
+
async getDevices() {
|
|
329
|
+
if (!this.devicesLoaded)
|
|
330
|
+
await (0, utils_1.waitForEvent)(this.loadingEmitter, "devices loaded");
|
|
331
|
+
const arr = [];
|
|
332
|
+
Object.keys(this.devices).forEach((serialNumber) => {
|
|
333
|
+
arr.push(this.devices[serialNumber]);
|
|
334
|
+
});
|
|
335
|
+
return arr;
|
|
336
|
+
}
|
|
337
|
+
async getDevice(deviceSN) {
|
|
338
|
+
if (!this.devicesLoaded)
|
|
339
|
+
await (0, utils_1.waitForEvent)(this.loadingEmitter, "devices loaded");
|
|
340
|
+
if (Object.keys(this.devices).includes(deviceSN))
|
|
341
|
+
return this.devices[deviceSN];
|
|
342
|
+
throw new error_1.DeviceNotFoundError(`Device with this serial ${deviceSN} doesn't exists!`);
|
|
343
|
+
}
|
|
344
|
+
async getStationDevice(stationSN, channel) {
|
|
345
|
+
if (!this.devicesLoaded)
|
|
346
|
+
await (0, utils_1.waitForEvent)(this.loadingEmitter, "devices loaded");
|
|
347
|
+
for (const device of Object.values(this.devices)) {
|
|
348
|
+
if ((device.getStationSerial() === stationSN && device.getChannel() === channel) || (device.getStationSerial() === stationSN && device.getSerial() === stationSN)) {
|
|
349
|
+
return device;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
throw new error_1.DeviceNotFoundError(`No device with channel ${channel} found on station with serial number: ${stationSN}!`);
|
|
353
|
+
}
|
|
354
|
+
async getStations() {
|
|
355
|
+
if (!this.stationsLoaded)
|
|
356
|
+
await (0, utils_1.waitForEvent)(this.loadingEmitter, "stations loaded");
|
|
357
|
+
const arr = [];
|
|
358
|
+
Object.keys(this.stations).forEach((serialNumber) => {
|
|
359
|
+
arr.push(this.stations[serialNumber]);
|
|
360
|
+
});
|
|
361
|
+
return arr;
|
|
362
|
+
}
|
|
363
|
+
async getStation(stationSN) {
|
|
364
|
+
if (!this.stationsLoaded)
|
|
365
|
+
await (0, utils_1.waitForEvent)(this.loadingEmitter, "stations loaded");
|
|
366
|
+
if (Object.keys(this.stations).includes(stationSN))
|
|
367
|
+
return this.stations[stationSN];
|
|
368
|
+
throw new error_1.StationNotFoundError(`No station with serial number: ${stationSN}!`);
|
|
369
|
+
}
|
|
370
|
+
getApi() {
|
|
371
|
+
return this.api;
|
|
372
|
+
}
|
|
373
|
+
async connectToStation(stationSN, p2pConnectionType = types_2.P2PConnectionType.QUICKEST) {
|
|
374
|
+
const station = await this.getStation(stationSN);
|
|
375
|
+
station.setConnectionType(p2pConnectionType);
|
|
376
|
+
station.connect();
|
|
377
|
+
}
|
|
378
|
+
async isStationConnected(stationSN) {
|
|
379
|
+
const station = await this.getStation(stationSN);
|
|
380
|
+
return station.isConnected();
|
|
381
|
+
}
|
|
382
|
+
async isStationEnergySavingDevice(stationSN) {
|
|
383
|
+
const station = await this.getStation(stationSN);
|
|
384
|
+
return station.isEnergySavingDevice();
|
|
385
|
+
}
|
|
386
|
+
handleHouses(houses) {
|
|
387
|
+
this.log.debug("Got houses:", houses);
|
|
388
|
+
//TODO: Finish implementation
|
|
389
|
+
this.houses = houses;
|
|
390
|
+
}
|
|
391
|
+
handleHubs(hubs) {
|
|
392
|
+
this.log.debug("Got hubs:", hubs);
|
|
393
|
+
const stationsSNs = Object.keys(this.stations);
|
|
394
|
+
const newStationsSNs = Object.keys(hubs);
|
|
395
|
+
const promises = [];
|
|
396
|
+
for (const hub of Object.values(hubs)) {
|
|
397
|
+
if (stationsSNs.includes(hub.station_sn)) {
|
|
398
|
+
this.updateStation(hub);
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
let ipAddress;
|
|
402
|
+
if (this.config.stationIPAddresses !== undefined) {
|
|
403
|
+
ipAddress = this.config.stationIPAddresses[hub.station_sn];
|
|
404
|
+
}
|
|
405
|
+
const station = station_1.Station.initialize(this.api, hub, ipAddress);
|
|
406
|
+
promises.push(station.then((station) => {
|
|
407
|
+
try {
|
|
408
|
+
station.on("connect", (station) => this.onStationConnect(station));
|
|
409
|
+
station.on("connection error", (station, error) => this.onStationConnectionError(station, error));
|
|
410
|
+
station.on("close", (station) => this.onStationClose(station));
|
|
411
|
+
station.on("raw device property changed", (deviceSN, params) => this.updateDeviceProperties(deviceSN, params));
|
|
412
|
+
station.on("livestream start", (station, channel, metadata, videostream, audiostream) => this.onStartStationLivestream(station, channel, metadata, videostream, audiostream));
|
|
413
|
+
station.on("livestream stop", (station, channel) => this.onStopStationLivestream(station, channel));
|
|
414
|
+
station.on("livestream error", (station, channel, error) => this.onErrorStationLivestream(station, channel, error));
|
|
415
|
+
station.on("download start", (station, channel, metadata, videoStream, audioStream) => this.onStationStartDownload(station, channel, metadata, videoStream, audioStream));
|
|
416
|
+
station.on("download finish", (station, channel) => this.onStationFinishDownload(station, channel));
|
|
417
|
+
station.on("command result", (station, result) => this.onStationCommandResult(station, result));
|
|
418
|
+
station.on("guard mode", (station, guardMode) => this.onStationGuardMode(station, guardMode));
|
|
419
|
+
station.on("current mode", (station, currentMode) => this.onStationCurrentMode(station, currentMode));
|
|
420
|
+
station.on("rtsp livestream start", (station, channel) => this.onStartStationRTSPLivestream(station, channel));
|
|
421
|
+
station.on("rtsp livestream stop", (station, channel) => this.onStopStationRTSPLivestream(station, channel));
|
|
422
|
+
station.on("rtsp url", (station, channel, value) => this.onStationRtspUrl(station, channel, value));
|
|
423
|
+
station.on("property changed", (station, name, value) => this.onStationPropertyChanged(station, name, value));
|
|
424
|
+
station.on("raw property changed", (station, type, value) => this.onStationRawPropertyChanged(station, type, value));
|
|
425
|
+
station.on("alarm event", (station, alarmEvent) => this.onStationAlarmEvent(station, alarmEvent));
|
|
426
|
+
station.on("runtime state", (station, channel, batteryLevel, temperature) => this.onStationRuntimeState(station, channel, batteryLevel, temperature));
|
|
427
|
+
station.on("charging state", (station, channel, chargeType, batteryLevel) => this.onStationChargingState(station, channel, chargeType, batteryLevel));
|
|
428
|
+
station.on("wifi rssi", (station, channel, rssi) => this.onStationWifiRssi(station, channel, rssi));
|
|
429
|
+
station.on("floodlight manual switch", (station, channel, enabled) => this.onFloodlightManualSwitch(station, channel, enabled));
|
|
430
|
+
station.on("alarm delay event", (station, alarmDelayEvent, alarmDelay) => this.onStationAlarmDelayEvent(station, alarmDelayEvent, alarmDelay));
|
|
431
|
+
station.on("talkback started", (station, channel, talkbackStream) => this.onStationTalkbackStart(station, channel, talkbackStream));
|
|
432
|
+
station.on("talkback stopped", (station, channel) => this.onStationTalkbackStop(station, channel));
|
|
433
|
+
station.on("talkback error", (station, channel, error) => this.onStationTalkbackError(station, channel, error));
|
|
434
|
+
station.on("alarm armed event", (station) => this.onStationAlarmArmedEvent(station));
|
|
435
|
+
station.on("alarm arm delay event", (station, armDelay) => this.onStationArmDelayEvent(station, armDelay));
|
|
436
|
+
station.on("secondary command result", (station, result) => this.onStationSecondaryCommandResult(station, result));
|
|
437
|
+
station.on("device shake alarm", (deviceSN, event) => this.onStationDeviceShakeAlarm(deviceSN, event));
|
|
438
|
+
station.on("device 911 alarm", (deviceSN, event) => this.onStationDevice911Alarm(deviceSN, event));
|
|
439
|
+
station.on("device jammed", (deviceSN) => this.onStationDeviceJammed(deviceSN));
|
|
440
|
+
station.on("device low battery", (deviceSN) => this.onStationDeviceLowBattery(deviceSN));
|
|
441
|
+
station.on("device wrong try-protect alarm", (deviceSN) => this.onStationDeviceWrongTryProtectAlarm(deviceSN));
|
|
442
|
+
station.on("device pin verified", (deviceSN, successfull) => this.onStationDevicePinVerified(deviceSN, successfull));
|
|
443
|
+
station.on("sd info ex", (station, sdStatus, sdCapacity, sdCapacityAvailable) => this.onStationSdInfoEx(station, sdStatus, sdCapacity, sdCapacityAvailable));
|
|
444
|
+
this.addStation(station);
|
|
445
|
+
}
|
|
446
|
+
catch (error) {
|
|
447
|
+
this.log.error("Error", error);
|
|
448
|
+
}
|
|
449
|
+
return station;
|
|
450
|
+
}));
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
Promise.all(promises).then(() => {
|
|
454
|
+
this.stationsLoaded = true;
|
|
455
|
+
this.loadingEmitter.emit("stations loaded");
|
|
456
|
+
});
|
|
457
|
+
for (const stationSN of stationsSNs) {
|
|
458
|
+
if (!newStationsSNs.includes(stationSN)) {
|
|
459
|
+
this.getStation(stationSN).then((station) => {
|
|
460
|
+
this.removeStation(station);
|
|
461
|
+
}).catch((error) => {
|
|
462
|
+
this.log.error("Error removing station", error);
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
onStationConnect(station) {
|
|
468
|
+
this.emit("station connect", station);
|
|
469
|
+
if ((device_1.Device.isCamera(station.getDeviceType()) && !device_1.Device.isWiredDoorbell(station.getDeviceType()) || device_1.Device.isSmartSafe(station.getDeviceType()))) {
|
|
470
|
+
station.getCameraInfo().catch(error => {
|
|
471
|
+
this.log.error(`Error during station ${station.getSerial()} p2p data refreshing`, error);
|
|
472
|
+
});
|
|
473
|
+
if (this.refreshEufySecurityP2PTimeout[station.getSerial()] !== undefined) {
|
|
474
|
+
clearTimeout(this.refreshEufySecurityP2PTimeout[station.getSerial()]);
|
|
475
|
+
delete this.refreshEufySecurityP2PTimeout[station.getSerial()];
|
|
476
|
+
}
|
|
477
|
+
if (!station.isEnergySavingDevice()) {
|
|
478
|
+
this.refreshEufySecurityP2PTimeout[station.getSerial()] = setTimeout(() => {
|
|
479
|
+
station.getCameraInfo().catch(error => {
|
|
480
|
+
this.log.error(`Error during station ${station.getSerial()} p2p data refreshing`, error);
|
|
481
|
+
});
|
|
482
|
+
}, this.P2P_REFRESH_INTERVAL_MIN * 60 * 1000);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
onStationConnectionError(station, error) {
|
|
487
|
+
this.emit("station connection error", station, error);
|
|
488
|
+
}
|
|
489
|
+
onStationClose(station) {
|
|
490
|
+
this.emit("station close", station);
|
|
491
|
+
for (const device_sn of this.cameraStationLivestreamTimeout.keys()) {
|
|
492
|
+
this.getDevice(device_sn).then((device) => {
|
|
493
|
+
if (device !== null && device.getStationSerial() === station.getSerial()) {
|
|
494
|
+
clearTimeout(this.cameraStationLivestreamTimeout.get(device_sn));
|
|
495
|
+
this.cameraStationLivestreamTimeout.delete(device_sn);
|
|
496
|
+
}
|
|
497
|
+
}).catch((error) => {
|
|
498
|
+
this.log.error(`Station ${station.getSerial()} - Error:`, error);
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
handleDevices(devices) {
|
|
503
|
+
this.log.debug("Got devices:", devices);
|
|
504
|
+
const deviceSNs = Object.keys(this.devices);
|
|
505
|
+
const newDeviceSNs = Object.keys(devices);
|
|
506
|
+
const promises = [];
|
|
507
|
+
for (const device of Object.values(devices)) {
|
|
508
|
+
if (deviceSNs.includes(device.device_sn)) {
|
|
509
|
+
this.updateDevice(device);
|
|
510
|
+
}
|
|
511
|
+
else {
|
|
512
|
+
let new_device;
|
|
513
|
+
if (device_1.Device.isIndoorCamera(device.device_type)) {
|
|
514
|
+
new_device = device_1.IndoorCamera.initialize(this.api, device);
|
|
515
|
+
}
|
|
516
|
+
else if (device_1.Device.isSoloCameras(device.device_type)) {
|
|
517
|
+
new_device = device_1.SoloCamera.initialize(this.api, device);
|
|
518
|
+
}
|
|
519
|
+
else if (device_1.Device.isBatteryDoorbell(device.device_type)) {
|
|
520
|
+
new_device = device_1.BatteryDoorbellCamera.initialize(this.api, device);
|
|
521
|
+
}
|
|
522
|
+
else if (device_1.Device.isWiredDoorbell(device.device_type) || device_1.Device.isWiredDoorbellDual(device.device_type)) {
|
|
523
|
+
new_device = device_1.WiredDoorbellCamera.initialize(this.api, device);
|
|
524
|
+
}
|
|
525
|
+
else if (device_1.Device.isFloodLight(device.device_type)) {
|
|
526
|
+
new_device = device_1.FloodlightCamera.initialize(this.api, device);
|
|
527
|
+
}
|
|
528
|
+
else if (device_1.Device.isCamera(device.device_type)) {
|
|
529
|
+
new_device = device_1.Camera.initialize(this.api, device);
|
|
530
|
+
}
|
|
531
|
+
else if (device_1.Device.isLock(device.device_type)) {
|
|
532
|
+
new_device = device_1.Lock.initialize(this.api, device);
|
|
533
|
+
}
|
|
534
|
+
else if (device_1.Device.isMotionSensor(device.device_type)) {
|
|
535
|
+
new_device = device_1.MotionSensor.initialize(this.api, device);
|
|
536
|
+
}
|
|
537
|
+
else if (device_1.Device.isEntrySensor(device.device_type)) {
|
|
538
|
+
new_device = device_1.EntrySensor.initialize(this.api, device);
|
|
539
|
+
}
|
|
540
|
+
else if (device_1.Device.isKeyPad(device.device_type)) {
|
|
541
|
+
new_device = device_1.Keypad.initialize(this.api, device);
|
|
542
|
+
}
|
|
543
|
+
else if (device_1.Device.isSmartSafe(device.device_type)) {
|
|
544
|
+
new_device = device_1.SmartSafe.initialize(this.api, device);
|
|
545
|
+
}
|
|
546
|
+
else {
|
|
547
|
+
new_device = device_1.UnknownDevice.initialize(this.api, device);
|
|
548
|
+
}
|
|
549
|
+
promises.push(new_device.then((device) => {
|
|
550
|
+
try {
|
|
551
|
+
device.on("property changed", (device, name, value) => this.onDevicePropertyChanged(device, name, value));
|
|
552
|
+
device.on("raw property changed", (device, type, value) => this.onDeviceRawPropertyChanged(device, type, value));
|
|
553
|
+
device.on("crying detected", (device, state) => this.onDeviceCryingDetected(device, state));
|
|
554
|
+
device.on("sound detected", (device, state) => this.onDeviceSoundDetected(device, state));
|
|
555
|
+
device.on("pet detected", (device, state) => this.onDevicePetDetected(device, state));
|
|
556
|
+
device.on("vehicle detected", (device, state) => this.onDeviceVehicleDetected(device, state));
|
|
557
|
+
device.on("motion detected", (device, state) => this.onDeviceMotionDetected(device, state));
|
|
558
|
+
device.on("person detected", (device, state, person) => this.onDevicePersonDetected(device, state, person));
|
|
559
|
+
device.on("rings", (device, state) => this.onDeviceRings(device, state));
|
|
560
|
+
device.on("locked", (device, state) => this.onDeviceLocked(device, state));
|
|
561
|
+
device.on("open", (device, state) => this.onDeviceOpen(device, state));
|
|
562
|
+
device.on("ready", (device) => this.onDeviceReady(device));
|
|
563
|
+
device.on("package delivered", (device, state) => this.onDevicePackageDelivered(device, state));
|
|
564
|
+
device.on("package stranded", (device, state) => this.onDevicePackageStranded(device, state));
|
|
565
|
+
device.on("package taken", (device, state) => this.onDevicePackageTaken(device, state));
|
|
566
|
+
device.on("someone loitering", (device, state) => this.onDeviceSomeoneLoitering(device, state));
|
|
567
|
+
device.on("radar motion detected", (device, state) => this.onDeviceRadarMotionDetected(device, state));
|
|
568
|
+
device.on("911 alarm", (device, state, detail) => this.onDevice911Alarm(device, state, detail));
|
|
569
|
+
device.on("shake alarm", (device, state, detail) => this.onDeviceShakeAlarm(device, state, detail));
|
|
570
|
+
device.on("wrong try-protect alarm", (device, state) => this.onDeviceWrongTryProtectAlarm(device, state));
|
|
571
|
+
device.on("long time not close", (device, state) => this.onDeviceLongTimeNotClose(device, state));
|
|
572
|
+
device.on("low battery", (device, state) => this.onDeviceLowBattery(device, state));
|
|
573
|
+
device.on("jammed", (device, state) => this.onDeviceJammed(device, state));
|
|
574
|
+
device.on("stranger person detected", (device, state) => this.onDeviceStrangerPersonDetected(device, state));
|
|
575
|
+
device.on("dog detected", (device, state) => this.onDeviceDogDetected(device, state));
|
|
576
|
+
device.on("dog lick detected", (device, state) => this.onDeviceDogLickDetected(device, state));
|
|
577
|
+
device.on("dog poop detected", (device, state) => this.onDeviceDogPoopDetected(device, state));
|
|
578
|
+
this.addDevice(device);
|
|
579
|
+
}
|
|
580
|
+
catch (error) {
|
|
581
|
+
this.log.error("Error", error);
|
|
582
|
+
}
|
|
583
|
+
return device;
|
|
584
|
+
}));
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
Promise.all(promises).then((devices) => {
|
|
588
|
+
devices.forEach((device) => {
|
|
589
|
+
this.getStation(device.getStationSerial()).then((station) => {
|
|
590
|
+
if (!station.isConnected()) {
|
|
591
|
+
station.setConnectionType(this.config.p2pConnectionSetup);
|
|
592
|
+
station.connect();
|
|
593
|
+
}
|
|
594
|
+
}).catch((error) => {
|
|
595
|
+
this.log.error("Error trying to connect to station afte device loaded", error);
|
|
596
|
+
});
|
|
597
|
+
});
|
|
598
|
+
this.devicesLoaded = true;
|
|
599
|
+
this.loadingEmitter.emit("devices loaded");
|
|
600
|
+
});
|
|
601
|
+
for (const deviceSN of deviceSNs) {
|
|
602
|
+
if (!newDeviceSNs.includes(deviceSN)) {
|
|
603
|
+
this.getDevice(deviceSN).then((device) => {
|
|
604
|
+
this.removeDevice(device);
|
|
605
|
+
}).catch((error) => {
|
|
606
|
+
this.log.error("Error removing device", error);
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
async refreshCloudData() {
|
|
612
|
+
if (this.config.acceptInvitations) {
|
|
613
|
+
await this.processInvitations().catch(error => {
|
|
614
|
+
this.log.error("Error in processing invitations", error);
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
await this.api.refreshAllData().catch(error => {
|
|
618
|
+
this.log.error("Error during API data refreshing", error);
|
|
619
|
+
});
|
|
620
|
+
if (this.refreshEufySecurityCloudTimeout !== undefined)
|
|
621
|
+
clearTimeout(this.refreshEufySecurityCloudTimeout);
|
|
622
|
+
this.refreshEufySecurityCloudTimeout = setTimeout(() => { this.refreshCloudData(); }, this.config.pollingIntervalMinutes * 60 * 1000);
|
|
623
|
+
}
|
|
624
|
+
close() {
|
|
625
|
+
for (const device_sn of this.cameraStationLivestreamTimeout.keys()) {
|
|
626
|
+
this.stopStationLivestream(device_sn);
|
|
627
|
+
}
|
|
628
|
+
for (const device_sn of this.cameraCloudLivestreamTimeout.keys()) {
|
|
629
|
+
this.stopCloudLivestream(device_sn);
|
|
630
|
+
}
|
|
631
|
+
if (this.refreshEufySecurityCloudTimeout !== undefined)
|
|
632
|
+
clearTimeout(this.refreshEufySecurityCloudTimeout);
|
|
633
|
+
Object.keys(this.refreshEufySecurityP2PTimeout).forEach(station_sn => {
|
|
634
|
+
clearTimeout(this.refreshEufySecurityP2PTimeout[station_sn]);
|
|
635
|
+
delete this.refreshEufySecurityP2PTimeout[station_sn];
|
|
636
|
+
});
|
|
637
|
+
Object.keys(this.deviceSnoozeTimeout).forEach(device_sn => {
|
|
638
|
+
clearTimeout(this.deviceSnoozeTimeout[device_sn]);
|
|
639
|
+
delete this.deviceSnoozeTimeout[device_sn];
|
|
640
|
+
});
|
|
641
|
+
this.savePushPersistentIds();
|
|
642
|
+
this.pushService.close();
|
|
643
|
+
this.mqttService.close();
|
|
644
|
+
Object.values(this.stations).forEach(station => {
|
|
645
|
+
station.close();
|
|
646
|
+
});
|
|
647
|
+
Object.values(this.devices).forEach(device => {
|
|
648
|
+
device.destroy();
|
|
649
|
+
});
|
|
650
|
+
if (this.connected)
|
|
651
|
+
this.emit("close");
|
|
652
|
+
this.connected = false;
|
|
653
|
+
}
|
|
654
|
+
setCameraMaxLivestreamDuration(seconds) {
|
|
655
|
+
this.cameraMaxLivestreamSeconds = seconds;
|
|
656
|
+
}
|
|
657
|
+
getCameraMaxLivestreamDuration() {
|
|
658
|
+
return this.cameraMaxLivestreamSeconds;
|
|
659
|
+
}
|
|
660
|
+
async registerPushNotifications(credentials, persistentIds) {
|
|
661
|
+
if (credentials)
|
|
662
|
+
this.pushService.setCredentials(credentials);
|
|
663
|
+
if (persistentIds)
|
|
664
|
+
this.pushService.setPersistentIds(persistentIds);
|
|
665
|
+
this.pushService.open();
|
|
666
|
+
}
|
|
667
|
+
async connect(options) {
|
|
668
|
+
await this.api.login(options)
|
|
669
|
+
.then(async () => {
|
|
670
|
+
if (options === null || options === void 0 ? void 0 : options.verifyCode) {
|
|
671
|
+
let trusted = false;
|
|
672
|
+
const trusted_devices = await this.api.listTrustDevice();
|
|
673
|
+
trusted_devices.forEach(trusted_device => {
|
|
674
|
+
if (trusted_device.is_current_device === 1) {
|
|
675
|
+
trusted = true;
|
|
676
|
+
}
|
|
677
|
+
});
|
|
678
|
+
if (!trusted)
|
|
679
|
+
return await this.api.addTrustDevice(options === null || options === void 0 ? void 0 : options.verifyCode);
|
|
680
|
+
}
|
|
681
|
+
})
|
|
682
|
+
.catch((error) => {
|
|
683
|
+
this.log.error("Connect Error", error);
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
getPushPersistentIds() {
|
|
687
|
+
return this.pushService.getPersistentIds();
|
|
688
|
+
}
|
|
689
|
+
updateDeviceProperties(deviceSN, values) {
|
|
690
|
+
this.getDevice(deviceSN).then((device) => {
|
|
691
|
+
device.updateRawProperties(values);
|
|
692
|
+
}).catch((error) => {
|
|
693
|
+
this.log.error(`Update device ${deviceSN} properties error`, error);
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
async onAPIClose() {
|
|
697
|
+
if (this.refreshEufySecurityCloudTimeout !== undefined)
|
|
698
|
+
clearTimeout(this.refreshEufySecurityCloudTimeout);
|
|
699
|
+
this.connected = false;
|
|
700
|
+
this.emit("close");
|
|
701
|
+
if (this.retries < 1) {
|
|
702
|
+
this.retries++;
|
|
703
|
+
await this.connect();
|
|
704
|
+
}
|
|
705
|
+
else {
|
|
706
|
+
this.log.error(`Tried to re-authenticate to Eufy cloud, but failed in the process. Manual intervention is required!`);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
async onAPIConnect() {
|
|
710
|
+
this.connected = true;
|
|
711
|
+
this.retries = 0;
|
|
712
|
+
this.saveCloudToken();
|
|
713
|
+
await this.refreshCloudData();
|
|
714
|
+
this.emit("connect");
|
|
715
|
+
this.registerPushNotifications(this.persistentData.push_credentials, this.persistentData.push_persistentIds);
|
|
716
|
+
const loginData = this.api.getPersistentData();
|
|
717
|
+
if (loginData) {
|
|
718
|
+
this.mqttService.connect(loginData.user_id, this.persistentData.openudid, this.api.getAPIBase(), loginData.email);
|
|
719
|
+
}
|
|
720
|
+
else {
|
|
721
|
+
this.log.warn("No login data recevied to initialize MQTT connection...");
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
onAPIConnectionError(error) {
|
|
725
|
+
this.emit("connection error", error);
|
|
726
|
+
}
|
|
727
|
+
async startStationLivestream(deviceSN) {
|
|
728
|
+
const device = await this.getDevice(deviceSN);
|
|
729
|
+
const station = await this.getStation(device.getStationSerial());
|
|
730
|
+
if (!device.hasCommand(types_1.CommandName.DeviceStartLivestream))
|
|
731
|
+
throw new error_1.NotSupportedError(`This functionality is not implemented or supported by ${device.getSerial()}`);
|
|
732
|
+
const camera = device;
|
|
733
|
+
if (!station.isLiveStreaming(camera)) {
|
|
734
|
+
await station.startLivestream(camera);
|
|
735
|
+
if (this.cameraMaxLivestreamSeconds > 0) {
|
|
736
|
+
this.cameraStationLivestreamTimeout.set(deviceSN, setTimeout(() => {
|
|
737
|
+
this.log.info(`Stopping the station stream for the device ${deviceSN}, because we have reached the configured maximum stream timeout (${this.cameraMaxLivestreamSeconds} seconds)`);
|
|
738
|
+
this.stopStationLivestream(deviceSN);
|
|
739
|
+
}, this.cameraMaxLivestreamSeconds * 1000));
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
else {
|
|
743
|
+
this.log.warn(`The station stream for the device ${deviceSN} cannot be started, because it is already streaming!`);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
async startCloudLivestream(deviceSN) {
|
|
747
|
+
const device = await this.getDevice(deviceSN);
|
|
748
|
+
const station = await this.getStation(device.getStationSerial());
|
|
749
|
+
if (!device.hasCommand(types_1.CommandName.DeviceStartLivestream))
|
|
750
|
+
throw new error_1.NotSupportedError(`This functionality is not implemented or supported by ${device.getSerial()}`);
|
|
751
|
+
const camera = device;
|
|
752
|
+
if (!camera.isStreaming()) {
|
|
753
|
+
const url = await camera.startStream();
|
|
754
|
+
if (url !== "") {
|
|
755
|
+
if (this.cameraMaxLivestreamSeconds > 0) {
|
|
756
|
+
this.cameraCloudLivestreamTimeout.set(deviceSN, setTimeout(() => {
|
|
757
|
+
this.log.info(`Stopping the station stream for the device ${deviceSN}, because we have reached the configured maximum stream timeout (${this.cameraMaxLivestreamSeconds} seconds)`);
|
|
758
|
+
this.stopCloudLivestream(deviceSN);
|
|
759
|
+
}, this.cameraMaxLivestreamSeconds * 1000));
|
|
760
|
+
}
|
|
761
|
+
this.emit("cloud livestream start", station, camera, url);
|
|
762
|
+
}
|
|
763
|
+
else {
|
|
764
|
+
this.log.error(`Failed to start cloud stream for the device ${deviceSN}`);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
else {
|
|
768
|
+
this.log.warn(`The cloud stream for the device ${deviceSN} cannot be started, because it is already streaming!`);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
async stopStationLivestream(deviceSN) {
|
|
772
|
+
const device = await this.getDevice(deviceSN);
|
|
773
|
+
const station = await this.getStation(device.getStationSerial());
|
|
774
|
+
if (!device.hasCommand(types_1.CommandName.DeviceStopLivestream))
|
|
775
|
+
throw new error_1.NotSupportedError(`This functionality is not implemented or supported by ${device.getSerial()}`);
|
|
776
|
+
if (station.isConnected() && station.isLiveStreaming(device)) {
|
|
777
|
+
await station.stopLivestream(device);
|
|
778
|
+
}
|
|
779
|
+
else {
|
|
780
|
+
this.log.warn(`The station stream for the device ${deviceSN} cannot be stopped, because it isn't streaming!`);
|
|
781
|
+
}
|
|
782
|
+
const timeout = this.cameraStationLivestreamTimeout.get(deviceSN);
|
|
783
|
+
if (timeout) {
|
|
784
|
+
clearTimeout(timeout);
|
|
785
|
+
this.cameraStationLivestreamTimeout.delete(deviceSN);
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
async stopCloudLivestream(deviceSN) {
|
|
789
|
+
const device = await this.getDevice(deviceSN);
|
|
790
|
+
const station = await this.getStation(device.getStationSerial());
|
|
791
|
+
if (!device.hasCommand(types_1.CommandName.DeviceStopLivestream))
|
|
792
|
+
throw new error_1.NotSupportedError(`This functionality is not implemented or supported by ${device.getSerial()}`);
|
|
793
|
+
const camera = device;
|
|
794
|
+
if (camera.isStreaming()) {
|
|
795
|
+
await camera.stopStream();
|
|
796
|
+
this.emit("cloud livestream stop", station, camera);
|
|
797
|
+
}
|
|
798
|
+
else {
|
|
799
|
+
this.log.warn(`The cloud stream for the device ${deviceSN} cannot be stopped, because it isn't streaming!`);
|
|
800
|
+
}
|
|
801
|
+
const timeout = this.cameraCloudLivestreamTimeout.get(deviceSN);
|
|
802
|
+
if (timeout) {
|
|
803
|
+
clearTimeout(timeout);
|
|
804
|
+
this.cameraCloudLivestreamTimeout.delete(deviceSN);
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
writePersistentData() {
|
|
808
|
+
var _a, _b;
|
|
809
|
+
this.persistentData.login_hash = (0, utils_1.md5)(`${this.config.username}:${this.config.password}`);
|
|
810
|
+
this.persistentData.httpApi = (_a = this.api) === null || _a === void 0 ? void 0 : _a.getPersistentData();
|
|
811
|
+
this.persistentData.country = (_b = this.api) === null || _b === void 0 ? void 0 : _b.getCountry();
|
|
812
|
+
try {
|
|
813
|
+
fse.writeFileSync(this.persistentFile, JSON.stringify(this.persistentData));
|
|
814
|
+
}
|
|
815
|
+
catch (error) {
|
|
816
|
+
this.log.error("Error:", error);
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
saveCloudToken() {
|
|
820
|
+
const token = this.api.getToken();
|
|
821
|
+
const token_expiration = this.api.getTokenExpiration();
|
|
822
|
+
if (!!token && !!token_expiration) {
|
|
823
|
+
this.log.debug("Save cloud token and token expiration", { token: token, tokenExpiration: token_expiration });
|
|
824
|
+
this.persistentData.cloud_token = token;
|
|
825
|
+
this.persistentData.cloud_token_expiration = token_expiration.getTime();
|
|
826
|
+
this.writePersistentData();
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
savePushCredentials(credentials) {
|
|
830
|
+
this.persistentData.push_credentials = credentials;
|
|
831
|
+
this.writePersistentData();
|
|
832
|
+
}
|
|
833
|
+
savePushPersistentIds() {
|
|
834
|
+
this.persistentData.push_persistentIds = this.getPushPersistentIds();
|
|
835
|
+
this.writePersistentData();
|
|
836
|
+
}
|
|
837
|
+
getVersion() {
|
|
838
|
+
return _1.libVersion;
|
|
839
|
+
}
|
|
840
|
+
isPushConnected() {
|
|
841
|
+
return this.pushService.isConnected();
|
|
842
|
+
}
|
|
843
|
+
isMQTTConnected() {
|
|
844
|
+
return this.mqttService.isConnected();
|
|
845
|
+
}
|
|
846
|
+
isConnected() {
|
|
847
|
+
return this.connected;
|
|
848
|
+
}
|
|
849
|
+
async processInvitations() {
|
|
850
|
+
let refreshCloud = false;
|
|
851
|
+
const invites = await this.api.getInvites().catch(error => {
|
|
852
|
+
this.log.error("processInvitations - getInvites - Error:", error);
|
|
853
|
+
return error;
|
|
854
|
+
});
|
|
855
|
+
if (Object.keys(invites).length > 0) {
|
|
856
|
+
const confirmInvites = [];
|
|
857
|
+
for (const invite of Object.values(invites)) {
|
|
858
|
+
const devices = [];
|
|
859
|
+
invite.devices.forEach(device => {
|
|
860
|
+
devices.push(device.device_sn);
|
|
861
|
+
});
|
|
862
|
+
if (devices.length > 0) {
|
|
863
|
+
confirmInvites.push({
|
|
864
|
+
invite_id: invite.invite_id,
|
|
865
|
+
station_sn: invite.station_sn,
|
|
866
|
+
device_sns: devices
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
if (confirmInvites.length > 0) {
|
|
871
|
+
const result = await this.api.confirmInvites(confirmInvites).catch(error => {
|
|
872
|
+
this.log.error("processInvitations - confirmInvites - Error:", error);
|
|
873
|
+
return error;
|
|
874
|
+
});
|
|
875
|
+
if (result) {
|
|
876
|
+
this.log.info(`Accepted received invitations`, confirmInvites);
|
|
877
|
+
refreshCloud = true;
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
const houseInvites = await this.api.getHouseInviteList().catch(error => {
|
|
882
|
+
this.log.error("processInvitations - getHouseInviteList - Error:", error);
|
|
883
|
+
return error;
|
|
884
|
+
});
|
|
885
|
+
if (Object.keys(houseInvites).length > 0) {
|
|
886
|
+
for (const invite of Object.values(houseInvites)) {
|
|
887
|
+
const result = await this.api.confirmHouseInvite(invite.house_id, invite.id).catch(error => {
|
|
888
|
+
this.log.error("processInvitations - confirmHouseInvite - Error:", error);
|
|
889
|
+
return error;
|
|
890
|
+
});
|
|
891
|
+
if (result) {
|
|
892
|
+
this.log.info(`Accepted received house invitation from ${invite.action_user_email}`, invite);
|
|
893
|
+
refreshCloud = true;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
if (refreshCloud)
|
|
898
|
+
this.refreshCloudData();
|
|
899
|
+
}
|
|
900
|
+
onPushMessage(message) {
|
|
901
|
+
this.emit("push message", message);
|
|
902
|
+
try {
|
|
903
|
+
this.log.debug("Received push message", message);
|
|
904
|
+
try {
|
|
905
|
+
if ((message.type === types_3.ServerPushEvent.INVITE_DEVICE || message.type === types_3.ServerPushEvent.HOUSE_INVITE) && this.config.acceptInvitations) {
|
|
906
|
+
if (this.isConnected())
|
|
907
|
+
this.processInvitations();
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
catch (error) {
|
|
911
|
+
this.log.error(`Error processing server push notification for device invitation`, error);
|
|
912
|
+
}
|
|
913
|
+
try {
|
|
914
|
+
if (message.type === types_3.ServerPushEvent.REMOVE_DEVICE || message.type === types_3.ServerPushEvent.REMOVE_HOMEBASE || message.type === types_3.ServerPushEvent.HOUSE_REMOVE) {
|
|
915
|
+
if (this.isConnected())
|
|
916
|
+
this.refreshCloudData();
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
catch (error) {
|
|
920
|
+
this.log.error(`Error processing server push notification for device/station/house removal`, error);
|
|
921
|
+
}
|
|
922
|
+
this.getStations().then((stations) => {
|
|
923
|
+
stations.forEach(station => {
|
|
924
|
+
try {
|
|
925
|
+
station.processPushNotification(message);
|
|
926
|
+
}
|
|
927
|
+
catch (error) {
|
|
928
|
+
this.log.error(`Error processing push notification for station ${station.getSerial()}`, error);
|
|
929
|
+
}
|
|
930
|
+
});
|
|
931
|
+
}).catch((error) => {
|
|
932
|
+
this.log.error("Process push notification for stations", error);
|
|
933
|
+
});
|
|
934
|
+
this.getDevices().then((devices) => {
|
|
935
|
+
devices.forEach(device => {
|
|
936
|
+
try {
|
|
937
|
+
device.processPushNotification(message, this.config.eventDurationSeconds);
|
|
938
|
+
}
|
|
939
|
+
catch (error) {
|
|
940
|
+
this.log.error(`Error processing push notification for device ${device.getSerial()}`, error);
|
|
941
|
+
}
|
|
942
|
+
});
|
|
943
|
+
}).catch((error) => {
|
|
944
|
+
this.log.error("Process push notification for devices", error);
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
catch (error) {
|
|
948
|
+
this.log.error("Generic Error:", error);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
async startStationDownload(deviceSN, path, cipherID) {
|
|
952
|
+
const device = await this.getDevice(deviceSN);
|
|
953
|
+
const station = await this.getStation(device.getStationSerial());
|
|
954
|
+
if (!device.isCamera())
|
|
955
|
+
throw new error_1.NotSupportedError(`This functionality is not implemented or supported by ${device.getSerial()}`);
|
|
956
|
+
if (!station.isDownloading(device)) {
|
|
957
|
+
await station.startDownload(device, path, cipherID);
|
|
958
|
+
}
|
|
959
|
+
else {
|
|
960
|
+
this.log.warn(`The station is already downloading a video for the device ${deviceSN}!`);
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
async cancelStationDownload(deviceSN) {
|
|
964
|
+
const device = await this.getDevice(deviceSN);
|
|
965
|
+
const station = await this.getStation(device.getStationSerial());
|
|
966
|
+
if (!device.isCamera())
|
|
967
|
+
throw new error_1.NotSupportedError(`This functionality is not implemented or supported by ${device.getSerial()}`);
|
|
968
|
+
if (station.isConnected() && station.isDownloading(device)) {
|
|
969
|
+
await station.cancelDownload(device);
|
|
970
|
+
}
|
|
971
|
+
else {
|
|
972
|
+
this.log.warn(`The station isn't downloading a video for the device ${deviceSN}!`);
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
getConfig() {
|
|
976
|
+
return this.config;
|
|
977
|
+
}
|
|
978
|
+
async setDeviceProperty(deviceSN, name, value) {
|
|
979
|
+
const device = await this.getDevice(deviceSN);
|
|
980
|
+
const station = await this.getStation(device.getStationSerial());
|
|
981
|
+
const metadata = device.getPropertyMetadata(name);
|
|
982
|
+
value = (0, utils_1.parseValue)(metadata, value);
|
|
983
|
+
switch (name) {
|
|
984
|
+
case types_1.PropertyName.DeviceEnabled:
|
|
985
|
+
await station.enableDevice(device, value);
|
|
986
|
+
break;
|
|
987
|
+
case types_1.PropertyName.DeviceStatusLed:
|
|
988
|
+
await station.setStatusLed(device, value);
|
|
989
|
+
break;
|
|
990
|
+
case types_1.PropertyName.DeviceAutoNightvision:
|
|
991
|
+
await station.setAutoNightVision(device, value);
|
|
992
|
+
break;
|
|
993
|
+
case types_1.PropertyName.DeviceMotionDetection:
|
|
994
|
+
await station.setMotionDetection(device, value);
|
|
995
|
+
break;
|
|
996
|
+
case types_1.PropertyName.DeviceSoundDetection:
|
|
997
|
+
await station.setSoundDetection(device, value);
|
|
998
|
+
break;
|
|
999
|
+
case types_1.PropertyName.DevicePetDetection:
|
|
1000
|
+
await station.setPetDetection(device, value);
|
|
1001
|
+
break;
|
|
1002
|
+
case types_1.PropertyName.DeviceRTSPStream:
|
|
1003
|
+
await station.setRTSPStream(device, value);
|
|
1004
|
+
break;
|
|
1005
|
+
case types_1.PropertyName.DeviceAntitheftDetection:
|
|
1006
|
+
await station.setAntiTheftDetection(device, value);
|
|
1007
|
+
break;
|
|
1008
|
+
case types_1.PropertyName.DeviceLocked:
|
|
1009
|
+
await station.lockDevice(device, value);
|
|
1010
|
+
break;
|
|
1011
|
+
case types_1.PropertyName.DeviceWatermark:
|
|
1012
|
+
await station.setWatermark(device, value);
|
|
1013
|
+
break;
|
|
1014
|
+
case types_1.PropertyName.DeviceLight:
|
|
1015
|
+
await station.switchLight(device, value);
|
|
1016
|
+
break;
|
|
1017
|
+
case types_1.PropertyName.DeviceLightSettingsEnable:
|
|
1018
|
+
await station.setFloodlightLightSettingsEnable(device, value);
|
|
1019
|
+
break;
|
|
1020
|
+
case types_1.PropertyName.DeviceLightSettingsBrightnessManual:
|
|
1021
|
+
await station.setFloodlightLightSettingsBrightnessManual(device, value);
|
|
1022
|
+
break;
|
|
1023
|
+
case types_1.PropertyName.DeviceLightSettingsBrightnessMotion:
|
|
1024
|
+
await station.setFloodlightLightSettingsBrightnessMotion(device, value);
|
|
1025
|
+
break;
|
|
1026
|
+
case types_1.PropertyName.DeviceLightSettingsBrightnessSchedule:
|
|
1027
|
+
await station.setFloodlightLightSettingsBrightnessSchedule(device, value);
|
|
1028
|
+
break;
|
|
1029
|
+
case types_1.PropertyName.DeviceLightSettingsMotionTriggered:
|
|
1030
|
+
await station.setFloodlightLightSettingsMotionTriggered(device, value);
|
|
1031
|
+
break;
|
|
1032
|
+
case types_1.PropertyName.DeviceLightSettingsMotionTriggeredDistance:
|
|
1033
|
+
await station.setFloodlightLightSettingsMotionTriggeredDistance(device, value);
|
|
1034
|
+
break;
|
|
1035
|
+
case types_1.PropertyName.DeviceLightSettingsMotionTriggeredTimer:
|
|
1036
|
+
await station.setFloodlightLightSettingsMotionTriggeredTimer(device, value);
|
|
1037
|
+
break;
|
|
1038
|
+
case types_1.PropertyName.DeviceMicrophone:
|
|
1039
|
+
await station.setMicMute(device, value);
|
|
1040
|
+
break;
|
|
1041
|
+
case types_1.PropertyName.DeviceSpeaker:
|
|
1042
|
+
await station.enableSpeaker(device, value);
|
|
1043
|
+
break;
|
|
1044
|
+
case types_1.PropertyName.DeviceSpeakerVolume:
|
|
1045
|
+
await station.setSpeakerVolume(device, value);
|
|
1046
|
+
break;
|
|
1047
|
+
case types_1.PropertyName.DeviceAudioRecording:
|
|
1048
|
+
await station.setAudioRecording(device, value);
|
|
1049
|
+
break;
|
|
1050
|
+
case types_1.PropertyName.DevicePowerSource:
|
|
1051
|
+
await station.setPowerSource(device, value);
|
|
1052
|
+
break;
|
|
1053
|
+
case types_1.PropertyName.DevicePowerWorkingMode:
|
|
1054
|
+
await station.setPowerWorkingMode(device, value);
|
|
1055
|
+
break;
|
|
1056
|
+
case types_1.PropertyName.DeviceRecordingEndClipMotionStops:
|
|
1057
|
+
await station.setRecordingEndClipMotionStops(device, value);
|
|
1058
|
+
break;
|
|
1059
|
+
case types_1.PropertyName.DeviceRecordingClipLength:
|
|
1060
|
+
await station.setRecordingClipLength(device, value);
|
|
1061
|
+
break;
|
|
1062
|
+
case types_1.PropertyName.DeviceRecordingRetriggerInterval:
|
|
1063
|
+
await station.setRecordingRetriggerInterval(device, value);
|
|
1064
|
+
break;
|
|
1065
|
+
case types_1.PropertyName.DeviceVideoStreamingQuality:
|
|
1066
|
+
await station.setVideoStreamingQuality(device, value);
|
|
1067
|
+
break;
|
|
1068
|
+
case types_1.PropertyName.DeviceVideoRecordingQuality:
|
|
1069
|
+
await station.setVideoRecordingQuality(device, value);
|
|
1070
|
+
break;
|
|
1071
|
+
case types_1.PropertyName.DeviceMotionDetectionSensitivity:
|
|
1072
|
+
await station.setMotionDetectionSensitivity(device, value);
|
|
1073
|
+
break;
|
|
1074
|
+
case types_1.PropertyName.DeviceMotionTracking:
|
|
1075
|
+
await station.setMotionTracking(device, value);
|
|
1076
|
+
break;
|
|
1077
|
+
case types_1.PropertyName.DeviceMotionDetectionType:
|
|
1078
|
+
await station.setMotionDetectionType(device, value);
|
|
1079
|
+
break;
|
|
1080
|
+
case types_1.PropertyName.DeviceMotionZone:
|
|
1081
|
+
await station.setMotionZone(device, value);
|
|
1082
|
+
break;
|
|
1083
|
+
case types_1.PropertyName.DeviceVideoWDR:
|
|
1084
|
+
await station.setWDR(device, value);
|
|
1085
|
+
break;
|
|
1086
|
+
case types_1.PropertyName.DeviceRingtoneVolume:
|
|
1087
|
+
await station.setRingtoneVolume(device, value);
|
|
1088
|
+
break;
|
|
1089
|
+
case types_1.PropertyName.DeviceChimeIndoor:
|
|
1090
|
+
await station.enableIndoorChime(device, value);
|
|
1091
|
+
break;
|
|
1092
|
+
case types_1.PropertyName.DeviceChimeHomebase:
|
|
1093
|
+
await station.enableHomebaseChime(device, value);
|
|
1094
|
+
break;
|
|
1095
|
+
case types_1.PropertyName.DeviceChimeHomebaseRingtoneVolume:
|
|
1096
|
+
await station.setHomebaseChimeRingtoneVolume(device, value);
|
|
1097
|
+
break;
|
|
1098
|
+
case types_1.PropertyName.DeviceChimeHomebaseRingtoneType:
|
|
1099
|
+
await station.setHomebaseChimeRingtoneType(device, value);
|
|
1100
|
+
break;
|
|
1101
|
+
case types_1.PropertyName.DeviceNotificationType:
|
|
1102
|
+
await station.setNotificationType(device, value);
|
|
1103
|
+
break;
|
|
1104
|
+
case types_1.PropertyName.DeviceNotificationPerson:
|
|
1105
|
+
await station.setNotificationPerson(device, value);
|
|
1106
|
+
break;
|
|
1107
|
+
case types_1.PropertyName.DeviceNotificationPet:
|
|
1108
|
+
await station.setNotificationPet(device, value);
|
|
1109
|
+
break;
|
|
1110
|
+
case types_1.PropertyName.DeviceNotificationAllOtherMotion:
|
|
1111
|
+
await station.setNotificationAllOtherMotion(device, value);
|
|
1112
|
+
break;
|
|
1113
|
+
case types_1.PropertyName.DeviceNotificationAllSound:
|
|
1114
|
+
await station.setNotificationAllSound(device, value);
|
|
1115
|
+
break;
|
|
1116
|
+
case types_1.PropertyName.DeviceNotificationCrying:
|
|
1117
|
+
await station.setNotificationCrying(device, value);
|
|
1118
|
+
break;
|
|
1119
|
+
case types_1.PropertyName.DeviceNotificationMotion:
|
|
1120
|
+
await station.setNotificationMotion(device, value);
|
|
1121
|
+
break;
|
|
1122
|
+
case types_1.PropertyName.DeviceNotificationRing:
|
|
1123
|
+
await station.setNotificationRing(device, value);
|
|
1124
|
+
break;
|
|
1125
|
+
case types_1.PropertyName.DeviceChirpVolume:
|
|
1126
|
+
await station.setChirpVolume(device, value);
|
|
1127
|
+
break;
|
|
1128
|
+
case types_1.PropertyName.DeviceChirpTone:
|
|
1129
|
+
await station.setChirpTone(device, value);
|
|
1130
|
+
break;
|
|
1131
|
+
case types_1.PropertyName.DeviceVideoHDR:
|
|
1132
|
+
await station.setHDR(device, value);
|
|
1133
|
+
break;
|
|
1134
|
+
case types_1.PropertyName.DeviceVideoDistortionCorrection:
|
|
1135
|
+
await station.setDistortionCorrection(device, value);
|
|
1136
|
+
break;
|
|
1137
|
+
case types_1.PropertyName.DeviceVideoRingRecord:
|
|
1138
|
+
await station.setRingRecord(device, value);
|
|
1139
|
+
break;
|
|
1140
|
+
case types_1.PropertyName.DeviceRotationSpeed:
|
|
1141
|
+
await station.setPanAndTiltRotationSpeed(device, value);
|
|
1142
|
+
break;
|
|
1143
|
+
case types_1.PropertyName.DeviceNightvision:
|
|
1144
|
+
await station.setNightVision(device, value);
|
|
1145
|
+
break;
|
|
1146
|
+
case types_1.PropertyName.DeviceMotionDetectionRange:
|
|
1147
|
+
await station.setMotionDetectionRange(device, value);
|
|
1148
|
+
break;
|
|
1149
|
+
case types_1.PropertyName.DeviceMotionDetectionRangeStandardSensitivity:
|
|
1150
|
+
await station.setMotionDetectionRangeStandardSensitivity(device, value);
|
|
1151
|
+
break;
|
|
1152
|
+
case types_1.PropertyName.DeviceMotionDetectionRangeAdvancedLeftSensitivity:
|
|
1153
|
+
await station.setMotionDetectionRangeAdvancedLeftSensitivity(device, value);
|
|
1154
|
+
break;
|
|
1155
|
+
case types_1.PropertyName.DeviceMotionDetectionRangeAdvancedMiddleSensitivity:
|
|
1156
|
+
await station.setMotionDetectionRangeAdvancedMiddleSensitivity(device, value);
|
|
1157
|
+
break;
|
|
1158
|
+
case types_1.PropertyName.DeviceMotionDetectionRangeAdvancedRightSensitivity:
|
|
1159
|
+
await station.setMotionDetectionRangeAdvancedRightSensitivity(device, value);
|
|
1160
|
+
break;
|
|
1161
|
+
case types_1.PropertyName.DeviceMotionDetectionTestMode:
|
|
1162
|
+
await station.setMotionDetectionTestMode(device, value);
|
|
1163
|
+
break;
|
|
1164
|
+
case types_1.PropertyName.DeviceMotionTrackingSensitivity:
|
|
1165
|
+
await station.setMotionTrackingSensitivity(device, value);
|
|
1166
|
+
break;
|
|
1167
|
+
case types_1.PropertyName.DeviceMotionAutoCruise:
|
|
1168
|
+
await station.setMotionAutoCruise(device, value);
|
|
1169
|
+
break;
|
|
1170
|
+
case types_1.PropertyName.DeviceMotionOutOfViewDetection:
|
|
1171
|
+
await station.setMotionOutOfViewDetection(device, value);
|
|
1172
|
+
break;
|
|
1173
|
+
case types_1.PropertyName.DeviceLightSettingsColorTemperatureManual:
|
|
1174
|
+
await station.setLightSettingsColorTemperatureManual(device, value);
|
|
1175
|
+
break;
|
|
1176
|
+
case types_1.PropertyName.DeviceLightSettingsColorTemperatureMotion:
|
|
1177
|
+
await station.setLightSettingsColorTemperatureMotion(device, value);
|
|
1178
|
+
break;
|
|
1179
|
+
case types_1.PropertyName.DeviceLightSettingsColorTemperatureSchedule:
|
|
1180
|
+
await station.setLightSettingsColorTemperatureSchedule(device, value);
|
|
1181
|
+
break;
|
|
1182
|
+
case types_1.PropertyName.DeviceLightSettingsMotionActivationMode:
|
|
1183
|
+
await station.setLightSettingsMotionActivationMode(device, value);
|
|
1184
|
+
break;
|
|
1185
|
+
case types_1.PropertyName.DeviceVideoNightvisionImageAdjustment:
|
|
1186
|
+
await station.setVideoNightvisionImageAdjustment(device, value);
|
|
1187
|
+
break;
|
|
1188
|
+
case types_1.PropertyName.DeviceVideoColorNightvision:
|
|
1189
|
+
await station.setVideoColorNightvision(device, value);
|
|
1190
|
+
break;
|
|
1191
|
+
case types_1.PropertyName.DeviceAutoCalibration:
|
|
1192
|
+
await station.setAutoCalibration(device, value);
|
|
1193
|
+
break;
|
|
1194
|
+
case types_1.PropertyName.DeviceAutoLock:
|
|
1195
|
+
await station.setAutoLock(device, value);
|
|
1196
|
+
break;
|
|
1197
|
+
case types_1.PropertyName.DeviceAutoLockSchedule:
|
|
1198
|
+
await station.setAutoLockSchedule(device, value);
|
|
1199
|
+
break;
|
|
1200
|
+
case types_1.PropertyName.DeviceAutoLockScheduleStartTime:
|
|
1201
|
+
await station.setAutoLockScheduleStartTime(device, value);
|
|
1202
|
+
break;
|
|
1203
|
+
case types_1.PropertyName.DeviceAutoLockScheduleEndTime:
|
|
1204
|
+
await station.setAutoLockScheduleEndTime(device, value);
|
|
1205
|
+
break;
|
|
1206
|
+
case types_1.PropertyName.DeviceAutoLockTimer:
|
|
1207
|
+
await station.setAutoLockTimer(device, value);
|
|
1208
|
+
break;
|
|
1209
|
+
case types_1.PropertyName.DeviceOneTouchLocking:
|
|
1210
|
+
await station.setOneTouchLocking(device, value);
|
|
1211
|
+
break;
|
|
1212
|
+
case types_1.PropertyName.DeviceSound:
|
|
1213
|
+
await station.setSound(device, value);
|
|
1214
|
+
break;
|
|
1215
|
+
case types_1.PropertyName.DeviceNotification:
|
|
1216
|
+
await station.setNotification(device, value);
|
|
1217
|
+
break;
|
|
1218
|
+
case types_1.PropertyName.DeviceNotificationLocked:
|
|
1219
|
+
await station.setNotificationLocked(device, value);
|
|
1220
|
+
break;
|
|
1221
|
+
case types_1.PropertyName.DeviceNotificationUnlocked:
|
|
1222
|
+
await station.setNotificationUnlocked(device, value);
|
|
1223
|
+
break;
|
|
1224
|
+
case types_1.PropertyName.DeviceScramblePasscode:
|
|
1225
|
+
await station.setScramblePasscode(device, value);
|
|
1226
|
+
break;
|
|
1227
|
+
case types_1.PropertyName.DeviceWrongTryProtection:
|
|
1228
|
+
await station.setWrongTryProtection(device, value);
|
|
1229
|
+
break;
|
|
1230
|
+
case types_1.PropertyName.DeviceWrongTryAttempts:
|
|
1231
|
+
await station.setWrongTryAttempts(device, value);
|
|
1232
|
+
break;
|
|
1233
|
+
case types_1.PropertyName.DeviceWrongTryLockdownTime:
|
|
1234
|
+
await station.setWrongTryLockdownTime(device, value);
|
|
1235
|
+
break;
|
|
1236
|
+
case types_1.PropertyName.DeviceLoiteringDetection:
|
|
1237
|
+
await station.setLoiteringDetection(device, value);
|
|
1238
|
+
break;
|
|
1239
|
+
case types_1.PropertyName.DeviceLoiteringDetectionRange:
|
|
1240
|
+
await station.setLoiteringDetectionRange(device, value);
|
|
1241
|
+
break;
|
|
1242
|
+
case types_1.PropertyName.DeviceLoiteringDetectionLength:
|
|
1243
|
+
await station.setLoiteringDetectionLength(device, value);
|
|
1244
|
+
break;
|
|
1245
|
+
case types_1.PropertyName.DeviceLoiteringCustomResponseAutoVoiceResponse:
|
|
1246
|
+
await station.setLoiteringCustomResponseAutoVoiceResponse(device, value);
|
|
1247
|
+
break;
|
|
1248
|
+
case types_1.PropertyName.DeviceLoiteringCustomResponseHomeBaseNotification:
|
|
1249
|
+
await station.setLoiteringCustomResponseHomeBaseNotification(device, value);
|
|
1250
|
+
break;
|
|
1251
|
+
case types_1.PropertyName.DeviceLoiteringCustomResponsePhoneNotification:
|
|
1252
|
+
await station.setLoiteringCustomResponsePhoneNotification(device, value);
|
|
1253
|
+
break;
|
|
1254
|
+
case types_1.PropertyName.DeviceLoiteringCustomResponseAutoVoiceResponseVoice:
|
|
1255
|
+
await station.setLoiteringCustomResponseAutoVoiceResponseVoice(device, value);
|
|
1256
|
+
break;
|
|
1257
|
+
case types_1.PropertyName.DeviceLoiteringCustomResponseTimeFrom:
|
|
1258
|
+
await station.setLoiteringCustomResponseTimeFrom(device, value);
|
|
1259
|
+
break;
|
|
1260
|
+
case types_1.PropertyName.DeviceLoiteringCustomResponseTimeTo:
|
|
1261
|
+
await station.setLoiteringCustomResponseTimeTo(device, value);
|
|
1262
|
+
break;
|
|
1263
|
+
case types_1.PropertyName.DeviceMotionDetectionSensitivityMode:
|
|
1264
|
+
await station.setMotionDetectionSensitivityMode(device, value);
|
|
1265
|
+
break;
|
|
1266
|
+
case types_1.PropertyName.DeviceMotionDetectionSensitivityStandard:
|
|
1267
|
+
await station.setMotionDetectionSensitivityStandard(device, value);
|
|
1268
|
+
break;
|
|
1269
|
+
case types_1.PropertyName.DeviceMotionDetectionSensitivityAdvancedA:
|
|
1270
|
+
await station.setMotionDetectionSensitivityAdvancedA(device, value);
|
|
1271
|
+
break;
|
|
1272
|
+
case types_1.PropertyName.DeviceMotionDetectionSensitivityAdvancedB:
|
|
1273
|
+
await station.setMotionDetectionSensitivityAdvancedB(device, value);
|
|
1274
|
+
break;
|
|
1275
|
+
case types_1.PropertyName.DeviceMotionDetectionSensitivityAdvancedC:
|
|
1276
|
+
await station.setMotionDetectionSensitivityAdvancedC(device, value);
|
|
1277
|
+
break;
|
|
1278
|
+
case types_1.PropertyName.DeviceMotionDetectionSensitivityAdvancedD:
|
|
1279
|
+
await station.setMotionDetectionSensitivityAdvancedD(device, value);
|
|
1280
|
+
break;
|
|
1281
|
+
case types_1.PropertyName.DeviceMotionDetectionSensitivityAdvancedE:
|
|
1282
|
+
await station.setMotionDetectionSensitivityAdvancedE(device, value);
|
|
1283
|
+
break;
|
|
1284
|
+
case types_1.PropertyName.DeviceMotionDetectionSensitivityAdvancedF:
|
|
1285
|
+
await station.setMotionDetectionSensitivityAdvancedF(device, value);
|
|
1286
|
+
break;
|
|
1287
|
+
case types_1.PropertyName.DeviceMotionDetectionSensitivityAdvancedG:
|
|
1288
|
+
await station.setMotionDetectionSensitivityAdvancedG(device, value);
|
|
1289
|
+
break;
|
|
1290
|
+
case types_1.PropertyName.DeviceMotionDetectionSensitivityAdvancedH:
|
|
1291
|
+
await station.setMotionDetectionSensitivityAdvancedH(device, value);
|
|
1292
|
+
break;
|
|
1293
|
+
case types_1.PropertyName.DeviceDeliveryGuard:
|
|
1294
|
+
await station.setDeliveryGuard(device, value);
|
|
1295
|
+
break;
|
|
1296
|
+
case types_1.PropertyName.DeviceDeliveryGuardPackageGuarding:
|
|
1297
|
+
await station.setDeliveryGuardPackageGuarding(device, value);
|
|
1298
|
+
break;
|
|
1299
|
+
case types_1.PropertyName.DeviceDeliveryGuardPackageGuardingVoiceResponseVoice:
|
|
1300
|
+
await station.setDeliveryGuardPackageGuardingVoiceResponseVoice(device, value);
|
|
1301
|
+
break;
|
|
1302
|
+
case types_1.PropertyName.DeviceDeliveryGuardPackageGuardingActivatedTimeFrom:
|
|
1303
|
+
await station.setDeliveryGuardPackageGuardingActivatedTimeFrom(device, value);
|
|
1304
|
+
break;
|
|
1305
|
+
case types_1.PropertyName.DeviceDeliveryGuardPackageGuardingActivatedTimeTo:
|
|
1306
|
+
await station.setDeliveryGuardPackageGuardingActivatedTimeTo(device, value);
|
|
1307
|
+
break;
|
|
1308
|
+
case types_1.PropertyName.DeviceDeliveryGuardUncollectedPackageAlert:
|
|
1309
|
+
await station.setDeliveryGuardUncollectedPackageAlert(device, value);
|
|
1310
|
+
break;
|
|
1311
|
+
case types_1.PropertyName.DeviceDeliveryGuardPackageLiveCheckAssistance:
|
|
1312
|
+
await station.setDeliveryGuardPackageLiveCheckAssistance(device, value);
|
|
1313
|
+
break;
|
|
1314
|
+
case types_1.PropertyName.DeviceDualCamWatchViewMode:
|
|
1315
|
+
await station.setDualCamWatchViewMode(device, value);
|
|
1316
|
+
break;
|
|
1317
|
+
case types_1.PropertyName.DeviceRingAutoResponse:
|
|
1318
|
+
await station.setRingAutoResponse(device, value);
|
|
1319
|
+
break;
|
|
1320
|
+
case types_1.PropertyName.DeviceRingAutoResponseVoiceResponse:
|
|
1321
|
+
await station.setRingAutoResponseVoiceResponse(device, value);
|
|
1322
|
+
break;
|
|
1323
|
+
case types_1.PropertyName.DeviceRingAutoResponseVoiceResponseVoice:
|
|
1324
|
+
await station.setRingAutoResponseVoiceResponseVoice(device, value);
|
|
1325
|
+
break;
|
|
1326
|
+
case types_1.PropertyName.DeviceRingAutoResponseTimeFrom:
|
|
1327
|
+
await station.setRingAutoResponseTimeFrom(device, value);
|
|
1328
|
+
break;
|
|
1329
|
+
case types_1.PropertyName.DeviceRingAutoResponseTimeTo:
|
|
1330
|
+
await station.setRingAutoResponseTimeTo(device, value);
|
|
1331
|
+
break;
|
|
1332
|
+
case types_1.PropertyName.DeviceNotificationRadarDetector:
|
|
1333
|
+
await station.setNotificationRadarDetector(device, value);
|
|
1334
|
+
break;
|
|
1335
|
+
case types_1.PropertyName.DeviceSoundDetectionSensitivity:
|
|
1336
|
+
await station.setSoundDetectionSensitivity(device, value);
|
|
1337
|
+
break;
|
|
1338
|
+
case types_1.PropertyName.DeviceContinuousRecording:
|
|
1339
|
+
await station.setContinuousRecording(device, value);
|
|
1340
|
+
break;
|
|
1341
|
+
case types_1.PropertyName.DeviceContinuousRecordingType:
|
|
1342
|
+
await station.setContinuousRecordingType(device, value);
|
|
1343
|
+
break;
|
|
1344
|
+
case types_1.PropertyName.DeviceDefaultAngle:
|
|
1345
|
+
await station.enableDefaultAngle(device, value);
|
|
1346
|
+
break;
|
|
1347
|
+
case types_1.PropertyName.DeviceDefaultAngleIdleTime:
|
|
1348
|
+
await station.setDefaultAngleIdleTime(device, value);
|
|
1349
|
+
break;
|
|
1350
|
+
case types_1.PropertyName.DeviceNotificationIntervalTime:
|
|
1351
|
+
await station.setNotificationIntervalTime(device, value);
|
|
1352
|
+
break;
|
|
1353
|
+
case types_1.PropertyName.DeviceSoundDetectionRoundLook:
|
|
1354
|
+
await station.setSoundDetectionRoundLook(device, value);
|
|
1355
|
+
break;
|
|
1356
|
+
case types_1.PropertyName.DeviceDeliveryGuardUncollectedPackageAlertTimeToCheck:
|
|
1357
|
+
await station.setDeliveryGuardUncollectedPackageAlertTimeToCheck(device, value);
|
|
1358
|
+
break;
|
|
1359
|
+
case types_1.PropertyName.DeviceLeftOpenAlarm:
|
|
1360
|
+
case types_1.PropertyName.DeviceLeftOpenAlarmDuration:
|
|
1361
|
+
case types_1.PropertyName.DeviceDualUnlock:
|
|
1362
|
+
case types_1.PropertyName.DevicePowerSave:
|
|
1363
|
+
case types_1.PropertyName.DeviceInteriorBrightness:
|
|
1364
|
+
case types_1.PropertyName.DeviceInteriorBrightnessDuration:
|
|
1365
|
+
case types_1.PropertyName.DeviceTamperAlarm:
|
|
1366
|
+
case types_1.PropertyName.DeviceRemoteUnlock:
|
|
1367
|
+
case types_1.PropertyName.DeviceRemoteUnlockMasterPIN:
|
|
1368
|
+
case types_1.PropertyName.DeviceAlarmVolume:
|
|
1369
|
+
case types_1.PropertyName.DevicePromptVolume:
|
|
1370
|
+
case types_1.PropertyName.DeviceNotificationUnlockByKey:
|
|
1371
|
+
case types_1.PropertyName.DeviceNotificationUnlockByPIN:
|
|
1372
|
+
case types_1.PropertyName.DeviceNotificationUnlockByFingerprint:
|
|
1373
|
+
case types_1.PropertyName.DeviceNotificationUnlockByApp:
|
|
1374
|
+
case types_1.PropertyName.DeviceNotificationDualUnlock:
|
|
1375
|
+
case types_1.PropertyName.DeviceNotificationDualLock:
|
|
1376
|
+
case types_1.PropertyName.DeviceNotificationWrongTryProtect:
|
|
1377
|
+
case types_1.PropertyName.DeviceNotificationJammed:
|
|
1378
|
+
await station.setSmartSafeParams(device, name, value);
|
|
1379
|
+
break;
|
|
1380
|
+
case types_1.PropertyName.DeviceVideoTypeStoreToNAS:
|
|
1381
|
+
await station.setVideoTypeStoreToNAS(device, value);
|
|
1382
|
+
break;
|
|
1383
|
+
case types_1.PropertyName.DeviceMotionDetectionTypeHumanRecognition:
|
|
1384
|
+
await station.setMotionDetectionTypeHB3(device, types_1.HB3DetectionTypes.HUMAN_RECOGNITION, value);
|
|
1385
|
+
break;
|
|
1386
|
+
case types_1.PropertyName.DeviceMotionDetectionTypeHuman:
|
|
1387
|
+
await station.setMotionDetectionTypeHB3(device, types_1.HB3DetectionTypes.HUMAN_DETECTION, value);
|
|
1388
|
+
break;
|
|
1389
|
+
case types_1.PropertyName.DeviceMotionDetectionTypePet:
|
|
1390
|
+
await station.setMotionDetectionTypeHB3(device, types_1.HB3DetectionTypes.PET_DETECTION, value);
|
|
1391
|
+
break;
|
|
1392
|
+
case types_1.PropertyName.DeviceMotionDetectionTypeVehicle:
|
|
1393
|
+
await station.setMotionDetectionTypeHB3(device, types_1.HB3DetectionTypes.VEHICLE_DETECTION, value);
|
|
1394
|
+
break;
|
|
1395
|
+
case types_1.PropertyName.DeviceMotionDetectionTypeAllOtherMotions:
|
|
1396
|
+
await station.setMotionDetectionTypeHB3(device, types_1.HB3DetectionTypes.ALL_OTHER_MOTION, value);
|
|
1397
|
+
break;
|
|
1398
|
+
default:
|
|
1399
|
+
if (!Object.values(types_1.PropertyName).includes(name))
|
|
1400
|
+
throw new error_1.ReadOnlyPropertyError(`Property ${name} is read only`);
|
|
1401
|
+
throw new error_2.InvalidPropertyError(`Device ${deviceSN} has no writable property named ${name}`);
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
async setStationProperty(stationSN, name, value) {
|
|
1405
|
+
const station = await this.getStation(stationSN);
|
|
1406
|
+
const metadata = station.getPropertyMetadata(name);
|
|
1407
|
+
value = (0, utils_1.parseValue)(metadata, value);
|
|
1408
|
+
switch (name) {
|
|
1409
|
+
case types_1.PropertyName.StationGuardMode:
|
|
1410
|
+
await station.setGuardMode(value);
|
|
1411
|
+
break;
|
|
1412
|
+
case types_1.PropertyName.StationAlarmTone:
|
|
1413
|
+
await station.setStationAlarmTone(value);
|
|
1414
|
+
break;
|
|
1415
|
+
case types_1.PropertyName.StationAlarmVolume:
|
|
1416
|
+
await station.setStationAlarmRingtoneVolume(value);
|
|
1417
|
+
break;
|
|
1418
|
+
case types_1.PropertyName.StationPromptVolume:
|
|
1419
|
+
await station.setStationPromptVolume(value);
|
|
1420
|
+
break;
|
|
1421
|
+
case types_1.PropertyName.StationNotificationSwitchModeApp:
|
|
1422
|
+
await station.setStationNotificationSwitchMode(types_1.NotificationSwitchMode.APP, value);
|
|
1423
|
+
break;
|
|
1424
|
+
case types_1.PropertyName.StationNotificationSwitchModeGeofence:
|
|
1425
|
+
await station.setStationNotificationSwitchMode(types_1.NotificationSwitchMode.GEOFENCE, value);
|
|
1426
|
+
break;
|
|
1427
|
+
case types_1.PropertyName.StationNotificationSwitchModeSchedule:
|
|
1428
|
+
await station.setStationNotificationSwitchMode(types_1.NotificationSwitchMode.SCHEDULE, value);
|
|
1429
|
+
break;
|
|
1430
|
+
case types_1.PropertyName.StationNotificationSwitchModeKeypad:
|
|
1431
|
+
await station.setStationNotificationSwitchMode(types_1.NotificationSwitchMode.KEYPAD, value);
|
|
1432
|
+
break;
|
|
1433
|
+
case types_1.PropertyName.StationNotificationStartAlarmDelay:
|
|
1434
|
+
await station.setStationNotificationStartAlarmDelay(value);
|
|
1435
|
+
break;
|
|
1436
|
+
case types_1.PropertyName.StationTimeFormat:
|
|
1437
|
+
await station.setStationTimeFormat(value);
|
|
1438
|
+
break;
|
|
1439
|
+
case types_1.PropertyName.StationSwitchModeWithAccessCode:
|
|
1440
|
+
await station.setStationSwitchModeWithAccessCode(value);
|
|
1441
|
+
break;
|
|
1442
|
+
case types_1.PropertyName.StationAutoEndAlarm:
|
|
1443
|
+
await station.setStationAutoEndAlarm(value);
|
|
1444
|
+
break;
|
|
1445
|
+
case types_1.PropertyName.StationTurnOffAlarmWithButton:
|
|
1446
|
+
await station.setStationTurnOffAlarmWithButton(value);
|
|
1447
|
+
break;
|
|
1448
|
+
default:
|
|
1449
|
+
if (!Object.values(types_1.PropertyName).includes(name))
|
|
1450
|
+
throw new error_1.ReadOnlyPropertyError(`Property ${name} is read only`);
|
|
1451
|
+
throw new error_2.InvalidPropertyError(`Station ${stationSN} has no writable property named ${name}`);
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
onStartStationLivestream(station, channel, metadata, videostream, audiostream) {
|
|
1455
|
+
this.getStationDevice(station.getSerial(), channel).then((device) => {
|
|
1456
|
+
this.emit("station livestream start", station, device, metadata, videostream, audiostream);
|
|
1457
|
+
}).catch((error) => {
|
|
1458
|
+
this.log.error(`Station start livestream error (station: ${station.getSerial()} channel: ${channel})`, error);
|
|
1459
|
+
});
|
|
1460
|
+
}
|
|
1461
|
+
onStopStationLivestream(station, channel) {
|
|
1462
|
+
this.getStationDevice(station.getSerial(), channel).then((device) => {
|
|
1463
|
+
this.emit("station livestream stop", station, device);
|
|
1464
|
+
}).catch((error) => {
|
|
1465
|
+
this.log.error(`Station stop livestream error (station: ${station.getSerial()} channel: ${channel})`, error);
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
onErrorStationLivestream(station, channel, _error) {
|
|
1469
|
+
this.getStationDevice(station.getSerial(), channel).then((device) => {
|
|
1470
|
+
station.stopLivestream(device).catch((error) => {
|
|
1471
|
+
this.log.error(`Station livestream error (station: ${station.getSerial()} channel: ${channel} error: ${_error}})`, error);
|
|
1472
|
+
});
|
|
1473
|
+
}).catch((error) => {
|
|
1474
|
+
this.log.error(`Station livestream error (station: ${station.getSerial()} channel: ${channel} error: ${_error}})`, error);
|
|
1475
|
+
});
|
|
1476
|
+
}
|
|
1477
|
+
onStartStationRTSPLivestream(station, channel) {
|
|
1478
|
+
this.getStationDevice(station.getSerial(), channel).then((device) => {
|
|
1479
|
+
this.emit("station rtsp livestream start", station, device);
|
|
1480
|
+
}).catch((error) => {
|
|
1481
|
+
this.log.error(`Station start rtsp livestream error (station: ${station.getSerial()} channel: ${channel})`, error);
|
|
1482
|
+
});
|
|
1483
|
+
}
|
|
1484
|
+
onStopStationRTSPLivestream(station, channel) {
|
|
1485
|
+
this.getStationDevice(station.getSerial(), channel).then((device) => {
|
|
1486
|
+
this.emit("station rtsp livestream stop", station, device);
|
|
1487
|
+
}).catch((error) => {
|
|
1488
|
+
this.log.error(`Station stop rtsp livestream error (station: ${station.getSerial()} channel: ${channel})`, error);
|
|
1489
|
+
});
|
|
1490
|
+
}
|
|
1491
|
+
onStationStartDownload(station, channel, metadata, videoStream, audioStream) {
|
|
1492
|
+
this.getStationDevice(station.getSerial(), channel).then((device) => {
|
|
1493
|
+
this.emit("station download start", station, device, metadata, videoStream, audioStream);
|
|
1494
|
+
}).catch((error) => {
|
|
1495
|
+
this.log.error(`Station start download error (station: ${station.getSerial()} channel: ${channel})`, error);
|
|
1496
|
+
});
|
|
1497
|
+
}
|
|
1498
|
+
onStationFinishDownload(station, channel) {
|
|
1499
|
+
this.getStationDevice(station.getSerial(), channel).then((device) => {
|
|
1500
|
+
this.emit("station download finish", station, device);
|
|
1501
|
+
}).catch((error) => {
|
|
1502
|
+
this.log.error(`Station finish download error (station: ${station.getSerial()} channel: ${channel})`, error);
|
|
1503
|
+
});
|
|
1504
|
+
}
|
|
1505
|
+
onStationCommandResult(station, result) {
|
|
1506
|
+
this.emit("station command result", station, result);
|
|
1507
|
+
if (result.return_code === 0) {
|
|
1508
|
+
this.getStationDevice(station.getSerial(), result.channel).then((device) => {
|
|
1509
|
+
if ((result.customData !== undefined && result.customData.property !== undefined && !device.isLockWifiR10() && !device.isLockWifiR20() && !device.isLockWifiVideo() && !device.isSmartSafe()) ||
|
|
1510
|
+
(result.customData !== undefined && result.customData.property !== undefined && device.isSmartSafe() && result.command_type !== types_2.CommandType.CMD_SMARTSAFE_SETTINGS)) {
|
|
1511
|
+
if (device.hasProperty(result.customData.property.name)) {
|
|
1512
|
+
device.updateProperty(result.customData.property.name, result.customData.property.value);
|
|
1513
|
+
}
|
|
1514
|
+
else if (station.hasProperty(result.customData.property.name)) {
|
|
1515
|
+
station.updateProperty(result.customData.property.name, result.customData.property.value);
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
else if (result.customData !== undefined && result.customData.command !== undefined && result.customData.command.name === types_1.CommandName.DeviceSnooze) {
|
|
1519
|
+
const snoozeTime = result.customData.command.value !== undefined && result.customData.command.value.snooze_time !== undefined ? result.customData.command.value.snooze_time : 0;
|
|
1520
|
+
if (snoozeTime > 0) {
|
|
1521
|
+
device.updateProperty(types_1.PropertyName.DeviceSnooze, true);
|
|
1522
|
+
device.updateProperty(types_1.PropertyName.DeviceSnoozeTime, snoozeTime);
|
|
1523
|
+
}
|
|
1524
|
+
this.api.refreshAllData().then(() => {
|
|
1525
|
+
const snoozeStartTime = device.getPropertyValue(types_1.PropertyName.DeviceSnoozeStartTime);
|
|
1526
|
+
const currentTime = Math.trunc(new Date().getTime() / 1000);
|
|
1527
|
+
let timeoutMS;
|
|
1528
|
+
if (snoozeStartTime !== undefined && snoozeStartTime !== 0) {
|
|
1529
|
+
timeoutMS = (snoozeStartTime + snoozeTime - currentTime) * 1000;
|
|
1530
|
+
}
|
|
1531
|
+
else {
|
|
1532
|
+
timeoutMS = snoozeTime * 1000;
|
|
1533
|
+
}
|
|
1534
|
+
this.deviceSnoozeTimeout[device.getSerial()] = setTimeout(() => {
|
|
1535
|
+
device.updateProperty(types_1.PropertyName.DeviceSnooze, false);
|
|
1536
|
+
device.updateProperty(types_1.PropertyName.DeviceSnoozeTime, 0);
|
|
1537
|
+
device.updateProperty(types_1.PropertyName.DeviceSnoozeStartTime, 0);
|
|
1538
|
+
if (device.hasProperty(types_1.PropertyName.DeviceSnoozeHomebase)) {
|
|
1539
|
+
device.updateProperty(types_1.PropertyName.DeviceSnoozeHomebase, false);
|
|
1540
|
+
}
|
|
1541
|
+
if (device.hasProperty(types_1.PropertyName.DeviceSnoozeMotion)) {
|
|
1542
|
+
device.updateProperty(types_1.PropertyName.DeviceSnoozeMotion, false);
|
|
1543
|
+
}
|
|
1544
|
+
if (device.hasProperty(types_1.PropertyName.DeviceSnoozeChime)) {
|
|
1545
|
+
device.updateProperty(types_1.PropertyName.DeviceSnoozeChime, false);
|
|
1546
|
+
}
|
|
1547
|
+
delete this.deviceSnoozeTimeout[device.getSerial()];
|
|
1548
|
+
}, timeoutMS);
|
|
1549
|
+
}).catch(error => {
|
|
1550
|
+
this.log.error("Error during API data refreshing", error);
|
|
1551
|
+
});
|
|
1552
|
+
}
|
|
1553
|
+
}).catch((error) => {
|
|
1554
|
+
if (error instanceof error_1.DeviceNotFoundError) {
|
|
1555
|
+
if (result.customData !== undefined && result.customData.property !== undefined) {
|
|
1556
|
+
station.updateProperty(result.customData.property.name, result.customData.property.value);
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
else {
|
|
1560
|
+
this.log.error(`Station command result error (station: ${station.getSerial()})`, error);
|
|
1561
|
+
}
|
|
1562
|
+
});
|
|
1563
|
+
if (station.isIntegratedDevice() && result.command_type === types_2.CommandType.CMD_SET_ARMING && station.isConnected() && station.getDeviceType() !== types_1.DeviceType.DOORBELL) {
|
|
1564
|
+
station.getCameraInfo();
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
if (result.customData !== undefined && result.customData.command !== undefined) {
|
|
1568
|
+
const customValue = result.customData.command.value;
|
|
1569
|
+
switch (result.customData.command.name) {
|
|
1570
|
+
case types_1.CommandName.DeviceAddUser:
|
|
1571
|
+
this.getStationDevice(station.getSerial(), result.channel).then((device) => {
|
|
1572
|
+
switch (result.return_code) {
|
|
1573
|
+
case 0:
|
|
1574
|
+
this.emit("user added", device, customValue.username, customValue.schedule);
|
|
1575
|
+
break;
|
|
1576
|
+
case 4:
|
|
1577
|
+
this.emit("user error", device, customValue.username, new error_1.AddUserError("Passcode already used by another user, please choose a different one"));
|
|
1578
|
+
break;
|
|
1579
|
+
default:
|
|
1580
|
+
this.emit("user error", device, customValue.username, new error_1.AddUserError(`Error creating user with return code ${result.return_code}`));
|
|
1581
|
+
break;
|
|
1582
|
+
}
|
|
1583
|
+
});
|
|
1584
|
+
break;
|
|
1585
|
+
case types_1.CommandName.DeviceDeleteUser:
|
|
1586
|
+
this.getStationDevice(station.getSerial(), result.channel).then((device) => {
|
|
1587
|
+
switch (result.return_code) {
|
|
1588
|
+
case 0:
|
|
1589
|
+
this.api.deleteUser(device.getSerial(), customValue.short_user_id, device.getStationSerial()).then((result) => {
|
|
1590
|
+
if (result) {
|
|
1591
|
+
this.emit("user deleted", device, customValue.username);
|
|
1592
|
+
}
|
|
1593
|
+
else {
|
|
1594
|
+
this.emit("user error", device, customValue.username, new error_1.DeleteUserError(`Error in deleting user "${customValue.username}" with id "${customValue.short_user_id}" through cloud api call`));
|
|
1595
|
+
}
|
|
1596
|
+
});
|
|
1597
|
+
break;
|
|
1598
|
+
default:
|
|
1599
|
+
this.emit("user error", device, customValue.username, new Error(`Error deleting user with return code ${result.return_code}`));
|
|
1600
|
+
break;
|
|
1601
|
+
}
|
|
1602
|
+
});
|
|
1603
|
+
break;
|
|
1604
|
+
case types_1.CommandName.DeviceUpdateUserPasscode:
|
|
1605
|
+
this.getStationDevice(station.getSerial(), result.channel).then((device) => {
|
|
1606
|
+
switch (result.return_code) {
|
|
1607
|
+
case 0:
|
|
1608
|
+
this.emit("user passcode updated", device, customValue.username);
|
|
1609
|
+
break;
|
|
1610
|
+
default:
|
|
1611
|
+
this.emit("user error", device, customValue.username, new error_1.UpdateUserPasscodeError(`Error updating user passcode with return code ${result.return_code}`));
|
|
1612
|
+
break;
|
|
1613
|
+
}
|
|
1614
|
+
});
|
|
1615
|
+
break;
|
|
1616
|
+
case types_1.CommandName.DeviceUpdateUserSchedule:
|
|
1617
|
+
this.getStationDevice(station.getSerial(), result.channel).then((device) => {
|
|
1618
|
+
switch (result.return_code) {
|
|
1619
|
+
case 0:
|
|
1620
|
+
this.emit("user schedule updated", device, customValue.username, customValue.schedule);
|
|
1621
|
+
break;
|
|
1622
|
+
default:
|
|
1623
|
+
this.emit("user error", device, customValue.username, new error_1.UpdateUserScheduleError(`Error updating user schedule with return code ${result.return_code}`));
|
|
1624
|
+
break;
|
|
1625
|
+
}
|
|
1626
|
+
});
|
|
1627
|
+
break;
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
onStationSecondaryCommandResult(station, result) {
|
|
1632
|
+
if (result.return_code === 0) {
|
|
1633
|
+
this.getStationDevice(station.getSerial(), result.channel).then((device) => {
|
|
1634
|
+
if (result.customData !== undefined && result.customData.property !== undefined) {
|
|
1635
|
+
if (device.hasProperty(result.customData.property.name))
|
|
1636
|
+
device.updateProperty(result.customData.property.name, result.customData.property.value);
|
|
1637
|
+
else if (station.hasProperty(result.customData.property.name)) {
|
|
1638
|
+
station.updateProperty(result.customData.property.name, result.customData.property.value);
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
}).catch((error) => {
|
|
1642
|
+
if (error instanceof error_1.DeviceNotFoundError) {
|
|
1643
|
+
if (result.customData !== undefined && result.customData.property !== undefined) {
|
|
1644
|
+
station.updateProperty(result.customData.property.name, result.customData.property.value);
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
else {
|
|
1648
|
+
this.log.error(`Station secondary command result error (station: ${station.getSerial()})`, error);
|
|
1649
|
+
}
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
onStationRtspUrl(station, channel, value) {
|
|
1654
|
+
this.getStationDevice(station.getSerial(), channel).then((device) => {
|
|
1655
|
+
this.emit("station rtsp url", station, device, value);
|
|
1656
|
+
device.setCustomPropertyValue(types_1.PropertyName.DeviceRTSPStreamUrl, value);
|
|
1657
|
+
}).catch((error) => {
|
|
1658
|
+
this.log.error(`Station rtsp url error (station: ${station.getSerial()} channel: ${channel})`, error);
|
|
1659
|
+
});
|
|
1660
|
+
}
|
|
1661
|
+
onStationGuardMode(station, guardMode) {
|
|
1662
|
+
this.emit("station guard mode", station, guardMode);
|
|
1663
|
+
}
|
|
1664
|
+
onStationCurrentMode(station, currentMode) {
|
|
1665
|
+
this.emit("station current mode", station, currentMode);
|
|
1666
|
+
}
|
|
1667
|
+
onStationPropertyChanged(station, name, value) {
|
|
1668
|
+
this.emit("station property changed", station, name, value);
|
|
1669
|
+
}
|
|
1670
|
+
onStationRawPropertyChanged(station, type, value) {
|
|
1671
|
+
this.emit("station raw property changed", station, type, value);
|
|
1672
|
+
}
|
|
1673
|
+
onStationAlarmEvent(station, alarmEvent) {
|
|
1674
|
+
this.emit("station alarm event", station, alarmEvent);
|
|
1675
|
+
}
|
|
1676
|
+
onStationAlarmDelayEvent(station, alarmDelayEvent, alarmDelay) {
|
|
1677
|
+
this.emit("station alarm delay event", station, alarmDelayEvent, alarmDelay);
|
|
1678
|
+
}
|
|
1679
|
+
onStationArmDelayEvent(station, armDelay) {
|
|
1680
|
+
this.emit("station alarm arm delay event", station, armDelay);
|
|
1681
|
+
}
|
|
1682
|
+
onStationAlarmArmedEvent(station) {
|
|
1683
|
+
this.emit("station alarm armed", station);
|
|
1684
|
+
}
|
|
1685
|
+
onDevicePropertyChanged(device, name, value) {
|
|
1686
|
+
try {
|
|
1687
|
+
this.emit("device property changed", device, name, value);
|
|
1688
|
+
if (name === types_1.PropertyName.DeviceRTSPStream && value === true && (device.getPropertyValue(types_1.PropertyName.DeviceRTSPStreamUrl) === undefined || (device.getPropertyValue(types_1.PropertyName.DeviceRTSPStreamUrl) !== undefined && device.getPropertyValue(types_1.PropertyName.DeviceRTSPStreamUrl) === ""))) {
|
|
1689
|
+
this.getStation(device.getStationSerial()).then((station) => {
|
|
1690
|
+
station.setRTSPStream(device, true);
|
|
1691
|
+
}).catch((error) => {
|
|
1692
|
+
this.log.error(`Device property changed error (device: ${device.getSerial()} name: ${name}) - station enable rtsp (station: ${device.getStationSerial()})`, error);
|
|
1693
|
+
});
|
|
1694
|
+
}
|
|
1695
|
+
else if (name === types_1.PropertyName.DeviceRTSPStream && value === false) {
|
|
1696
|
+
device.setCustomPropertyValue(types_1.PropertyName.DeviceRTSPStreamUrl, "");
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
catch (error) {
|
|
1700
|
+
this.log.error(`Device property changed error (device: ${device.getSerial()} name: ${name})`, error);
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
onDeviceRawPropertyChanged(device, type, value) {
|
|
1704
|
+
this.emit("device raw property changed", device, type, value);
|
|
1705
|
+
}
|
|
1706
|
+
onDeviceCryingDetected(device, state) {
|
|
1707
|
+
this.emit("device crying detected", device, state);
|
|
1708
|
+
}
|
|
1709
|
+
onDeviceSoundDetected(device, state) {
|
|
1710
|
+
this.emit("device sound detected", device, state);
|
|
1711
|
+
}
|
|
1712
|
+
onDevicePetDetected(device, state) {
|
|
1713
|
+
this.emit("device pet detected", device, state);
|
|
1714
|
+
}
|
|
1715
|
+
onDeviceVehicleDetected(device, state) {
|
|
1716
|
+
this.emit("device vehicle detected", device, state);
|
|
1717
|
+
}
|
|
1718
|
+
onDeviceMotionDetected(device, state) {
|
|
1719
|
+
this.emit("device motion detected", device, state);
|
|
1720
|
+
}
|
|
1721
|
+
onDevicePersonDetected(device, state, person) {
|
|
1722
|
+
this.emit("device person detected", device, state, person);
|
|
1723
|
+
}
|
|
1724
|
+
onDeviceRings(device, state) {
|
|
1725
|
+
this.emit("device rings", device, state);
|
|
1726
|
+
}
|
|
1727
|
+
onDeviceLocked(device, state) {
|
|
1728
|
+
this.emit("device locked", device, state);
|
|
1729
|
+
}
|
|
1730
|
+
onDeviceOpen(device, state) {
|
|
1731
|
+
this.emit("device open", device, state);
|
|
1732
|
+
}
|
|
1733
|
+
onDevicePackageDelivered(device, state) {
|
|
1734
|
+
this.emit("device package delivered", device, state);
|
|
1735
|
+
}
|
|
1736
|
+
onDevicePackageStranded(device, state) {
|
|
1737
|
+
this.emit("device package stranded", device, state);
|
|
1738
|
+
}
|
|
1739
|
+
onDevicePackageTaken(device, state) {
|
|
1740
|
+
this.emit("device package taken", device, state);
|
|
1741
|
+
}
|
|
1742
|
+
onDeviceSomeoneLoitering(device, state) {
|
|
1743
|
+
this.emit("device someone loitering", device, state);
|
|
1744
|
+
}
|
|
1745
|
+
onDeviceRadarMotionDetected(device, state) {
|
|
1746
|
+
this.emit("device radar motion detected", device, state);
|
|
1747
|
+
}
|
|
1748
|
+
onDevice911Alarm(device, state, detail) {
|
|
1749
|
+
this.emit("device 911 alarm", device, state, detail);
|
|
1750
|
+
}
|
|
1751
|
+
onDeviceShakeAlarm(device, state, detail) {
|
|
1752
|
+
this.emit("device shake alarm", device, state, detail);
|
|
1753
|
+
}
|
|
1754
|
+
onDeviceWrongTryProtectAlarm(device, state) {
|
|
1755
|
+
this.emit("device wrong try-protect alarm", device, state);
|
|
1756
|
+
}
|
|
1757
|
+
onDeviceLongTimeNotClose(device, state) {
|
|
1758
|
+
this.emit("device long time not close", device, state);
|
|
1759
|
+
}
|
|
1760
|
+
onDeviceLowBattery(device, state) {
|
|
1761
|
+
this.emit("device low battery", device, state);
|
|
1762
|
+
}
|
|
1763
|
+
onDeviceJammed(device, state) {
|
|
1764
|
+
this.emit("device jammed", device, state);
|
|
1765
|
+
}
|
|
1766
|
+
onDeviceStrangerPersonDetected(device, state) {
|
|
1767
|
+
this.emit("device stranger person detected", device, state);
|
|
1768
|
+
}
|
|
1769
|
+
onDeviceDogDetected(device, state) {
|
|
1770
|
+
this.emit("device dog detected", device, state);
|
|
1771
|
+
}
|
|
1772
|
+
onDeviceDogLickDetected(device, state) {
|
|
1773
|
+
this.emit("device dog lick detected", device, state);
|
|
1774
|
+
}
|
|
1775
|
+
onDeviceDogPoopDetected(device, state) {
|
|
1776
|
+
this.emit("device dog poop detected", device, state);
|
|
1777
|
+
}
|
|
1778
|
+
onDeviceReady(device) {
|
|
1779
|
+
try {
|
|
1780
|
+
if (device.getPropertyValue(types_1.PropertyName.DeviceRTSPStream) !== undefined && device.getPropertyValue(types_1.PropertyName.DeviceRTSPStream) === true) {
|
|
1781
|
+
this.getStation(device.getStationSerial()).then((station) => {
|
|
1782
|
+
station.setRTSPStream(device, true);
|
|
1783
|
+
}).catch((error) => {
|
|
1784
|
+
this.log.error(`Device ready error (device: ${device.getSerial()}) - station enable rtsp (station: ${device.getStationSerial()})`, error);
|
|
1785
|
+
});
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
catch (error) {
|
|
1789
|
+
this.log.error(`Device ready error (device: ${device.getSerial()})`, error);
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
onStationRuntimeState(station, channel, batteryLevel, temperature) {
|
|
1793
|
+
this.getStationDevice(station.getSerial(), channel).then((device) => {
|
|
1794
|
+
if (device.hasProperty(types_1.PropertyName.DeviceBattery)) {
|
|
1795
|
+
const metadataBattery = device.getPropertyMetadata(types_1.PropertyName.DeviceBattery);
|
|
1796
|
+
device.updateRawProperty(metadataBattery.key, batteryLevel.toString());
|
|
1797
|
+
}
|
|
1798
|
+
if (device.hasProperty(types_1.PropertyName.DeviceBatteryTemp)) {
|
|
1799
|
+
const metadataBatteryTemperature = device.getPropertyMetadata(types_1.PropertyName.DeviceBatteryTemp);
|
|
1800
|
+
device.updateRawProperty(metadataBatteryTemperature.key, temperature.toString());
|
|
1801
|
+
}
|
|
1802
|
+
}).catch((error) => {
|
|
1803
|
+
this.log.error(`Station runtime state error (station: ${station.getSerial()} channel: ${channel})`, error);
|
|
1804
|
+
});
|
|
1805
|
+
}
|
|
1806
|
+
onStationChargingState(station, channel, chargeType, batteryLevel) {
|
|
1807
|
+
this.getStationDevice(station.getSerial(), channel).then((device) => {
|
|
1808
|
+
if (device.hasProperty(types_1.PropertyName.DeviceBattery)) {
|
|
1809
|
+
const metadataBattery = device.getPropertyMetadata(types_1.PropertyName.DeviceBattery);
|
|
1810
|
+
if (chargeType !== types_2.ChargingType.PLUGGED && batteryLevel > 0)
|
|
1811
|
+
device.updateRawProperty(metadataBattery.key, batteryLevel.toString());
|
|
1812
|
+
}
|
|
1813
|
+
if (device.hasProperty(types_1.PropertyName.DeviceChargingStatus)) {
|
|
1814
|
+
const metadataChargingStatus = device.getPropertyMetadata(types_1.PropertyName.DeviceChargingStatus);
|
|
1815
|
+
device.updateRawProperty(metadataChargingStatus.key, chargeType.toString());
|
|
1816
|
+
}
|
|
1817
|
+
}).catch((error) => {
|
|
1818
|
+
this.log.error(`Station charging state error (station: ${station.getSerial()} channel: ${channel})`, error);
|
|
1819
|
+
});
|
|
1820
|
+
}
|
|
1821
|
+
onStationWifiRssi(station, channel, rssi) {
|
|
1822
|
+
this.getStationDevice(station.getSerial(), channel).then((device) => {
|
|
1823
|
+
if (device.hasProperty(types_1.PropertyName.DeviceWifiRSSI)) {
|
|
1824
|
+
const metadataWifiRssi = device.getPropertyMetadata(types_1.PropertyName.DeviceWifiRSSI);
|
|
1825
|
+
device.updateRawProperty(metadataWifiRssi.key, rssi.toString());
|
|
1826
|
+
}
|
|
1827
|
+
}).catch((error) => {
|
|
1828
|
+
this.log.error(`Station wifi rssi error (station: ${station.getSerial()} channel: ${channel})`, error);
|
|
1829
|
+
});
|
|
1830
|
+
}
|
|
1831
|
+
onCaptchaRequest(id, captcha) {
|
|
1832
|
+
this.emit("captcha request", id, captcha);
|
|
1833
|
+
}
|
|
1834
|
+
onFloodlightManualSwitch(station, channel, enabled) {
|
|
1835
|
+
this.getStationDevice(station.getSerial(), channel).then((device) => {
|
|
1836
|
+
if (device.hasProperty(types_1.PropertyName.DeviceLight)) {
|
|
1837
|
+
const metadataLight = device.getPropertyMetadata(types_1.PropertyName.DeviceLight);
|
|
1838
|
+
device.updateRawProperty(metadataLight.key, enabled === true ? "1" : "0");
|
|
1839
|
+
}
|
|
1840
|
+
}).catch((error) => {
|
|
1841
|
+
this.log.error(`Station floodlight manual switch error (station: ${station.getSerial()} channel: ${channel})`, error);
|
|
1842
|
+
});
|
|
1843
|
+
}
|
|
1844
|
+
onAuthTokenInvalidated() {
|
|
1845
|
+
this.persistentData.cloud_token = undefined;
|
|
1846
|
+
this.persistentData.cloud_token_expiration = undefined;
|
|
1847
|
+
this.writePersistentData();
|
|
1848
|
+
}
|
|
1849
|
+
onTfaRequest() {
|
|
1850
|
+
this.emit("tfa request");
|
|
1851
|
+
}
|
|
1852
|
+
onStationTalkbackStart(station, channel, talkbackStream) {
|
|
1853
|
+
this.getStationDevice(station.getSerial(), channel).then((device) => {
|
|
1854
|
+
this.emit("station talkback start", station, device, talkbackStream);
|
|
1855
|
+
}).catch((error) => {
|
|
1856
|
+
this.log.error(`Station talkback start error (station: ${station.getSerial()} channel: ${channel})`, error);
|
|
1857
|
+
});
|
|
1858
|
+
}
|
|
1859
|
+
onStationTalkbackStop(station, channel) {
|
|
1860
|
+
this.getStationDevice(station.getSerial(), channel).then((device) => {
|
|
1861
|
+
this.emit("station talkback stop", station, device);
|
|
1862
|
+
}).catch((error) => {
|
|
1863
|
+
this.log.error(`Station talkback stop error (station: ${station.getSerial()} channel: ${channel})`, error);
|
|
1864
|
+
});
|
|
1865
|
+
}
|
|
1866
|
+
onStationTalkbackError(station, channel, _error) {
|
|
1867
|
+
this.getStationDevice(station.getSerial(), channel).then((device) => {
|
|
1868
|
+
station.stopTalkback(device);
|
|
1869
|
+
}).catch((error) => {
|
|
1870
|
+
this.log.error(`Station talkback error (station: ${station.getSerial()} channel: ${channel} error: ${_error}})`, error);
|
|
1871
|
+
});
|
|
1872
|
+
}
|
|
1873
|
+
async startStationTalkback(deviceSN) {
|
|
1874
|
+
const device = await this.getDevice(deviceSN);
|
|
1875
|
+
const station = await this.getStation(device.getStationSerial());
|
|
1876
|
+
if (!device.hasCommand(types_1.CommandName.DeviceStartTalkback))
|
|
1877
|
+
throw new error_1.NotSupportedError(`This functionality is not implemented or supported by ${device.getSerial()}`);
|
|
1878
|
+
if (station.isLiveStreaming(device)) {
|
|
1879
|
+
if (!station.isTalkbackOngoing(device)) {
|
|
1880
|
+
station.startTalkback(device);
|
|
1881
|
+
}
|
|
1882
|
+
else {
|
|
1883
|
+
this.log.warn(`The station talkback for the device ${deviceSN} cannot be started, because it is ongoing!`);
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
else {
|
|
1887
|
+
this.log.warn(`The station talkback for the device ${deviceSN} cannot be started, because it isn't live streaming!`);
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
async stopStationTalkback(deviceSN) {
|
|
1891
|
+
const device = await this.getDevice(deviceSN);
|
|
1892
|
+
const station = await this.getStation(device.getStationSerial());
|
|
1893
|
+
if (!device.hasCommand(types_1.CommandName.DeviceStopTalkback))
|
|
1894
|
+
throw new error_1.NotSupportedError(`This functionality is not implemented or supported by ${device.getSerial()}`);
|
|
1895
|
+
if (station.isLiveStreaming(device)) {
|
|
1896
|
+
if (station.isTalkbackOngoing(device)) {
|
|
1897
|
+
station.stopTalkback(device);
|
|
1898
|
+
}
|
|
1899
|
+
else {
|
|
1900
|
+
this.log.warn(`The station talkback for the device ${deviceSN} cannot be stopped, because it isn't ongoing!`);
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
else {
|
|
1904
|
+
this.log.warn(`The station talkback for the device ${deviceSN} cannot be stopped, because it isn't live streaming!`);
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
onStationDeviceShakeAlarm(deviceSN, event) {
|
|
1908
|
+
this.getDevice(deviceSN).then((device) => {
|
|
1909
|
+
if (device.isSmartSafe())
|
|
1910
|
+
device.shakeEvent(event, this.config.eventDurationSeconds);
|
|
1911
|
+
}).catch((error) => {
|
|
1912
|
+
this.log.error(`onStationShakeAlarm device ${deviceSN} error`, error);
|
|
1913
|
+
});
|
|
1914
|
+
}
|
|
1915
|
+
onStationDevice911Alarm(deviceSN, event) {
|
|
1916
|
+
this.getDevice(deviceSN).then((device) => {
|
|
1917
|
+
if (device.isSmartSafe())
|
|
1918
|
+
device.alarm911Event(event, this.config.eventDurationSeconds);
|
|
1919
|
+
}).catch((error) => {
|
|
1920
|
+
this.log.error(`onStation911Alarm device ${deviceSN} error`, error);
|
|
1921
|
+
});
|
|
1922
|
+
}
|
|
1923
|
+
onStationDeviceJammed(deviceSN) {
|
|
1924
|
+
this.getDevice(deviceSN).then((device) => {
|
|
1925
|
+
if (device.isSmartSafe())
|
|
1926
|
+
device.jammedEvent(this.config.eventDurationSeconds);
|
|
1927
|
+
}).catch((error) => {
|
|
1928
|
+
this.log.error(`onStationDeviceJammed device ${deviceSN} error`, error);
|
|
1929
|
+
});
|
|
1930
|
+
}
|
|
1931
|
+
onStationDeviceLowBattery(deviceSN) {
|
|
1932
|
+
this.getDevice(deviceSN).then((device) => {
|
|
1933
|
+
if (device.isSmartSafe())
|
|
1934
|
+
device.lowBatteryEvent(this.config.eventDurationSeconds);
|
|
1935
|
+
}).catch((error) => {
|
|
1936
|
+
this.log.error(`onStationDeviceLowBattery device ${deviceSN} error`, error);
|
|
1937
|
+
});
|
|
1938
|
+
}
|
|
1939
|
+
onStationDeviceWrongTryProtectAlarm(deviceSN) {
|
|
1940
|
+
this.getDevice(deviceSN).then((device) => {
|
|
1941
|
+
if (device.isSmartSafe())
|
|
1942
|
+
device.wrongTryProtectAlarmEvent(this.config.eventDurationSeconds);
|
|
1943
|
+
}).catch((error) => {
|
|
1944
|
+
this.log.error(`onStationDeviceWrongTryProtectAlarm device ${deviceSN} error`, error);
|
|
1945
|
+
});
|
|
1946
|
+
}
|
|
1947
|
+
async addUser(deviceSN, username, passcode, schedule) {
|
|
1948
|
+
const device = await this.getDevice(deviceSN);
|
|
1949
|
+
const station = await this.getStation(device.getStationSerial());
|
|
1950
|
+
try {
|
|
1951
|
+
if (!device.hasCommand(types_1.CommandName.DeviceAddUser))
|
|
1952
|
+
throw new error_1.NotSupportedError(`This functionality is not implemented or supported by ${device.getSerial()}`);
|
|
1953
|
+
const addUserResponse = await this.api.addUser(deviceSN, username, device.getStationSerial());
|
|
1954
|
+
if (addUserResponse !== null) {
|
|
1955
|
+
await station.addUser(device, username, addUserResponse.short_user_id, passcode, schedule);
|
|
1956
|
+
}
|
|
1957
|
+
else {
|
|
1958
|
+
this.emit("user error", device, username, new error_1.AddUserError("Error on creating user through cloud api call"));
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
catch (error) {
|
|
1962
|
+
this.log.error(`addUser device ${deviceSN} error`, error);
|
|
1963
|
+
this.emit("user error", device, username, new error_1.AddUserError(`Got exception: ${error}`));
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
async deleteUser(deviceSN, username) {
|
|
1967
|
+
const device = await this.getDevice(deviceSN);
|
|
1968
|
+
const station = await this.getStation(device.getStationSerial());
|
|
1969
|
+
if (!device.hasCommand(types_1.CommandName.DeviceDeleteUser))
|
|
1970
|
+
throw new error_1.NotSupportedError(`This functionality is not implemented or supported by ${device.getSerial()}`);
|
|
1971
|
+
try {
|
|
1972
|
+
const users = await this.api.getUsers(deviceSN, device.getStationSerial());
|
|
1973
|
+
if (users !== null) {
|
|
1974
|
+
let found = false;
|
|
1975
|
+
for (const user of users) {
|
|
1976
|
+
if (user.user_name === username) {
|
|
1977
|
+
await station.deleteUser(device, user.user_name, user.short_user_id);
|
|
1978
|
+
found = true;
|
|
1979
|
+
break;
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
if (!found) {
|
|
1983
|
+
this.emit("user error", device, username, new error_1.DeleteUserError(`User with username "${username}" not found`));
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
else {
|
|
1987
|
+
this.emit("user error", device, username, new error_1.DeleteUserError("Error on getting user list through cloud api call"));
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
catch (error) {
|
|
1991
|
+
this.log.error(`deleteUser device ${deviceSN} error`, error);
|
|
1992
|
+
this.emit("user error", device, username, new error_1.DeleteUserError(`Got exception: ${error}`));
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
async updateUser(deviceSN, username, newUsername) {
|
|
1996
|
+
const device = await this.getDevice(deviceSN);
|
|
1997
|
+
if (!device.hasCommand(types_1.CommandName.DeviceUpdateUsername))
|
|
1998
|
+
throw new error_1.NotSupportedError(`This functionality is not implemented or supported by ${device.getSerial()}`);
|
|
1999
|
+
try {
|
|
2000
|
+
const users = await this.api.getUsers(deviceSN, device.getStationSerial());
|
|
2001
|
+
if (users !== null) {
|
|
2002
|
+
let found = false;
|
|
2003
|
+
for (const user of users) {
|
|
2004
|
+
if (user.user_name === username) {
|
|
2005
|
+
const result = await this.api.updateUser(deviceSN, device.getStationSerial(), user.short_user_id, newUsername);
|
|
2006
|
+
if (result) {
|
|
2007
|
+
this.emit("user username updated", device, username);
|
|
2008
|
+
}
|
|
2009
|
+
else {
|
|
2010
|
+
this.emit("user error", device, username, new error_1.UpdateUserUsernameError(`Error in changing username "${username}" to "${newUsername}" through cloud api call`));
|
|
2011
|
+
}
|
|
2012
|
+
found = true;
|
|
2013
|
+
break;
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
if (!found) {
|
|
2017
|
+
this.emit("user error", device, username, new error_1.UpdateUserUsernameError(`Error in changing username "${username}" to "${newUsername}" through cloud api call`));
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
else {
|
|
2021
|
+
this.emit("user error", device, username, new error_1.UpdateUserUsernameError("Error on getting user list through cloud api call"));
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
catch (error) {
|
|
2025
|
+
this.log.error(`updateUser device ${deviceSN} error`, error);
|
|
2026
|
+
this.emit("user error", device, username, new error_1.UpdateUserUsernameError(`Got exception: ${error}`));
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
async updateUserPasscode(deviceSN, username, passcode) {
|
|
2030
|
+
const device = await this.getDevice(deviceSN);
|
|
2031
|
+
const station = await this.getStation(device.getStationSerial());
|
|
2032
|
+
if (!device.hasCommand(types_1.CommandName.DeviceUpdateUserPasscode))
|
|
2033
|
+
throw new error_1.NotSupportedError(`This functionality is not implemented or supported by ${device.getSerial()}`);
|
|
2034
|
+
try {
|
|
2035
|
+
const users = await this.api.getUsers(deviceSN, device.getStationSerial());
|
|
2036
|
+
if (users !== null) {
|
|
2037
|
+
let found = false;
|
|
2038
|
+
for (const user of users) {
|
|
2039
|
+
if (user.user_name === username) {
|
|
2040
|
+
await station.updateUserPasscode(device, user.user_name, user.short_user_id, passcode);
|
|
2041
|
+
found = true;
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
if (!found) {
|
|
2045
|
+
this.emit("user error", device, username, new error_1.UpdateUserPasscodeError(`User with username "${username}" not found`));
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
else {
|
|
2049
|
+
this.emit("user error", device, username, new error_1.UpdateUserPasscodeError("Error on getting user list through cloud api call"));
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
catch (error) {
|
|
2053
|
+
this.log.error(`updateUserPasscode device ${deviceSN} error`, error);
|
|
2054
|
+
this.emit("user error", device, username, new error_1.UpdateUserPasscodeError(`Got exception: ${error}`));
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
async updateUserSchedule(deviceSN, username, schedule) {
|
|
2058
|
+
const device = await this.getDevice(deviceSN);
|
|
2059
|
+
const station = await this.getStation(device.getStationSerial());
|
|
2060
|
+
if (!device.hasCommand(types_1.CommandName.DeviceUpdateUserPasscode))
|
|
2061
|
+
throw new error_1.NotSupportedError(`This functionality is not implemented or supported by ${device.getSerial()}`);
|
|
2062
|
+
try {
|
|
2063
|
+
const users = await this.api.getUsers(deviceSN, device.getStationSerial());
|
|
2064
|
+
if (users !== null) {
|
|
2065
|
+
let found = false;
|
|
2066
|
+
for (const user of users) {
|
|
2067
|
+
if (user.user_name === username) {
|
|
2068
|
+
await station.updateUserSchedule(device, user.user_name, user.short_user_id, schedule);
|
|
2069
|
+
found = true;
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
if (!found) {
|
|
2073
|
+
this.emit("user error", device, username, new error_1.UpdateUserScheduleError(`User with username "${username}" not found`));
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
else {
|
|
2077
|
+
this.emit("user error", device, username, new error_1.UpdateUserScheduleError("Error on getting user list through cloud api call"));
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
catch (error) {
|
|
2081
|
+
this.log.error(`updateUserSchedule device ${deviceSN} error`, error);
|
|
2082
|
+
this.emit("user error", device, username, new error_1.UpdateUserScheduleError(`Got exception: ${error}`));
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
onStationDevicePinVerified(deviceSN, successfull) {
|
|
2086
|
+
this.getDevice(deviceSN).then((device) => {
|
|
2087
|
+
this.emit("device pin verified", device, successfull);
|
|
2088
|
+
}).catch((error) => {
|
|
2089
|
+
this.log.error(`onStationDevicePinVerified device ${deviceSN} error`, error);
|
|
2090
|
+
});
|
|
2091
|
+
}
|
|
2092
|
+
onStationSdInfoEx(station, sdStatus, sdCapacity, sdCapacityAvailable) {
|
|
2093
|
+
if (station.hasProperty(types_1.PropertyName.StationSdStatus)) {
|
|
2094
|
+
station.updateProperty(types_1.PropertyName.StationSdStatus, sdStatus);
|
|
2095
|
+
}
|
|
2096
|
+
if (station.hasProperty(types_1.PropertyName.StationSdCapacity)) {
|
|
2097
|
+
station.updateProperty(types_1.PropertyName.StationSdCapacity, sdCapacity);
|
|
2098
|
+
}
|
|
2099
|
+
if (station.hasProperty(types_1.PropertyName.StationSdCapacityAvailable)) {
|
|
2100
|
+
station.updateProperty(types_1.PropertyName.StationSdCapacityAvailable, sdCapacityAvailable);
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
exports.EufySecurity = EufySecurity;
|
|
2092
2105
|
//# sourceMappingURL=eufysecurity.js.map
|