@switchbot/homebridge-switchbot 2.0.0-beta.23 → 2.0.0-beta.24
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/config.schema.json +25 -1
- package/dist/platform.d.ts +6 -2
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +136 -111
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +2 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +1 -1
- package/src/platform.ts +143 -117
- package/src/settings.ts +2 -0
package/config.schema.json
CHANGED
|
@@ -909,6 +909,28 @@
|
|
|
909
909
|
"enum": ["debug"]
|
|
910
910
|
}
|
|
911
911
|
]
|
|
912
|
+
},
|
|
913
|
+
"discoverDevices": {
|
|
914
|
+
"title": "Rediscover Devices Periodically",
|
|
915
|
+
"type": "boolean"
|
|
916
|
+
},
|
|
917
|
+
"discoverDevicesInterval": {
|
|
918
|
+
"title": "Rediscover Devices Interval",
|
|
919
|
+
"type": "number",
|
|
920
|
+
"oneOf": [
|
|
921
|
+
{
|
|
922
|
+
"title": "1 Day",
|
|
923
|
+
"enum": [86400]
|
|
924
|
+
},
|
|
925
|
+
{
|
|
926
|
+
"title": "7 Days",
|
|
927
|
+
"enum": [604800]
|
|
928
|
+
},
|
|
929
|
+
{
|
|
930
|
+
"title": "30 Days",
|
|
931
|
+
"enum": [2592000]
|
|
932
|
+
}
|
|
933
|
+
]
|
|
912
934
|
}
|
|
913
935
|
}
|
|
914
936
|
}
|
|
@@ -1040,7 +1062,9 @@
|
|
|
1040
1062
|
"key": "options.pushRate",
|
|
1041
1063
|
"notitle": true
|
|
1042
1064
|
},
|
|
1043
|
-
"options.logging"
|
|
1065
|
+
"options.logging",
|
|
1066
|
+
"options.discoverDevices",
|
|
1067
|
+
"options.discoverDevicesInterval"
|
|
1044
1068
|
]
|
|
1045
1069
|
}
|
|
1046
1070
|
]
|
package/dist/platform.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { API, DynamicPlatformPlugin, Logger, PlatformAccessory, Service, Characteristic } from 'homebridge';
|
|
2
|
-
import {
|
|
3
|
+
import { device, SwitchBotPlatformConfig, devicesConfig } from './settings';
|
|
4
|
+
import { IncomingMessage } from 'http';
|
|
3
5
|
/**
|
|
4
6
|
* HomebridgePlatform
|
|
5
7
|
* This class is the main constructor for your plugin, this is where you should
|
|
@@ -69,7 +71,9 @@ export declare class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
69
71
|
externalAccessory(accessory: PlatformAccessory): Promise<void>;
|
|
70
72
|
unregisterPlatformAccessories(existingAccessory: PlatformAccessory): void;
|
|
71
73
|
deviceListInfo(devices: any): void;
|
|
72
|
-
|
|
74
|
+
statusCode({ res }: {
|
|
75
|
+
res: IncomingMessage;
|
|
76
|
+
}): Promise<void>;
|
|
73
77
|
connectBLE(): any;
|
|
74
78
|
/**
|
|
75
79
|
* If device level logging is turned on, log to log.warn
|
package/dist/platform.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,GAAG,EAAE,qBAAqB,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5G,OAAO,
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";AA0BA,OAAO,EAAE,GAAG,EAAE,qBAAqB,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5G,OAAO,EAAwC,MAAM,EAAE,uBAAuB,EAAE,aAAa,EAA0B,MAAM,YAAY,CAAC;AAC1I,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAGvC;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,qBAAqB;aAejC,GAAG,EAAE,MAAM;aAAkB,MAAM,EAAE,uBAAuB;aAAkB,GAAG,EAAE,GAAG;IAdlH,SAAgB,OAAO,EAAE,OAAO,OAAO,CAAwB;IAC/D,SAAgB,cAAc,EAAE,OAAO,cAAc,CAA+B;IAGpF,SAAgB,WAAW,EAAE,iBAAiB,EAAE,CAAM;IAEtD,OAAO,MAAkD;IACzD,YAAY,EAAG,GAAG,CAAC;IACnB,iBAAiB,EAAG,OAAO,CAAC;IAC5B,SAAS,EAAG,OAAO,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,SAAgB,WAAW,EAAE,GAAG,CAAC;gBAEL,GAAG,EAAE,MAAM,EAAkB,MAAM,EAAE,uBAAuB,EAAkB,GAAG,EAAE,GAAG;IAsDlH,IAAI;IAoBJ;;;OAGG;IACH,kBAAkB,CAAC,SAAS,EAAE,iBAAiB;IAO/C;;OAEG;IACG,YAAY;IAkGlB;;;;OAIG;IACG,WAAW;IAoDjB;;OAEG;IACG,eAAe;IA4KrB,WAAW,CAAC,CAAC,EAAE,GAAG;IA0ClB,OAAO,CAAC,YAAY;IAmEpB,OAAO,CAAC,cAAc;YA+DR,gBAAgB;YAsDhB,SAAS;YA2DT,WAAW;YAsDX,eAAe;YAsDf,YAAY;YAsDZ,aAAa;YAsDb,aAAa;IAiE3B,OAAO,CAAC,gBAAgB;YAeV,UAAU;YAsDV,UAAU;YAsDV,eAAe;YAsDf,gBAAgB;YAsDhB,QAAQ;YAqDR,SAAS;YAsDT,WAAW;YAsDX,oBAAoB;YAsDpB,iBAAiB;YAsDjB,iBAAiB;YAsDjB,mBAAmB;YAsDnB,YAAY;YAsDZ,YAAY;IAsDpB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC;IAU5D,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa;IA4BtC,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,EAAE,SAAS,EAAE,iBAAiB;IAU/E,iBAAiB,CAAC,SAAS,EAAE,iBAAiB;IAIpD,6BAA6B,CAAC,iBAAiB,EAAE,iBAAiB;IAMlE,cAAc,CAAC,OAAO,KAAA;IAMvB,UAAU,CAAC,EAAE,GAAG,EAAE,EAAE;QAAE,GAAG,EAAE,eAAe,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAiClE,UAAU;IAaV;;;OAGG;IACH,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAM5B,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAM5B,QAAQ,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAM7B,QAAQ,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAU7B,uBAAuB,IAAI,OAAO;CAGnC"}
|
package/dist/platform.js
CHANGED
|
@@ -31,6 +31,7 @@ const fakegato_history_1 = __importDefault(require("fakegato-history"));
|
|
|
31
31
|
const super_stringify_1 = __importDefault(require("super-stringify"));
|
|
32
32
|
const fs_1 = require("fs");
|
|
33
33
|
const settings_1 = require("./settings");
|
|
34
|
+
const rxjs_1 = require("rxjs");
|
|
34
35
|
/**
|
|
35
36
|
* HomebridgePlatform
|
|
36
37
|
* This class is the main constructor for your plugin, this is where you should
|
|
@@ -64,7 +65,7 @@ class SwitchBotPlatform {
|
|
|
64
65
|
catch (e) {
|
|
65
66
|
this.errorLog((0, super_stringify_1.default)(e.message));
|
|
66
67
|
if (this.platformLogging?.includes('debug')) {
|
|
67
|
-
this.errorLog(
|
|
68
|
+
this.errorLog(`Verify Config: ${e}`);
|
|
68
69
|
}
|
|
69
70
|
return;
|
|
70
71
|
}
|
|
@@ -92,7 +93,7 @@ class SwitchBotPlatform {
|
|
|
92
93
|
catch (e) {
|
|
93
94
|
this.errorLog('Failed to Discover Devices.', (0, super_stringify_1.default)(e.message));
|
|
94
95
|
if (this.platformLogging?.includes('debug')) {
|
|
95
|
-
this.errorLog(
|
|
96
|
+
this.errorLog(`Platform: ${e}`);
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
});
|
|
@@ -209,6 +210,15 @@ class SwitchBotPlatform {
|
|
|
209
210
|
}
|
|
210
211
|
}
|
|
211
212
|
}
|
|
213
|
+
// Re-Discover Devices
|
|
214
|
+
if (!this.config.options.discoverDevices) {
|
|
215
|
+
this.config.options.discoverDevices = false;
|
|
216
|
+
this.debugLog(`Rediscover Devices disabled, discoverDevices: ${this.config.options.discoverDevices}`);
|
|
217
|
+
}
|
|
218
|
+
if (!this.config.options.discoverDevicesInterval) {
|
|
219
|
+
this.config.options.discoverDevicesInterval = 86400;
|
|
220
|
+
this.debugLog(`Default Rediscover Devices Interval, discoverDevicesInterval: ${this.config.options.discoverDevicesInterval}`);
|
|
221
|
+
}
|
|
212
222
|
}
|
|
213
223
|
/**
|
|
214
224
|
* The openToken was old config.
|
|
@@ -258,7 +268,7 @@ class SwitchBotPlatform {
|
|
|
258
268
|
this.verifyConfig();
|
|
259
269
|
}
|
|
260
270
|
catch (e) {
|
|
261
|
-
this.errorLog(e);
|
|
271
|
+
this.errorLog(`Update Token: ${e}`);
|
|
262
272
|
}
|
|
263
273
|
}
|
|
264
274
|
/**
|
|
@@ -286,8 +296,9 @@ class SwitchBotPlatform {
|
|
|
286
296
|
'Content-Type': 'application/json',
|
|
287
297
|
},
|
|
288
298
|
};
|
|
289
|
-
const req = https_1.default.request(options, (res) => {
|
|
299
|
+
const req = https_1.default.request(options, async (res) => {
|
|
290
300
|
this.debugLog(`statusCode: ${res.statusCode}`);
|
|
301
|
+
await this.statusCode({ res });
|
|
291
302
|
this.debugLog(`headers: ${(0, super_stringify_1.default)(res.headers)}`);
|
|
292
303
|
let rawData = '';
|
|
293
304
|
res.on('data', (d) => {
|
|
@@ -299,86 +310,106 @@ class SwitchBotPlatform {
|
|
|
299
310
|
const devicesAPI = JSON.parse(rawData);
|
|
300
311
|
this.debugLog(`devicesAPI: ${(0, super_stringify_1.default)(devicesAPI.body)}`);
|
|
301
312
|
// SwitchBot Devices
|
|
302
|
-
if (devicesAPI.body.deviceList.length !== 0) {
|
|
303
|
-
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
if (
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
313
|
+
/*if (devicesAPI.body.deviceList.length !== 0) {
|
|
314
|
+
this.infoLog(`Total SwitchBot Devices Found: ${devicesAPI.body.deviceList.length}`);
|
|
315
|
+
} else {
|
|
316
|
+
this.debugLog(`Total SwitchBot Devices Found: ${devicesAPI.body.deviceList.length}`);
|
|
317
|
+
}*/
|
|
318
|
+
const deviceBodyList = devicesAPI.body.deviceList;
|
|
319
|
+
let deviceLists;
|
|
320
|
+
if (deviceBodyList) {
|
|
321
|
+
if (deviceBodyList.length > 1) {
|
|
322
|
+
deviceLists = deviceBodyList;
|
|
323
|
+
this.infoLog(`Total SwitchBot Devices Found: ${deviceLists.length}`);
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
deviceLists = [deviceBodyList];
|
|
327
|
+
this.infoLog(`Total SwitchBot Devices Found: ${deviceLists.length}`);
|
|
328
|
+
}
|
|
329
|
+
if (!this.config.options?.devices) {
|
|
330
|
+
this.debugLog(`SwitchBot Device Config Not Set: ${(0, super_stringify_1.default)(this.config.options?.devices)}`);
|
|
331
|
+
const devices = deviceLists.map((v) => v);
|
|
332
|
+
for (const device of devices) {
|
|
333
|
+
if (device.deviceType) {
|
|
334
|
+
if (device.configDeviceName) {
|
|
335
|
+
device.deviceName = device.configDeviceName;
|
|
336
|
+
}
|
|
337
|
+
this.createDevice(device);
|
|
316
338
|
}
|
|
317
|
-
this.createDevice(device);
|
|
318
339
|
}
|
|
319
340
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
341
|
+
else if (this.config.credentials?.token && this.config.options.devices) {
|
|
342
|
+
this.debugLog(`SwitchBot Device Config Set: ${(0, super_stringify_1.default)(this.config.options?.devices)}`);
|
|
343
|
+
const deviceConfigs = this.config.options?.devices;
|
|
344
|
+
const mergeBydeviceId = (a1, a2) => a1.map((itm) => ({
|
|
345
|
+
...a2.find((item) => item.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') === itm.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') && item),
|
|
346
|
+
...itm,
|
|
347
|
+
}));
|
|
348
|
+
const devices = mergeBydeviceId(deviceLists, deviceConfigs);
|
|
349
|
+
this.debugLog(`SwitchBot Devices: ${(0, super_stringify_1.default)(devices)}`);
|
|
350
|
+
for (const device of devices) {
|
|
351
|
+
if (device.deviceType) {
|
|
352
|
+
if (device.configDeviceName) {
|
|
353
|
+
device.deviceName = device.configDeviceName;
|
|
354
|
+
}
|
|
355
|
+
this.createDevice(device);
|
|
334
356
|
}
|
|
335
|
-
this.createDevice(device);
|
|
336
357
|
}
|
|
337
358
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
359
|
+
else {
|
|
360
|
+
this.errorLog('SwitchBot Token Supplied, Issue with Auth.');
|
|
361
|
+
}
|
|
341
362
|
}
|
|
342
363
|
// IR Devices
|
|
343
|
-
if (devicesAPI.body.infraredRemoteList.length !== 0) {
|
|
344
|
-
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
if (
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
364
|
+
/*if (devicesAPI.body.infraredRemoteList.length !== 0) {
|
|
365
|
+
this.infoLog(`Total IR Devices Found: ${devicesAPI.body.infraredRemoteList.length}`);
|
|
366
|
+
} else {
|
|
367
|
+
this.debugLog(`Total IR Devices Found: ${devicesAPI.body.infraredRemoteList.length}`);
|
|
368
|
+
}*/
|
|
369
|
+
const irDeviceBodyList = devicesAPI.body.infraredRemoteList;
|
|
370
|
+
let irDeviceLists;
|
|
371
|
+
if (irDeviceBodyList) {
|
|
372
|
+
if (irDeviceBodyList.length > 1) {
|
|
373
|
+
irDeviceLists = irDeviceBodyList;
|
|
374
|
+
this.infoLog(`Total IR Devices Found: ${irDeviceLists.length}`);
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
irDeviceLists = [irDeviceBodyList];
|
|
378
|
+
this.infoLog(`Total IR Devices Found: ${irDeviceLists.length}`);
|
|
379
|
+
}
|
|
380
|
+
if (!this.config.options?.irdevices) {
|
|
381
|
+
this.debugLog(`IR Device Config Not Set: ${(0, super_stringify_1.default)(this.config.options?.irdevices)}`);
|
|
382
|
+
const devices = irDeviceLists.map((v) => v);
|
|
383
|
+
for (const device of devices) {
|
|
384
|
+
if (device.remoteType) {
|
|
385
|
+
this.createIRDevice(device);
|
|
386
|
+
}
|
|
356
387
|
}
|
|
357
388
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
389
|
+
else {
|
|
390
|
+
this.debugLog(`IR Device Config Set: ${(0, super_stringify_1.default)(this.config.options?.irdevices)}`);
|
|
391
|
+
const irDeviceConfig = this.config.options?.irdevices;
|
|
392
|
+
const mergeIRBydeviceId = (a1, a2) => a1.map((itm) => ({
|
|
393
|
+
...a2.find((item) => item.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') === itm.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') && item),
|
|
394
|
+
...itm,
|
|
395
|
+
}));
|
|
396
|
+
const devices = mergeIRBydeviceId(irDeviceLists, irDeviceConfig);
|
|
397
|
+
this.debugLog(`IR Devices: ${(0, super_stringify_1.default)(devices)}`);
|
|
398
|
+
for (const device of devices) {
|
|
399
|
+
if (device.remoteType) {
|
|
400
|
+
this.createIRDevice(device);
|
|
401
|
+
}
|
|
371
402
|
}
|
|
372
403
|
}
|
|
373
404
|
}
|
|
374
405
|
}
|
|
375
406
|
catch (e) {
|
|
376
|
-
this.errorLog(e
|
|
407
|
+
this.errorLog(`API Request: ${e}`);
|
|
377
408
|
}
|
|
378
409
|
});
|
|
379
410
|
});
|
|
380
|
-
req.on('error', (
|
|
381
|
-
this.errorLog(
|
|
411
|
+
req.on('error', (e) => {
|
|
412
|
+
this.errorLog(`req: ${e}`);
|
|
382
413
|
});
|
|
383
414
|
req.end();
|
|
384
415
|
}
|
|
@@ -399,7 +430,14 @@ class SwitchBotPlatform {
|
|
|
399
430
|
}
|
|
400
431
|
}
|
|
401
432
|
catch (e) {
|
|
402
|
-
this.deviceError(e);
|
|
433
|
+
this.deviceError(`Discover Devices: ${e}`);
|
|
434
|
+
}
|
|
435
|
+
if (this.config.options?.discoverDevices) {
|
|
436
|
+
(0, rxjs_1.interval)(this.config.options.discoverDevicesInterval * 1000)
|
|
437
|
+
.pipe((0, rxjs_1.take)(1))
|
|
438
|
+
.subscribe(async () => {
|
|
439
|
+
await this.discoverDevices();
|
|
440
|
+
});
|
|
403
441
|
}
|
|
404
442
|
}
|
|
405
443
|
deviceError(e) {
|
|
@@ -447,7 +485,7 @@ class SwitchBotPlatform {
|
|
|
447
485
|
this.errorLog(`Failed to Discover Devices, Error Message: ${(0, super_stringify_1.default)(e.message)}`);
|
|
448
486
|
}
|
|
449
487
|
if (this.platformLogging === 'debugMode') {
|
|
450
|
-
this.errorLog(`Failed to Discover Devices, Error: ${
|
|
488
|
+
this.errorLog(`Failed to Discover Devices, Error: ${e}`);
|
|
451
489
|
}
|
|
452
490
|
}
|
|
453
491
|
createDevice(device) {
|
|
@@ -505,7 +543,6 @@ class SwitchBotPlatform {
|
|
|
505
543
|
this.createStripLight(device);
|
|
506
544
|
break;
|
|
507
545
|
case 'Indoor Cam':
|
|
508
|
-
this.deviceInfo(device);
|
|
509
546
|
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
510
547
|
this.warnLog(`Device: ${device.deviceName} with Device Type: ${device.deviceType}, is currently not supported.`);
|
|
511
548
|
break;
|
|
@@ -513,7 +550,6 @@ class SwitchBotPlatform {
|
|
|
513
550
|
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId} is Not Supported.`);
|
|
514
551
|
break;
|
|
515
552
|
default:
|
|
516
|
-
this.deviceInfo(device);
|
|
517
553
|
this.warnLog(`Device: ${device.deviceName} with Device Type: ${device.deviceType}, is currently not supported.`);
|
|
518
554
|
this.warnLog('Submit Feature Requests Here: https://git.io/JL14Z');
|
|
519
555
|
}
|
|
@@ -575,7 +611,7 @@ class SwitchBotPlatform {
|
|
|
575
611
|
this.createOthers(device);
|
|
576
612
|
break;
|
|
577
613
|
default:
|
|
578
|
-
this.
|
|
614
|
+
this.debugLog(`Unsupported Device: ${(0, super_stringify_1.default)(device)}`);
|
|
579
615
|
this.warnLog(`Device: ${device.deviceName} with Device Type: ${device.remoteType}, is currently not supported.`);
|
|
580
616
|
this.warnLog('Submit Feature Requests Here: https://git.io/JL14Z');
|
|
581
617
|
}
|
|
@@ -1691,46 +1727,35 @@ class SwitchBotPlatform {
|
|
|
1691
1727
|
this.warnLog(`deviceListInfoStatus: ${(0, super_stringify_1.default)(devices)}`);
|
|
1692
1728
|
}
|
|
1693
1729
|
}
|
|
1694
|
-
async
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
this.errorLog(error);
|
|
1724
|
-
});
|
|
1725
|
-
req.end();
|
|
1726
|
-
this.deviceStatus = req;
|
|
1727
|
-
if (this.deviceStatus.message === 'success') {
|
|
1728
|
-
this.warnLog(`${device.deviceName} deviceInfoStatus: ${(0, super_stringify_1.default)(this.deviceStatus)}`);
|
|
1729
|
-
}
|
|
1730
|
-
else {
|
|
1731
|
-
this.warnLog(`${device.deviceName} deviceInfoStatus: ${(0, super_stringify_1.default)(this.deviceStatus.message)}`);
|
|
1732
|
-
this.warnLog('Unable to retreive deviceInfoStatus.');
|
|
1733
|
-
}
|
|
1730
|
+
async statusCode({ res }) {
|
|
1731
|
+
switch (res.statusCode) {
|
|
1732
|
+
case 151:
|
|
1733
|
+
this.errorLog('Command not supported by this device type.');
|
|
1734
|
+
break;
|
|
1735
|
+
case 152:
|
|
1736
|
+
this.errorLog('Device not found.');
|
|
1737
|
+
break;
|
|
1738
|
+
case 160:
|
|
1739
|
+
this.errorLog('Command is not supported.');
|
|
1740
|
+
break;
|
|
1741
|
+
case 161:
|
|
1742
|
+
this.errorLog('Device is offline.');
|
|
1743
|
+
break;
|
|
1744
|
+
case 171:
|
|
1745
|
+
this.errorLog('is offline');
|
|
1746
|
+
break;
|
|
1747
|
+
case 190:
|
|
1748
|
+
this.errorLog('Requests reached the daily limit');
|
|
1749
|
+
break;
|
|
1750
|
+
case 100:
|
|
1751
|
+
if (this.debugMode) {
|
|
1752
|
+
this.debugLog('Command successfully sent.');
|
|
1753
|
+
}
|
|
1754
|
+
break;
|
|
1755
|
+
default:
|
|
1756
|
+
if (this.debugMode) {
|
|
1757
|
+
this.debugLog('Unknown statusCode.');
|
|
1758
|
+
}
|
|
1734
1759
|
}
|
|
1735
1760
|
}
|
|
1736
1761
|
// BLE Connection
|