eufy-security-client 2.6.2 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +762 -745
- package/build/error.d.ts +126 -56
- package/build/error.js +80 -58
- package/build/error.js.map +1 -1
- package/build/eufysecurity.d.ts +4 -2
- package/build/eufysecurity.js +372 -184
- package/build/eufysecurity.js.map +1 -1
- package/build/http/api.js +164 -113
- package/build/http/api.js.map +1 -1
- package/build/http/cache.js +2 -2
- package/build/http/cache.js.map +1 -1
- package/build/http/device.d.ts +26 -1
- package/build/http/device.js +544 -167
- package/build/http/device.js.map +1 -1
- package/build/http/error.d.ts +64 -19
- package/build/http/error.js +53 -29
- package/build/http/error.js.map +1 -1
- package/build/http/interfaces.d.ts +3 -0
- package/build/http/models.d.ts +25 -0
- package/build/http/parameter.d.ts +1 -1
- package/build/http/parameter.js +19 -17
- package/build/http/parameter.js.map +1 -1
- package/build/http/station.d.ts +30 -6
- package/build/http/station.js +1599 -530
- package/build/http/station.js.map +1 -1
- package/build/http/types.d.ts +125 -2
- package/build/http/types.js +932 -53
- package/build/http/types.js.map +1 -1
- package/build/http/utils.js +11 -9
- package/build/http/utils.js.map +1 -1
- package/build/mqtt/service.js +19 -16
- package/build/mqtt/service.js.map +1 -1
- package/build/p2p/ble.js +14 -6
- package/build/p2p/ble.js.map +1 -1
- package/build/p2p/error.d.ts +48 -23
- package/build/p2p/error.js +25 -24
- package/build/p2p/error.js.map +1 -1
- package/build/p2p/interfaces.d.ts +23 -0
- package/build/p2p/models.d.ts +11 -1
- package/build/p2p/session.d.ts +5 -0
- package/build/p2p/session.js +210 -142
- package/build/p2p/session.js.map +1 -1
- package/build/p2p/talkback.js +1 -1
- package/build/p2p/talkback.js.map +1 -1
- package/build/p2p/types.d.ts +36 -1
- package/build/p2p/types.js +72 -31
- package/build/p2p/types.js.map +1 -1
- package/build/p2p/utils.d.ts +3 -1
- package/build/p2p/utils.js +13 -1
- package/build/p2p/utils.js.map +1 -1
- package/build/push/client.js +24 -15
- package/build/push/client.js.map +1 -1
- package/build/push/error.d.ts +73 -0
- package/build/push/error.js +101 -0
- package/build/push/error.js.map +1 -0
- package/build/push/index.d.ts +1 -0
- package/build/push/index.js +1 -0
- package/build/push/index.js.map +1 -1
- package/build/push/models.d.ts +17 -1
- package/build/push/models.js +9 -2
- package/build/push/models.js.map +1 -1
- package/build/push/parser.js +17 -13
- package/build/push/parser.js.map +1 -1
- package/build/push/service.js +160 -62
- package/build/push/service.js.map +1 -1
- package/build/push/types.d.ts +10 -0
- package/build/push/types.js +25 -14
- package/build/push/types.js.map +1 -1
- package/build/push/utils.js +2 -1
- package/build/push/utils.js.map +1 -1
- package/build/utils.d.ts +2 -1
- package/build/utils.js +56 -26
- package/build/utils.js.map +1 -1
- package/package.json +77 -77
package/build/http/device.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnknownDevice = exports.SmartSafe = exports.Keypad = exports.Lock = exports.MotionSensor = exports.EntrySensor = exports.Sensor = exports.FloodlightCamera = exports.BatteryDoorbellCamera = exports.WiredDoorbellCamera = exports.DoorbellCamera = exports.IndoorCamera = exports.SoloCamera = exports.Camera = exports.Device = void 0;
|
|
3
|
+
exports.UnknownDevice = exports.SmartSafe = exports.Keypad = exports.Lock = exports.MotionSensor = exports.EntrySensor = exports.Sensor = exports.GarageCamera = exports.WallLightCam = exports.FloodlightCamera = exports.BatteryDoorbellCamera = exports.WiredDoorbellCamera = exports.DoorbellCamera = exports.IndoorCamera = exports.SoloCamera = exports.Camera = exports.Device = void 0;
|
|
4
4
|
const tiny_typed_emitter_1 = require("tiny-typed-emitter");
|
|
5
5
|
const types_1 = require("./types");
|
|
6
6
|
const parameter_1 = require("./parameter");
|
|
@@ -10,13 +10,17 @@ const utils_2 = require("../p2p/utils");
|
|
|
10
10
|
const types_3 = require("../push/types");
|
|
11
11
|
const utils_3 = require("../utils");
|
|
12
12
|
const error_1 = require("./error");
|
|
13
|
+
const error_2 = require("../error");
|
|
13
14
|
class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
15
|
+
api;
|
|
16
|
+
rawDevice;
|
|
17
|
+
log;
|
|
18
|
+
eventTimeouts = new Map();
|
|
19
|
+
properties = {};
|
|
20
|
+
rawProperties = {};
|
|
21
|
+
ready = false;
|
|
14
22
|
constructor(api, device) {
|
|
15
23
|
super();
|
|
16
|
-
this.eventTimeouts = new Map();
|
|
17
|
-
this.properties = {};
|
|
18
|
-
this.rawProperties = {};
|
|
19
|
-
this.ready = false;
|
|
20
24
|
this.api = api;
|
|
21
25
|
this.rawDevice = device;
|
|
22
26
|
this.log = api.getLog();
|
|
@@ -52,16 +56,17 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
52
56
|
}
|
|
53
57
|
this.log.debug("Normalized Properties", { deviceSN: this.getSerial(), properties: this.properties });
|
|
54
58
|
}
|
|
55
|
-
updateProperty(name, value) {
|
|
59
|
+
updateProperty(name, value, force = false) {
|
|
56
60
|
if ((this.properties[name] !== undefined && this.properties[name] !== value)
|
|
57
|
-
|| this.properties[name] === undefined) {
|
|
61
|
+
|| this.properties[name] === undefined || force) {
|
|
58
62
|
const oldValue = this.properties[name];
|
|
59
63
|
this.properties[name] = value;
|
|
60
64
|
this.emit("property changed", this, name, value, this.ready);
|
|
61
65
|
try {
|
|
62
66
|
this.handlePropertyChange(this.getPropertyMetadata(name, true), oldValue, this.properties[name]);
|
|
63
67
|
}
|
|
64
|
-
catch (
|
|
68
|
+
catch (err) {
|
|
69
|
+
const error = (0, error_2.ensureError)(err);
|
|
65
70
|
if (error instanceof error_1.InvalidPropertyError) {
|
|
66
71
|
this.log.error(`Invalid Property ${name} error`, error);
|
|
67
72
|
}
|
|
@@ -113,14 +118,15 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
113
118
|
this.updateProperty(types_1.PropertyName.DeviceCellularSignalLevel, (0, utils_1.calculateCellularSignalLevel)(newValue));
|
|
114
119
|
}
|
|
115
120
|
}
|
|
116
|
-
catch (
|
|
121
|
+
catch (err) {
|
|
122
|
+
const error = (0, error_2.ensureError)(err);
|
|
117
123
|
this.log.error(`Device handlePropertyChange error`, error, { metadata: metadata, oldValue: oldValue, newValue: newValue });
|
|
118
124
|
}
|
|
119
125
|
}
|
|
120
126
|
updateRawProperty(type, value) {
|
|
121
127
|
const parsedValue = parameter_1.ParameterHelper.readValue(type, value, this.log);
|
|
122
|
-
if ((this.rawProperties[type] !== undefined && this.rawProperties[type] !== parsedValue)
|
|
123
|
-
|| this.rawProperties[type] === undefined) {
|
|
128
|
+
if (parsedValue !== undefined && ((this.rawProperties[type] !== undefined && this.rawProperties[type] !== parsedValue)
|
|
129
|
+
|| this.rawProperties[type] === undefined)) {
|
|
124
130
|
this.rawProperties[type] = parsedValue;
|
|
125
131
|
if (this.ready)
|
|
126
132
|
this.emit("raw property changed", this, type, this.rawProperties[type]);
|
|
@@ -130,7 +136,8 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
130
136
|
try {
|
|
131
137
|
this.updateProperty(property.name, this.convertRawPropertyValue(property, this.rawProperties[type]));
|
|
132
138
|
}
|
|
133
|
-
catch (
|
|
139
|
+
catch (err) {
|
|
140
|
+
const error = (0, error_2.ensureError)(err);
|
|
134
141
|
if (error instanceof error_1.PropertyNotSupportedError) {
|
|
135
142
|
this.log.debug("Property not supported error", error);
|
|
136
143
|
}
|
|
@@ -159,8 +166,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
159
166
|
try {
|
|
160
167
|
return value !== undefined ? (Number.parseInt(value.notification_ring_onoff) === 1 ? true : false) : booleanProperty.default !== undefined ? booleanProperty.default : false;
|
|
161
168
|
}
|
|
162
|
-
catch (
|
|
163
|
-
|
|
169
|
+
catch (err) {
|
|
170
|
+
const error = (0, error_2.ensureError)(err);
|
|
171
|
+
this.log.error("Convert CMD_BAT_DOORBELL_SET_NOTIFICATION_MODE DeviceNotificationRing Error", { property: property, value: value, error: error });
|
|
164
172
|
return booleanProperty.default !== undefined ? booleanProperty.default : false;
|
|
165
173
|
}
|
|
166
174
|
}
|
|
@@ -169,8 +177,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
169
177
|
try {
|
|
170
178
|
return value !== undefined ? (Number.parseInt(value.notification_motion_onoff) === 1 ? true : false) : booleanProperty.default !== undefined ? booleanProperty.default : false;
|
|
171
179
|
}
|
|
172
|
-
catch (
|
|
173
|
-
|
|
180
|
+
catch (err) {
|
|
181
|
+
const error = (0, error_2.ensureError)(err);
|
|
182
|
+
this.log.error("Convert CMD_BAT_DOORBELL_SET_NOTIFICATION_MODE DeviceNotificationMotion Error", { property: property, value: value, error: error });
|
|
174
183
|
return booleanProperty.default !== undefined ? booleanProperty.default : false;
|
|
175
184
|
}
|
|
176
185
|
}
|
|
@@ -179,8 +188,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
179
188
|
try {
|
|
180
189
|
return value !== undefined ? Number.parseInt(value.notification_style) : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
|
|
181
190
|
}
|
|
182
|
-
catch (
|
|
183
|
-
|
|
191
|
+
catch (err) {
|
|
192
|
+
const error = (0, error_2.ensureError)(err);
|
|
193
|
+
this.log.error("Convert CMD_BAT_DOORBELL_SET_NOTIFICATION_MODE DeviceNotificationType Error", { property: property, value: value, error: error });
|
|
184
194
|
return numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0);
|
|
185
195
|
}
|
|
186
196
|
}
|
|
@@ -195,8 +205,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
195
205
|
return value !== undefined ? (Number.parseInt(value) === 3 || Number.parseInt(value) === 2 ? true : false) : false;
|
|
196
206
|
}
|
|
197
207
|
}
|
|
198
|
-
catch (
|
|
199
|
-
|
|
208
|
+
catch (err) {
|
|
209
|
+
const error = (0, error_2.ensureError)(err);
|
|
210
|
+
this.log.error("Convert DOORBELL_NOTIFICATION_OPEN Error", { property: property, value: value, error: error });
|
|
200
211
|
return false;
|
|
201
212
|
}
|
|
202
213
|
}
|
|
@@ -241,8 +252,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
241
252
|
return value !== undefined ? Number.parseInt(value) : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
|
|
242
253
|
}
|
|
243
254
|
}
|
|
244
|
-
catch (
|
|
245
|
-
|
|
255
|
+
catch (err) {
|
|
256
|
+
const error = (0, error_2.ensureError)(err);
|
|
257
|
+
this.log.error("Convert CMD_SET_PIRSENSITIVITY Error", { property: property, value: value, error: error });
|
|
246
258
|
return numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0);
|
|
247
259
|
}
|
|
248
260
|
}
|
|
@@ -276,8 +288,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
276
288
|
return value !== undefined && value.model === 1 ? (0, utils_1.getDistances)(value.block_list)[7] : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
|
|
277
289
|
}
|
|
278
290
|
}
|
|
279
|
-
catch (
|
|
280
|
-
|
|
291
|
+
catch (err) {
|
|
292
|
+
const error = (0, error_2.ensureError)(err);
|
|
293
|
+
this.log.error(`Convert CMD_DOORBELL_DUAL_RADAR_WD_DETECTION_SENSITIVITY ${property.name} Error`, { property: property, value: value, error: error });
|
|
281
294
|
return numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0);
|
|
282
295
|
}
|
|
283
296
|
}
|
|
@@ -288,8 +301,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
288
301
|
try {
|
|
289
302
|
return (value.setting !== undefined && value.setting.length > 0 !== undefined && value.setting[0].start_hour !== undefined && value.setting[0].start_min !== undefined) ? `${value.setting[0].start_hour.padStart(2, "0")}:${value.setting[0].start_min.padStart(2, "0")}` : stringProperty.default !== undefined ? stringProperty.default : "";
|
|
290
303
|
}
|
|
291
|
-
catch (
|
|
292
|
-
|
|
304
|
+
catch (err) {
|
|
305
|
+
const error = (0, error_2.ensureError)(err);
|
|
306
|
+
this.log.error("Convert CMD_DOORBELL_DUAL_RADAR_WD_AUTO_RESPONSE DeviceLoiteringCustomResponseTimeFrom Error", { property: property, value: value, error: error });
|
|
293
307
|
return stringProperty.default !== undefined ? stringProperty.default : "";
|
|
294
308
|
}
|
|
295
309
|
}
|
|
@@ -298,8 +312,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
298
312
|
try {
|
|
299
313
|
return (value.setting !== undefined && value.setting.length > 0 !== undefined && value.setting[0].end_hour !== undefined && value.setting[0].end_min !== undefined) ? `${value.setting[0].end_hour.padStart(2, "0")}:${value.setting[0].end_min.padStart(2, "0")}` : stringProperty.default !== undefined ? stringProperty.default : "";
|
|
300
314
|
}
|
|
301
|
-
catch (
|
|
302
|
-
|
|
315
|
+
catch (err) {
|
|
316
|
+
const error = (0, error_2.ensureError)(err);
|
|
317
|
+
this.log.error("Convert CMD_DOORBELL_DUAL_RADAR_WD_AUTO_RESPONSE DeviceLoiteringCustomResponseTimeTo Error", { property: property, value: value, error: error });
|
|
303
318
|
return stringProperty.default !== undefined ? stringProperty.default : "";
|
|
304
319
|
}
|
|
305
320
|
}
|
|
@@ -308,8 +323,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
308
323
|
try {
|
|
309
324
|
return value.setting[0].push_notify === 1 ? true : booleanProperty.default !== undefined ? booleanProperty.default : false;
|
|
310
325
|
}
|
|
311
|
-
catch (
|
|
312
|
-
|
|
326
|
+
catch (err) {
|
|
327
|
+
const error = (0, error_2.ensureError)(err);
|
|
328
|
+
this.log.error("Convert CMD_DOORBELL_DUAL_RADAR_WD_AUTO_RESPONSE DeviceLoiteringCustomResponsePhoneNotification Error", { property: property, value: value, error: error });
|
|
313
329
|
return booleanProperty.default !== undefined ? booleanProperty.default : false;
|
|
314
330
|
}
|
|
315
331
|
}
|
|
@@ -318,8 +334,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
318
334
|
try {
|
|
319
335
|
return value.setting[0].homebase_alert === 1 ? true : booleanProperty.default !== undefined ? booleanProperty.default : false;
|
|
320
336
|
}
|
|
321
|
-
catch (
|
|
322
|
-
|
|
337
|
+
catch (err) {
|
|
338
|
+
const error = (0, error_2.ensureError)(err);
|
|
339
|
+
this.log.error("Convert CMD_DOORBELL_DUAL_RADAR_WD_AUTO_RESPONSE DeviceLoiteringCustomResponseHomeBaseNotification Error", { property: property, value: value, error: error });
|
|
323
340
|
return booleanProperty.default !== undefined ? booleanProperty.default : false;
|
|
324
341
|
}
|
|
325
342
|
}
|
|
@@ -328,8 +345,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
328
345
|
try {
|
|
329
346
|
return value.setting[0].auto_voice_resp === 1 ? true : booleanProperty.default !== undefined ? booleanProperty.default : false;
|
|
330
347
|
}
|
|
331
|
-
catch (
|
|
332
|
-
|
|
348
|
+
catch (err) {
|
|
349
|
+
const error = (0, error_2.ensureError)(err);
|
|
350
|
+
this.log.error("Convert CMD_DOORBELL_DUAL_RADAR_WD_AUTO_RESPONSE DeviceLoiteringCustomResponseAutoVoiceResponse Error", { property: property, value: value, error: error });
|
|
333
351
|
return booleanProperty.default !== undefined ? booleanProperty.default : false;
|
|
334
352
|
}
|
|
335
353
|
}
|
|
@@ -338,8 +356,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
338
356
|
try {
|
|
339
357
|
return (value.setting !== undefined && value.setting.length > 0 !== undefined && value.setting[0].auto_voice_id !== undefined) ? value.setting[0].auto_voice_id : numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0);
|
|
340
358
|
}
|
|
341
|
-
catch (
|
|
342
|
-
|
|
359
|
+
catch (err) {
|
|
360
|
+
const error = (0, error_2.ensureError)(err);
|
|
361
|
+
this.log.error("Convert CMD_DOORBELL_DUAL_RADAR_WD_AUTO_RESPONSE DeviceLoiteringCustomResponseAutoVoiceResponseVoice Error", { property: property, value: value, error: error });
|
|
343
362
|
return numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0);
|
|
344
363
|
}
|
|
345
364
|
}
|
|
@@ -350,8 +369,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
350
369
|
try {
|
|
351
370
|
return value !== undefined && value.ai_bottom_switch !== undefined ? value.ai_bottom_switch === 1024 : (booleanProperty.default !== undefined ? booleanProperty.default : false);
|
|
352
371
|
}
|
|
353
|
-
catch (
|
|
354
|
-
|
|
372
|
+
catch (err) {
|
|
373
|
+
const error = (0, error_2.ensureError)(err);
|
|
374
|
+
this.log.error("Convert CMD_DOORBELL_DUAL_DELIVERY_GUARD_SWITCH Error", { property: property, value: value, error: error });
|
|
355
375
|
return booleanProperty.default !== undefined ? booleanProperty.default : false;
|
|
356
376
|
}
|
|
357
377
|
}
|
|
@@ -360,8 +380,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
360
380
|
try {
|
|
361
381
|
return (value.start_h !== undefined && value.start_m !== undefined) ? `${value.start_h.toString().padStart(2, "0")}:${value.start_m.toString().padStart(2, "0")}` : stringProperty.default !== undefined ? stringProperty.default : "";
|
|
362
382
|
}
|
|
363
|
-
catch (
|
|
364
|
-
|
|
383
|
+
catch (err) {
|
|
384
|
+
const error = (0, error_2.ensureError)(err);
|
|
385
|
+
this.log.error("Convert CMD_DOORBELL_DUAL_PACKAGE_STRAND_TIME Error", { property: property, value: value, error: error });
|
|
365
386
|
return stringProperty.default !== undefined ? stringProperty.default : "";
|
|
366
387
|
}
|
|
367
388
|
}
|
|
@@ -372,8 +393,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
372
393
|
try {
|
|
373
394
|
return value.setting[0].active === 1 ? true : booleanProperty.default !== undefined ? booleanProperty.default : false;
|
|
374
395
|
}
|
|
375
|
-
catch (
|
|
376
|
-
|
|
396
|
+
catch (err) {
|
|
397
|
+
const error = (0, error_2.ensureError)(err);
|
|
398
|
+
this.log.error("Convert CMD_DOORBELL_DUAL_RING_AUTO_RESPONSE DeviceRingAutoResponse Error", { property: property, value: value, error: error });
|
|
377
399
|
return booleanProperty.default !== undefined ? booleanProperty.default : false;
|
|
378
400
|
}
|
|
379
401
|
}
|
|
@@ -382,8 +404,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
382
404
|
try {
|
|
383
405
|
return value.setting[0].active === 1 ? true : booleanProperty.default !== undefined ? booleanProperty.default : false;
|
|
384
406
|
}
|
|
385
|
-
catch (
|
|
386
|
-
|
|
407
|
+
catch (err) {
|
|
408
|
+
const error = (0, error_2.ensureError)(err);
|
|
409
|
+
this.log.error("Convert CMD_DOORBELL_DUAL_RING_AUTO_RESPONSE DeviceRingAutoResponseVoiceResponse Error", { property: property, value: value, error: error });
|
|
387
410
|
return booleanProperty.default !== undefined ? booleanProperty.default : false;
|
|
388
411
|
}
|
|
389
412
|
}
|
|
@@ -392,8 +415,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
392
415
|
try {
|
|
393
416
|
return (value.setting !== undefined && value.setting.length > 0 !== undefined && value.setting[0].start_hour !== undefined && value.setting[0].start_min !== undefined) ? `${value.setting[0].start_hour.padStart(2, "0")}:${value.setting[0].start_min.padStart(2, "0")}` : stringProperty.default !== undefined ? stringProperty.default : "";
|
|
394
417
|
}
|
|
395
|
-
catch (
|
|
396
|
-
|
|
418
|
+
catch (err) {
|
|
419
|
+
const error = (0, error_2.ensureError)(err);
|
|
420
|
+
this.log.error("Convert CMD_DOORBELL_DUAL_RING_AUTO_RESPONSE DeviceRingAutoResponseTimeFrom Error", { property: property, value: value, error: error });
|
|
397
421
|
return stringProperty.default !== undefined ? stringProperty.default : "";
|
|
398
422
|
}
|
|
399
423
|
}
|
|
@@ -402,8 +426,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
402
426
|
try {
|
|
403
427
|
return (value.setting !== undefined && value.setting.length > 0 !== undefined && value.setting[0].end_hour !== undefined && value.setting[0].end_min !== undefined) ? `${value.setting[0].end_hour.padStart(2, "0")}:${value.setting[0].end_min.padStart(2, "0")}` : stringProperty.default !== undefined ? stringProperty.default : "";
|
|
404
428
|
}
|
|
405
|
-
catch (
|
|
406
|
-
|
|
429
|
+
catch (err) {
|
|
430
|
+
const error = (0, error_2.ensureError)(err);
|
|
431
|
+
this.log.error("Convert CMD_DOORBELL_DUAL_RING_AUTO_RESPONSE DeviceRingAutoResponseTimeTo Error", { property: property, value: value, error: error });
|
|
407
432
|
return stringProperty.default !== undefined ? stringProperty.default : "";
|
|
408
433
|
}
|
|
409
434
|
}
|
|
@@ -412,8 +437,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
412
437
|
try {
|
|
413
438
|
return (value.setting !== undefined && value.setting.length > 0 !== undefined && value.setting[0].auto_voice_id !== undefined) ? value.setting[0].auto_voice_id : numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0);
|
|
414
439
|
}
|
|
415
|
-
catch (
|
|
416
|
-
|
|
440
|
+
catch (err) {
|
|
441
|
+
const error = (0, error_2.ensureError)(err);
|
|
442
|
+
this.log.error("Convert CMD_DOORBELL_DUAL_RING_AUTO_RESPONSE DeviceRingAutoResponseVoiceResponseVoice Error", { property: property, value: value, error: error });
|
|
417
443
|
return numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0);
|
|
418
444
|
}
|
|
419
445
|
}
|
|
@@ -426,8 +452,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
426
452
|
try {
|
|
427
453
|
return (value.start_h !== undefined && value.start_m !== undefined) ? `${value.start_h.toString().padStart(2, "0")}:${value.start_m.toString().padStart(2, "0")}` : stringProperty.default !== undefined ? stringProperty.default : "";
|
|
428
454
|
}
|
|
429
|
-
catch (
|
|
430
|
-
|
|
455
|
+
catch (err) {
|
|
456
|
+
const error = (0, error_2.ensureError)(err);
|
|
457
|
+
this.log.error("Convert CMD_DOORBELL_DUAL_PACKAGE_GUARD_TIME DeviceDeliveryGuardPackageGuardingActivatedTimeFrom Error", { property: property, value: value, error: error });
|
|
431
458
|
return stringProperty.default !== undefined ? stringProperty.default : "";
|
|
432
459
|
}
|
|
433
460
|
}
|
|
@@ -436,8 +463,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
436
463
|
try {
|
|
437
464
|
return (value.end_h !== undefined && value.end_m !== undefined) ? `${value.end_h.toString().padStart(2, "0")}:${value.end_m.toString().padStart(2, "0")}` : stringProperty.default !== undefined ? stringProperty.default : "";
|
|
438
465
|
}
|
|
439
|
-
catch (
|
|
440
|
-
|
|
466
|
+
catch (err) {
|
|
467
|
+
const error = (0, error_2.ensureError)(err);
|
|
468
|
+
this.log.error("Convert CMD_DOORBELL_DUAL_PACKAGE_GUARD_TIME DeviceDeliveryGuardPackageGuardingActivatedTimeTo Error", { property: property, value: value, error: error });
|
|
441
469
|
return stringProperty.default !== undefined ? stringProperty.default : "";
|
|
442
470
|
}
|
|
443
471
|
}
|
|
@@ -448,8 +476,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
448
476
|
try {
|
|
449
477
|
return value !== undefined && value.radar_wd_distance !== undefined ? value.radar_wd_distance : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
|
|
450
478
|
}
|
|
451
|
-
catch (
|
|
452
|
-
|
|
479
|
+
catch (err) {
|
|
480
|
+
const error = (0, error_2.ensureError)(err);
|
|
481
|
+
this.log.error("Convert CMD_DOORBELL_DUAL_RADAR_WD_DISTANCE Error", { property: property, value: value, error: error });
|
|
453
482
|
return numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0);
|
|
454
483
|
}
|
|
455
484
|
}
|
|
@@ -458,8 +487,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
458
487
|
try {
|
|
459
488
|
return value !== undefined && value.radar_wd_time !== undefined ? value.radar_wd_time : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
|
|
460
489
|
}
|
|
461
|
-
catch (
|
|
462
|
-
|
|
490
|
+
catch (err) {
|
|
491
|
+
const error = (0, error_2.ensureError)(err);
|
|
492
|
+
this.log.error("Convert CMD_DOORBELL_DUAL_RADAR_WD_TIME Error", { property: property, value: value, error: error });
|
|
463
493
|
return numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0);
|
|
464
494
|
}
|
|
465
495
|
}
|
|
@@ -468,8 +498,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
468
498
|
try {
|
|
469
499
|
return value !== undefined && value.auto_voice_id !== undefined ? value.auto_voice_id : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
|
|
470
500
|
}
|
|
471
|
-
catch (
|
|
472
|
-
|
|
501
|
+
catch (err) {
|
|
502
|
+
const error = (0, error_2.ensureError)(err);
|
|
503
|
+
this.log.error("Convert CMD_DOORBELL_DUAL_PACKAGE_GUARD_VOICE Error", { property: property, value: value, error: error });
|
|
473
504
|
return numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0);
|
|
474
505
|
}
|
|
475
506
|
}
|
|
@@ -480,8 +511,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
480
511
|
try {
|
|
481
512
|
return value !== undefined && value.snooze_time !== undefined && value.snooze_time !== "" && Number.parseInt(value.snooze_time) !== 0 ? true : booleanProperty.default !== undefined ? booleanProperty.default : false;
|
|
482
513
|
}
|
|
483
|
-
catch (
|
|
484
|
-
|
|
514
|
+
catch (err) {
|
|
515
|
+
const error = (0, error_2.ensureError)(err);
|
|
516
|
+
this.log.error("Convert CMD_SET_SNOOZE_MODE DeviceSnooze Error", { property: property, value: value, error: error });
|
|
485
517
|
return booleanProperty.default !== undefined ? booleanProperty.default : false;
|
|
486
518
|
}
|
|
487
519
|
}
|
|
@@ -490,8 +522,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
490
522
|
try {
|
|
491
523
|
return value !== undefined && value.snooze_time !== undefined && value.snooze_time !== "" ? Number.parseInt(value.snooze_time) : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
|
|
492
524
|
}
|
|
493
|
-
catch (
|
|
494
|
-
|
|
525
|
+
catch (err) {
|
|
526
|
+
const error = (0, error_2.ensureError)(err);
|
|
527
|
+
this.log.error("Convert CMD_SET_SNOOZE_MODE DeviceSnoozeTime Error", { property: property, value: value, error: error });
|
|
495
528
|
return numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0);
|
|
496
529
|
}
|
|
497
530
|
}
|
|
@@ -500,8 +533,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
500
533
|
try {
|
|
501
534
|
return value !== undefined && value.startTime !== undefined ? Number.parseInt(value.startTime) : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
|
|
502
535
|
}
|
|
503
|
-
catch (
|
|
504
|
-
|
|
536
|
+
catch (err) {
|
|
537
|
+
const error = (0, error_2.ensureError)(err);
|
|
538
|
+
this.log.error("Convert CMD_SET_SNOOZE_MODE DeviceSnoozeTime Error", { property: property, value: value, error: error });
|
|
505
539
|
return numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0);
|
|
506
540
|
}
|
|
507
541
|
}
|
|
@@ -510,8 +544,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
510
544
|
try {
|
|
511
545
|
return value !== undefined && value.homebase_onoff !== undefined ? (value.homebase_onoff === 1 ? true : false) : (booleanProperty.default !== undefined ? booleanProperty.default : false);
|
|
512
546
|
}
|
|
513
|
-
catch (
|
|
514
|
-
|
|
547
|
+
catch (err) {
|
|
548
|
+
const error = (0, error_2.ensureError)(err);
|
|
549
|
+
this.log.error("Convert CMD_SET_SNOOZE_MODE DeviceSnoozeHomebase Error", { property: property, value: value, error: error });
|
|
515
550
|
return booleanProperty.default !== undefined ? booleanProperty.default : false;
|
|
516
551
|
}
|
|
517
552
|
}
|
|
@@ -520,8 +555,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
520
555
|
try {
|
|
521
556
|
return value !== undefined && value.motion_notify_onoff !== undefined ? (value.motion_notify_onoff === 1 ? true : false) : (booleanProperty.default !== undefined ? booleanProperty.default : false);
|
|
522
557
|
}
|
|
523
|
-
catch (
|
|
524
|
-
|
|
558
|
+
catch (err) {
|
|
559
|
+
const error = (0, error_2.ensureError)(err);
|
|
560
|
+
this.log.error("Convert CMD_SET_SNOOZE_MODE DeviceSnoozeMotion Error", { property: property, value: value, error: error });
|
|
525
561
|
return booleanProperty.default !== undefined ? booleanProperty.default : false;
|
|
526
562
|
}
|
|
527
563
|
}
|
|
@@ -530,24 +566,26 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
530
566
|
try {
|
|
531
567
|
return value !== undefined && value.chime_onoff !== undefined ? (value.chime_onoff === 1 ? true : false) : (booleanProperty.default !== undefined ? booleanProperty.default : false);
|
|
532
568
|
}
|
|
533
|
-
catch (
|
|
534
|
-
|
|
569
|
+
catch (err) {
|
|
570
|
+
const error = (0, error_2.ensureError)(err);
|
|
571
|
+
this.log.error("Convert CMD_SET_SNOOZE_MODE DeviceSnoozeChime Error", { property: property, value: value, error: error });
|
|
535
572
|
return booleanProperty.default !== undefined ? booleanProperty.default : false;
|
|
536
573
|
}
|
|
537
574
|
}
|
|
538
575
|
}
|
|
539
576
|
}
|
|
540
|
-
else if (property.name === types_1.PropertyName.DeviceMotionDetectionTypeHuman ||
|
|
577
|
+
else if ((property.name === types_1.PropertyName.DeviceMotionDetectionTypeHuman ||
|
|
541
578
|
property.name === types_1.PropertyName.DeviceMotionDetectionTypeHumanRecognition ||
|
|
542
579
|
property.name === types_1.PropertyName.DeviceMotionDetectionTypePet ||
|
|
543
580
|
property.name === types_1.PropertyName.DeviceMotionDetectionTypeVehicle ||
|
|
544
|
-
property.name === types_1.PropertyName.DeviceMotionDetectionTypeAllOtherMotions) {
|
|
581
|
+
property.name === types_1.PropertyName.DeviceMotionDetectionTypeAllOtherMotions) && this.getStationSerial().startsWith("T8030")) {
|
|
545
582
|
const booleanProperty = property;
|
|
546
583
|
try {
|
|
547
584
|
return (0, utils_1.isHB3DetectionModeEnabled)(Number.parseInt(value), property.name === types_1.PropertyName.DeviceMotionDetectionTypeHuman ? types_1.HB3DetectionTypes.HUMAN_DETECTION : property.name === types_1.PropertyName.DeviceMotionDetectionTypeHumanRecognition ? types_1.HB3DetectionTypes.HUMAN_RECOGNITION : property.name === types_1.PropertyName.DeviceMotionDetectionTypePet ? types_1.HB3DetectionTypes.PET_DETECTION : property.name === types_1.PropertyName.DeviceMotionDetectionTypeVehicle ? types_1.HB3DetectionTypes.VEHICLE_DETECTION : types_1.HB3DetectionTypes.ALL_OTHER_MOTION);
|
|
548
585
|
}
|
|
549
|
-
catch (
|
|
550
|
-
|
|
586
|
+
catch (err) {
|
|
587
|
+
const error = (0, error_2.ensureError)(err);
|
|
588
|
+
this.log.error("Convert HB3 motion detection type Error", { property: property, value: value, error: error });
|
|
551
589
|
return booleanProperty.default !== undefined ? booleanProperty.default : false;
|
|
552
590
|
}
|
|
553
591
|
}
|
|
@@ -576,8 +614,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
576
614
|
try {
|
|
577
615
|
return value !== undefined ? Number.parseInt(value) : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
|
|
578
616
|
}
|
|
579
|
-
catch (
|
|
580
|
-
|
|
617
|
+
catch (err) {
|
|
618
|
+
const error = (0, error_2.ensureError)(err);
|
|
619
|
+
this.log.warn("PropertyMetadataNumeric Convert Error", { property: property, value: value, error: error });
|
|
581
620
|
return numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0);
|
|
582
621
|
}
|
|
583
622
|
}
|
|
@@ -586,8 +625,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
586
625
|
try {
|
|
587
626
|
return value !== undefined ? (value === "1" || value.toLowerCase() === "true" ? true : false) : (booleanProperty.default !== undefined ? booleanProperty.default : false);
|
|
588
627
|
}
|
|
589
|
-
catch (
|
|
590
|
-
|
|
628
|
+
catch (err) {
|
|
629
|
+
const error = (0, error_2.ensureError)(err);
|
|
630
|
+
this.log.warn("PropertyMetadataBoolean Convert Error", { property: property, value: value, error: error });
|
|
591
631
|
return booleanProperty.default !== undefined ? booleanProperty.default : false;
|
|
592
632
|
}
|
|
593
633
|
}
|
|
@@ -600,8 +640,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
600
640
|
return value !== undefined ? value : (objectProperty.default !== undefined ? objectProperty.default : undefined);
|
|
601
641
|
}
|
|
602
642
|
}
|
|
603
|
-
catch (
|
|
604
|
-
|
|
643
|
+
catch (err) {
|
|
644
|
+
const error = (0, error_2.ensureError)(err);
|
|
645
|
+
this.log.error("Convert Error", { property: property, value: value, error: error });
|
|
605
646
|
}
|
|
606
647
|
return value;
|
|
607
648
|
}
|
|
@@ -609,7 +650,7 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
609
650
|
const property = this.getPropertiesMetadata(hidden)[name];
|
|
610
651
|
if (property !== undefined)
|
|
611
652
|
return property;
|
|
612
|
-
throw new error_1.InvalidPropertyError(
|
|
653
|
+
throw new error_1.InvalidPropertyError("Property name is not valid", { context: { name: name } });
|
|
613
654
|
}
|
|
614
655
|
getPropertyValue(name) {
|
|
615
656
|
return this.properties[name];
|
|
@@ -678,7 +719,7 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
678
719
|
newMetadata[types_1.PropertyName.DeviceEnabled] = types_1.DeviceEnabledSoloProperty;
|
|
679
720
|
metadata = newMetadata;
|
|
680
721
|
}
|
|
681
|
-
else if (metadata ===
|
|
722
|
+
else if (Object.keys(metadata).length === 0) {
|
|
682
723
|
metadata = {
|
|
683
724
|
...types_1.GenericDeviceProperties
|
|
684
725
|
};
|
|
@@ -755,7 +796,13 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
755
796
|
type == types_1.DeviceType.INDOOR_COST_DOWN_CAMERA ||
|
|
756
797
|
type == types_1.DeviceType.FLOODLIGHT_CAMERA_8422 ||
|
|
757
798
|
type == types_1.DeviceType.FLOODLIGHT_CAMERA_8423 ||
|
|
758
|
-
type == types_1.DeviceType.FLOODLIGHT_CAMERA_8424
|
|
799
|
+
type == types_1.DeviceType.FLOODLIGHT_CAMERA_8424 ||
|
|
800
|
+
type == types_1.DeviceType.WALL_LIGHT_CAM ||
|
|
801
|
+
type == types_1.DeviceType.WALL_LIGHT_CAM_81A0 ||
|
|
802
|
+
type == types_1.DeviceType.CAMERA_GARAGE_T8453_COMMON ||
|
|
803
|
+
type == types_1.DeviceType.CAMERA_GARAGE_T8453 ||
|
|
804
|
+
type == types_1.DeviceType.CAMERA_GARAGE_T8452 ||
|
|
805
|
+
type == types_1.DeviceType.CAMERA_FG)
|
|
759
806
|
return true;
|
|
760
807
|
return false;
|
|
761
808
|
}
|
|
@@ -787,7 +834,8 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
787
834
|
type == types_1.DeviceType.SMART_SAFE_7401 ||
|
|
788
835
|
type == types_1.DeviceType.SMART_SAFE_7402 ||
|
|
789
836
|
type == types_1.DeviceType.SMART_SAFE_7403 ||
|
|
790
|
-
type == types_1.DeviceType.CAMERA_FG
|
|
837
|
+
type == types_1.DeviceType.CAMERA_FG ||
|
|
838
|
+
type == types_1.DeviceType.WALL_LIGHT_CAM_81A0)
|
|
791
839
|
//TODO: Add other battery devices
|
|
792
840
|
return true;
|
|
793
841
|
return false;
|
|
@@ -863,6 +911,11 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
863
911
|
return true;
|
|
864
912
|
return false;
|
|
865
913
|
}
|
|
914
|
+
static isWallLightCam(type) {
|
|
915
|
+
if (type == types_1.DeviceType.WALL_LIGHT_CAM || type == types_1.DeviceType.WALL_LIGHT_CAM_81A0)
|
|
916
|
+
return true;
|
|
917
|
+
return false;
|
|
918
|
+
}
|
|
866
919
|
static isLock(type) {
|
|
867
920
|
return Device.isLockBle(type) ||
|
|
868
921
|
Device.isLockWifi(type) ||
|
|
@@ -1001,6 +1054,13 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1001
1054
|
return true;
|
|
1002
1055
|
return false;
|
|
1003
1056
|
}
|
|
1057
|
+
static isGarageCamera(type) {
|
|
1058
|
+
if (type == types_1.DeviceType.CAMERA_GARAGE_T8452 ||
|
|
1059
|
+
type == types_1.DeviceType.CAMERA_GARAGE_T8453 ||
|
|
1060
|
+
type == types_1.DeviceType.CAMERA_GARAGE_T8453_COMMON)
|
|
1061
|
+
return true;
|
|
1062
|
+
return false;
|
|
1063
|
+
}
|
|
1004
1064
|
static isIntegratedDeviceBySn(sn) {
|
|
1005
1065
|
return sn.startsWith("T8420") ||
|
|
1006
1066
|
sn.startsWith("T820") ||
|
|
@@ -1025,6 +1085,22 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1025
1085
|
sn.startsWith("T8123") ||
|
|
1026
1086
|
sn.startsWith("T8124");
|
|
1027
1087
|
}
|
|
1088
|
+
static isSmartTrackCard(type) {
|
|
1089
|
+
if (type == types_1.DeviceType.SMART_TRACK_CARD)
|
|
1090
|
+
return true;
|
|
1091
|
+
return false;
|
|
1092
|
+
}
|
|
1093
|
+
static isSmartTrackLink(type) {
|
|
1094
|
+
if (type == types_1.DeviceType.SMART_TRACK_LINK)
|
|
1095
|
+
return true;
|
|
1096
|
+
return false;
|
|
1097
|
+
}
|
|
1098
|
+
static isSmartTrack(type) {
|
|
1099
|
+
if (type == types_1.DeviceType.SMART_TRACK_LINK ||
|
|
1100
|
+
type == types_1.DeviceType.SMART_TRACK_CARD)
|
|
1101
|
+
return true;
|
|
1102
|
+
return false;
|
|
1103
|
+
}
|
|
1028
1104
|
isCamera() {
|
|
1029
1105
|
return Device.isCamera(this.rawDevice.device_type);
|
|
1030
1106
|
}
|
|
@@ -1034,6 +1110,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1034
1110
|
isFloodLightT8420X() {
|
|
1035
1111
|
return Device.isFloodLightT8420X(this.rawDevice.device_type, this.rawDevice.device_sn);
|
|
1036
1112
|
}
|
|
1113
|
+
isWallLightCam() {
|
|
1114
|
+
return Device.isWallLightCam(this.rawDevice.device_type);
|
|
1115
|
+
}
|
|
1037
1116
|
isDoorbell() {
|
|
1038
1117
|
return Device.isDoorbell(this.rawDevice.device_type);
|
|
1039
1118
|
}
|
|
@@ -1169,11 +1248,23 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1169
1248
|
isSmartSafe() {
|
|
1170
1249
|
return Device.isSmartSafe(this.rawDevice.device_type);
|
|
1171
1250
|
}
|
|
1251
|
+
isGarageCamera() {
|
|
1252
|
+
return Device.isGarageCamera(this.rawDevice.device_type);
|
|
1253
|
+
}
|
|
1172
1254
|
isIntegratedDevice() {
|
|
1173
1255
|
if (this.isLock() || this.isSmartDrop()) {
|
|
1174
1256
|
return this.rawDevice.device_sn === this.rawDevice.station_sn;
|
|
1175
1257
|
}
|
|
1176
|
-
return this.isWiredDoorbellDual() || this.isFloodLight() || this.isWiredDoorbell() || this.isIndoorCamera() || this.isSoloCameras();
|
|
1258
|
+
return this.isWiredDoorbellDual() || this.isFloodLight() || this.isWiredDoorbell() || this.isIndoorCamera() || this.isSoloCameras() || this.isWallLightCam();
|
|
1259
|
+
}
|
|
1260
|
+
isSmartTrack() {
|
|
1261
|
+
return Device.isSmartTrack(this.rawDevice.device_type);
|
|
1262
|
+
}
|
|
1263
|
+
isSmartTrackCard() {
|
|
1264
|
+
return Device.isSmartTrackCard(this.rawDevice.device_type);
|
|
1265
|
+
}
|
|
1266
|
+
isSmartTrackLink() {
|
|
1267
|
+
return Device.isSmartTrackLink(this.rawDevice.device_type);
|
|
1177
1268
|
}
|
|
1178
1269
|
hasBattery() {
|
|
1179
1270
|
return Device.hasBattery(this.rawDevice.device_type);
|
|
@@ -1208,6 +1299,7 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1208
1299
|
getChannel() {
|
|
1209
1300
|
return this.rawDevice.device_channel;
|
|
1210
1301
|
}
|
|
1302
|
+
//TODO: To remove
|
|
1211
1303
|
getStateID(state, level = 2) {
|
|
1212
1304
|
switch (level) {
|
|
1213
1305
|
case 0:
|
|
@@ -1235,9 +1327,9 @@ class Device extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1235
1327
|
}
|
|
1236
1328
|
exports.Device = Device;
|
|
1237
1329
|
class Camera extends Device {
|
|
1330
|
+
_isStreaming = false;
|
|
1238
1331
|
constructor(api, device) {
|
|
1239
1332
|
super(api, device);
|
|
1240
|
-
this._isStreaming = false;
|
|
1241
1333
|
this.properties[types_1.PropertyName.DeviceMotionDetected] = false;
|
|
1242
1334
|
this.properties[types_1.PropertyName.DevicePersonDetected] = false;
|
|
1243
1335
|
this.properties[types_1.PropertyName.DevicePersonName] = "";
|
|
@@ -1255,8 +1347,9 @@ class Camera extends Device {
|
|
|
1255
1347
|
return value !== undefined ? (value === "0" ? true : false) : false;
|
|
1256
1348
|
}
|
|
1257
1349
|
}
|
|
1258
|
-
catch (
|
|
1259
|
-
|
|
1350
|
+
catch (err) {
|
|
1351
|
+
const error = (0, error_2.ensureError)(err);
|
|
1352
|
+
this.log.error("Convert Error", { property: property, value: value, error: error });
|
|
1260
1353
|
}
|
|
1261
1354
|
return super.convertRawPropertyValue(property, value);
|
|
1262
1355
|
}
|
|
@@ -1268,12 +1361,15 @@ class Camera extends Device {
|
|
|
1268
1361
|
}
|
|
1269
1362
|
async startDetection() {
|
|
1270
1363
|
// Start camera detection.
|
|
1271
|
-
|
|
1272
|
-
|
|
1364
|
+
//TODO: Deprecated. Will be removed!
|
|
1365
|
+
await this.setParameters([{ paramType: types_1.ParamType.DETECT_SWITCH, paramValue: 1 }]).catch(err => {
|
|
1366
|
+
const error = (0, error_2.ensureError)(err);
|
|
1367
|
+
this.log.error("Start detection Error", error);
|
|
1273
1368
|
});
|
|
1274
1369
|
}
|
|
1275
1370
|
async startStream() {
|
|
1276
1371
|
// Start the camera stream and return the RTSP URL.
|
|
1372
|
+
//TODO: Deprecated. Will be removed!
|
|
1277
1373
|
try {
|
|
1278
1374
|
const response = await this.api.request({
|
|
1279
1375
|
method: "post",
|
|
@@ -1283,9 +1379,6 @@ class Camera extends Device {
|
|
|
1283
1379
|
station_sn: this.rawDevice.station_sn,
|
|
1284
1380
|
proto: 2
|
|
1285
1381
|
}
|
|
1286
|
-
}).catch(error => {
|
|
1287
|
-
this.log.error("Error:", error);
|
|
1288
|
-
return error;
|
|
1289
1382
|
});
|
|
1290
1383
|
this.log.debug("Response:", response.data);
|
|
1291
1384
|
if (response.status == 200) {
|
|
@@ -1305,8 +1398,9 @@ class Camera extends Device {
|
|
|
1305
1398
|
this.log.error("Status return code not 200", { status: response.status, statusText: response.statusText });
|
|
1306
1399
|
}
|
|
1307
1400
|
}
|
|
1308
|
-
catch (
|
|
1309
|
-
|
|
1401
|
+
catch (err) {
|
|
1402
|
+
const error = (0, error_2.ensureError)(err);
|
|
1403
|
+
this.log.error("Generic Error", error);
|
|
1310
1404
|
}
|
|
1311
1405
|
return "";
|
|
1312
1406
|
}
|
|
@@ -1316,6 +1410,7 @@ class Camera extends Device {
|
|
|
1316
1410
|
}
|
|
1317
1411
|
async stopStream() {
|
|
1318
1412
|
// Stop the camera stream.
|
|
1413
|
+
//TODO: Deprecated. Will be removed!
|
|
1319
1414
|
try {
|
|
1320
1415
|
const response = await this.api.request({
|
|
1321
1416
|
method: "post",
|
|
@@ -1325,9 +1420,6 @@ class Camera extends Device {
|
|
|
1325
1420
|
station_sn: this.rawDevice.station_sn,
|
|
1326
1421
|
proto: 2
|
|
1327
1422
|
}
|
|
1328
|
-
}).catch(error => {
|
|
1329
|
-
this.log.error("Error:", error);
|
|
1330
|
-
return error;
|
|
1331
1423
|
});
|
|
1332
1424
|
this.log.debug("Response:", response.data);
|
|
1333
1425
|
if (response.status == 200) {
|
|
@@ -1344,8 +1436,9 @@ class Camera extends Device {
|
|
|
1344
1436
|
this.log.error("Status return code not 200", { status: response.status, statusText: response.statusText });
|
|
1345
1437
|
}
|
|
1346
1438
|
}
|
|
1347
|
-
catch (
|
|
1348
|
-
|
|
1439
|
+
catch (err) {
|
|
1440
|
+
const error = (0, error_2.ensureError)(err);
|
|
1441
|
+
this.log.error("Generic Error", error);
|
|
1349
1442
|
}
|
|
1350
1443
|
}
|
|
1351
1444
|
getState() {
|
|
@@ -1446,10 +1539,11 @@ class Camera extends Device {
|
|
|
1446
1539
|
if (!(0, utils_3.isEmpty)(message.pic_url)) {
|
|
1447
1540
|
(0, utils_1.getImage)(this.api, this.getSerial(), message.pic_url).then((image) => {
|
|
1448
1541
|
if (image.data.length > 0) {
|
|
1449
|
-
this.updateProperty(types_1.PropertyName.DevicePicture, image);
|
|
1542
|
+
this.updateProperty(types_1.PropertyName.DevicePicture, image, true);
|
|
1450
1543
|
}
|
|
1451
|
-
}).catch((
|
|
1452
|
-
|
|
1544
|
+
}).catch((err) => {
|
|
1545
|
+
const error = (0, error_2.ensureError)(err);
|
|
1546
|
+
this.log.debug(`CusPushEvent.SECURITY - Device: ${message.device_sn} - Get picture - Error`, error);
|
|
1453
1547
|
});
|
|
1454
1548
|
}
|
|
1455
1549
|
if (message.fetch_id !== undefined) {
|
|
@@ -1473,8 +1567,9 @@ class Camera extends Device {
|
|
|
1473
1567
|
}, eventDurationSeconds * 1000));
|
|
1474
1568
|
}
|
|
1475
1569
|
}
|
|
1476
|
-
catch (
|
|
1477
|
-
|
|
1570
|
+
catch (err) {
|
|
1571
|
+
const error = (0, error_2.ensureError)(err);
|
|
1572
|
+
this.log.debug(`CusPushEvent.SECURITY - Device: ${message.device_sn} Error`, error);
|
|
1478
1573
|
}
|
|
1479
1574
|
}
|
|
1480
1575
|
else if (message.msg_type === types_1.DeviceType.HB3) {
|
|
@@ -1483,10 +1578,11 @@ class Camera extends Device {
|
|
|
1483
1578
|
if (!(0, utils_3.isEmpty)(message.pic_url)) {
|
|
1484
1579
|
(0, utils_1.getImage)(this.api, this.getSerial(), message.pic_url).then((image) => {
|
|
1485
1580
|
if (image.data.length > 0) {
|
|
1486
|
-
this.updateProperty(types_1.PropertyName.DevicePicture, image);
|
|
1581
|
+
this.updateProperty(types_1.PropertyName.DevicePicture, image, true);
|
|
1487
1582
|
}
|
|
1488
|
-
}).catch((
|
|
1489
|
-
|
|
1583
|
+
}).catch((err) => {
|
|
1584
|
+
const error = (0, error_2.ensureError)(err);
|
|
1585
|
+
this.log.debug(`HB3PairedDevicePushEvent - Device: ${message.device_sn} - Get picture - Error`, error);
|
|
1490
1586
|
});
|
|
1491
1587
|
}
|
|
1492
1588
|
switch (message.event_type) {
|
|
@@ -1589,8 +1685,9 @@ class Camera extends Device {
|
|
|
1589
1685
|
break;
|
|
1590
1686
|
}
|
|
1591
1687
|
}
|
|
1592
|
-
catch (
|
|
1593
|
-
|
|
1688
|
+
catch (err) {
|
|
1689
|
+
const error = (0, error_2.ensureError)(err);
|
|
1690
|
+
this.log.debug(`HB3PairedDevicePushEvent - Device: ${message.device_sn} Error`, error);
|
|
1594
1691
|
}
|
|
1595
1692
|
}
|
|
1596
1693
|
}
|
|
@@ -1616,10 +1713,11 @@ class SoloCamera extends Camera {
|
|
|
1616
1713
|
if (!(0, utils_3.isEmpty)(message.pic_url)) {
|
|
1617
1714
|
(0, utils_1.getImage)(this.api, this.getSerial(), message.pic_url).then((image) => {
|
|
1618
1715
|
if (image.data.length > 0) {
|
|
1619
|
-
this.updateProperty(types_1.PropertyName.DevicePicture, image);
|
|
1716
|
+
this.updateProperty(types_1.PropertyName.DevicePicture, image, true);
|
|
1620
1717
|
}
|
|
1621
|
-
}).catch((
|
|
1622
|
-
|
|
1718
|
+
}).catch((err) => {
|
|
1719
|
+
const error = (0, error_2.ensureError)(err);
|
|
1720
|
+
this.log.debug(`SoloPushEvent - Device: ${message.device_sn} - Get picture - Error`, error);
|
|
1623
1721
|
});
|
|
1624
1722
|
}
|
|
1625
1723
|
switch (message.event_type) {
|
|
@@ -1646,8 +1744,9 @@ class SoloCamera extends Camera {
|
|
|
1646
1744
|
break;
|
|
1647
1745
|
}
|
|
1648
1746
|
}
|
|
1649
|
-
catch (
|
|
1650
|
-
|
|
1747
|
+
catch (err) {
|
|
1748
|
+
const error = (0, error_2.ensureError)(err);
|
|
1749
|
+
this.log.debug(`SoloPushEvent - Device: ${message.device_sn} Error`, error);
|
|
1651
1750
|
}
|
|
1652
1751
|
}
|
|
1653
1752
|
}
|
|
@@ -1693,10 +1792,11 @@ class IndoorCamera extends Camera {
|
|
|
1693
1792
|
if (!(0, utils_3.isEmpty)(message.pic_url)) {
|
|
1694
1793
|
(0, utils_1.getImage)(this.api, this.getSerial(), message.pic_url).then((image) => {
|
|
1695
1794
|
if (image.data.length > 0) {
|
|
1696
|
-
this.updateProperty(types_1.PropertyName.DevicePicture, image);
|
|
1795
|
+
this.updateProperty(types_1.PropertyName.DevicePicture, image, true);
|
|
1697
1796
|
}
|
|
1698
|
-
}).catch((
|
|
1699
|
-
|
|
1797
|
+
}).catch((err) => {
|
|
1798
|
+
const error = (0, error_2.ensureError)(err);
|
|
1799
|
+
this.log.debug(`IndoorPushEvent - Device: ${message.device_sn} - Get picture - Error`, error);
|
|
1700
1800
|
});
|
|
1701
1801
|
}
|
|
1702
1802
|
switch (message.event_type) {
|
|
@@ -1747,8 +1847,9 @@ class IndoorCamera extends Camera {
|
|
|
1747
1847
|
break;
|
|
1748
1848
|
}
|
|
1749
1849
|
}
|
|
1750
|
-
catch (
|
|
1751
|
-
|
|
1850
|
+
catch (err) {
|
|
1851
|
+
const error = (0, error_2.ensureError)(err);
|
|
1852
|
+
this.log.debug(`IndoorPushEvent - Device: ${message.device_sn} Error`, error);
|
|
1752
1853
|
}
|
|
1753
1854
|
}
|
|
1754
1855
|
}
|
|
@@ -1759,6 +1860,7 @@ class IndoorCamera extends Camera {
|
|
|
1759
1860
|
}
|
|
1760
1861
|
exports.IndoorCamera = IndoorCamera;
|
|
1761
1862
|
class DoorbellCamera extends Camera {
|
|
1863
|
+
voices;
|
|
1762
1864
|
constructor(api, device, voices) {
|
|
1763
1865
|
super(api, device);
|
|
1764
1866
|
this.voices = voices;
|
|
@@ -1825,10 +1927,11 @@ class DoorbellCamera extends Camera {
|
|
|
1825
1927
|
if (!(0, utils_3.isEmpty)(message.pic_url)) {
|
|
1826
1928
|
(0, utils_1.getImage)(this.api, this.getSerial(), message.pic_url).then((image) => {
|
|
1827
1929
|
if (image.data.length > 0) {
|
|
1828
|
-
this.updateProperty(types_1.PropertyName.DevicePicture, image);
|
|
1930
|
+
this.updateProperty(types_1.PropertyName.DevicePicture, image, true);
|
|
1829
1931
|
}
|
|
1830
|
-
}).catch((
|
|
1831
|
-
|
|
1932
|
+
}).catch((err) => {
|
|
1933
|
+
const error = (0, error_2.ensureError)(err);
|
|
1934
|
+
this.log.debug(`DoorbellPushEvent - Device: ${message.device_sn} - Get picture - Error`, error);
|
|
1832
1935
|
});
|
|
1833
1936
|
}
|
|
1834
1937
|
switch (message.event_type) {
|
|
@@ -1904,8 +2007,9 @@ class DoorbellCamera extends Camera {
|
|
|
1904
2007
|
break;
|
|
1905
2008
|
}
|
|
1906
2009
|
}
|
|
1907
|
-
catch (
|
|
1908
|
-
|
|
2010
|
+
catch (err) {
|
|
2011
|
+
const error = (0, error_2.ensureError)(err);
|
|
2012
|
+
this.log.debug(`DoorbellPushEvent - Device: ${message.device_sn} Error`, error);
|
|
1909
2013
|
}
|
|
1910
2014
|
}
|
|
1911
2015
|
}
|
|
@@ -1982,8 +2086,9 @@ class FloodlightCamera extends Camera {
|
|
|
1982
2086
|
}
|
|
1983
2087
|
}
|
|
1984
2088
|
}
|
|
1985
|
-
catch (
|
|
1986
|
-
|
|
2089
|
+
catch (err) {
|
|
2090
|
+
const error = (0, error_2.ensureError)(err);
|
|
2091
|
+
this.log.error("Convert Error", { property: property, value: value, error: error });
|
|
1987
2092
|
}
|
|
1988
2093
|
return super.convertRawPropertyValue(property, value);
|
|
1989
2094
|
}
|
|
@@ -1995,10 +2100,11 @@ class FloodlightCamera extends Camera {
|
|
|
1995
2100
|
if (!(0, utils_3.isEmpty)(message.pic_url)) {
|
|
1996
2101
|
(0, utils_1.getImage)(this.api, this.getSerial(), message.pic_url).then((image) => {
|
|
1997
2102
|
if (image.data.length > 0) {
|
|
1998
|
-
this.updateProperty(types_1.PropertyName.DevicePicture, image);
|
|
2103
|
+
this.updateProperty(types_1.PropertyName.DevicePicture, image, true);
|
|
1999
2104
|
}
|
|
2000
|
-
}).catch((
|
|
2001
|
-
|
|
2105
|
+
}).catch((err) => {
|
|
2106
|
+
const error = (0, error_2.ensureError)(err);
|
|
2107
|
+
this.log.debug(`FloodlightPushEvent - Device: ${message.device_sn} - Get picture - Error`, error);
|
|
2002
2108
|
});
|
|
2003
2109
|
}
|
|
2004
2110
|
switch (message.event_type) {
|
|
@@ -2025,14 +2131,279 @@ class FloodlightCamera extends Camera {
|
|
|
2025
2131
|
break;
|
|
2026
2132
|
}
|
|
2027
2133
|
}
|
|
2028
|
-
catch (
|
|
2029
|
-
|
|
2134
|
+
catch (err) {
|
|
2135
|
+
const error = (0, error_2.ensureError)(err);
|
|
2136
|
+
this.log.debug(`FloodlightPushEvent - Device: ${message.device_sn} Error`, error);
|
|
2030
2137
|
}
|
|
2031
2138
|
}
|
|
2032
2139
|
}
|
|
2033
2140
|
}
|
|
2034
2141
|
}
|
|
2035
2142
|
exports.FloodlightCamera = FloodlightCamera;
|
|
2143
|
+
class WallLightCam extends Camera {
|
|
2144
|
+
static async getInstance(api, device) {
|
|
2145
|
+
return new WallLightCam(api, device);
|
|
2146
|
+
}
|
|
2147
|
+
isLedEnabled() {
|
|
2148
|
+
return this.getPropertyValue(types_1.PropertyName.DeviceStatusLed);
|
|
2149
|
+
}
|
|
2150
|
+
isMotionDetectionEnabled() {
|
|
2151
|
+
return this.getPropertyValue(types_1.PropertyName.DeviceMotionDetection);
|
|
2152
|
+
}
|
|
2153
|
+
convertRawPropertyValue(property, value) {
|
|
2154
|
+
try {
|
|
2155
|
+
switch (property.key) {
|
|
2156
|
+
case types_2.CommandType.CMD_DEV_RECORD_AUTOSTOP:
|
|
2157
|
+
return value !== undefined ? (value === "0" ? true : false) : false;
|
|
2158
|
+
case types_2.CommandType.CMD_SET_AUDIO_MUTE_RECORD:
|
|
2159
|
+
return value !== undefined ? (value === "1" ? true : false) : false;
|
|
2160
|
+
case types_2.CommandType.CMD_WALL_LIGHT_SETTINGS_MANUAL_COLORED_LIGHTING:
|
|
2161
|
+
case types_2.CommandType.CMD_WALL_LIGHT_SETTINGS_MOTION_COLORED_LIGHTING:
|
|
2162
|
+
case types_2.CommandType.CMD_WALL_LIGHT_SETTINGS_SCHEDULE_COLORED_LIGHTING:
|
|
2163
|
+
{
|
|
2164
|
+
const defaultColor = {
|
|
2165
|
+
red: 0,
|
|
2166
|
+
green: 0,
|
|
2167
|
+
blue: 0
|
|
2168
|
+
};
|
|
2169
|
+
const internal = value;
|
|
2170
|
+
return internal !== undefined ? (internal.rgb_color !== undefined ? (0, utils_2.DecimalToRGBColor)(internal.rgb_color) : defaultColor) : defaultColor;
|
|
2171
|
+
}
|
|
2172
|
+
case types_2.CommandType.CMD_WALL_LIGHT_SETTINGS_COLORED_LIGHTING_COLORS: {
|
|
2173
|
+
const result = [];
|
|
2174
|
+
for (const color of value) {
|
|
2175
|
+
result.push((0, utils_2.DecimalToRGBColor)(color.color));
|
|
2176
|
+
}
|
|
2177
|
+
return result;
|
|
2178
|
+
}
|
|
2179
|
+
case types_2.CommandType.CMD_WALL_LIGHT_SETTINGS_DYNAMIC_LIGHTING_THEMES: {
|
|
2180
|
+
const result = [];
|
|
2181
|
+
for (const theme of value) {
|
|
2182
|
+
result.push({
|
|
2183
|
+
colors: theme.colors.map((color) => (0, utils_2.DecimalToRGBColor)(color)),
|
|
2184
|
+
mode: theme.mode,
|
|
2185
|
+
name: theme.name,
|
|
2186
|
+
speed: theme.speed // Control speed 500 msec to 5 sec.; 500 msec steps
|
|
2187
|
+
});
|
|
2188
|
+
}
|
|
2189
|
+
return result;
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
catch (err) {
|
|
2194
|
+
const error = (0, error_2.ensureError)(err);
|
|
2195
|
+
this.log.error("Convert Error", { property: property, value: value, error: error });
|
|
2196
|
+
}
|
|
2197
|
+
return super.convertRawPropertyValue(property, value);
|
|
2198
|
+
}
|
|
2199
|
+
getPropertiesMetadata(hidden = false) {
|
|
2200
|
+
const metadata = super.getPropertiesMetadata(hidden);
|
|
2201
|
+
const themes = this.getPropertyValue(types_1.PropertyName.DeviceLightSettingsDynamicLightingThemes);
|
|
2202
|
+
if (themes !== undefined) {
|
|
2203
|
+
const states = {};
|
|
2204
|
+
for (let i = 0; i < themes.length; i++) {
|
|
2205
|
+
states[i] = themes[i].name;
|
|
2206
|
+
}
|
|
2207
|
+
metadata[types_1.PropertyName.DeviceLightSettingsManualDynamicLighting].states = states;
|
|
2208
|
+
metadata[types_1.PropertyName.DeviceLightSettingsScheduleDynamicLighting].states = states;
|
|
2209
|
+
metadata[types_1.PropertyName.DeviceLightSettingsMotionDynamicLighting].states = states;
|
|
2210
|
+
}
|
|
2211
|
+
return metadata;
|
|
2212
|
+
}
|
|
2213
|
+
processPushNotification(message, eventDurationSeconds) {
|
|
2214
|
+
super.processPushNotification(message, eventDurationSeconds);
|
|
2215
|
+
if (message.type !== undefined && message.event_type !== undefined) {
|
|
2216
|
+
if (message.device_sn === this.getSerial()) {
|
|
2217
|
+
try {
|
|
2218
|
+
if (!(0, utils_3.isEmpty)(message.pic_url)) {
|
|
2219
|
+
(0, utils_1.getImage)(this.api, this.getSerial(), message.pic_url).then((image) => {
|
|
2220
|
+
if (image.data.length > 0) {
|
|
2221
|
+
this.updateProperty(types_1.PropertyName.DevicePicture, image);
|
|
2222
|
+
}
|
|
2223
|
+
}).catch((err) => {
|
|
2224
|
+
const error = (0, error_2.ensureError)(err);
|
|
2225
|
+
this.log.debug(`WallLightCamPushEvent - Device: ${message.device_sn} - Get picture - Error`, error);
|
|
2226
|
+
});
|
|
2227
|
+
}
|
|
2228
|
+
switch (message.event_type) {
|
|
2229
|
+
case types_3.IndoorPushEvent.MOTION_DETECTION:
|
|
2230
|
+
this.updateProperty(types_1.PropertyName.DeviceMotionDetected, true);
|
|
2231
|
+
this.clearEventTimeout(types_1.DeviceEvent.MotionDetected);
|
|
2232
|
+
this.eventTimeouts.set(types_1.DeviceEvent.MotionDetected, setTimeout(async () => {
|
|
2233
|
+
this.updateProperty(types_1.PropertyName.DeviceMotionDetected, false);
|
|
2234
|
+
this.eventTimeouts.delete(types_1.DeviceEvent.MotionDetected);
|
|
2235
|
+
}, eventDurationSeconds * 1000));
|
|
2236
|
+
break;
|
|
2237
|
+
case types_3.IndoorPushEvent.FACE_DETECTION:
|
|
2238
|
+
this.updateProperty(types_1.PropertyName.DevicePersonName, !(0, utils_3.isEmpty)(message.person_name) ? message.person_name : "Unknown");
|
|
2239
|
+
this.updateProperty(types_1.PropertyName.DevicePersonDetected, true);
|
|
2240
|
+
this.clearEventTimeout(types_1.DeviceEvent.PersonDetected);
|
|
2241
|
+
this.eventTimeouts.set(types_1.DeviceEvent.PersonDetected, setTimeout(async () => {
|
|
2242
|
+
this.updateProperty(types_1.PropertyName.DevicePersonName, "");
|
|
2243
|
+
this.updateProperty(types_1.PropertyName.DevicePersonDetected, false);
|
|
2244
|
+
this.eventTimeouts.delete(types_1.DeviceEvent.PersonDetected);
|
|
2245
|
+
}, eventDurationSeconds * 1000));
|
|
2246
|
+
break;
|
|
2247
|
+
default:
|
|
2248
|
+
this.log.debug("Unhandled WallLightCam push event", message);
|
|
2249
|
+
break;
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
catch (err) {
|
|
2253
|
+
const error = (0, error_2.ensureError)(err);
|
|
2254
|
+
this.log.debug(`WallLightCamPushEvent - Device: ${message.device_sn} Error`, error);
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
exports.WallLightCam = WallLightCam;
|
|
2261
|
+
class GarageCamera extends Camera {
|
|
2262
|
+
static async getInstance(api, device) {
|
|
2263
|
+
return new GarageCamera(api, device);
|
|
2264
|
+
}
|
|
2265
|
+
isLedEnabled() {
|
|
2266
|
+
return this.getPropertyValue(types_1.PropertyName.DeviceStatusLed);
|
|
2267
|
+
}
|
|
2268
|
+
isMotionDetectionEnabled() {
|
|
2269
|
+
return this.getPropertyValue(types_1.PropertyName.DeviceMotionDetection);
|
|
2270
|
+
}
|
|
2271
|
+
convertRawPropertyValue(property, value) {
|
|
2272
|
+
try {
|
|
2273
|
+
switch (property.key) {
|
|
2274
|
+
case types_2.CommandType.CMD_SET_AUDIO_MUTE_RECORD:
|
|
2275
|
+
return value !== undefined ? (value === "1" ? true : false) : false;
|
|
2276
|
+
case types_2.CommandType.CMD_CAMERA_GARAGE_DOOR_STATUS:
|
|
2277
|
+
if (value != undefined) {
|
|
2278
|
+
const status = Number.parseInt(value);
|
|
2279
|
+
if (status >= 0) {
|
|
2280
|
+
if (property.name === types_1.PropertyName.DeviceDoor1Open) {
|
|
2281
|
+
return (status & types_1.GarageDoorState.A_OPENED) === types_1.GarageDoorState.A_OPENED;
|
|
2282
|
+
}
|
|
2283
|
+
else if (property.name === types_1.PropertyName.DeviceDoor2Open) {
|
|
2284
|
+
return (status & types_1.GarageDoorState.B_OPENED) === types_1.GarageDoorState.B_OPENED;
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
return false;
|
|
2289
|
+
case types_2.CommandType.CMD_CAMERA_GARAGE_DOOR_SENSORS:
|
|
2290
|
+
if (value != undefined) {
|
|
2291
|
+
const sensorsData = value;
|
|
2292
|
+
if (property.name === types_1.PropertyName.DeviceDoorSensor1BatteryLevel) {
|
|
2293
|
+
if (sensorsData?.data?.door_1?.power !== undefined && sensorsData?.data?.door_1?.power > 1) {
|
|
2294
|
+
this.updateProperty(types_1.PropertyName.DeviceDoorSensor1LowBattery, false);
|
|
2295
|
+
}
|
|
2296
|
+
return sensorsData?.data?.door_1?.power !== undefined ? sensorsData?.data?.door_1?.power : 0;
|
|
2297
|
+
}
|
|
2298
|
+
else if (property.name === types_1.PropertyName.DeviceDoorSensor2BatteryLevel) {
|
|
2299
|
+
if (sensorsData?.data?.door_2?.power !== undefined && sensorsData?.data?.door_2?.power > 1) {
|
|
2300
|
+
this.updateProperty(types_1.PropertyName.DeviceDoorSensor1LowBattery, false);
|
|
2301
|
+
}
|
|
2302
|
+
return sensorsData?.data?.door_2?.power !== undefined ? sensorsData?.data?.door_2?.power : 0;
|
|
2303
|
+
}
|
|
2304
|
+
else if (property.name === types_1.PropertyName.DeviceDoorSensor1MacAddress) {
|
|
2305
|
+
return sensorsData?.data?.door_1?.mac_address !== undefined ? sensorsData?.data?.door_1?.mac_address : "";
|
|
2306
|
+
}
|
|
2307
|
+
else if (property.name === types_1.PropertyName.DeviceDoorSensor2MacAddress) {
|
|
2308
|
+
return sensorsData?.data?.door_2?.mac_address !== undefined ? sensorsData?.data?.door_2?.mac_address : "";
|
|
2309
|
+
}
|
|
2310
|
+
else if (property.name === types_1.PropertyName.DeviceDoorSensor1Name) {
|
|
2311
|
+
return sensorsData?.data?.door_1?.name !== undefined ? sensorsData?.data?.door_1?.name : "";
|
|
2312
|
+
}
|
|
2313
|
+
else if (property.name === types_1.PropertyName.DeviceDoorSensor2Name) {
|
|
2314
|
+
return sensorsData?.data?.door_2?.name !== undefined ? sensorsData?.data?.door_2?.name : "";
|
|
2315
|
+
}
|
|
2316
|
+
else if (property.name === types_1.PropertyName.DeviceDoorSensor1SerialNumber) {
|
|
2317
|
+
return sensorsData?.data?.door_1?.sn !== undefined ? sensorsData?.data?.door_1?.sn : "";
|
|
2318
|
+
}
|
|
2319
|
+
else if (property.name === types_1.PropertyName.DeviceDoorSensor2SerialNumber) {
|
|
2320
|
+
return sensorsData?.data?.door_2?.sn !== undefined ? sensorsData?.data?.door_2?.sn : "";
|
|
2321
|
+
}
|
|
2322
|
+
else if (property.name === types_1.PropertyName.DeviceDoorSensor1Version) {
|
|
2323
|
+
return sensorsData?.data?.door_1?.version !== undefined ? sensorsData?.data?.door_1?.version : "";
|
|
2324
|
+
}
|
|
2325
|
+
else if (property.name === types_1.PropertyName.DeviceDoorSensor2Version) {
|
|
2326
|
+
return sensorsData?.data?.door_2?.version !== undefined ? sensorsData?.data?.door_2?.version : "";
|
|
2327
|
+
}
|
|
2328
|
+
else if (property.name === types_1.PropertyName.DeviceDoorControlWarning) {
|
|
2329
|
+
return sensorsData?.data?.door_1?.playalarm !== undefined ? sensorsData?.data?.door_1?.playalarm === 1 ? true : false : false;
|
|
2330
|
+
}
|
|
2331
|
+
else if (property.name === types_1.PropertyName.DeviceDoorSensor1Status) {
|
|
2332
|
+
return sensorsData?.data?.door_1?.power !== undefined ? sensorsData?.data?.door_1?.power >= 1 && sensorsData?.data?.door_1?.sn !== "" ? 1 : 0 : 0;
|
|
2333
|
+
}
|
|
2334
|
+
else if (property.name === types_1.PropertyName.DeviceDoorSensor2Status) {
|
|
2335
|
+
return sensorsData?.data?.door_2?.power !== undefined ? sensorsData?.data?.door_2?.power >= 1 && sensorsData?.data?.door_2?.sn !== "" ? 1 : 0 : 0;
|
|
2336
|
+
}
|
|
2337
|
+
}
|
|
2338
|
+
break;
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2341
|
+
catch (err) {
|
|
2342
|
+
const error = (0, error_2.ensureError)(err);
|
|
2343
|
+
this.log.error("Convert Error", { property: property, value: value, error: error });
|
|
2344
|
+
}
|
|
2345
|
+
return super.convertRawPropertyValue(property, value);
|
|
2346
|
+
}
|
|
2347
|
+
processPushNotification(message, eventDurationSeconds) {
|
|
2348
|
+
super.processPushNotification(message, eventDurationSeconds);
|
|
2349
|
+
if (message.type !== undefined && message.event_type !== undefined) {
|
|
2350
|
+
if (message.device_sn === this.getSerial()) {
|
|
2351
|
+
try {
|
|
2352
|
+
if (!(0, utils_3.isEmpty)(message.pic_url)) {
|
|
2353
|
+
(0, utils_1.getImage)(this.api, this.getSerial(), message.pic_url).then((image) => {
|
|
2354
|
+
if (image.data.length > 0) {
|
|
2355
|
+
this.updateProperty(types_1.PropertyName.DevicePicture, image);
|
|
2356
|
+
}
|
|
2357
|
+
}).catch((err) => {
|
|
2358
|
+
const error = (0, error_2.ensureError)(err);
|
|
2359
|
+
this.log.debug(`GarageDoorPushEvent - Device: ${message.device_sn} - Get picture - Error`, error);
|
|
2360
|
+
});
|
|
2361
|
+
}
|
|
2362
|
+
switch (message.event_type) {
|
|
2363
|
+
case types_3.GarageDoorPushEvent.CLOSED_DOOR_BY_APP:
|
|
2364
|
+
case types_3.GarageDoorPushEvent.CLOSED_DOOR_WITHOUT_APP:
|
|
2365
|
+
case types_3.GarageDoorPushEvent.TIMEOUT_CLOSED_DOOR:
|
|
2366
|
+
if (message.door_id === 1) {
|
|
2367
|
+
this.updateProperty(types_1.PropertyName.DeviceDoor1Open, false);
|
|
2368
|
+
}
|
|
2369
|
+
else if (message.door_id === 2) {
|
|
2370
|
+
this.updateProperty(types_1.PropertyName.DeviceDoor2Open, false);
|
|
2371
|
+
}
|
|
2372
|
+
break;
|
|
2373
|
+
case types_3.GarageDoorPushEvent.OPEN_DOOR_BY_APP:
|
|
2374
|
+
case types_3.GarageDoorPushEvent.OPEN_DOOR_WITHOUT_APP:
|
|
2375
|
+
case types_3.GarageDoorPushEvent.TIMEOUT_DOOR_OPEN_WARNING:
|
|
2376
|
+
case types_3.GarageDoorPushEvent.TIMEOUT_DOOR_OPEN_WARNING_MINUTES:
|
|
2377
|
+
if (message.door_id === 1) {
|
|
2378
|
+
this.updateProperty(types_1.PropertyName.DeviceDoor1Open, true);
|
|
2379
|
+
}
|
|
2380
|
+
else if (message.door_id === 2) {
|
|
2381
|
+
this.updateProperty(types_1.PropertyName.DeviceDoor2Open, true);
|
|
2382
|
+
}
|
|
2383
|
+
break;
|
|
2384
|
+
case types_3.GarageDoorPushEvent.LOW_BATTERY:
|
|
2385
|
+
//TODO: Check if low battery status resets to false after battery change
|
|
2386
|
+
if (message.door_id === 1) {
|
|
2387
|
+
this.updateProperty(types_1.PropertyName.DeviceDoorSensor1LowBattery, true);
|
|
2388
|
+
}
|
|
2389
|
+
else if (message.door_id === 2) {
|
|
2390
|
+
this.updateProperty(types_1.PropertyName.DeviceDoorSensor2LowBattery, true);
|
|
2391
|
+
}
|
|
2392
|
+
break;
|
|
2393
|
+
default:
|
|
2394
|
+
this.log.debug("Unhandled GarageDoor push event", message);
|
|
2395
|
+
break;
|
|
2396
|
+
}
|
|
2397
|
+
}
|
|
2398
|
+
catch (err) {
|
|
2399
|
+
const error = (0, error_2.ensureError)(err);
|
|
2400
|
+
this.log.debug(`GarageDoorPushEvent - Device: ${message.device_sn} Error`, error);
|
|
2401
|
+
}
|
|
2402
|
+
}
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
exports.GarageCamera = GarageCamera;
|
|
2036
2407
|
class Sensor extends Device {
|
|
2037
2408
|
static async getInstance(api, device) {
|
|
2038
2409
|
return new Sensor(api, device);
|
|
@@ -2067,8 +2438,9 @@ class EntrySensor extends Sensor {
|
|
|
2067
2438
|
this.updateRawProperty(types_2.CommandType.CMD_ENTRY_SENSOR_STATUS, message.sensor_open ? "1" : "0");
|
|
2068
2439
|
}
|
|
2069
2440
|
}
|
|
2070
|
-
catch (
|
|
2071
|
-
|
|
2441
|
+
catch (err) {
|
|
2442
|
+
const error = (0, error_2.ensureError)(err);
|
|
2443
|
+
this.log.debug(`CusPushEvent.DOOR_SENSOR - Device: ${message.device_sn} Error`, error);
|
|
2072
2444
|
}
|
|
2073
2445
|
}
|
|
2074
2446
|
}
|
|
@@ -2082,6 +2454,7 @@ class EntrySensor extends Sensor {
|
|
|
2082
2454
|
}
|
|
2083
2455
|
exports.EntrySensor = EntrySensor;
|
|
2084
2456
|
class MotionSensor extends Sensor {
|
|
2457
|
+
static MOTION_COOLDOWN_MS = 120000;
|
|
2085
2458
|
//TODO: CMD_MOTION_SENSOR_ENABLE_LED = 1607
|
|
2086
2459
|
//TODO: CMD_MOTION_SENSOR_ENTER_USER_TEST_MODE = 1613
|
|
2087
2460
|
//TODO: CMD_MOTION_SENSOR_EXIT_USER_TEST_MODE = 1610
|
|
@@ -2134,16 +2507,17 @@ class MotionSensor extends Sensor {
|
|
|
2134
2507
|
this.eventTimeouts.delete(types_1.DeviceEvent.MotionDetected);
|
|
2135
2508
|
}, eventDurationSeconds * 1000));
|
|
2136
2509
|
}
|
|
2137
|
-
catch (
|
|
2138
|
-
|
|
2510
|
+
catch (err) {
|
|
2511
|
+
const error = (0, error_2.ensureError)(err);
|
|
2512
|
+
this.log.debug(`CusPushEvent.MOTION_SENSOR_PIR - Device: ${message.device_sn} Error`, error);
|
|
2139
2513
|
}
|
|
2140
2514
|
}
|
|
2141
2515
|
}
|
|
2142
2516
|
}
|
|
2143
2517
|
}
|
|
2144
|
-
MotionSensor.MOTION_COOLDOWN_MS = 120000;
|
|
2145
2518
|
exports.MotionSensor = MotionSensor;
|
|
2146
2519
|
class Lock extends Device {
|
|
2520
|
+
static VERSION_CODE_LOCKV12 = 18;
|
|
2147
2521
|
static async getInstance(api, device) {
|
|
2148
2522
|
return new Lock(api, device);
|
|
2149
2523
|
}
|
|
@@ -2273,8 +2647,9 @@ class Lock extends Device {
|
|
|
2273
2647
|
break;
|
|
2274
2648
|
}
|
|
2275
2649
|
}
|
|
2276
|
-
catch (
|
|
2277
|
-
|
|
2650
|
+
catch (err) {
|
|
2651
|
+
const error = (0, error_2.ensureError)(err);
|
|
2652
|
+
this.log.debug(`LockEvent - Device: ${deviceSN} Error`, error);
|
|
2278
2653
|
}
|
|
2279
2654
|
}
|
|
2280
2655
|
}
|
|
@@ -2420,6 +2795,12 @@ class Lock extends Device {
|
|
|
2420
2795
|
ssbytes.write(this.getCurrentTimeInSeconds());
|
|
2421
2796
|
return ssbytes.getData();
|
|
2422
2797
|
}
|
|
2798
|
+
static hexTime = function (time) {
|
|
2799
|
+
const buf = Buffer.allocUnsafe(2);
|
|
2800
|
+
buf.writeUint8(Number.parseInt(time.split(":")[0]));
|
|
2801
|
+
buf.writeUint8(Number.parseInt(time.split(":")[1]));
|
|
2802
|
+
return buf.readUInt16BE().toString(16).padStart(4, "0");
|
|
2803
|
+
};
|
|
2423
2804
|
static encodeCmdSetLockParamAutoLockSchedule(enabled, schedule_start, schedule_end) {
|
|
2424
2805
|
const ssbytes = new utils_1.SmartSafeByteWriter();
|
|
2425
2806
|
ssbytes.write(this.getUint16BEBuffer(types_2.CommandType.CMD_SMARTLOCK_AUTO_LOCK_SCHEDULE));
|
|
@@ -2460,13 +2841,6 @@ class Lock extends Device {
|
|
|
2460
2841
|
return ssbytes.getData();
|
|
2461
2842
|
}
|
|
2462
2843
|
}
|
|
2463
|
-
Lock.VERSION_CODE_LOCKV12 = 18;
|
|
2464
|
-
Lock.hexTime = function (time) {
|
|
2465
|
-
const buf = Buffer.allocUnsafe(2);
|
|
2466
|
-
buf.writeUint8(Number.parseInt(time.split(":")[0]));
|
|
2467
|
-
buf.writeUint8(Number.parseInt(time.split(":")[1]));
|
|
2468
|
-
return buf.readUInt16BE().toString(16).padStart(4, "0");
|
|
2469
|
-
};
|
|
2470
2844
|
exports.Lock = Lock;
|
|
2471
2845
|
class Keypad extends Device {
|
|
2472
2846
|
//TODO: CMD_KEYPAD_BATTERY_CHARGER_STATE = 1655
|
|
@@ -2498,14 +2872,28 @@ class Keypad extends Device {
|
|
|
2498
2872
|
return value !== undefined ? (value === "0" || value === "2" ? false : true) : false;
|
|
2499
2873
|
}
|
|
2500
2874
|
}
|
|
2501
|
-
catch (
|
|
2502
|
-
|
|
2875
|
+
catch (err) {
|
|
2876
|
+
const error = (0, error_2.ensureError)(err);
|
|
2877
|
+
this.log.error("Convert Error", { property: property, value: value, error: error });
|
|
2503
2878
|
}
|
|
2504
2879
|
return super.convertRawPropertyValue(property, value);
|
|
2505
2880
|
}
|
|
2506
2881
|
}
|
|
2507
2882
|
exports.Keypad = Keypad;
|
|
2508
2883
|
class SmartSafe extends Device {
|
|
2884
|
+
static IV = "052E19EB3F880512E99EBB684D4DC1FE";
|
|
2885
|
+
static DATA_HEADER = [-1, 9];
|
|
2886
|
+
static VERSION_CODE = 1;
|
|
2887
|
+
static PUSH_NOTIFICATION_POSITION = {
|
|
2888
|
+
[types_1.PropertyName.DeviceNotificationUnlockByKey]: 0,
|
|
2889
|
+
[types_1.PropertyName.DeviceNotificationUnlockByPIN]: 1,
|
|
2890
|
+
[types_1.PropertyName.DeviceNotificationUnlockByFingerprint]: 2,
|
|
2891
|
+
[types_1.PropertyName.DeviceNotificationUnlockByApp]: 3,
|
|
2892
|
+
[types_1.PropertyName.DeviceNotificationDualUnlock]: 4,
|
|
2893
|
+
[types_1.PropertyName.DeviceNotificationDualLock]: 5,
|
|
2894
|
+
[types_1.PropertyName.DeviceNotificationWrongTryProtect]: 6,
|
|
2895
|
+
[types_1.PropertyName.DeviceNotificationJammed]: 7,
|
|
2896
|
+
};
|
|
2509
2897
|
static async getInstance(api, device) {
|
|
2510
2898
|
return new SmartSafe(api, device);
|
|
2511
2899
|
}
|
|
@@ -2635,8 +3023,9 @@ class SmartSafe extends Device {
|
|
|
2635
3023
|
return value !== undefined ? ((Number.parseInt(value) >> SmartSafe.PUSH_NOTIFICATION_POSITION[property.name]) & 1) === 1 : booleanProperty.default !== undefined ? booleanProperty.default : false;
|
|
2636
3024
|
}
|
|
2637
3025
|
}
|
|
2638
|
-
catch (
|
|
2639
|
-
|
|
3026
|
+
catch (err) {
|
|
3027
|
+
const error = (0, error_2.ensureError)(err);
|
|
3028
|
+
this.log.error("Convert Error", { property: property, value: value, error: error });
|
|
2640
3029
|
}
|
|
2641
3030
|
return super.convertRawPropertyValue(property, value);
|
|
2642
3031
|
}
|
|
@@ -2754,8 +3143,9 @@ class SmartSafe extends Device {
|
|
|
2754
3143
|
break;
|
|
2755
3144
|
}
|
|
2756
3145
|
}
|
|
2757
|
-
catch (
|
|
2758
|
-
|
|
3146
|
+
catch (err) {
|
|
3147
|
+
const error = (0, error_2.ensureError)(err);
|
|
3148
|
+
this.log.debug(`LockEvent - Device: ${message.device_sn} Error`, error);
|
|
2759
3149
|
}
|
|
2760
3150
|
}
|
|
2761
3151
|
}
|
|
@@ -2797,19 +3187,6 @@ class SmartSafe extends Device {
|
|
|
2797
3187
|
return this.getPropertyValue(types_1.PropertyName.DeviceLocked);
|
|
2798
3188
|
}
|
|
2799
3189
|
}
|
|
2800
|
-
SmartSafe.IV = "052E19EB3F880512E99EBB684D4DC1FE";
|
|
2801
|
-
SmartSafe.DATA_HEADER = [-1, 9];
|
|
2802
|
-
SmartSafe.VERSION_CODE = 1;
|
|
2803
|
-
SmartSafe.PUSH_NOTIFICATION_POSITION = {
|
|
2804
|
-
[types_1.PropertyName.DeviceNotificationUnlockByKey]: 0,
|
|
2805
|
-
[types_1.PropertyName.DeviceNotificationUnlockByPIN]: 1,
|
|
2806
|
-
[types_1.PropertyName.DeviceNotificationUnlockByFingerprint]: 2,
|
|
2807
|
-
[types_1.PropertyName.DeviceNotificationUnlockByApp]: 3,
|
|
2808
|
-
[types_1.PropertyName.DeviceNotificationDualUnlock]: 4,
|
|
2809
|
-
[types_1.PropertyName.DeviceNotificationDualLock]: 5,
|
|
2810
|
-
[types_1.PropertyName.DeviceNotificationWrongTryProtect]: 6,
|
|
2811
|
-
[types_1.PropertyName.DeviceNotificationJammed]: 7,
|
|
2812
|
-
};
|
|
2813
3190
|
exports.SmartSafe = SmartSafe;
|
|
2814
3191
|
class UnknownDevice extends Device {
|
|
2815
3192
|
static async getInstance(api, device) {
|