eufy-security-client 3.6.0 → 3.7.1
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/.prettierignore/342/200/216 +8 -0
- package/.prettierrc +11 -0
- package/README.md +18 -0
- package/a.ts +61 -0
- package/build/error.js.map +1 -1
- package/build/eufysecurity.d.ts +1 -0
- package/build/eufysecurity.js +721 -224
- package/build/eufysecurity.js.map +1 -1
- package/build/http/api.d.ts +29 -0
- package/build/http/api.js +991 -701
- package/build/http/api.js.map +1 -1
- package/build/http/cache.js.map +1 -1
- package/build/http/const.d.ts +6 -1
- package/build/http/const.js +2044 -7536
- package/build/http/const.js.map +1 -1
- package/build/http/device.d.ts +4 -0
- package/build/http/device.js +1325 -440
- package/build/http/device.js.map +1 -1
- package/build/http/error.js.map +1 -1
- package/build/http/index.js.map +1 -1
- package/build/http/interfaces.d.ts +22 -15
- package/build/http/models.d.ts +2 -1
- package/build/http/parameter.js +74 -63
- package/build/http/parameter.js.map +1 -1
- package/build/http/station.d.ts +20 -2
- package/build/http/station.js +8639 -3566
- package/build/http/station.js.map +1 -1
- package/build/http/types.d.ts +12 -0
- package/build/http/types.js +297 -155
- package/build/http/types.js.map +1 -1
- package/build/http/utils.d.ts +16 -6
- package/build/http/utils.js +335 -208
- package/build/http/utils.js.map +1 -1
- package/build/index.js.map +1 -1
- package/build/interfaces.d.ts +4 -3
- package/build/logging.js +8 -13
- package/build/logging.js.map +1 -1
- package/build/mqtt/interface.d.ts +2 -2
- package/build/mqtt/service.js +12 -3
- package/build/mqtt/service.js.map +1 -1
- package/build/p2p/ble.js +7 -6
- package/build/p2p/ble.js.map +1 -1
- package/build/p2p/error.js.map +1 -1
- package/build/p2p/interfaces.d.ts +41 -6
- package/build/p2p/session.js +1484 -383
- package/build/p2p/session.js.map +1 -1
- package/build/p2p/talkback.js.map +1 -1
- package/build/p2p/types.js +36 -36
- package/build/p2p/types.js.map +1 -1
- package/build/p2p/utils.d.ts +10 -0
- package/build/p2p/utils.js +183 -90
- package/build/p2p/utils.js.map +1 -1
- package/build/push/client.js +15 -4
- package/build/push/client.js.map +1 -1
- package/build/push/error.js.map +1 -1
- package/build/push/interfaces.d.ts +8 -8
- package/build/push/models.js.map +1 -1
- package/build/push/parser.js +6 -2
- package/build/push/parser.js.map +1 -1
- package/build/push/service.js +214 -85
- package/build/push/service.js.map +1 -1
- package/build/push/types.js.map +1 -1
- package/build/push/utils.js.map +1 -1
- package/build/utils.js +7 -15
- package/build/utils.js.map +1 -1
- package/coverage/clover.xml +11133 -13648
- package/coverage/coverage-final.json +20 -30
- package/coverage/lcov-report/error.ts.html +3 -3
- package/coverage/lcov-report/index.html +50 -65
- package/coverage/lcov-report/logging.ts.html +598 -0
- package/coverage/lcov.info +21072 -25751
- package/dont-care.js +101 -0
- package/package.json +9 -5
- package/build/package.json +0 -81
package/build/eufysecurity.js
CHANGED
|
@@ -53,7 +53,6 @@ const _1 = require(".");
|
|
|
53
53
|
const error_2 = require("./http/error");
|
|
54
54
|
const types_3 = require("./push/types");
|
|
55
55
|
const service_2 = require("./mqtt/service");
|
|
56
|
-
const const_1 = require("./http/const");
|
|
57
56
|
const utils_2 = require("./http/utils");
|
|
58
57
|
const logging_1 = require("./logging");
|
|
59
58
|
const typescript_logging_1 = require("typescript-logging");
|
|
@@ -80,7 +79,7 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
80
79
|
push_persistentIds: [],
|
|
81
80
|
login_hash: "",
|
|
82
81
|
version: "",
|
|
83
|
-
httpApi: undefined
|
|
82
|
+
httpApi: undefined,
|
|
84
83
|
};
|
|
85
84
|
connected = false;
|
|
86
85
|
retries = 0;
|
|
@@ -102,7 +101,9 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
102
101
|
}
|
|
103
102
|
async _initializeInternals() {
|
|
104
103
|
if (this.config.logging) {
|
|
105
|
-
if (this.config.logging.level !== undefined &&
|
|
104
|
+
if (this.config.logging.level !== undefined &&
|
|
105
|
+
typeof this.config.logging.level === "number" &&
|
|
106
|
+
Object.values(typescript_logging_1.LogLevel).includes(this.config.logging.level))
|
|
106
107
|
(0, logging_1.setLoggingLevel)("all", this.config.logging.level);
|
|
107
108
|
if (this.config.logging.categories !== undefined && Array.isArray(this.config.logging.categories)) {
|
|
108
109
|
for (const category of this.config.logging.categories) {
|
|
@@ -147,7 +148,7 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
147
148
|
}
|
|
148
149
|
if (this.config.deviceConfig === undefined) {
|
|
149
150
|
this.config.deviceConfig = {
|
|
150
|
-
simultaneousDetections: true
|
|
151
|
+
simultaneousDetections: true,
|
|
151
152
|
};
|
|
152
153
|
}
|
|
153
154
|
if (this.config.persistentDir === undefined) {
|
|
@@ -176,8 +177,13 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
176
177
|
try {
|
|
177
178
|
if (this.persistentData.version !== _1.libVersion) {
|
|
178
179
|
const currentVersion = Number.parseFloat((0, utils_1.removeLastChar)(_1.libVersion, "."));
|
|
179
|
-
const previousVersion = this.persistentData.version !== "" && this.persistentData.version !== undefined
|
|
180
|
-
|
|
180
|
+
const previousVersion = this.persistentData.version !== "" && this.persistentData.version !== undefined
|
|
181
|
+
? Number.parseFloat((0, utils_1.removeLastChar)(this.persistentData.version, "."))
|
|
182
|
+
: 0;
|
|
183
|
+
logging_1.rootMainLogger.debug("Handling of driver update", {
|
|
184
|
+
currentVersion: currentVersion,
|
|
185
|
+
previousVersion: previousVersion,
|
|
186
|
+
});
|
|
181
187
|
if (previousVersion < currentVersion) {
|
|
182
188
|
this.persistentData = (0, utils_1.handleUpdate)(this.persistentData, previousVersion);
|
|
183
189
|
this.persistentData.version = _1.libVersion;
|
|
@@ -193,8 +199,7 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
193
199
|
this.config.trustedDeviceName = this.persistentData.fallbackTrustedDeviceName;
|
|
194
200
|
}
|
|
195
201
|
else {
|
|
196
|
-
|
|
197
|
-
this.persistentData.fallbackTrustedDeviceName = const_1.PhoneModels[rnd];
|
|
202
|
+
this.persistentData.fallbackTrustedDeviceName = (0, utils_2.getRandomPhoneModel)();
|
|
198
203
|
this.config.trustedDeviceName = this.persistentData.fallbackTrustedDeviceName;
|
|
199
204
|
}
|
|
200
205
|
}
|
|
@@ -212,13 +217,19 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
212
217
|
this.persistentData.cloud_token_expiration = 0;
|
|
213
218
|
this.persistentData.httpApi = undefined;
|
|
214
219
|
}
|
|
215
|
-
if (this.persistentData.country !== undefined &&
|
|
220
|
+
if (this.persistentData.country !== undefined &&
|
|
221
|
+
this.persistentData.country !== "" &&
|
|
222
|
+
this.persistentData.country !== this.config.country) {
|
|
216
223
|
logging_1.rootMainLogger.info("Country property changed, invalidate saved cloud token.");
|
|
217
224
|
this.persistentData.cloud_token = "";
|
|
218
225
|
this.persistentData.cloud_token_expiration = 0;
|
|
219
226
|
this.persistentData.httpApi = undefined;
|
|
220
227
|
}
|
|
221
|
-
if (this.persistentData.httpApi !== undefined &&
|
|
228
|
+
if (this.persistentData.httpApi !== undefined &&
|
|
229
|
+
(this.persistentData.httpApi.clientPrivateKey === undefined ||
|
|
230
|
+
this.persistentData.httpApi.clientPrivateKey === "" ||
|
|
231
|
+
this.persistentData.httpApi.serverPublicKey === undefined ||
|
|
232
|
+
this.persistentData.httpApi.serverPublicKey === "")) {
|
|
222
233
|
logging_1.rootMainLogger.debug("Incomplete persistent data for v2 encrypted cloud api communication. Invalidate authenticated session data.");
|
|
223
234
|
this.persistentData.cloud_token = "";
|
|
224
235
|
this.persistentData.cloud_token_expiration = 0;
|
|
@@ -236,8 +247,14 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
236
247
|
this.api.on("auth token invalidated", () => this.onAuthTokenInvalidated());
|
|
237
248
|
this.api.on("tfa request", () => this.onTfaRequest());
|
|
238
249
|
this.api.on("connection error", (error) => this.onAPIConnectionError(error));
|
|
239
|
-
if (this.persistentData.cloud_token &&
|
|
240
|
-
|
|
250
|
+
if (this.persistentData.cloud_token &&
|
|
251
|
+
this.persistentData.cloud_token != "" &&
|
|
252
|
+
this.persistentData.cloud_token_expiration) {
|
|
253
|
+
logging_1.rootMainLogger.debug("Load previous token", {
|
|
254
|
+
token: this.persistentData.cloud_token,
|
|
255
|
+
tokenExpiration: this.persistentData.cloud_token_expiration,
|
|
256
|
+
persistentHttpApi: this.persistentData.httpApi,
|
|
257
|
+
});
|
|
241
258
|
this.api.setToken(this.persistentData.cloud_token);
|
|
242
259
|
this.api.setTokenExpiration(new Date(this.persistentData.cloud_token_expiration));
|
|
243
260
|
}
|
|
@@ -286,14 +303,17 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
286
303
|
this.emit("mqtt close");
|
|
287
304
|
});
|
|
288
305
|
this.mqttService.on("lock message", (message) => {
|
|
289
|
-
this.getDevice(message.data.data.deviceSn)
|
|
306
|
+
this.getDevice(message.data.data.deviceSn)
|
|
307
|
+
.then((device) => {
|
|
290
308
|
device.processMQTTNotification(message.data.data, this.config.eventDurationSeconds);
|
|
291
|
-
})
|
|
309
|
+
})
|
|
310
|
+
.catch((err) => {
|
|
292
311
|
const error = (0, error_1.ensureError)(err);
|
|
293
312
|
if (!(error instanceof error_1.DeviceNotFoundError)) {
|
|
294
313
|
logging_1.rootMainLogger.error("Lock MQTT Message Error", { error: (0, utils_1.getError)(error) });
|
|
295
314
|
}
|
|
296
|
-
})
|
|
315
|
+
})
|
|
316
|
+
.finally(() => {
|
|
297
317
|
this.emit("mqtt lock message", message);
|
|
298
318
|
});
|
|
299
319
|
});
|
|
@@ -350,9 +370,13 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
350
370
|
await this.stationsLoaded;
|
|
351
371
|
if (Object.keys(this.stations).includes(hub.station_sn)) {
|
|
352
372
|
this.stations[hub.station_sn].update(hub);
|
|
353
|
-
if (!this.stations[hub.station_sn].isConnected() &&
|
|
373
|
+
if (!this.stations[hub.station_sn].isConnected() &&
|
|
374
|
+
!this.stations[hub.station_sn].isEnergySavingDevice() &&
|
|
375
|
+
this.stations[hub.station_sn].isP2PConnectableDevice()) {
|
|
354
376
|
this.stations[hub.station_sn].setConnectionType(this.config.p2pConnectionSetup);
|
|
355
|
-
logging_1.rootMainLogger.debug(`Updating station cloud data - initiate station connection to get local data over p2p`, {
|
|
377
|
+
logging_1.rootMainLogger.debug(`Updating station cloud data - initiate station connection to get local data over p2p`, {
|
|
378
|
+
stationSN: hub.station_sn,
|
|
379
|
+
});
|
|
356
380
|
this.stations[hub.station_sn].connect();
|
|
357
381
|
}
|
|
358
382
|
}
|
|
@@ -421,11 +445,14 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
421
445
|
if (this.devicesLoaded)
|
|
422
446
|
await this.devicesLoaded;
|
|
423
447
|
for (const device of Object.values(this.devices)) {
|
|
424
|
-
if ((device.getStationSerial() === stationSN && device.getChannel() === channel) ||
|
|
448
|
+
if ((device.getStationSerial() === stationSN && device.getChannel() === channel) ||
|
|
449
|
+
(device.getStationSerial() === stationSN && device.getSerial() === stationSN)) {
|
|
425
450
|
return device;
|
|
426
451
|
}
|
|
427
452
|
}
|
|
428
|
-
throw new error_1.DeviceNotFoundError("No device with passed channel found on station", {
|
|
453
|
+
throw new error_1.DeviceNotFoundError("No device with passed channel found on station", {
|
|
454
|
+
context: { station: stationSN, channel: channel },
|
|
455
|
+
});
|
|
429
456
|
}
|
|
430
457
|
async getStations() {
|
|
431
458
|
if (this.stationsLoaded)
|
|
@@ -525,6 +552,7 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
525
552
|
station.on("image download", (station, file, image) => this.onStationImageDownload(station, file, image));
|
|
526
553
|
station.on("database query latest", (station, returnCode, data) => this.onStationDatabaseQueryLatest(station, returnCode, data));
|
|
527
554
|
station.on("database query local", (station, returnCode, data) => this.onStationDatabaseQueryLocal(station, returnCode, data));
|
|
555
|
+
station.on("database query by date", (station, returnCode, data) => this.onStationDatabaseQueryByDate(station, returnCode, data));
|
|
528
556
|
station.on("database count by date", (station, returnCode, data) => this.onStationDatabaseCountByDate(station, returnCode, data));
|
|
529
557
|
station.on("database delete", (station, returnCode, failedIds) => this.onStationDatabaseDelete(station, returnCode, failedIds));
|
|
530
558
|
station.on("sensor status", (station, channel, status) => this.onStationSensorStatus(station, channel, status));
|
|
@@ -551,9 +579,11 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
551
579
|
}
|
|
552
580
|
for (const stationSN of stationsSNs) {
|
|
553
581
|
if (!newStationsSNs.includes(stationSN)) {
|
|
554
|
-
this.getStation(stationSN)
|
|
582
|
+
this.getStation(stationSN)
|
|
583
|
+
.then((station) => {
|
|
555
584
|
this.removeStation(station);
|
|
556
|
-
})
|
|
585
|
+
})
|
|
586
|
+
.catch((err) => {
|
|
557
587
|
const error = (0, error_1.ensureError)(err);
|
|
558
588
|
logging_1.rootMainLogger.error("Error removing station", { error: (0, utils_1.getError)(error), stationSN: stationSN });
|
|
559
589
|
});
|
|
@@ -561,14 +591,18 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
561
591
|
}
|
|
562
592
|
}
|
|
563
593
|
refreshP2PData(station) {
|
|
564
|
-
if (station.isStation() ||
|
|
594
|
+
if (station.isStation() ||
|
|
595
|
+
(device_1.Device.isCamera(station.getDeviceType()) && !device_1.Device.isWiredDoorbell(station.getDeviceType())) ||
|
|
596
|
+
device_1.Device.isSmartSafe(station.getDeviceType())) {
|
|
565
597
|
station.getCameraInfo();
|
|
566
598
|
}
|
|
567
599
|
if (device_1.Device.isLock(station.getDeviceType())) {
|
|
568
600
|
station.getLockParameters();
|
|
569
601
|
station.getLockStatus();
|
|
570
602
|
}
|
|
571
|
-
if (station.isStation() ||
|
|
603
|
+
if (station.isStation() ||
|
|
604
|
+
(station.hasProperty(types_1.PropertyName.StationSdStatus) &&
|
|
605
|
+
station.getPropertyValue(types_1.PropertyName.StationSdStatus) !== types_2.TFCardStatus.REMOVE)) {
|
|
572
606
|
station.getStorageInfoEx();
|
|
573
607
|
}
|
|
574
608
|
}
|
|
@@ -589,12 +623,14 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
589
623
|
onStationClose(station) {
|
|
590
624
|
this.emit("station close", station);
|
|
591
625
|
for (const device_sn of this.cameraStationLivestreamTimeout.keys()) {
|
|
592
|
-
this.getDevice(device_sn)
|
|
626
|
+
this.getDevice(device_sn)
|
|
627
|
+
.then((device) => {
|
|
593
628
|
if (device !== null && device.getStationSerial() === station.getSerial()) {
|
|
594
629
|
clearTimeout(this.cameraStationLivestreamTimeout.get(device_sn));
|
|
595
630
|
this.cameraStationLivestreamTimeout.delete(device_sn);
|
|
596
631
|
}
|
|
597
|
-
})
|
|
632
|
+
})
|
|
633
|
+
.catch((err) => {
|
|
598
634
|
const error = (0, error_1.ensureError)(err);
|
|
599
635
|
logging_1.rootMainLogger.error(`Station close Error`, { error: (0, utils_1.getError)(error), stationSN: station.getSerial() });
|
|
600
636
|
});
|
|
@@ -716,15 +752,22 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
716
752
|
}
|
|
717
753
|
Promise.all(promises).then((devices) => {
|
|
718
754
|
devices.forEach((device) => {
|
|
719
|
-
this.getStation(device.getStationSerial())
|
|
755
|
+
this.getStation(device.getStationSerial())
|
|
756
|
+
.then((station) => {
|
|
720
757
|
if (!station.isConnected() && station.isP2PConnectableDevice()) {
|
|
721
758
|
station.setConnectionType(this.config.p2pConnectionSetup);
|
|
722
|
-
logging_1.rootMainLogger.debug(`Initiate first station connection to get data over p2p`, {
|
|
759
|
+
logging_1.rootMainLogger.debug(`Initiate first station connection to get data over p2p`, {
|
|
760
|
+
stationSN: station.getSerial(),
|
|
761
|
+
});
|
|
723
762
|
station.connect();
|
|
724
763
|
}
|
|
725
|
-
})
|
|
764
|
+
})
|
|
765
|
+
.catch((err) => {
|
|
726
766
|
const error = (0, error_1.ensureError)(err);
|
|
727
|
-
logging_1.rootMainLogger.error("Error trying to connect to station afte device loaded", {
|
|
767
|
+
logging_1.rootMainLogger.error("Error trying to connect to station afte device loaded", {
|
|
768
|
+
error: (0, utils_1.getError)(error),
|
|
769
|
+
deviceSN: device.getSerial(),
|
|
770
|
+
});
|
|
728
771
|
});
|
|
729
772
|
});
|
|
730
773
|
this.loadingEmitter.emit("devices loaded");
|
|
@@ -736,9 +779,11 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
736
779
|
}
|
|
737
780
|
for (const deviceSN of deviceSNs) {
|
|
738
781
|
if (!newDeviceSNs.includes(deviceSN)) {
|
|
739
|
-
this.getDevice(deviceSN)
|
|
782
|
+
this.getDevice(deviceSN)
|
|
783
|
+
.then((device) => {
|
|
740
784
|
this.removeDevice(device);
|
|
741
|
-
})
|
|
785
|
+
})
|
|
786
|
+
.catch((err) => {
|
|
742
787
|
const error = (0, error_1.ensureError)(err);
|
|
743
788
|
logging_1.rootMainLogger.error("Error removing device", { error: (0, utils_1.getError)(error), deviceSN: deviceSN });
|
|
744
789
|
});
|
|
@@ -747,19 +792,21 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
747
792
|
}
|
|
748
793
|
async refreshCloudData() {
|
|
749
794
|
if (this.config.acceptInvitations) {
|
|
750
|
-
await this.processInvitations().catch(err => {
|
|
795
|
+
await this.processInvitations().catch((err) => {
|
|
751
796
|
const error = (0, error_1.ensureError)(err);
|
|
752
797
|
logging_1.rootMainLogger.error("Error in processing invitations", { error: (0, utils_1.getError)(error) });
|
|
753
798
|
});
|
|
754
799
|
}
|
|
755
|
-
await this.api.refreshAllData().catch(err => {
|
|
800
|
+
await this.api.refreshAllData().catch((err) => {
|
|
756
801
|
const error = (0, error_1.ensureError)(err);
|
|
757
802
|
logging_1.rootMainLogger.error("Error during API data refreshing", { error: (0, utils_1.getError)(error) });
|
|
758
803
|
});
|
|
759
804
|
if (this.refreshEufySecurityCloudTimeout !== undefined)
|
|
760
805
|
clearTimeout(this.refreshEufySecurityCloudTimeout);
|
|
761
806
|
if (this.config.pollingIntervalMinutes > 0)
|
|
762
|
-
this.refreshEufySecurityCloudTimeout = setTimeout(() => {
|
|
807
|
+
this.refreshEufySecurityCloudTimeout = setTimeout(() => {
|
|
808
|
+
this.refreshCloudData();
|
|
809
|
+
}, this.config.pollingIntervalMinutes * 60 * 1000);
|
|
763
810
|
else
|
|
764
811
|
logging_1.rootMainLogger.info(`Automatic retrieval of data from the cloud has been deactivated (config pollingIntervalMinutes: ${this.config.pollingIntervalMinutes})`);
|
|
765
812
|
}
|
|
@@ -769,21 +816,21 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
769
816
|
}
|
|
770
817
|
if (this.refreshEufySecurityCloudTimeout !== undefined)
|
|
771
818
|
clearTimeout(this.refreshEufySecurityCloudTimeout);
|
|
772
|
-
Object.keys(this.refreshEufySecurityP2PTimeout).forEach(station_sn => {
|
|
819
|
+
Object.keys(this.refreshEufySecurityP2PTimeout).forEach((station_sn) => {
|
|
773
820
|
clearTimeout(this.refreshEufySecurityP2PTimeout[station_sn]);
|
|
774
821
|
delete this.refreshEufySecurityP2PTimeout[station_sn];
|
|
775
822
|
});
|
|
776
|
-
Object.keys(this.deviceSnoozeTimeout).forEach(device_sn => {
|
|
823
|
+
Object.keys(this.deviceSnoozeTimeout).forEach((device_sn) => {
|
|
777
824
|
clearTimeout(this.deviceSnoozeTimeout[device_sn]);
|
|
778
825
|
delete this.deviceSnoozeTimeout[device_sn];
|
|
779
826
|
});
|
|
780
827
|
this.savePushPersistentIds();
|
|
781
828
|
this.pushService.close();
|
|
782
829
|
this.mqttService.close();
|
|
783
|
-
Object.values(this.stations).forEach(station => {
|
|
830
|
+
Object.values(this.stations).forEach((station) => {
|
|
784
831
|
station.close();
|
|
785
832
|
});
|
|
786
|
-
Object.values(this.devices).forEach(device => {
|
|
833
|
+
Object.values(this.devices).forEach((device) => {
|
|
787
834
|
device.destroy();
|
|
788
835
|
});
|
|
789
836
|
if (this.connected)
|
|
@@ -804,12 +851,13 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
804
851
|
this.pushService.open();
|
|
805
852
|
}
|
|
806
853
|
async connect(options) {
|
|
807
|
-
await this.api
|
|
854
|
+
await this.api
|
|
855
|
+
.login(options)
|
|
808
856
|
.then(async () => {
|
|
809
857
|
if (options?.verifyCode) {
|
|
810
858
|
let trusted = false;
|
|
811
859
|
const trusted_devices = await this.api.listTrustDevice();
|
|
812
|
-
trusted_devices.forEach(trusted_device => {
|
|
860
|
+
trusted_devices.forEach((trusted_device) => {
|
|
813
861
|
if (trusted_device.is_current_device === 1) {
|
|
814
862
|
trusted = true;
|
|
815
863
|
}
|
|
@@ -827,11 +875,17 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
827
875
|
return this.pushService.getPersistentIds();
|
|
828
876
|
}
|
|
829
877
|
updateDeviceProperties(deviceSN, values) {
|
|
830
|
-
this.getDevice(deviceSN)
|
|
878
|
+
this.getDevice(deviceSN)
|
|
879
|
+
.then((device) => {
|
|
831
880
|
device.updateRawProperties(values);
|
|
832
|
-
})
|
|
881
|
+
})
|
|
882
|
+
.catch((err) => {
|
|
833
883
|
const error = (0, error_1.ensureError)(err);
|
|
834
|
-
logging_1.rootMainLogger.error("Update device properties error", {
|
|
884
|
+
logging_1.rootMainLogger.error("Update device properties error", {
|
|
885
|
+
error: (0, utils_1.getError)(error),
|
|
886
|
+
deviceSN: deviceSN,
|
|
887
|
+
values: values,
|
|
888
|
+
});
|
|
835
889
|
});
|
|
836
890
|
}
|
|
837
891
|
async onAPIClose() {
|
|
@@ -869,7 +923,9 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
869
923
|
const device = await this.getDevice(deviceSN);
|
|
870
924
|
const station = await this.getStation(device.getStationSerial());
|
|
871
925
|
if (!device.hasCommand(types_1.CommandName.DeviceStartLivestream))
|
|
872
|
-
throw new error_1.NotSupportedError("This functionality is not implemented or supported by this device", {
|
|
926
|
+
throw new error_1.NotSupportedError("This functionality is not implemented or supported by this device", {
|
|
927
|
+
context: { device: deviceSN, commandName: types_1.CommandName.DeviceStartLivestream },
|
|
928
|
+
});
|
|
873
929
|
const camera = device;
|
|
874
930
|
if (!station.isLiveStreaming(camera)) {
|
|
875
931
|
station.startLivestream(camera);
|
|
@@ -888,7 +944,9 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
888
944
|
const device = await this.getDevice(deviceSN);
|
|
889
945
|
const station = await this.getStation(device.getStationSerial());
|
|
890
946
|
if (!device.hasCommand(types_1.CommandName.DeviceStopLivestream))
|
|
891
|
-
throw new error_1.NotSupportedError("This functionality is not implemented or supported by this device", {
|
|
947
|
+
throw new error_1.NotSupportedError("This functionality is not implemented or supported by this device", {
|
|
948
|
+
context: { device: deviceSN, commandName: types_1.CommandName.DeviceStopLivestream },
|
|
949
|
+
});
|
|
892
950
|
if (station.isConnected() && station.isLiveStreaming(device)) {
|
|
893
951
|
station.stopLivestream(device);
|
|
894
952
|
}
|
|
@@ -924,7 +982,10 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
924
982
|
const token = this.api.getToken();
|
|
925
983
|
const token_expiration = this.api.getTokenExpiration();
|
|
926
984
|
if (!!token && !!token_expiration) {
|
|
927
|
-
logging_1.rootMainLogger.debug("Save cloud token and token expiration", {
|
|
985
|
+
logging_1.rootMainLogger.debug("Save cloud token and token expiration", {
|
|
986
|
+
token: token,
|
|
987
|
+
tokenExpiration: token_expiration,
|
|
988
|
+
});
|
|
928
989
|
this.persistentData.cloud_token = token;
|
|
929
990
|
this.persistentData.cloud_token_expiration = token_expiration.getTime();
|
|
930
991
|
this.writePersistentData();
|
|
@@ -952,7 +1013,7 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
952
1013
|
}
|
|
953
1014
|
async processInvitations() {
|
|
954
1015
|
let refreshCloud = false;
|
|
955
|
-
const invites = await this.api.getInvites().catch(err => {
|
|
1016
|
+
const invites = await this.api.getInvites().catch((err) => {
|
|
956
1017
|
const error = (0, error_1.ensureError)(err);
|
|
957
1018
|
logging_1.rootMainLogger.error("Error getting invites from cloud", { error: (0, utils_1.getError)(error) });
|
|
958
1019
|
return error;
|
|
@@ -961,21 +1022,24 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
961
1022
|
const confirmInvites = [];
|
|
962
1023
|
for (const invite of Object.values(invites)) {
|
|
963
1024
|
const devices = [];
|
|
964
|
-
invite.devices.forEach(device => {
|
|
1025
|
+
invite.devices.forEach((device) => {
|
|
965
1026
|
devices.push(device.device_sn);
|
|
966
1027
|
});
|
|
967
1028
|
if (devices.length > 0) {
|
|
968
1029
|
confirmInvites.push({
|
|
969
1030
|
invite_id: invite.invite_id,
|
|
970
1031
|
station_sn: invite.station_sn,
|
|
971
|
-
device_sns: devices
|
|
1032
|
+
device_sns: devices,
|
|
972
1033
|
});
|
|
973
1034
|
}
|
|
974
1035
|
}
|
|
975
1036
|
if (confirmInvites.length > 0) {
|
|
976
|
-
const result = await this.api.confirmInvites(confirmInvites).catch(err => {
|
|
1037
|
+
const result = await this.api.confirmInvites(confirmInvites).catch((err) => {
|
|
977
1038
|
const error = (0, error_1.ensureError)(err);
|
|
978
|
-
logging_1.rootMainLogger.error("Error in confirmation of invitations", {
|
|
1039
|
+
logging_1.rootMainLogger.error("Error in confirmation of invitations", {
|
|
1040
|
+
error: (0, utils_1.getError)(error),
|
|
1041
|
+
confirmInvites: confirmInvites,
|
|
1042
|
+
});
|
|
979
1043
|
return error;
|
|
980
1044
|
});
|
|
981
1045
|
if (result) {
|
|
@@ -984,20 +1048,22 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
984
1048
|
}
|
|
985
1049
|
}
|
|
986
1050
|
}
|
|
987
|
-
const houseInvites = await this.api.getHouseInviteList().catch(err => {
|
|
1051
|
+
const houseInvites = await this.api.getHouseInviteList().catch((err) => {
|
|
988
1052
|
const error = (0, error_1.ensureError)(err);
|
|
989
1053
|
logging_1.rootMainLogger.error("Error getting house invites from cloud", { error: (0, utils_1.getError)(error) });
|
|
990
1054
|
return error;
|
|
991
1055
|
});
|
|
992
1056
|
if (Object.keys(houseInvites).length > 0) {
|
|
993
1057
|
for (const invite of Object.values(houseInvites)) {
|
|
994
|
-
const result = await this.api.confirmHouseInvite(invite.house_id, invite.id).catch(err => {
|
|
1058
|
+
const result = await this.api.confirmHouseInvite(invite.house_id, invite.id).catch((err) => {
|
|
995
1059
|
const error = (0, error_1.ensureError)(err);
|
|
996
1060
|
logging_1.rootMainLogger.error("Error in confirmation of house invitations", { error: (0, utils_1.getError)(error) });
|
|
997
1061
|
return error;
|
|
998
1062
|
});
|
|
999
1063
|
if (result) {
|
|
1000
|
-
logging_1.rootMainLogger.info(`Accepted received house invitation from ${invite.action_user_email}`, {
|
|
1064
|
+
logging_1.rootMainLogger.info(`Accepted received house invitation from ${invite.action_user_email}`, {
|
|
1065
|
+
invite: invite,
|
|
1066
|
+
});
|
|
1001
1067
|
refreshCloud = true;
|
|
1002
1068
|
}
|
|
1003
1069
|
}
|
|
@@ -1010,55 +1076,81 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1010
1076
|
try {
|
|
1011
1077
|
logging_1.rootMainLogger.debug("Received push message", { message: message });
|
|
1012
1078
|
try {
|
|
1013
|
-
if ((message.type === types_3.ServerPushEvent.INVITE_DEVICE || message.type === types_3.ServerPushEvent.HOUSE_INVITE) &&
|
|
1079
|
+
if ((message.type === types_3.ServerPushEvent.INVITE_DEVICE || message.type === types_3.ServerPushEvent.HOUSE_INVITE) &&
|
|
1080
|
+
this.config.acceptInvitations) {
|
|
1014
1081
|
if (this.isConnected())
|
|
1015
1082
|
this.processInvitations();
|
|
1016
1083
|
}
|
|
1017
1084
|
}
|
|
1018
1085
|
catch (err) {
|
|
1019
1086
|
const error = (0, error_1.ensureError)(err);
|
|
1020
|
-
logging_1.rootMainLogger.error(`Error processing server push notification for device invitation`, {
|
|
1087
|
+
logging_1.rootMainLogger.error(`Error processing server push notification for device invitation`, {
|
|
1088
|
+
error: (0, utils_1.getError)(error),
|
|
1089
|
+
message: message,
|
|
1090
|
+
});
|
|
1021
1091
|
}
|
|
1022
1092
|
try {
|
|
1023
|
-
if (message.type === types_3.ServerPushEvent.REMOVE_DEVICE ||
|
|
1093
|
+
if (message.type === types_3.ServerPushEvent.REMOVE_DEVICE ||
|
|
1094
|
+
message.type === types_3.ServerPushEvent.REMOVE_HOMEBASE ||
|
|
1095
|
+
message.type === types_3.ServerPushEvent.HOUSE_REMOVE) {
|
|
1024
1096
|
if (this.isConnected())
|
|
1025
1097
|
this.refreshCloudData();
|
|
1026
1098
|
}
|
|
1027
1099
|
}
|
|
1028
1100
|
catch (err) {
|
|
1029
1101
|
const error = (0, error_1.ensureError)(err);
|
|
1030
|
-
logging_1.rootMainLogger.error(`Error processing server push notification for device/station/house removal`, {
|
|
1102
|
+
logging_1.rootMainLogger.error(`Error processing server push notification for device/station/house removal`, {
|
|
1103
|
+
error: (0, utils_1.getError)(error),
|
|
1104
|
+
message: message,
|
|
1105
|
+
});
|
|
1031
1106
|
}
|
|
1032
|
-
this.getStations()
|
|
1033
|
-
|
|
1107
|
+
this.getStations()
|
|
1108
|
+
.then((stations) => {
|
|
1109
|
+
stations.forEach((station) => {
|
|
1034
1110
|
try {
|
|
1035
1111
|
station.processPushNotification(message);
|
|
1036
1112
|
}
|
|
1037
1113
|
catch (err) {
|
|
1038
1114
|
const error = (0, error_1.ensureError)(err);
|
|
1039
|
-
logging_1.rootMainLogger.error(`Error processing push notification for station`, {
|
|
1115
|
+
logging_1.rootMainLogger.error(`Error processing push notification for station`, {
|
|
1116
|
+
error: (0, utils_1.getError)(error),
|
|
1117
|
+
stationSN: station.getSerial(),
|
|
1118
|
+
message: message,
|
|
1119
|
+
});
|
|
1040
1120
|
}
|
|
1041
1121
|
});
|
|
1042
|
-
})
|
|
1122
|
+
})
|
|
1123
|
+
.catch((err) => {
|
|
1043
1124
|
const error = (0, error_1.ensureError)(err);
|
|
1044
1125
|
logging_1.rootMainLogger.error("Process push notification for stations", { error: (0, utils_1.getError)(error), message: message });
|
|
1045
1126
|
});
|
|
1046
|
-
this.getDevices()
|
|
1047
|
-
|
|
1048
|
-
|
|
1127
|
+
this.getDevices()
|
|
1128
|
+
.then((devices) => {
|
|
1129
|
+
devices.forEach((device) => {
|
|
1130
|
+
this.getStation(device.getStationSerial())
|
|
1131
|
+
.then((station) => {
|
|
1049
1132
|
try {
|
|
1050
1133
|
device.processPushNotification(station, message, this.config.eventDurationSeconds);
|
|
1051
1134
|
}
|
|
1052
1135
|
catch (err) {
|
|
1053
1136
|
const error = (0, error_1.ensureError)(err);
|
|
1054
|
-
logging_1.rootMainLogger.error(`Error processing push notification for device`, {
|
|
1137
|
+
logging_1.rootMainLogger.error(`Error processing push notification for device`, {
|
|
1138
|
+
error: (0, utils_1.getError)(error),
|
|
1139
|
+
deviceSN: device.getSerial(),
|
|
1140
|
+
message: message,
|
|
1141
|
+
});
|
|
1055
1142
|
}
|
|
1056
|
-
})
|
|
1143
|
+
})
|
|
1144
|
+
.catch((err) => {
|
|
1057
1145
|
const error = (0, error_1.ensureError)(err);
|
|
1058
|
-
logging_1.rootMainLogger.error("Process push notification for devices loading station", {
|
|
1146
|
+
logging_1.rootMainLogger.error("Process push notification for devices loading station", {
|
|
1147
|
+
error: (0, utils_1.getError)(error),
|
|
1148
|
+
message: message,
|
|
1149
|
+
});
|
|
1059
1150
|
});
|
|
1060
1151
|
});
|
|
1061
|
-
})
|
|
1152
|
+
})
|
|
1153
|
+
.catch((err) => {
|
|
1062
1154
|
const error = (0, error_1.ensureError)(err);
|
|
1063
1155
|
logging_1.rootMainLogger.error("Process push notification for devices", { error: (0, utils_1.getError)(error), message: message });
|
|
1064
1156
|
});
|
|
@@ -1072,7 +1164,9 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1072
1164
|
const device = await this.getDevice(deviceSN);
|
|
1073
1165
|
const station = await this.getStation(device.getStationSerial());
|
|
1074
1166
|
if (!device.hasCommand(types_1.CommandName.DeviceStartDownload))
|
|
1075
|
-
throw new error_1.NotSupportedError("This functionality is not implemented or supported by this device", {
|
|
1167
|
+
throw new error_1.NotSupportedError("This functionality is not implemented or supported by this device", {
|
|
1168
|
+
context: { device: deviceSN, commandName: types_1.CommandName.DeviceStartDownload, path: path, cipherID: cipherID },
|
|
1169
|
+
});
|
|
1076
1170
|
if (!station.isDownloading(device)) {
|
|
1077
1171
|
await station.startDownload(device, path, cipherID);
|
|
1078
1172
|
}
|
|
@@ -1084,7 +1178,9 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1084
1178
|
const device = await this.getDevice(deviceSN);
|
|
1085
1179
|
const station = await this.getStation(device.getStationSerial());
|
|
1086
1180
|
if (!device.hasCommand(types_1.CommandName.DeviceCancelDownload))
|
|
1087
|
-
throw new error_1.NotSupportedError("This functionality is not implemented or supported by this device", {
|
|
1181
|
+
throw new error_1.NotSupportedError("This functionality is not implemented or supported by this device", {
|
|
1182
|
+
context: { device: deviceSN, commandName: types_1.CommandName.DeviceCancelDownload },
|
|
1183
|
+
});
|
|
1088
1184
|
if (station.isConnected() && station.isDownloading(device)) {
|
|
1089
1185
|
station.cancelDownload(device);
|
|
1090
1186
|
}
|
|
@@ -1225,7 +1321,7 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1225
1321
|
if (device.isIndoorPanAndTiltCameraS350()) {
|
|
1226
1322
|
station.setNotificationIndoor(device, types_1.IndoorS350NotificationTypes.HUMAN, value);
|
|
1227
1323
|
}
|
|
1228
|
-
else if (device.isFloodLightT8425()) {
|
|
1324
|
+
else if (device.isFloodLightT8425() || device.isCameraC35()) {
|
|
1229
1325
|
station.setNotificationFloodlightT8425(device, types_1.FloodlightT8425NotificationTypes.HUMAN, value);
|
|
1230
1326
|
}
|
|
1231
1327
|
else {
|
|
@@ -1236,7 +1332,7 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1236
1332
|
if (device.isIndoorPanAndTiltCameraS350()) {
|
|
1237
1333
|
station.setNotificationIndoor(device, types_1.IndoorS350NotificationTypes.PET, value);
|
|
1238
1334
|
}
|
|
1239
|
-
else if (device.isFloodLightT8425()) {
|
|
1335
|
+
else if (device.isFloodLightT8425() || device.isCameraC35()) {
|
|
1240
1336
|
station.setNotificationFloodlightT8425(device, types_1.FloodlightT8425NotificationTypes.PET, value);
|
|
1241
1337
|
}
|
|
1242
1338
|
else {
|
|
@@ -1247,7 +1343,7 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1247
1343
|
if (device.isIndoorPanAndTiltCameraS350()) {
|
|
1248
1344
|
station.setNotificationIndoor(device, types_1.IndoorS350NotificationTypes.ALL_OTHER_MOTION, value);
|
|
1249
1345
|
}
|
|
1250
|
-
else if (device.isFloodLightT8425()) {
|
|
1346
|
+
else if (device.isFloodLightT8425() || device.isCameraC35()) {
|
|
1251
1347
|
station.setNotificationFloodlightT8425(device, types_1.FloodlightT8425NotificationTypes.ALL_OTHER_MOTION, value);
|
|
1252
1348
|
}
|
|
1253
1349
|
else {
|
|
@@ -1271,11 +1367,13 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1271
1367
|
}
|
|
1272
1368
|
break;
|
|
1273
1369
|
case types_1.PropertyName.DeviceNotificationVehicle:
|
|
1274
|
-
if (device.isFloodLightT8425()) {
|
|
1370
|
+
if (device.isFloodLightT8425() || device.isCameraC35()) {
|
|
1275
1371
|
station.setNotificationFloodlightT8425(device, types_1.FloodlightT8425NotificationTypes.VEHICLE, value);
|
|
1276
1372
|
}
|
|
1277
1373
|
else {
|
|
1278
|
-
throw new error_2.InvalidPropertyError("Station has no writable property", {
|
|
1374
|
+
throw new error_2.InvalidPropertyError("Station has no writable property", {
|
|
1375
|
+
context: { station: station.getSerial(), propertyName: name, propertyValue: value },
|
|
1376
|
+
});
|
|
1279
1377
|
}
|
|
1280
1378
|
break;
|
|
1281
1379
|
case types_1.PropertyName.DeviceNotificationMotion:
|
|
@@ -1566,6 +1664,9 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1566
1664
|
if (device.isIndoorPanAndTiltCameraS350()) {
|
|
1567
1665
|
station.setMotionDetectionTypeHB3(device, types_1.IndoorS350DetectionTypes.PET_DETECTION, value);
|
|
1568
1666
|
}
|
|
1667
|
+
else if (device.isCameraC35()) {
|
|
1668
|
+
station.setMotionDetectionTypeHB3(device, types_1.EufyCamC35DetectionTypes.PET_DETECTION, value);
|
|
1669
|
+
}
|
|
1569
1670
|
else {
|
|
1570
1671
|
station.setMotionDetectionTypeHB3(device, types_1.HB3DetectionTypes.PET_DETECTION, value);
|
|
1571
1672
|
}
|
|
@@ -1574,6 +1675,9 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1574
1675
|
if (device.isOutdoorPanAndTiltCamera()) {
|
|
1575
1676
|
station.setMotionDetectionTypeHB3(device, types_1.T8170DetectionTypes.VEHICLE_DETECTION, value);
|
|
1576
1677
|
}
|
|
1678
|
+
else if (device.isCameraC35()) {
|
|
1679
|
+
station.setMotionDetectionTypeHB3(device, types_1.EufyCamC35DetectionTypes.VEHICLE_DETECTION, value);
|
|
1680
|
+
}
|
|
1577
1681
|
else {
|
|
1578
1682
|
station.setMotionDetectionTypeHB3(device, types_1.HB3DetectionTypes.VEHICLE_DETECTION, value);
|
|
1579
1683
|
}
|
|
@@ -1585,12 +1689,15 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1585
1689
|
else if (device.isOutdoorPanAndTiltCamera()) {
|
|
1586
1690
|
station.setMotionDetectionTypeHB3(device, types_1.T8170DetectionTypes.ALL_OTHER_MOTION, value);
|
|
1587
1691
|
}
|
|
1588
|
-
else if (device.isSoloCameras()) {
|
|
1692
|
+
else if (device.isSoloCameras() && !device.isCameraC35()) {
|
|
1589
1693
|
station.setMotionDetectionTypeHB3(device, types_1.SoloCameraDetectionTypes.ALL_OTHER_MOTION, value);
|
|
1590
1694
|
}
|
|
1591
1695
|
else if (device.isIndoorPanAndTiltCameraS350()) {
|
|
1592
1696
|
station.setMotionDetectionTypeHB3(device, types_1.IndoorS350DetectionTypes.ALL_OTHER_MOTION, value);
|
|
1593
1697
|
}
|
|
1698
|
+
else if (device.isCameraC35()) {
|
|
1699
|
+
station.setMotionDetectionTypeHB3(device, types_1.EufyCamC35DetectionTypes.ALL_OTHER_MOTION, value);
|
|
1700
|
+
}
|
|
1594
1701
|
else {
|
|
1595
1702
|
station.setMotionDetectionTypeHB3(device, types_1.HB3DetectionTypes.ALL_OTHER_MOTION, value);
|
|
1596
1703
|
}
|
|
@@ -1708,8 +1815,12 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1708
1815
|
break;
|
|
1709
1816
|
default:
|
|
1710
1817
|
if (!Object.values(types_1.PropertyName).includes(name))
|
|
1711
|
-
throw new error_1.ReadOnlyPropertyError("Property is read only", {
|
|
1712
|
-
|
|
1818
|
+
throw new error_1.ReadOnlyPropertyError("Property is read only", {
|
|
1819
|
+
context: { device: deviceSN, propertyName: name, propertyValue: value },
|
|
1820
|
+
});
|
|
1821
|
+
throw new error_2.InvalidPropertyError("Device has no writable property", {
|
|
1822
|
+
context: { device: deviceSN, propertyName: name, propertyValue: value },
|
|
1823
|
+
});
|
|
1713
1824
|
}
|
|
1714
1825
|
}
|
|
1715
1826
|
async setStationProperty(stationSN, name, value) {
|
|
@@ -1773,64 +1884,113 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1773
1884
|
break;
|
|
1774
1885
|
default:
|
|
1775
1886
|
if (!Object.values(types_1.PropertyName).includes(name))
|
|
1776
|
-
throw new error_1.ReadOnlyPropertyError("Property is read only", {
|
|
1777
|
-
|
|
1887
|
+
throw new error_1.ReadOnlyPropertyError("Property is read only", {
|
|
1888
|
+
context: { station: stationSN, propertyName: name, propertyValue: value },
|
|
1889
|
+
});
|
|
1890
|
+
throw new error_2.InvalidPropertyError("Station has no writable property", {
|
|
1891
|
+
context: { station: stationSN, propertyName: name, propertyValue: value },
|
|
1892
|
+
});
|
|
1778
1893
|
}
|
|
1779
1894
|
}
|
|
1780
1895
|
onStartStationLivestream(station, channel, metadata, videostream, audiostream) {
|
|
1781
|
-
this.getStationDevice(station.getSerial(), channel)
|
|
1896
|
+
this.getStationDevice(station.getSerial(), channel)
|
|
1897
|
+
.then((device) => {
|
|
1782
1898
|
this.emit("station livestream start", station, device, metadata, videostream, audiostream);
|
|
1783
|
-
})
|
|
1899
|
+
})
|
|
1900
|
+
.catch((err) => {
|
|
1784
1901
|
const error = (0, error_1.ensureError)(err);
|
|
1785
|
-
logging_1.rootMainLogger.error(`Station start livestream error`, {
|
|
1902
|
+
logging_1.rootMainLogger.error(`Station start livestream error`, {
|
|
1903
|
+
error: (0, utils_1.getError)(error),
|
|
1904
|
+
stationSN: station.getSerial(),
|
|
1905
|
+
channel: channel,
|
|
1906
|
+
metadata: metadata,
|
|
1907
|
+
});
|
|
1786
1908
|
});
|
|
1787
1909
|
}
|
|
1788
1910
|
onStopStationLivestream(station, channel) {
|
|
1789
|
-
this.getStationDevice(station.getSerial(), channel)
|
|
1911
|
+
this.getStationDevice(station.getSerial(), channel)
|
|
1912
|
+
.then((device) => {
|
|
1790
1913
|
this.emit("station livestream stop", station, device);
|
|
1791
|
-
})
|
|
1914
|
+
})
|
|
1915
|
+
.catch((err) => {
|
|
1792
1916
|
const error = (0, error_1.ensureError)(err);
|
|
1793
|
-
logging_1.rootMainLogger.error(`Station stop livestream error`, {
|
|
1917
|
+
logging_1.rootMainLogger.error(`Station stop livestream error`, {
|
|
1918
|
+
error: (0, utils_1.getError)(error),
|
|
1919
|
+
stationSN: station.getSerial(),
|
|
1920
|
+
channel: channel,
|
|
1921
|
+
});
|
|
1794
1922
|
});
|
|
1795
1923
|
}
|
|
1796
1924
|
onErrorStationLivestream(station, channel, origError) {
|
|
1797
|
-
this.getStationDevice(station.getSerial(), channel)
|
|
1925
|
+
this.getStationDevice(station.getSerial(), channel)
|
|
1926
|
+
.then((device) => {
|
|
1798
1927
|
station.stopLivestream(device);
|
|
1799
|
-
})
|
|
1928
|
+
})
|
|
1929
|
+
.catch((err) => {
|
|
1800
1930
|
const error = (0, error_1.ensureError)(err);
|
|
1801
|
-
logging_1.rootMainLogger.error(`Station livestream error`, {
|
|
1931
|
+
logging_1.rootMainLogger.error(`Station livestream error`, {
|
|
1932
|
+
error: (0, utils_1.getError)(error),
|
|
1933
|
+
stationSN: station.getSerial(),
|
|
1934
|
+
channel: channel,
|
|
1935
|
+
origError: (0, utils_1.getError)(origError),
|
|
1936
|
+
});
|
|
1802
1937
|
});
|
|
1803
1938
|
}
|
|
1804
1939
|
onStartStationRTSPLivestream(station, channel) {
|
|
1805
|
-
this.getStationDevice(station.getSerial(), channel)
|
|
1940
|
+
this.getStationDevice(station.getSerial(), channel)
|
|
1941
|
+
.then((device) => {
|
|
1806
1942
|
this.emit("station rtsp livestream start", station, device);
|
|
1807
|
-
})
|
|
1943
|
+
})
|
|
1944
|
+
.catch((err) => {
|
|
1808
1945
|
const error = (0, error_1.ensureError)(err);
|
|
1809
|
-
logging_1.rootMainLogger.error(`Station start rtsp livestream error`, {
|
|
1946
|
+
logging_1.rootMainLogger.error(`Station start rtsp livestream error`, {
|
|
1947
|
+
error: (0, utils_1.getError)(error),
|
|
1948
|
+
stationSN: station.getSerial(),
|
|
1949
|
+
channel: channel,
|
|
1950
|
+
});
|
|
1810
1951
|
});
|
|
1811
1952
|
}
|
|
1812
1953
|
onStopStationRTSPLivestream(station, channel) {
|
|
1813
|
-
this.getStationDevice(station.getSerial(), channel)
|
|
1954
|
+
this.getStationDevice(station.getSerial(), channel)
|
|
1955
|
+
.then((device) => {
|
|
1814
1956
|
this.emit("station rtsp livestream stop", station, device);
|
|
1815
|
-
})
|
|
1957
|
+
})
|
|
1958
|
+
.catch((err) => {
|
|
1816
1959
|
const error = (0, error_1.ensureError)(err);
|
|
1817
|
-
logging_1.rootMainLogger.error(`Station stop rtsp livestream error`, {
|
|
1960
|
+
logging_1.rootMainLogger.error(`Station stop rtsp livestream error`, {
|
|
1961
|
+
error: (0, utils_1.getError)(error),
|
|
1962
|
+
stationSN: station.getSerial(),
|
|
1963
|
+
channel: channel,
|
|
1964
|
+
});
|
|
1818
1965
|
});
|
|
1819
1966
|
}
|
|
1820
1967
|
onStationStartDownload(station, channel, metadata, videoStream, audioStream) {
|
|
1821
|
-
this.getStationDevice(station.getSerial(), channel)
|
|
1968
|
+
this.getStationDevice(station.getSerial(), channel)
|
|
1969
|
+
.then((device) => {
|
|
1822
1970
|
this.emit("station download start", station, device, metadata, videoStream, audioStream);
|
|
1823
|
-
})
|
|
1971
|
+
})
|
|
1972
|
+
.catch((err) => {
|
|
1824
1973
|
const error = (0, error_1.ensureError)(err);
|
|
1825
|
-
logging_1.rootMainLogger.error(`Station start download error`, {
|
|
1974
|
+
logging_1.rootMainLogger.error(`Station start download error`, {
|
|
1975
|
+
error: (0, utils_1.getError)(error),
|
|
1976
|
+
stationSN: station.getSerial(),
|
|
1977
|
+
channel: channel,
|
|
1978
|
+
metadata: metadata,
|
|
1979
|
+
});
|
|
1826
1980
|
});
|
|
1827
1981
|
}
|
|
1828
1982
|
onStationFinishDownload(station, channel) {
|
|
1829
|
-
this.getStationDevice(station.getSerial(), channel)
|
|
1983
|
+
this.getStationDevice(station.getSerial(), channel)
|
|
1984
|
+
.then((device) => {
|
|
1830
1985
|
this.emit("station download finish", station, device);
|
|
1831
|
-
})
|
|
1986
|
+
})
|
|
1987
|
+
.catch((err) => {
|
|
1832
1988
|
const error = (0, error_1.ensureError)(err);
|
|
1833
|
-
logging_1.rootMainLogger.error(`Station finish download error`, {
|
|
1989
|
+
logging_1.rootMainLogger.error(`Station finish download error`, {
|
|
1990
|
+
error: (0, utils_1.getError)(error),
|
|
1991
|
+
stationSN: station.getSerial(),
|
|
1992
|
+
channel: channel,
|
|
1993
|
+
});
|
|
1834
1994
|
});
|
|
1835
1995
|
}
|
|
1836
1996
|
onStationCommandResult(station, result) {
|
|
@@ -1842,13 +2002,35 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1842
2002
|
}
|
|
1843
2003
|
catch (err) {
|
|
1844
2004
|
const error = (0, error_1.ensureError)(err);
|
|
1845
|
-
logging_1.rootMainLogger.error(`Station command result - onSuccess callback error`, {
|
|
2005
|
+
logging_1.rootMainLogger.error(`Station command result - onSuccess callback error`, {
|
|
2006
|
+
error: (0, utils_1.getError)(error),
|
|
2007
|
+
stationSN: station.getSerial(),
|
|
2008
|
+
result: result,
|
|
2009
|
+
});
|
|
1846
2010
|
}
|
|
1847
2011
|
}
|
|
1848
|
-
this.getStationDevice(station.getSerial(), result.channel)
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
2012
|
+
this.getStationDevice(station.getSerial(), result.channel)
|
|
2013
|
+
.then((device) => {
|
|
2014
|
+
if ((result.customData !== undefined &&
|
|
2015
|
+
result.customData.property !== undefined &&
|
|
2016
|
+
!device.isLockWifiR10() &&
|
|
2017
|
+
!device.isLockWifiR20() &&
|
|
2018
|
+
!device.isSmartSafe() &&
|
|
2019
|
+
!device.isLockWifiT8506() &&
|
|
2020
|
+
!device.isLockWifiT8502() &&
|
|
2021
|
+
!device.isLockWifiT8510P() &&
|
|
2022
|
+
!device.isLockWifiT8520P()) ||
|
|
2023
|
+
(result.customData !== undefined &&
|
|
2024
|
+
result.customData.property !== undefined &&
|
|
2025
|
+
device.isSmartSafe() &&
|
|
2026
|
+
result.command_type !== types_2.CommandType.CMD_SMARTSAFE_SETTINGS) ||
|
|
2027
|
+
(result.customData !== undefined &&
|
|
2028
|
+
result.customData.property !== undefined &&
|
|
2029
|
+
(device.isLockWifiT8506() ||
|
|
2030
|
+
device.isLockWifiT8502() ||
|
|
2031
|
+
device.isLockWifiT8510P() ||
|
|
2032
|
+
device.isLockWifiT8520P()) &&
|
|
2033
|
+
result.command_type !== types_2.CommandType.CMD_DOORLOCK_SET_PUSH_MODE)) {
|
|
1852
2034
|
if (device.hasProperty(result.customData.property.name)) {
|
|
1853
2035
|
const metadata = device.getPropertyMetadata(result.customData.property.name);
|
|
1854
2036
|
if (typeof result.customData.property.value !== "object" || metadata.type === "object") {
|
|
@@ -1862,13 +2044,19 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1862
2044
|
}
|
|
1863
2045
|
}
|
|
1864
2046
|
}
|
|
1865
|
-
else if (result.customData !== undefined &&
|
|
1866
|
-
|
|
2047
|
+
else if (result.customData !== undefined &&
|
|
2048
|
+
result.customData.command !== undefined &&
|
|
2049
|
+
result.customData.command.name === types_1.CommandName.DeviceSnooze) {
|
|
2050
|
+
const snoozeTime = result.customData.command.value !== undefined && result.customData.command.value.snooze_time !== undefined
|
|
2051
|
+
? result.customData.command.value.snooze_time
|
|
2052
|
+
: 0;
|
|
1867
2053
|
if (snoozeTime > 0) {
|
|
1868
2054
|
device.updateProperty(types_1.PropertyName.DeviceSnooze, true);
|
|
1869
2055
|
device.updateProperty(types_1.PropertyName.DeviceSnoozeTime, snoozeTime);
|
|
1870
2056
|
}
|
|
1871
|
-
this.api
|
|
2057
|
+
this.api
|
|
2058
|
+
.refreshAllData()
|
|
2059
|
+
.then(() => {
|
|
1872
2060
|
const snoozeStartTime = device.getPropertyValue(types_1.PropertyName.DeviceSnoozeStartTime);
|
|
1873
2061
|
const currentTime = Math.trunc(new Date().getTime() / 1000);
|
|
1874
2062
|
let timeoutMS;
|
|
@@ -1893,12 +2081,14 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1893
2081
|
}
|
|
1894
2082
|
delete this.deviceSnoozeTimeout[device.getSerial()];
|
|
1895
2083
|
}, timeoutMS);
|
|
1896
|
-
})
|
|
2084
|
+
})
|
|
2085
|
+
.catch((err) => {
|
|
1897
2086
|
const error = (0, error_1.ensureError)(err);
|
|
1898
2087
|
logging_1.rootMainLogger.error("Error during API data refreshing", { error: (0, utils_1.getError)(error) });
|
|
1899
2088
|
});
|
|
1900
2089
|
}
|
|
1901
|
-
})
|
|
2090
|
+
})
|
|
2091
|
+
.catch((err) => {
|
|
1902
2092
|
const error = (0, error_1.ensureError)(err);
|
|
1903
2093
|
if (error instanceof error_1.DeviceNotFoundError) {
|
|
1904
2094
|
if (result.customData !== undefined && result.customData.property !== undefined) {
|
|
@@ -1906,10 +2096,17 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1906
2096
|
}
|
|
1907
2097
|
}
|
|
1908
2098
|
else {
|
|
1909
|
-
logging_1.rootMainLogger.error(`Station command result error`, {
|
|
2099
|
+
logging_1.rootMainLogger.error(`Station command result error`, {
|
|
2100
|
+
error: (0, utils_1.getError)(error),
|
|
2101
|
+
stationSN: station.getSerial(),
|
|
2102
|
+
result: result,
|
|
2103
|
+
});
|
|
1910
2104
|
}
|
|
1911
2105
|
});
|
|
1912
|
-
if (station.isIntegratedDevice() &&
|
|
2106
|
+
if (station.isIntegratedDevice() &&
|
|
2107
|
+
result.command_type === types_2.CommandType.CMD_SET_ARMING &&
|
|
2108
|
+
station.isConnected() &&
|
|
2109
|
+
station.getDeviceType() !== types_1.DeviceType.DOORBELL) {
|
|
1913
2110
|
station.getCameraInfo();
|
|
1914
2111
|
}
|
|
1915
2112
|
}
|
|
@@ -1920,7 +2117,11 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1920
2117
|
}
|
|
1921
2118
|
catch (err) {
|
|
1922
2119
|
const error = (0, error_1.ensureError)(err);
|
|
1923
|
-
logging_1.rootMainLogger.error(`Station command result - onFailure callback error`, {
|
|
2120
|
+
logging_1.rootMainLogger.error(`Station command result - onFailure callback error`, {
|
|
2121
|
+
error: (0, utils_1.getError)(error),
|
|
2122
|
+
stationSN: station.getSerial(),
|
|
2123
|
+
result: result,
|
|
2124
|
+
});
|
|
1924
2125
|
}
|
|
1925
2126
|
}
|
|
1926
2127
|
}
|
|
@@ -1934,10 +2135,23 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1934
2135
|
this.emit("user added", device, customValue.username, customValue.schedule);
|
|
1935
2136
|
break;
|
|
1936
2137
|
case 4:
|
|
1937
|
-
this.emit("user error", device, customValue.username, new error_1.AddUserError("Passcode already used by another user, please choose a different one", {
|
|
2138
|
+
this.emit("user error", device, customValue.username, new error_1.AddUserError("Passcode already used by another user, please choose a different one", {
|
|
2139
|
+
context: {
|
|
2140
|
+
device: device.getSerial(),
|
|
2141
|
+
username: customValue.username,
|
|
2142
|
+
schedule: customValue.schedule,
|
|
2143
|
+
},
|
|
2144
|
+
}));
|
|
1938
2145
|
break;
|
|
1939
2146
|
default:
|
|
1940
|
-
this.emit("user error", device, customValue.username, new error_1.AddUserError("Error creating user", {
|
|
2147
|
+
this.emit("user error", device, customValue.username, new error_1.AddUserError("Error creating user", {
|
|
2148
|
+
context: {
|
|
2149
|
+
device: device.getSerial(),
|
|
2150
|
+
username: customValue.username,
|
|
2151
|
+
schedule: customValue.schedule,
|
|
2152
|
+
returnode: result.return_code,
|
|
2153
|
+
},
|
|
2154
|
+
}));
|
|
1941
2155
|
break;
|
|
1942
2156
|
}
|
|
1943
2157
|
});
|
|
@@ -1946,17 +2160,32 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1946
2160
|
this.getStationDevice(station.getSerial(), result.channel).then((device) => {
|
|
1947
2161
|
switch (result.return_code) {
|
|
1948
2162
|
case 0:
|
|
1949
|
-
this.api
|
|
2163
|
+
this.api
|
|
2164
|
+
.deleteUser(device.getSerial(), customValue.shortUserId, device.getStationSerial())
|
|
2165
|
+
.then((result) => {
|
|
1950
2166
|
if (result) {
|
|
1951
2167
|
this.emit("user deleted", device, customValue.username);
|
|
1952
2168
|
}
|
|
1953
2169
|
else {
|
|
1954
|
-
this.emit("user error", device, customValue.username, new error_1.DeleteUserError("Error in deleting user through cloud api call", {
|
|
2170
|
+
this.emit("user error", device, customValue.username, new error_1.DeleteUserError("Error in deleting user through cloud api call", {
|
|
2171
|
+
context: {
|
|
2172
|
+
device: device.getSerial(),
|
|
2173
|
+
username: customValue.username,
|
|
2174
|
+
shortUserId: customValue.short_user_id,
|
|
2175
|
+
},
|
|
2176
|
+
}));
|
|
1955
2177
|
}
|
|
1956
2178
|
});
|
|
1957
2179
|
break;
|
|
1958
2180
|
default:
|
|
1959
|
-
this.emit("user error", device, customValue.username, new error_1.DeleteUserError("Error deleting user", {
|
|
2181
|
+
this.emit("user error", device, customValue.username, new error_1.DeleteUserError("Error deleting user", {
|
|
2182
|
+
context: {
|
|
2183
|
+
device: device.getSerial(),
|
|
2184
|
+
username: customValue.username,
|
|
2185
|
+
shortUserId: customValue.short_user_id,
|
|
2186
|
+
returnCode: result.return_code,
|
|
2187
|
+
},
|
|
2188
|
+
}));
|
|
1960
2189
|
break;
|
|
1961
2190
|
}
|
|
1962
2191
|
});
|
|
@@ -1968,7 +2197,13 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1968
2197
|
this.emit("user passcode updated", device, customValue.username);
|
|
1969
2198
|
break;
|
|
1970
2199
|
default:
|
|
1971
|
-
this.emit("user error", device, customValue.username, new error_1.UpdateUserPasscodeError("Error updating user passcode", {
|
|
2200
|
+
this.emit("user error", device, customValue.username, new error_1.UpdateUserPasscodeError("Error updating user passcode", {
|
|
2201
|
+
context: {
|
|
2202
|
+
device: device.getSerial(),
|
|
2203
|
+
username: customValue.username,
|
|
2204
|
+
returnCode: result.return_code,
|
|
2205
|
+
},
|
|
2206
|
+
}));
|
|
1972
2207
|
break;
|
|
1973
2208
|
}
|
|
1974
2209
|
});
|
|
@@ -1980,7 +2215,14 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1980
2215
|
this.emit("user schedule updated", device, customValue.username, customValue.schedule);
|
|
1981
2216
|
break;
|
|
1982
2217
|
default:
|
|
1983
|
-
this.emit("user error", device, customValue.username, new error_1.UpdateUserScheduleError("Error updating user schedule", {
|
|
2218
|
+
this.emit("user error", device, customValue.username, new error_1.UpdateUserScheduleError("Error updating user schedule", {
|
|
2219
|
+
context: {
|
|
2220
|
+
device: device.getSerial(),
|
|
2221
|
+
username: customValue.username,
|
|
2222
|
+
schedule: customValue.schedule,
|
|
2223
|
+
returnCode: result.return_code,
|
|
2224
|
+
},
|
|
2225
|
+
}));
|
|
1984
2226
|
break;
|
|
1985
2227
|
}
|
|
1986
2228
|
});
|
|
@@ -1990,7 +2232,8 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1990
2232
|
}
|
|
1991
2233
|
onStationSecondaryCommandResult(station, result) {
|
|
1992
2234
|
if (result.return_code === 0) {
|
|
1993
|
-
this.getStationDevice(station.getSerial(), result.channel)
|
|
2235
|
+
this.getStationDevice(station.getSerial(), result.channel)
|
|
2236
|
+
.then((device) => {
|
|
1994
2237
|
if (result.customData !== undefined && result.customData.property !== undefined) {
|
|
1995
2238
|
if (device.hasProperty(result.customData.property.name))
|
|
1996
2239
|
device.updateProperty(result.customData.property.name, result.customData.property.value);
|
|
@@ -1998,7 +2241,8 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
1998
2241
|
station.updateProperty(result.customData.property.name, result.customData.property.value);
|
|
1999
2242
|
}
|
|
2000
2243
|
}
|
|
2001
|
-
})
|
|
2244
|
+
})
|
|
2245
|
+
.catch((err) => {
|
|
2002
2246
|
const error = (0, error_1.ensureError)(err);
|
|
2003
2247
|
if (error instanceof error_1.DeviceNotFoundError) {
|
|
2004
2248
|
if (result.customData !== undefined && result.customData.property !== undefined) {
|
|
@@ -2006,18 +2250,29 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
2006
2250
|
}
|
|
2007
2251
|
}
|
|
2008
2252
|
else {
|
|
2009
|
-
logging_1.rootMainLogger.error(`Station secondary command result error`, {
|
|
2253
|
+
logging_1.rootMainLogger.error(`Station secondary command result error`, {
|
|
2254
|
+
error: (0, utils_1.getError)(error),
|
|
2255
|
+
stationSN: station.getSerial(),
|
|
2256
|
+
result: result,
|
|
2257
|
+
});
|
|
2010
2258
|
}
|
|
2011
2259
|
});
|
|
2012
2260
|
}
|
|
2013
2261
|
}
|
|
2014
2262
|
onStationRtspUrl(station, channel, value) {
|
|
2015
|
-
this.getStationDevice(station.getSerial(), channel)
|
|
2263
|
+
this.getStationDevice(station.getSerial(), channel)
|
|
2264
|
+
.then((device) => {
|
|
2016
2265
|
this.emit("station rtsp url", station, device, value);
|
|
2017
2266
|
device.setCustomPropertyValue(types_1.PropertyName.DeviceRTSPStreamUrl, value);
|
|
2018
|
-
})
|
|
2267
|
+
})
|
|
2268
|
+
.catch((err) => {
|
|
2019
2269
|
const error = (0, error_1.ensureError)(err);
|
|
2020
|
-
logging_1.rootMainLogger.error(`Station rtsp url error`, {
|
|
2270
|
+
logging_1.rootMainLogger.error(`Station rtsp url error`, {
|
|
2271
|
+
error: (0, utils_1.getError)(error),
|
|
2272
|
+
stationSN: station.getSerial(),
|
|
2273
|
+
channel: channel,
|
|
2274
|
+
url: value,
|
|
2275
|
+
});
|
|
2021
2276
|
});
|
|
2022
2277
|
}
|
|
2023
2278
|
onStationGuardMode(station, guardMode) {
|
|
@@ -2051,12 +2306,25 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
2051
2306
|
if (ready && !name.startsWith("hidden-")) {
|
|
2052
2307
|
this.emit("device property changed", device, name, value);
|
|
2053
2308
|
}
|
|
2054
|
-
if (name === types_1.PropertyName.DeviceRTSPStream &&
|
|
2055
|
-
|
|
2309
|
+
if (name === types_1.PropertyName.DeviceRTSPStream &&
|
|
2310
|
+
value === true &&
|
|
2311
|
+
(device.getPropertyValue(types_1.PropertyName.DeviceRTSPStreamUrl) === undefined ||
|
|
2312
|
+
(device.getPropertyValue(types_1.PropertyName.DeviceRTSPStreamUrl) !== undefined &&
|
|
2313
|
+
device.getPropertyValue(types_1.PropertyName.DeviceRTSPStreamUrl) === ""))) {
|
|
2314
|
+
this.getStation(device.getStationSerial())
|
|
2315
|
+
.then((station) => {
|
|
2056
2316
|
station.setRTSPStream(device, true);
|
|
2057
|
-
})
|
|
2317
|
+
})
|
|
2318
|
+
.catch((err) => {
|
|
2058
2319
|
const error = (0, error_1.ensureError)(err);
|
|
2059
|
-
logging_1.rootMainLogger.error(`Device property changed error - station enable rtsp`, {
|
|
2320
|
+
logging_1.rootMainLogger.error(`Device property changed error - station enable rtsp`, {
|
|
2321
|
+
error: (0, utils_1.getError)(error),
|
|
2322
|
+
deviceSN: device.getSerial(),
|
|
2323
|
+
stationSN: device.getStationSerial(),
|
|
2324
|
+
propertyName: name,
|
|
2325
|
+
propertyValue: value,
|
|
2326
|
+
ready: ready,
|
|
2327
|
+
});
|
|
2060
2328
|
});
|
|
2061
2329
|
}
|
|
2062
2330
|
else if (name === types_1.PropertyName.DeviceRTSPStream && value === false) {
|
|
@@ -2064,20 +2332,36 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
2064
2332
|
}
|
|
2065
2333
|
else if (name === types_1.PropertyName.DevicePictureUrl && value !== "") {
|
|
2066
2334
|
if (!(0, utils_1.isValidUrl)(value)) {
|
|
2067
|
-
this.getStation(device.getStationSerial())
|
|
2335
|
+
this.getStation(device.getStationSerial())
|
|
2336
|
+
.then((station) => {
|
|
2068
2337
|
if (station.hasCommand(types_1.CommandName.StationDownloadImage)) {
|
|
2069
2338
|
station.downloadImage(value);
|
|
2070
2339
|
}
|
|
2071
|
-
})
|
|
2340
|
+
})
|
|
2341
|
+
.catch((err) => {
|
|
2072
2342
|
const error = (0, error_1.ensureError)(err);
|
|
2073
|
-
logging_1.rootMainLogger.error(`Device property changed error - station download image`, {
|
|
2343
|
+
logging_1.rootMainLogger.error(`Device property changed error - station download image`, {
|
|
2344
|
+
error: (0, utils_1.getError)(error),
|
|
2345
|
+
deviceSN: device.getSerial(),
|
|
2346
|
+
stationSN: device.getStationSerial(),
|
|
2347
|
+
propertyName: name,
|
|
2348
|
+
propertyValue: value,
|
|
2349
|
+
ready: ready,
|
|
2350
|
+
});
|
|
2074
2351
|
});
|
|
2075
2352
|
}
|
|
2076
2353
|
}
|
|
2077
2354
|
}
|
|
2078
2355
|
catch (err) {
|
|
2079
2356
|
const error = (0, error_1.ensureError)(err);
|
|
2080
|
-
logging_1.rootMainLogger.error(`Device property changed error`, {
|
|
2357
|
+
logging_1.rootMainLogger.error(`Device property changed error`, {
|
|
2358
|
+
error: (0, utils_1.getError)(error),
|
|
2359
|
+
deviceSN: device.getSerial(),
|
|
2360
|
+
stationSN: device.getStationSerial(),
|
|
2361
|
+
propertyName: name,
|
|
2362
|
+
propertyValue: value,
|
|
2363
|
+
ready: ready,
|
|
2364
|
+
});
|
|
2081
2365
|
}
|
|
2082
2366
|
}
|
|
2083
2367
|
onDeviceRawPropertyChanged(device, type, value) {
|
|
@@ -2157,22 +2441,34 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
2157
2441
|
}
|
|
2158
2442
|
onDeviceReady(device) {
|
|
2159
2443
|
try {
|
|
2160
|
-
if (device.getPropertyValue(types_1.PropertyName.DeviceRTSPStream) !== undefined &&
|
|
2161
|
-
|
|
2444
|
+
if (device.getPropertyValue(types_1.PropertyName.DeviceRTSPStream) !== undefined &&
|
|
2445
|
+
device.getPropertyValue(types_1.PropertyName.DeviceRTSPStream) === true) {
|
|
2446
|
+
this.getStation(device.getStationSerial())
|
|
2447
|
+
.then((station) => {
|
|
2162
2448
|
station.setRTSPStream(device, true);
|
|
2163
|
-
})
|
|
2449
|
+
})
|
|
2450
|
+
.catch((err) => {
|
|
2164
2451
|
const error = (0, error_1.ensureError)(err);
|
|
2165
|
-
logging_1.rootMainLogger.error(`Device ready error - station enable rtsp`, {
|
|
2452
|
+
logging_1.rootMainLogger.error(`Device ready error - station enable rtsp`, {
|
|
2453
|
+
error: (0, utils_1.getError)(error),
|
|
2454
|
+
deviceSN: device.getSerial(),
|
|
2455
|
+
stationSN: device.getStationSerial(),
|
|
2456
|
+
});
|
|
2166
2457
|
});
|
|
2167
2458
|
}
|
|
2168
2459
|
}
|
|
2169
2460
|
catch (err) {
|
|
2170
2461
|
const error = (0, error_1.ensureError)(err);
|
|
2171
|
-
logging_1.rootMainLogger.error(`Device ready error`, {
|
|
2462
|
+
logging_1.rootMainLogger.error(`Device ready error`, {
|
|
2463
|
+
error: (0, utils_1.getError)(error),
|
|
2464
|
+
deviceSN: device.getSerial(),
|
|
2465
|
+
stationSN: device.getStationSerial(),
|
|
2466
|
+
});
|
|
2172
2467
|
}
|
|
2173
2468
|
}
|
|
2174
2469
|
onStationRuntimeState(station, channel, batteryLevel, temperature) {
|
|
2175
|
-
this.getStationDevice(station.getSerial(), channel)
|
|
2470
|
+
this.getStationDevice(station.getSerial(), channel)
|
|
2471
|
+
.then((device) => {
|
|
2176
2472
|
if (device.hasProperty(types_1.PropertyName.DeviceBattery)) {
|
|
2177
2473
|
const metadataBattery = device.getPropertyMetadata(types_1.PropertyName.DeviceBattery);
|
|
2178
2474
|
device.updateRawProperty(metadataBattery.key, batteryLevel.toString(), "p2p");
|
|
@@ -2181,13 +2477,21 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
2181
2477
|
const metadataBatteryTemperature = device.getPropertyMetadata(types_1.PropertyName.DeviceBatteryTemp);
|
|
2182
2478
|
device.updateRawProperty(metadataBatteryTemperature.key, temperature.toString(), "p2p");
|
|
2183
2479
|
}
|
|
2184
|
-
})
|
|
2480
|
+
})
|
|
2481
|
+
.catch((err) => {
|
|
2185
2482
|
const error = (0, error_1.ensureError)(err);
|
|
2186
|
-
logging_1.rootMainLogger.error(`Station runtime state error`, {
|
|
2483
|
+
logging_1.rootMainLogger.error(`Station runtime state error`, {
|
|
2484
|
+
error: (0, utils_1.getError)(error),
|
|
2485
|
+
stationSN: station.getSerial(),
|
|
2486
|
+
channel: channel,
|
|
2487
|
+
batteryLevel: batteryLevel,
|
|
2488
|
+
temperature: temperature,
|
|
2489
|
+
});
|
|
2187
2490
|
});
|
|
2188
2491
|
}
|
|
2189
2492
|
onStationChargingState(station, channel, chargeType, batteryLevel) {
|
|
2190
|
-
this.getStationDevice(station.getSerial(), channel)
|
|
2493
|
+
this.getStationDevice(station.getSerial(), channel)
|
|
2494
|
+
.then((device) => {
|
|
2191
2495
|
if (device.hasProperty(types_1.PropertyName.DeviceBattery)) {
|
|
2192
2496
|
const metadataBattery = device.getPropertyMetadata(types_1.PropertyName.DeviceBattery);
|
|
2193
2497
|
if ((0, utils_3.isCharging)(chargeType) && batteryLevel > 0)
|
|
@@ -2197,34 +2501,56 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
2197
2501
|
const metadataChargingStatus = device.getPropertyMetadata(types_1.PropertyName.DeviceChargingStatus);
|
|
2198
2502
|
device.updateRawProperty(metadataChargingStatus.key, chargeType.toString(), "p2p");
|
|
2199
2503
|
}
|
|
2200
|
-
})
|
|
2504
|
+
})
|
|
2505
|
+
.catch((err) => {
|
|
2201
2506
|
const error = (0, error_1.ensureError)(err);
|
|
2202
|
-
logging_1.rootMainLogger.error(`Station charging state error`, {
|
|
2507
|
+
logging_1.rootMainLogger.error(`Station charging state error`, {
|
|
2508
|
+
error: (0, utils_1.getError)(error),
|
|
2509
|
+
stationSN: station.getSerial(),
|
|
2510
|
+
channel: channel,
|
|
2511
|
+
chargeType: chargeType,
|
|
2512
|
+
charging: (0, utils_3.isCharging)(chargeType),
|
|
2513
|
+
batteryLevel: batteryLevel,
|
|
2514
|
+
});
|
|
2203
2515
|
});
|
|
2204
2516
|
}
|
|
2205
2517
|
onStationWifiRssi(station, channel, rssi) {
|
|
2206
|
-
this.getStationDevice(station.getSerial(), channel)
|
|
2518
|
+
this.getStationDevice(station.getSerial(), channel)
|
|
2519
|
+
.then((device) => {
|
|
2207
2520
|
if (device.hasProperty(types_1.PropertyName.DeviceWifiRSSI)) {
|
|
2208
2521
|
const metadataWifiRssi = device.getPropertyMetadata(types_1.PropertyName.DeviceWifiRSSI);
|
|
2209
2522
|
device.updateRawProperty(metadataWifiRssi.key, rssi.toString(), "p2p");
|
|
2210
2523
|
}
|
|
2211
|
-
})
|
|
2524
|
+
})
|
|
2525
|
+
.catch((err) => {
|
|
2212
2526
|
const error = (0, error_1.ensureError)(err);
|
|
2213
|
-
logging_1.rootMainLogger.error(`Station wifi rssi error`, {
|
|
2527
|
+
logging_1.rootMainLogger.error(`Station wifi rssi error`, {
|
|
2528
|
+
error: (0, utils_1.getError)(error),
|
|
2529
|
+
stationSN: station.getSerial(),
|
|
2530
|
+
channel: channel,
|
|
2531
|
+
rssi: rssi,
|
|
2532
|
+
});
|
|
2214
2533
|
});
|
|
2215
2534
|
}
|
|
2216
2535
|
onCaptchaRequest(id, captcha) {
|
|
2217
2536
|
this.emit("captcha request", id, captcha);
|
|
2218
2537
|
}
|
|
2219
2538
|
onFloodlightManualSwitch(station, channel, enabled) {
|
|
2220
|
-
this.getStationDevice(station.getSerial(), channel)
|
|
2539
|
+
this.getStationDevice(station.getSerial(), channel)
|
|
2540
|
+
.then((device) => {
|
|
2221
2541
|
if (device.hasProperty(types_1.PropertyName.DeviceLight)) {
|
|
2222
2542
|
const metadataLight = device.getPropertyMetadata(types_1.PropertyName.DeviceLight);
|
|
2223
2543
|
device.updateRawProperty(metadataLight.key, enabled ? "1" : "0", "p2p");
|
|
2224
2544
|
}
|
|
2225
|
-
})
|
|
2545
|
+
})
|
|
2546
|
+
.catch((err) => {
|
|
2226
2547
|
const error = (0, error_1.ensureError)(err);
|
|
2227
|
-
logging_1.rootMainLogger.error(`Station floodlight manual switch error`, {
|
|
2548
|
+
logging_1.rootMainLogger.error(`Station floodlight manual switch error`, {
|
|
2549
|
+
error: (0, utils_1.getError)(error),
|
|
2550
|
+
stationSN: station.getSerial(),
|
|
2551
|
+
channel: channel,
|
|
2552
|
+
enabled: enabled,
|
|
2553
|
+
});
|
|
2228
2554
|
});
|
|
2229
2555
|
}
|
|
2230
2556
|
onAuthTokenInvalidated() {
|
|
@@ -2236,34 +2562,55 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
2236
2562
|
this.emit("tfa request");
|
|
2237
2563
|
}
|
|
2238
2564
|
onStationTalkbackStart(station, channel, talkbackStream) {
|
|
2239
|
-
this.getStationDevice(station.getSerial(), channel)
|
|
2565
|
+
this.getStationDevice(station.getSerial(), channel)
|
|
2566
|
+
.then((device) => {
|
|
2240
2567
|
this.emit("station talkback start", station, device, talkbackStream);
|
|
2241
|
-
})
|
|
2568
|
+
})
|
|
2569
|
+
.catch((err) => {
|
|
2242
2570
|
const error = (0, error_1.ensureError)(err);
|
|
2243
|
-
logging_1.rootMainLogger.error(`Station talkback start error`, {
|
|
2571
|
+
logging_1.rootMainLogger.error(`Station talkback start error`, {
|
|
2572
|
+
error: (0, utils_1.getError)(error),
|
|
2573
|
+
stationSN: station.getSerial(),
|
|
2574
|
+
channel: channel,
|
|
2575
|
+
});
|
|
2244
2576
|
});
|
|
2245
2577
|
}
|
|
2246
2578
|
onStationTalkbackStop(station, channel) {
|
|
2247
|
-
this.getStationDevice(station.getSerial(), channel)
|
|
2579
|
+
this.getStationDevice(station.getSerial(), channel)
|
|
2580
|
+
.then((device) => {
|
|
2248
2581
|
this.emit("station talkback stop", station, device);
|
|
2249
|
-
})
|
|
2582
|
+
})
|
|
2583
|
+
.catch((err) => {
|
|
2250
2584
|
const error = (0, error_1.ensureError)(err);
|
|
2251
|
-
logging_1.rootMainLogger.error(`Station talkback stop error`, {
|
|
2585
|
+
logging_1.rootMainLogger.error(`Station talkback stop error`, {
|
|
2586
|
+
error: (0, utils_1.getError)(error),
|
|
2587
|
+
stationSN: station.getSerial(),
|
|
2588
|
+
channel: channel,
|
|
2589
|
+
});
|
|
2252
2590
|
});
|
|
2253
2591
|
}
|
|
2254
2592
|
onStationTalkbackError(station, channel, origError) {
|
|
2255
|
-
this.getStationDevice(station.getSerial(), channel)
|
|
2593
|
+
this.getStationDevice(station.getSerial(), channel)
|
|
2594
|
+
.then((device) => {
|
|
2256
2595
|
station.stopTalkback(device);
|
|
2257
|
-
})
|
|
2596
|
+
})
|
|
2597
|
+
.catch((err) => {
|
|
2258
2598
|
const error = (0, error_1.ensureError)(err);
|
|
2259
|
-
logging_1.rootMainLogger.error(`Station talkback error`, {
|
|
2599
|
+
logging_1.rootMainLogger.error(`Station talkback error`, {
|
|
2600
|
+
error: (0, utils_1.getError)(error),
|
|
2601
|
+
stationSN: station.getSerial(),
|
|
2602
|
+
channel: channel,
|
|
2603
|
+
origError: (0, utils_1.getError)(origError),
|
|
2604
|
+
});
|
|
2260
2605
|
});
|
|
2261
2606
|
}
|
|
2262
2607
|
async startStationTalkback(deviceSN) {
|
|
2263
2608
|
const device = await this.getDevice(deviceSN);
|
|
2264
2609
|
const station = await this.getStation(device.getStationSerial());
|
|
2265
2610
|
if (!device.hasCommand(types_1.CommandName.DeviceStartTalkback))
|
|
2266
|
-
throw new error_1.NotSupportedError("This functionality is not implemented or supported by this device", {
|
|
2611
|
+
throw new error_1.NotSupportedError("This functionality is not implemented or supported by this device", {
|
|
2612
|
+
context: { device: deviceSN, commandName: types_1.CommandName.DeviceStartTalkback },
|
|
2613
|
+
});
|
|
2267
2614
|
if (station.isLiveStreaming(device)) {
|
|
2268
2615
|
if (!station.isTalkbackOngoing(device)) {
|
|
2269
2616
|
station.startTalkback(device);
|
|
@@ -2280,7 +2627,9 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
2280
2627
|
const device = await this.getDevice(deviceSN);
|
|
2281
2628
|
const station = await this.getStation(device.getStationSerial());
|
|
2282
2629
|
if (!device.hasCommand(types_1.CommandName.DeviceStopTalkback))
|
|
2283
|
-
throw new error_1.NotSupportedError("This functionality is not implemented or supported by this device", {
|
|
2630
|
+
throw new error_1.NotSupportedError("This functionality is not implemented or supported by this device", {
|
|
2631
|
+
context: { device: deviceSN, commandName: types_1.CommandName.DeviceStopTalkback },
|
|
2632
|
+
});
|
|
2284
2633
|
if (station.isLiveStreaming(device)) {
|
|
2285
2634
|
if (station.isTalkbackOngoing(device)) {
|
|
2286
2635
|
station.stopTalkback(device);
|
|
@@ -2294,48 +2643,69 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
2294
2643
|
}
|
|
2295
2644
|
}
|
|
2296
2645
|
onStationDeviceShakeAlarm(deviceSN, event) {
|
|
2297
|
-
this.getDevice(deviceSN)
|
|
2646
|
+
this.getDevice(deviceSN)
|
|
2647
|
+
.then((device) => {
|
|
2298
2648
|
if (device.isSmartSafe())
|
|
2299
2649
|
device.shakeEvent(event, this.config.eventDurationSeconds);
|
|
2300
|
-
})
|
|
2650
|
+
})
|
|
2651
|
+
.catch((err) => {
|
|
2301
2652
|
const error = (0, error_1.ensureError)(err);
|
|
2302
|
-
logging_1.rootMainLogger.error(`onStationDeviceShakeAlarm error`, {
|
|
2653
|
+
logging_1.rootMainLogger.error(`onStationDeviceShakeAlarm error`, {
|
|
2654
|
+
error: (0, utils_1.getError)(error),
|
|
2655
|
+
deviceSN: deviceSN,
|
|
2656
|
+
event: types_2.SmartSafeShakeAlarmEvent[event],
|
|
2657
|
+
});
|
|
2303
2658
|
});
|
|
2304
2659
|
}
|
|
2305
2660
|
onStationDevice911Alarm(deviceSN, event) {
|
|
2306
|
-
this.getDevice(deviceSN)
|
|
2661
|
+
this.getDevice(deviceSN)
|
|
2662
|
+
.then((device) => {
|
|
2307
2663
|
if (device.isSmartSafe())
|
|
2308
2664
|
device.alarm911Event(event, this.config.eventDurationSeconds);
|
|
2309
|
-
})
|
|
2665
|
+
})
|
|
2666
|
+
.catch((err) => {
|
|
2310
2667
|
const error = (0, error_1.ensureError)(err);
|
|
2311
|
-
logging_1.rootMainLogger.error(`onStationDevice911Alarm error`, {
|
|
2668
|
+
logging_1.rootMainLogger.error(`onStationDevice911Alarm error`, {
|
|
2669
|
+
error: (0, utils_1.getError)(error),
|
|
2670
|
+
deviceSN: deviceSN,
|
|
2671
|
+
event: types_2.SmartSafeAlarm911Event[event],
|
|
2672
|
+
});
|
|
2312
2673
|
});
|
|
2313
2674
|
}
|
|
2314
2675
|
onStationDeviceJammed(deviceSN) {
|
|
2315
|
-
this.getDevice(deviceSN)
|
|
2676
|
+
this.getDevice(deviceSN)
|
|
2677
|
+
.then((device) => {
|
|
2316
2678
|
if (device.isSmartSafe())
|
|
2317
2679
|
device.jammedEvent(this.config.eventDurationSeconds);
|
|
2318
|
-
})
|
|
2680
|
+
})
|
|
2681
|
+
.catch((err) => {
|
|
2319
2682
|
const error = (0, error_1.ensureError)(err);
|
|
2320
2683
|
logging_1.rootMainLogger.error(`onStationDeviceJammed error`, { error: (0, utils_1.getError)(error), deviceSN: deviceSN });
|
|
2321
2684
|
});
|
|
2322
2685
|
}
|
|
2323
2686
|
onStationDeviceLowBattery(deviceSN) {
|
|
2324
|
-
this.getDevice(deviceSN)
|
|
2687
|
+
this.getDevice(deviceSN)
|
|
2688
|
+
.then((device) => {
|
|
2325
2689
|
if (device.isSmartSafe())
|
|
2326
2690
|
device.lowBatteryEvent(this.config.eventDurationSeconds);
|
|
2327
|
-
})
|
|
2691
|
+
})
|
|
2692
|
+
.catch((err) => {
|
|
2328
2693
|
const error = (0, error_1.ensureError)(err);
|
|
2329
2694
|
logging_1.rootMainLogger.error(`onStationDeviceLowBattery error`, { error: (0, utils_1.getError)(error), deviceSN: deviceSN });
|
|
2330
2695
|
});
|
|
2331
2696
|
}
|
|
2332
2697
|
onStationDeviceWrongTryProtectAlarm(deviceSN) {
|
|
2333
|
-
this.getDevice(deviceSN)
|
|
2698
|
+
this.getDevice(deviceSN)
|
|
2699
|
+
.then((device) => {
|
|
2334
2700
|
if (device.isSmartSafe())
|
|
2335
2701
|
device.wrongTryProtectAlarmEvent(this.config.eventDurationSeconds);
|
|
2336
|
-
})
|
|
2702
|
+
})
|
|
2703
|
+
.catch((err) => {
|
|
2337
2704
|
const error = (0, error_1.ensureError)(err);
|
|
2338
|
-
logging_1.rootMainLogger.error(`onStationDeviceWrongTryProtectAlarm error`, {
|
|
2705
|
+
logging_1.rootMainLogger.error(`onStationDeviceWrongTryProtectAlarm error`, {
|
|
2706
|
+
error: (0, utils_1.getError)(error),
|
|
2707
|
+
deviceSN: deviceSN,
|
|
2708
|
+
});
|
|
2339
2709
|
});
|
|
2340
2710
|
}
|
|
2341
2711
|
async addUser(deviceSN, username, passcode, schedule) {
|
|
@@ -2343,26 +2713,46 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
2343
2713
|
const station = await this.getStation(device.getStationSerial());
|
|
2344
2714
|
try {
|
|
2345
2715
|
if (!device.hasCommand(types_1.CommandName.DeviceAddUser))
|
|
2346
|
-
throw new error_1.NotSupportedError("This functionality is not implemented or supported by this device", {
|
|
2716
|
+
throw new error_1.NotSupportedError("This functionality is not implemented or supported by this device", {
|
|
2717
|
+
context: {
|
|
2718
|
+
device: deviceSN,
|
|
2719
|
+
commandName: types_1.CommandName.DeviceAddUser,
|
|
2720
|
+
username: username,
|
|
2721
|
+
passcode: "[redacted]",
|
|
2722
|
+
schedule: schedule,
|
|
2723
|
+
},
|
|
2724
|
+
});
|
|
2347
2725
|
const addUserResponse = await this.api.addUser(deviceSN, username, device.getStationSerial());
|
|
2348
2726
|
if (addUserResponse !== null) {
|
|
2349
2727
|
station.addUser(device, username, addUserResponse.short_user_id, passcode, schedule);
|
|
2350
2728
|
}
|
|
2351
2729
|
else {
|
|
2352
|
-
this.emit("user error", device, username, new error_1.AddUserError("Error on creating user through cloud api call", {
|
|
2730
|
+
this.emit("user error", device, username, new error_1.AddUserError("Error on creating user through cloud api call", {
|
|
2731
|
+
context: { deivce: deviceSN, username: username, passcode: "[redacted]", schedule: schedule },
|
|
2732
|
+
}));
|
|
2353
2733
|
}
|
|
2354
2734
|
}
|
|
2355
2735
|
catch (err) {
|
|
2356
2736
|
const error = (0, error_1.ensureError)(err);
|
|
2357
|
-
logging_1.rootMainLogger.error(`addUser error`, {
|
|
2358
|
-
|
|
2737
|
+
logging_1.rootMainLogger.error(`addUser error`, {
|
|
2738
|
+
error: (0, utils_1.getError)(error),
|
|
2739
|
+
deviceSN: deviceSN,
|
|
2740
|
+
username: username,
|
|
2741
|
+
schedule: schedule,
|
|
2742
|
+
});
|
|
2743
|
+
this.emit("user error", device, username, new error_1.AddUserError("Generic error", {
|
|
2744
|
+
cause: error,
|
|
2745
|
+
context: { device: deviceSN, username: username, passcode: "[redacted]", schedule: schedule },
|
|
2746
|
+
}));
|
|
2359
2747
|
}
|
|
2360
2748
|
}
|
|
2361
2749
|
async deleteUser(deviceSN, username) {
|
|
2362
2750
|
const device = await this.getDevice(deviceSN);
|
|
2363
2751
|
const station = await this.getStation(device.getStationSerial());
|
|
2364
2752
|
if (!device.hasCommand(types_1.CommandName.DeviceDeleteUser))
|
|
2365
|
-
throw new error_1.NotSupportedError("This functionality is not implemented or supported by this device", {
|
|
2753
|
+
throw new error_1.NotSupportedError("This functionality is not implemented or supported by this device", {
|
|
2754
|
+
context: { device: deviceSN, commandName: types_1.CommandName.DeviceDeleteUser, username: username },
|
|
2755
|
+
});
|
|
2366
2756
|
try {
|
|
2367
2757
|
const users = await this.api.getUsers(deviceSN, device.getStationSerial());
|
|
2368
2758
|
if (users !== null) {
|
|
@@ -2379,7 +2769,9 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
2379
2769
|
}
|
|
2380
2770
|
}
|
|
2381
2771
|
else {
|
|
2382
|
-
this.emit("user error", device, username, new error_1.DeleteUserError("Error on getting user list through cloud api call", {
|
|
2772
|
+
this.emit("user error", device, username, new error_1.DeleteUserError("Error on getting user list through cloud api call", {
|
|
2773
|
+
context: { device: deviceSN, username: username },
|
|
2774
|
+
}));
|
|
2383
2775
|
}
|
|
2384
2776
|
}
|
|
2385
2777
|
catch (err) {
|
|
@@ -2392,21 +2784,37 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
2392
2784
|
const device = await this.getDevice(deviceSN);
|
|
2393
2785
|
const station = await this.getStation(device.getStationSerial());
|
|
2394
2786
|
if (!device.hasCommand(types_1.CommandName.DeviceUpdateUsername))
|
|
2395
|
-
throw new error_1.NotSupportedError("This functionality is not implemented or supported by this device", {
|
|
2787
|
+
throw new error_1.NotSupportedError("This functionality is not implemented or supported by this device", {
|
|
2788
|
+
context: {
|
|
2789
|
+
device: deviceSN,
|
|
2790
|
+
commandName: types_1.CommandName.DeviceUpdateUsername,
|
|
2791
|
+
usernmae: username,
|
|
2792
|
+
newUsername: newUsername,
|
|
2793
|
+
},
|
|
2794
|
+
});
|
|
2396
2795
|
try {
|
|
2397
2796
|
const users = await this.api.getUsers(deviceSN, device.getStationSerial());
|
|
2398
2797
|
if (users !== null) {
|
|
2399
2798
|
let found = false;
|
|
2400
2799
|
for (const user of users) {
|
|
2401
2800
|
if (user.user_name === username) {
|
|
2402
|
-
if ((device.isLockWifiT8506() ||
|
|
2801
|
+
if ((device.isLockWifiT8506() ||
|
|
2802
|
+
device.isLockWifiT8502() ||
|
|
2803
|
+
device.isLockWifiT8510P() ||
|
|
2804
|
+
device.isLockWifiT8520P()) &&
|
|
2805
|
+
user.password_list.length > 0) {
|
|
2403
2806
|
for (const entry of user.password_list) {
|
|
2404
2807
|
if (entry.password_type === types_1.UserPasswordType.PIN) {
|
|
2405
2808
|
let schedule = entry.schedule;
|
|
2406
2809
|
if (schedule !== undefined && typeof schedule == "string") {
|
|
2407
2810
|
schedule = JSON.parse(schedule);
|
|
2408
2811
|
}
|
|
2409
|
-
if (schedule !== undefined &&
|
|
2812
|
+
if (schedule !== undefined &&
|
|
2813
|
+
schedule.endDay !== undefined &&
|
|
2814
|
+
schedule.endTime !== undefined &&
|
|
2815
|
+
schedule.startDay !== undefined &&
|
|
2816
|
+
schedule.startTime !== undefined &&
|
|
2817
|
+
schedule.week !== undefined) {
|
|
2410
2818
|
station.updateUserSchedule(device, newUsername, user.short_user_id, (0, utils_2.hexStringScheduleToSchedule)(schedule.startDay, schedule.startTime, schedule.endDay, schedule.endTime, schedule.week));
|
|
2411
2819
|
}
|
|
2412
2820
|
}
|
|
@@ -2424,31 +2832,52 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
2424
2832
|
this.emit("user username updated", device, username);
|
|
2425
2833
|
}
|
|
2426
2834
|
else {
|
|
2427
|
-
this.emit("user error", device, username, new error_1.UpdateUserUsernameError("Error in changing username through cloud api call", {
|
|
2835
|
+
this.emit("user error", device, username, new error_1.UpdateUserUsernameError("Error in changing username through cloud api call", {
|
|
2836
|
+
context: { device: deviceSN, username: username, newUsername: newUsername },
|
|
2837
|
+
}));
|
|
2428
2838
|
}
|
|
2429
2839
|
found = true;
|
|
2430
2840
|
break;
|
|
2431
2841
|
}
|
|
2432
2842
|
}
|
|
2433
2843
|
if (!found) {
|
|
2434
|
-
this.emit("user error", device, username, new error_1.UpdateUserUsernameError("User not found", {
|
|
2844
|
+
this.emit("user error", device, username, new error_1.UpdateUserUsernameError("User not found", {
|
|
2845
|
+
context: { device: deviceSN, username: username, newUsername: newUsername },
|
|
2846
|
+
}));
|
|
2435
2847
|
}
|
|
2436
2848
|
}
|
|
2437
2849
|
else {
|
|
2438
|
-
this.emit("user error", device, username, new error_1.UpdateUserUsernameError("Error on getting user list through cloud api call", {
|
|
2850
|
+
this.emit("user error", device, username, new error_1.UpdateUserUsernameError("Error on getting user list through cloud api call", {
|
|
2851
|
+
context: { device: deviceSN, username: username, newUsername: newUsername },
|
|
2852
|
+
}));
|
|
2439
2853
|
}
|
|
2440
2854
|
}
|
|
2441
2855
|
catch (err) {
|
|
2442
2856
|
const error = (0, error_1.ensureError)(err);
|
|
2443
|
-
logging_1.rootMainLogger.error(`updateUser error`, {
|
|
2444
|
-
|
|
2857
|
+
logging_1.rootMainLogger.error(`updateUser error`, {
|
|
2858
|
+
error: (0, utils_1.getError)(error),
|
|
2859
|
+
deviceSN: deviceSN,
|
|
2860
|
+
username: username,
|
|
2861
|
+
newUsername: newUsername,
|
|
2862
|
+
});
|
|
2863
|
+
this.emit("user error", device, username, new error_1.UpdateUserUsernameError("Generic error", {
|
|
2864
|
+
cause: error,
|
|
2865
|
+
context: { device: deviceSN, username: username, newUsername: newUsername },
|
|
2866
|
+
}));
|
|
2445
2867
|
}
|
|
2446
2868
|
}
|
|
2447
2869
|
async updateUserPasscode(deviceSN, username, passcode) {
|
|
2448
2870
|
const device = await this.getDevice(deviceSN);
|
|
2449
2871
|
const station = await this.getStation(device.getStationSerial());
|
|
2450
2872
|
if (!device.hasCommand(types_1.CommandName.DeviceUpdateUserPasscode))
|
|
2451
|
-
throw new error_1.NotSupportedError("This functionality is not implemented or supported by this device", {
|
|
2873
|
+
throw new error_1.NotSupportedError("This functionality is not implemented or supported by this device", {
|
|
2874
|
+
context: {
|
|
2875
|
+
device: deviceSN,
|
|
2876
|
+
commandName: types_1.CommandName.DeviceUpdateUserPasscode,
|
|
2877
|
+
username: username,
|
|
2878
|
+
passcode: "[redacted]",
|
|
2879
|
+
},
|
|
2880
|
+
});
|
|
2452
2881
|
try {
|
|
2453
2882
|
const users = await this.api.getUsers(deviceSN, device.getStationSerial());
|
|
2454
2883
|
if (users !== null) {
|
|
@@ -2464,24 +2893,42 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
2464
2893
|
}
|
|
2465
2894
|
}
|
|
2466
2895
|
if (!found) {
|
|
2467
|
-
this.emit("user error", device, username, new error_1.UpdateUserPasscodeError("User not found", {
|
|
2896
|
+
this.emit("user error", device, username, new error_1.UpdateUserPasscodeError("User not found", {
|
|
2897
|
+
context: { device: deviceSN, username: username, passcode: "[redacted]" },
|
|
2898
|
+
}));
|
|
2468
2899
|
}
|
|
2469
2900
|
}
|
|
2470
2901
|
else {
|
|
2471
|
-
this.emit("user error", device, username, new error_1.UpdateUserPasscodeError("Error on getting user list through cloud api call", {
|
|
2902
|
+
this.emit("user error", device, username, new error_1.UpdateUserPasscodeError("Error on getting user list through cloud api call", {
|
|
2903
|
+
context: { device: deviceSN, username: username, passcode: "[redacted]" },
|
|
2904
|
+
}));
|
|
2472
2905
|
}
|
|
2473
2906
|
}
|
|
2474
2907
|
catch (err) {
|
|
2475
2908
|
const error = (0, error_1.ensureError)(err);
|
|
2476
|
-
logging_1.rootMainLogger.error(`updateUserPasscode error`, {
|
|
2477
|
-
|
|
2909
|
+
logging_1.rootMainLogger.error(`updateUserPasscode error`, {
|
|
2910
|
+
error: (0, utils_1.getError)(error),
|
|
2911
|
+
deviceSN: deviceSN,
|
|
2912
|
+
username: username,
|
|
2913
|
+
});
|
|
2914
|
+
this.emit("user error", device, username, new error_1.UpdateUserPasscodeError("Generic error", {
|
|
2915
|
+
cause: error,
|
|
2916
|
+
context: { device: deviceSN, username: username, passcode: "[redacted]" },
|
|
2917
|
+
}));
|
|
2478
2918
|
}
|
|
2479
2919
|
}
|
|
2480
2920
|
async updateUserSchedule(deviceSN, username, schedule) {
|
|
2481
2921
|
const device = await this.getDevice(deviceSN);
|
|
2482
2922
|
const station = await this.getStation(device.getStationSerial());
|
|
2483
2923
|
if (!device.hasCommand(types_1.CommandName.DeviceUpdateUserSchedule))
|
|
2484
|
-
throw new error_1.NotSupportedError("This functionality is not implemented or supported by this device", {
|
|
2924
|
+
throw new error_1.NotSupportedError("This functionality is not implemented or supported by this device", {
|
|
2925
|
+
context: {
|
|
2926
|
+
device: deviceSN,
|
|
2927
|
+
commandName: types_1.CommandName.DeviceUpdateUserSchedule,
|
|
2928
|
+
usernmae: username,
|
|
2929
|
+
schedule: schedule,
|
|
2930
|
+
},
|
|
2931
|
+
});
|
|
2485
2932
|
try {
|
|
2486
2933
|
const users = await this.api.getUsers(deviceSN, device.getStationSerial());
|
|
2487
2934
|
if (users !== null) {
|
|
@@ -2493,25 +2940,43 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
2493
2940
|
}
|
|
2494
2941
|
}
|
|
2495
2942
|
if (!found) {
|
|
2496
|
-
this.emit("user error", device, username, new error_1.UpdateUserScheduleError("User not found", {
|
|
2943
|
+
this.emit("user error", device, username, new error_1.UpdateUserScheduleError("User not found", {
|
|
2944
|
+
context: { device: deviceSN, username: username, schedule: schedule },
|
|
2945
|
+
}));
|
|
2497
2946
|
}
|
|
2498
2947
|
}
|
|
2499
2948
|
else {
|
|
2500
|
-
this.emit("user error", device, username, new error_1.UpdateUserScheduleError("Error on getting user list through cloud api call", {
|
|
2949
|
+
this.emit("user error", device, username, new error_1.UpdateUserScheduleError("Error on getting user list through cloud api call", {
|
|
2950
|
+
context: { device: deviceSN, username: username, schedule: schedule },
|
|
2951
|
+
}));
|
|
2501
2952
|
}
|
|
2502
2953
|
}
|
|
2503
2954
|
catch (err) {
|
|
2504
2955
|
const error = (0, error_1.ensureError)(err);
|
|
2505
|
-
logging_1.rootMainLogger.error(`updateUserSchedule error`, {
|
|
2506
|
-
|
|
2956
|
+
logging_1.rootMainLogger.error(`updateUserSchedule error`, {
|
|
2957
|
+
error: (0, utils_1.getError)(error),
|
|
2958
|
+
deviceSN: deviceSN,
|
|
2959
|
+
username: username,
|
|
2960
|
+
schedule: schedule,
|
|
2961
|
+
});
|
|
2962
|
+
this.emit("user error", device, username, new error_1.UpdateUserScheduleError("Generic error", {
|
|
2963
|
+
cause: error,
|
|
2964
|
+
context: { device: deviceSN, username: username, schedule: schedule },
|
|
2965
|
+
}));
|
|
2507
2966
|
}
|
|
2508
2967
|
}
|
|
2509
2968
|
onStationDevicePinVerified(deviceSN, successfull) {
|
|
2510
|
-
this.getDevice(deviceSN)
|
|
2969
|
+
this.getDevice(deviceSN)
|
|
2970
|
+
.then((device) => {
|
|
2511
2971
|
this.emit("device pin verified", device, successfull);
|
|
2512
|
-
})
|
|
2972
|
+
})
|
|
2973
|
+
.catch((err) => {
|
|
2513
2974
|
const error = (0, error_1.ensureError)(err);
|
|
2514
|
-
logging_1.rootMainLogger.error(`onStationDevicePinVerified error`, {
|
|
2975
|
+
logging_1.rootMainLogger.error(`onStationDevicePinVerified error`, {
|
|
2976
|
+
error: (0, utils_1.getError)(error),
|
|
2977
|
+
deviceSN: deviceSN,
|
|
2978
|
+
successfull: successfull,
|
|
2979
|
+
});
|
|
2515
2980
|
});
|
|
2516
2981
|
}
|
|
2517
2982
|
onStationSdInfoEx(station, sdStatus, sdCapacity, sdCapacityAvailable) {
|
|
@@ -2527,7 +2992,8 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
2527
2992
|
}
|
|
2528
2993
|
_emitStationImageDownload(station, file, picture) {
|
|
2529
2994
|
this.emit("station image download", station, file, picture);
|
|
2530
|
-
this.getDevicesFromStation(station.getSerial())
|
|
2995
|
+
this.getDevicesFromStation(station.getSerial())
|
|
2996
|
+
.then((devices) => {
|
|
2531
2997
|
for (const device of devices) {
|
|
2532
2998
|
if (device.getPropertyValue(types_1.PropertyName.DevicePictureUrl) === file) {
|
|
2533
2999
|
logging_1.rootMainLogger.debug(`onStationImageDownload - Set picture for device ${device.getSerial()} file: ${file} picture_ext: ${picture.type.ext} picture_mime: ${picture.type.mime}`);
|
|
@@ -2535,37 +3001,48 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
2535
3001
|
break;
|
|
2536
3002
|
}
|
|
2537
3003
|
}
|
|
2538
|
-
})
|
|
3004
|
+
})
|
|
3005
|
+
.catch((err) => {
|
|
2539
3006
|
const error = (0, error_1.ensureError)(err);
|
|
2540
|
-
logging_1.rootMainLogger.error(`onStationImageDownload - Set picture error`, {
|
|
3007
|
+
logging_1.rootMainLogger.error(`onStationImageDownload - Set picture error`, {
|
|
3008
|
+
error: (0, utils_1.getError)(error),
|
|
3009
|
+
stationSN: station.getSerial(),
|
|
3010
|
+
file: file,
|
|
3011
|
+
});
|
|
2541
3012
|
});
|
|
2542
3013
|
}
|
|
2543
3014
|
onStationImageDownload(station, file, image) {
|
|
2544
|
-
import("image-type")
|
|
2545
|
-
|
|
3015
|
+
import("image-type")
|
|
3016
|
+
.then(({ default: imageType }) => {
|
|
3017
|
+
imageType(image)
|
|
3018
|
+
.then((type) => {
|
|
2546
3019
|
const picture = {
|
|
2547
3020
|
data: image,
|
|
2548
|
-
type: type !== null && type !== undefined ? type : { ext: "unknown", mime: "application/octet-stream" }
|
|
3021
|
+
type: type !== null && type !== undefined ? type : { ext: "unknown", mime: "application/octet-stream" },
|
|
2549
3022
|
};
|
|
2550
3023
|
this._emitStationImageDownload(station, file, picture);
|
|
2551
|
-
})
|
|
3024
|
+
})
|
|
3025
|
+
.catch(() => {
|
|
2552
3026
|
this._emitStationImageDownload(station, file, {
|
|
2553
3027
|
data: image,
|
|
2554
|
-
type: { ext: "unknown", mime: "application/octet-stream" }
|
|
3028
|
+
type: { ext: "unknown", mime: "application/octet-stream" },
|
|
2555
3029
|
});
|
|
2556
3030
|
});
|
|
2557
|
-
})
|
|
3031
|
+
})
|
|
3032
|
+
.catch(() => {
|
|
2558
3033
|
this._emitStationImageDownload(station, file, {
|
|
2559
3034
|
data: image,
|
|
2560
|
-
type: { ext: "unknown", mime: "application/octet-stream" }
|
|
3035
|
+
type: { ext: "unknown", mime: "application/octet-stream" },
|
|
2561
3036
|
});
|
|
2562
3037
|
});
|
|
2563
3038
|
}
|
|
2564
3039
|
onStationDatabaseQueryLatest(station, returnCode, data) {
|
|
2565
3040
|
if (returnCode === types_2.DatabaseReturnCode.SUCCESSFUL) {
|
|
2566
3041
|
for (const element of data) {
|
|
2567
|
-
if ((element.device_sn !== "" && !station.isStation()) ||
|
|
2568
|
-
|
|
3042
|
+
if ((element.device_sn !== "" && !station.isStation()) ||
|
|
3043
|
+
(station.isStation() && element.device_sn !== station.getSerial())) {
|
|
3044
|
+
this.getDevice(element.device_sn)
|
|
3045
|
+
.then((device) => {
|
|
2569
3046
|
const raw = device.getRawDevice();
|
|
2570
3047
|
if ("crop_local_path" in element) {
|
|
2571
3048
|
raw.cover_path = element.crop_local_path;
|
|
@@ -2574,10 +3051,15 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
2574
3051
|
raw.cover_path = element.crop_cloud_path;
|
|
2575
3052
|
}
|
|
2576
3053
|
device.update(raw);
|
|
2577
|
-
})
|
|
3054
|
+
})
|
|
3055
|
+
.catch((err) => {
|
|
2578
3056
|
const error = (0, error_1.ensureError)(err);
|
|
2579
3057
|
if (!(error instanceof error_1.DeviceNotFoundError)) {
|
|
2580
|
-
logging_1.rootMainLogger.error("onStationDatabaseQueryLatest Error", {
|
|
3058
|
+
logging_1.rootMainLogger.error("onStationDatabaseQueryLatest Error", {
|
|
3059
|
+
error: (0, utils_1.getError)(error),
|
|
3060
|
+
stationSN: station.getSerial(),
|
|
3061
|
+
returnCode: returnCode,
|
|
3062
|
+
});
|
|
2581
3063
|
}
|
|
2582
3064
|
});
|
|
2583
3065
|
}
|
|
@@ -2588,6 +3070,9 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
2588
3070
|
onStationDatabaseQueryLocal(station, returnCode, data) {
|
|
2589
3071
|
this.emit("station database query local", station, returnCode, data);
|
|
2590
3072
|
}
|
|
3073
|
+
onStationDatabaseQueryByDate(station, returnCode, data) {
|
|
3074
|
+
this.emit("station database query by date", station, returnCode, data);
|
|
3075
|
+
}
|
|
2591
3076
|
onStationDatabaseCountByDate(station, returnCode, data) {
|
|
2592
3077
|
this.emit("station database count by date", station, returnCode, data);
|
|
2593
3078
|
}
|
|
@@ -2595,22 +3080,34 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
2595
3080
|
this.emit("station database delete", station, returnCode, failedIds);
|
|
2596
3081
|
}
|
|
2597
3082
|
onStationSensorStatus(station, channel, status) {
|
|
2598
|
-
this.getStationDevice(station.getSerial(), channel)
|
|
3083
|
+
this.getStationDevice(station.getSerial(), channel)
|
|
3084
|
+
.then((device) => {
|
|
2599
3085
|
if (device.hasProperty(types_1.PropertyName.DeviceSensorOpen)) {
|
|
2600
3086
|
const metadataSensorOpen = device.getPropertyMetadata(types_1.PropertyName.DeviceSensorOpen);
|
|
2601
3087
|
device.updateRawProperty(metadataSensorOpen.key, status.toString(), "p2p");
|
|
2602
3088
|
}
|
|
2603
|
-
})
|
|
3089
|
+
})
|
|
3090
|
+
.catch((err) => {
|
|
2604
3091
|
const error = (0, error_1.ensureError)(err);
|
|
2605
|
-
logging_1.rootMainLogger.error(`Station sensor status error`, {
|
|
3092
|
+
logging_1.rootMainLogger.error(`Station sensor status error`, {
|
|
3093
|
+
error: (0, utils_1.getError)(error),
|
|
3094
|
+
stationSN: station.getSerial(),
|
|
3095
|
+
channel: channel,
|
|
3096
|
+
});
|
|
2606
3097
|
});
|
|
2607
3098
|
}
|
|
2608
3099
|
onStationGarageDoorStatus(station, channel, doorId, status) {
|
|
2609
|
-
this.getStationDevice(station.getSerial(), channel)
|
|
3100
|
+
this.getStationDevice(station.getSerial(), channel)
|
|
3101
|
+
.then((device) => {
|
|
2610
3102
|
device.updateRawProperty(types_2.CommandType.CMD_CAMERA_GARAGE_DOOR_STATUS, status.toString(), "p2p");
|
|
2611
|
-
})
|
|
3103
|
+
})
|
|
3104
|
+
.catch((err) => {
|
|
2612
3105
|
const error = (0, error_1.ensureError)(err);
|
|
2613
|
-
logging_1.rootMainLogger.error(`Station garage door status error`, {
|
|
3106
|
+
logging_1.rootMainLogger.error(`Station garage door status error`, {
|
|
3107
|
+
error: (0, utils_1.getError)(error),
|
|
3108
|
+
stationSN: station.getSerial(),
|
|
3109
|
+
channel: channel,
|
|
3110
|
+
});
|
|
2614
3111
|
});
|
|
2615
3112
|
}
|
|
2616
3113
|
onStorageInfoHb3(station, channel, storageInfo) {
|