@switchbot/homebridge-switchbot 2.0.0-beta.13 → 2.0.0-beta.15
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/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +19 -18
- package/dist/device/bot.js.map +1 -1
- package/dist/device/colorbulb.js +25 -25
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +7 -6
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +14 -13
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +18 -17
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +8 -7
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +9 -8
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +8 -7
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +7 -6
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +13 -12
- package/dist/device/plug.js.map +1 -1
- package/dist/device/striplight.d.ts.map +1 -1
- package/dist/device/striplight.js +27 -26
- package/dist/device/striplight.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +10 -9
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +8 -7
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +7 -6
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +10 -9
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +9 -8
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +7 -6
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +16 -15
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +7 -6
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +7 -6
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +44 -43
- package/dist/platform.js.map +1 -1
- package/package.json +1 -1
- package/src/device/bot.ts +19 -18
- package/src/device/colorbulb.ts +25 -25
- package/src/device/contact.ts +7 -6
- package/src/device/curtain.ts +14 -13
- package/src/device/humidifier.ts +18 -17
- package/src/device/lock.ts +8 -7
- package/src/device/meter.ts +9 -8
- package/src/device/meterplus.ts +8 -7
- package/src/device/motion.ts +7 -6
- package/src/device/plug.ts +13 -12
- package/src/device/striplight.ts +27 -26
- package/src/irdevice/airconditioner.ts +10 -9
- package/src/irdevice/airpurifier.ts +8 -7
- package/src/irdevice/camera.ts +7 -6
- package/src/irdevice/fan.ts +10 -9
- package/src/irdevice/light.ts +9 -8
- package/src/irdevice/other.ts +7 -6
- package/src/irdevice/tv.ts +16 -15
- package/src/irdevice/vacuumcleaner.ts +7 -6
- package/src/irdevice/waterheater.ts +7 -6
- package/src/platform.ts +44 -43
package/dist/platform.js
CHANGED
|
@@ -28,6 +28,7 @@ const https_1 = __importDefault(require("https"));
|
|
|
28
28
|
const crypto_1 = __importDefault(require("crypto"));
|
|
29
29
|
const buffer_1 = require("buffer");
|
|
30
30
|
const fakegato_history_1 = __importDefault(require("fakegato-history"));
|
|
31
|
+
const super_stringify_1 = __importDefault(require("super-stringify"));
|
|
31
32
|
const fs_1 = require("fs");
|
|
32
33
|
const settings_1 = require("./settings");
|
|
33
34
|
/**
|
|
@@ -61,9 +62,9 @@ class SwitchBotPlatform {
|
|
|
61
62
|
this.debugLog('Config OK');
|
|
62
63
|
}
|
|
63
64
|
catch (e) {
|
|
64
|
-
this.errorLog(
|
|
65
|
+
this.errorLog((0, super_stringify_1.default)(e.message));
|
|
65
66
|
if (this.platformLogging?.includes('debug')) {
|
|
66
|
-
this.errorLog(
|
|
67
|
+
this.errorLog((0, super_stringify_1.default)(e));
|
|
67
68
|
}
|
|
68
69
|
return;
|
|
69
70
|
}
|
|
@@ -85,9 +86,9 @@ class SwitchBotPlatform {
|
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
88
|
catch (e) {
|
|
88
|
-
this.errorLog('Failed to Discover Devices.',
|
|
89
|
+
this.errorLog('Failed to Discover Devices.', (0, super_stringify_1.default)(e.message));
|
|
89
90
|
if (this.platformLogging?.includes('debug')) {
|
|
90
|
-
this.errorLog(
|
|
91
|
+
this.errorLog((0, super_stringify_1.default)(e));
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
94
|
});
|
|
@@ -138,7 +139,7 @@ class SwitchBotPlatform {
|
|
|
138
139
|
platformConfig['pushRate'] = this.config.options.pushRate;
|
|
139
140
|
}
|
|
140
141
|
if (Object.entries(platformConfig).length !== 0) {
|
|
141
|
-
this.infoLog(`Platform Config: ${
|
|
142
|
+
this.infoLog(`Platform Config: ${(0, super_stringify_1.default)(platformConfig)}`);
|
|
142
143
|
}
|
|
143
144
|
if (this.config.options) {
|
|
144
145
|
// Device Config
|
|
@@ -242,7 +243,7 @@ class SwitchBotPlatform {
|
|
|
242
243
|
this.warnLog(`Token: ${pluginConfig.credentials.token}`);
|
|
243
244
|
}
|
|
244
245
|
// save the config, ensuring we maintain pretty json
|
|
245
|
-
(0, fs_1.writeFileSync)(this.api.user.configPath(),
|
|
246
|
+
(0, fs_1.writeFileSync)(this.api.user.configPath(), (0, super_stringify_1.default)(currentConfig, null, 4));
|
|
246
247
|
this.verifyConfig();
|
|
247
248
|
}
|
|
248
249
|
catch (e) {
|
|
@@ -276,7 +277,7 @@ class SwitchBotPlatform {
|
|
|
276
277
|
};
|
|
277
278
|
const req = https_1.default.request(options, (res) => {
|
|
278
279
|
this.debugLog(`statusCode: ${res.statusCode}`);
|
|
279
|
-
this.debugLog(`headers: ${
|
|
280
|
+
this.debugLog(`headers: ${(0, super_stringify_1.default)(res.headers)}`);
|
|
280
281
|
let rawData = '';
|
|
281
282
|
res.on('data', (d) => {
|
|
282
283
|
rawData += d;
|
|
@@ -285,7 +286,7 @@ class SwitchBotPlatform {
|
|
|
285
286
|
res.on('end', () => {
|
|
286
287
|
try {
|
|
287
288
|
const devicesAPI = JSON.parse(rawData);
|
|
288
|
-
this.debugLog(`devicesAPI: ${
|
|
289
|
+
this.debugLog(`devicesAPI: ${(0, super_stringify_1.default)(devicesAPI.body)}`);
|
|
289
290
|
// SwitchBot Devices
|
|
290
291
|
if (devicesAPI.body.deviceList.length !== 0) {
|
|
291
292
|
this.infoLog(`Total SwitchBot Devices Found: ${devicesAPI.body.deviceList.length}`);
|
|
@@ -295,7 +296,7 @@ class SwitchBotPlatform {
|
|
|
295
296
|
}
|
|
296
297
|
const deviceLists = devicesAPI.body.deviceList;
|
|
297
298
|
if (!this.config.options?.devices) {
|
|
298
|
-
this.debugLog(`SwitchBot Device Config Not Set: ${
|
|
299
|
+
this.debugLog(`SwitchBot Device Config Not Set: ${(0, super_stringify_1.default)(this.config.options?.devices)}`);
|
|
299
300
|
const devices = deviceLists.map((v) => v);
|
|
300
301
|
for (const device of devices) {
|
|
301
302
|
if (device.deviceType) {
|
|
@@ -307,14 +308,14 @@ class SwitchBotPlatform {
|
|
|
307
308
|
}
|
|
308
309
|
}
|
|
309
310
|
else if (this.config.credentials?.token && this.config.options.devices) {
|
|
310
|
-
this.debugLog(`SwitchBot Device Config Set: ${
|
|
311
|
+
this.debugLog(`SwitchBot Device Config Set: ${(0, super_stringify_1.default)(this.config.options?.devices)}`);
|
|
311
312
|
const deviceConfigs = this.config.options?.devices;
|
|
312
313
|
const mergeBydeviceId = (a1, a2) => a1.map((itm) => ({
|
|
313
314
|
...a2.find((item) => item.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') === itm.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') && item),
|
|
314
315
|
...itm,
|
|
315
316
|
}));
|
|
316
317
|
const devices = mergeBydeviceId(deviceLists, deviceConfigs);
|
|
317
|
-
this.debugLog(`SwitchBot Devices: ${
|
|
318
|
+
this.debugLog(`SwitchBot Devices: ${(0, super_stringify_1.default)(devices)}`);
|
|
318
319
|
for (const device of devices) {
|
|
319
320
|
if (device.deviceType) {
|
|
320
321
|
if (device.configDeviceName) {
|
|
@@ -336,7 +337,7 @@ class SwitchBotPlatform {
|
|
|
336
337
|
}
|
|
337
338
|
const irDeviceLists = devicesAPI.body.infraredRemoteList;
|
|
338
339
|
if (!this.config.options?.irdevices) {
|
|
339
|
-
this.debugLog(`IR Device Config Not Set: ${
|
|
340
|
+
this.debugLog(`IR Device Config Not Set: ${(0, super_stringify_1.default)(this.config.options?.irdevices)}`);
|
|
340
341
|
const devices = irDeviceLists.map((v) => v);
|
|
341
342
|
for (const device of devices) {
|
|
342
343
|
if (device.remoteType) {
|
|
@@ -345,14 +346,14 @@ class SwitchBotPlatform {
|
|
|
345
346
|
}
|
|
346
347
|
}
|
|
347
348
|
else {
|
|
348
|
-
this.debugLog(`IR Device Config Set: ${
|
|
349
|
+
this.debugLog(`IR Device Config Set: ${(0, super_stringify_1.default)(this.config.options?.irdevices)}`);
|
|
349
350
|
const irDeviceConfig = this.config.options?.irdevices;
|
|
350
351
|
const mergeIRBydeviceId = (a1, a2) => a1.map((itm) => ({
|
|
351
352
|
...a2.find((item) => item.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') === itm.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') && item),
|
|
352
353
|
...itm,
|
|
353
354
|
}));
|
|
354
355
|
const devices = mergeIRBydeviceId(irDeviceLists, irDeviceConfig);
|
|
355
|
-
this.debugLog(`IR Devices: ${
|
|
356
|
+
this.debugLog(`IR Devices: ${(0, super_stringify_1.default)(devices)}`);
|
|
356
357
|
for (const device of devices) {
|
|
357
358
|
if (device.remoteType) {
|
|
358
359
|
this.createIRDevice(device);
|
|
@@ -371,7 +372,7 @@ class SwitchBotPlatform {
|
|
|
371
372
|
req.end();
|
|
372
373
|
}
|
|
373
374
|
else if (!this.config.credentials?.token && this.config.options?.devices) {
|
|
374
|
-
this.debugLog(`SwitchBot Device Manual Config Set: ${
|
|
375
|
+
this.debugLog(`SwitchBot Device Manual Config Set: ${(0, super_stringify_1.default)(this.config.options?.devices)}`);
|
|
375
376
|
const deviceConfigs = this.config.options?.devices;
|
|
376
377
|
const devices = deviceConfigs.map((v) => v);
|
|
377
378
|
for (const device of devices) {
|
|
@@ -432,10 +433,10 @@ class SwitchBotPlatform {
|
|
|
432
433
|
this.errorLog('Failed to Discover Devices');
|
|
433
434
|
}
|
|
434
435
|
if (this.platformLogging === 'debug') {
|
|
435
|
-
this.errorLog(`Failed to Discover Devices, Error Message: ${
|
|
436
|
+
this.errorLog(`Failed to Discover Devices, Error Message: ${(0, super_stringify_1.default)(e.message)}`);
|
|
436
437
|
}
|
|
437
438
|
if (this.platformLogging === 'debugMode') {
|
|
438
|
-
this.errorLog(`Failed to Discover Devices, Error: ${
|
|
439
|
+
this.errorLog(`Failed to Discover Devices, Error: ${(0, super_stringify_1.default)(e)}`);
|
|
439
440
|
}
|
|
440
441
|
}
|
|
441
442
|
createDevice(device) {
|
|
@@ -581,7 +582,7 @@ class SwitchBotPlatform {
|
|
|
581
582
|
//existingAccessory.context.firmwareRevision = firmware;
|
|
582
583
|
existingAccessory.context.model = device.deviceType;
|
|
583
584
|
existingAccessory.context.deviceID = device.deviceId;
|
|
584
|
-
existingAccessory.displayName = device.deviceName;
|
|
585
|
+
existingAccessory.displayName = device.configDeviceName || device.deviceName;
|
|
585
586
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
586
587
|
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
587
588
|
await this.connectionTypeExistingAccessory(device, existingAccessory);
|
|
@@ -629,11 +630,11 @@ class SwitchBotPlatform {
|
|
|
629
630
|
// the accessory already exists
|
|
630
631
|
if (this.registerDevice(device)) {
|
|
631
632
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
632
|
-
this.debugLog(
|
|
633
|
+
this.debugLog((0, super_stringify_1.default)(device.bot?.mode));
|
|
633
634
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
634
635
|
existingAccessory.context.model = device.deviceType;
|
|
635
636
|
existingAccessory.context.deviceID = device.deviceId;
|
|
636
|
-
existingAccessory.displayName = device.deviceName;
|
|
637
|
+
existingAccessory.displayName = device.configDeviceName || device.deviceName;
|
|
637
638
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
638
639
|
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
639
640
|
await this.connectionTypeExistingAccessory(device, existingAccessory);
|
|
@@ -650,7 +651,7 @@ class SwitchBotPlatform {
|
|
|
650
651
|
else if (this.registerDevice(device)) {
|
|
651
652
|
// the accessory does not yet exist, so we need to create it
|
|
652
653
|
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
653
|
-
this.debugLog(
|
|
654
|
+
this.debugLog((0, super_stringify_1.default)(device.bot?.mode));
|
|
654
655
|
// create a new accessory
|
|
655
656
|
const accessory = new this.api.platformAccessory(device.deviceName, uuid);
|
|
656
657
|
// store a copy of the device object in the `accessory.context`
|
|
@@ -686,7 +687,7 @@ class SwitchBotPlatform {
|
|
|
686
687
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
687
688
|
existingAccessory.context.model = device.deviceType;
|
|
688
689
|
existingAccessory.context.deviceID = device.deviceId;
|
|
689
|
-
existingAccessory.displayName = device.deviceName;
|
|
690
|
+
existingAccessory.displayName = device.configDeviceName || device.deviceName;
|
|
690
691
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
691
692
|
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
692
693
|
await this.connectionTypeExistingAccessory(device, existingAccessory);
|
|
@@ -737,7 +738,7 @@ class SwitchBotPlatform {
|
|
|
737
738
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
738
739
|
existingAccessory.context.model = device.deviceType;
|
|
739
740
|
existingAccessory.context.deviceID = device.deviceId;
|
|
740
|
-
existingAccessory.displayName = device.deviceName;
|
|
741
|
+
existingAccessory.displayName = device.configDeviceName || device.deviceName;
|
|
741
742
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
742
743
|
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
743
744
|
await this.connectionTypeExistingAccessory(device, existingAccessory);
|
|
@@ -788,7 +789,7 @@ class SwitchBotPlatform {
|
|
|
788
789
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
789
790
|
existingAccessory.context.model = device.deviceType;
|
|
790
791
|
existingAccessory.context.deviceID = device.deviceId;
|
|
791
|
-
existingAccessory.displayName = device.deviceName;
|
|
792
|
+
existingAccessory.displayName = device.configDeviceName || device.deviceName;
|
|
792
793
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
793
794
|
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
794
795
|
await this.connectionTypeExistingAccessory(device, existingAccessory);
|
|
@@ -839,7 +840,7 @@ class SwitchBotPlatform {
|
|
|
839
840
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
840
841
|
existingAccessory.context.model = device.deviceType;
|
|
841
842
|
existingAccessory.context.deviceID = device.deviceId;
|
|
842
|
-
existingAccessory.displayName = device.deviceName;
|
|
843
|
+
existingAccessory.displayName = device.configDeviceName || device.deviceName;
|
|
843
844
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
844
845
|
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
845
846
|
await this.connectionTypeExistingAccessory(device, existingAccessory);
|
|
@@ -890,7 +891,7 @@ class SwitchBotPlatform {
|
|
|
890
891
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
891
892
|
existingAccessory.context.model = device.deviceType;
|
|
892
893
|
existingAccessory.context.deviceID = device.deviceId;
|
|
893
|
-
existingAccessory.displayName = device.deviceName;
|
|
894
|
+
existingAccessory.displayName = device.configDeviceName || device.deviceName;
|
|
894
895
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
895
896
|
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
896
897
|
await this.connectionTypeExistingAccessory(device, existingAccessory);
|
|
@@ -965,7 +966,7 @@ class SwitchBotPlatform {
|
|
|
965
966
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
966
967
|
existingAccessory.context.model = device.deviceType;
|
|
967
968
|
existingAccessory.context.deviceID = device.deviceId;
|
|
968
|
-
existingAccessory.displayName = device.deviceName;
|
|
969
|
+
existingAccessory.displayName = device.configDeviceName || device.deviceName;
|
|
969
970
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
970
971
|
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
971
972
|
await this.connectionTypeExistingAccessory(device, existingAccessory);
|
|
@@ -1016,7 +1017,7 @@ class SwitchBotPlatform {
|
|
|
1016
1017
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
1017
1018
|
existingAccessory.context.model = device.deviceType;
|
|
1018
1019
|
existingAccessory.context.deviceID = device.deviceId;
|
|
1019
|
-
existingAccessory.displayName = device.deviceName;
|
|
1020
|
+
existingAccessory.displayName = device.configDeviceName || device.deviceName;
|
|
1020
1021
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1021
1022
|
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
1022
1023
|
await this.connectionTypeExistingAccessory(device, existingAccessory);
|
|
@@ -1067,7 +1068,7 @@ class SwitchBotPlatform {
|
|
|
1067
1068
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
1068
1069
|
existingAccessory.context.model = device.deviceType;
|
|
1069
1070
|
existingAccessory.context.deviceID = device.deviceId;
|
|
1070
|
-
existingAccessory.displayName = device.deviceName;
|
|
1071
|
+
existingAccessory.displayName = device.configDeviceName || device.deviceName;
|
|
1071
1072
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1072
1073
|
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
1073
1074
|
await this.connectionTypeExistingAccessory(device, existingAccessory);
|
|
@@ -1118,7 +1119,7 @@ class SwitchBotPlatform {
|
|
|
1118
1119
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
1119
1120
|
existingAccessory.context.model = device.deviceType;
|
|
1120
1121
|
existingAccessory.context.deviceID = device.deviceId;
|
|
1121
|
-
existingAccessory.displayName = device.deviceName;
|
|
1122
|
+
existingAccessory.displayName = device.configDeviceName || device.deviceName;
|
|
1122
1123
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1123
1124
|
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
1124
1125
|
await this.connectionTypeExistingAccessory(device, existingAccessory);
|
|
@@ -1167,7 +1168,7 @@ class SwitchBotPlatform {
|
|
|
1167
1168
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
1168
1169
|
existingAccessory.context.model = device.remoteType;
|
|
1169
1170
|
existingAccessory.context.deviceID = device.deviceId;
|
|
1170
|
-
existingAccessory.displayName = device.deviceName;
|
|
1171
|
+
existingAccessory.displayName = device.configDeviceName || device.deviceName;
|
|
1171
1172
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1172
1173
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1173
1174
|
await this.connectionTypeExistingIRAccessory(existingAccessory);
|
|
@@ -1218,7 +1219,7 @@ class SwitchBotPlatform {
|
|
|
1218
1219
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
1219
1220
|
existingAccessory.context.model = device.remoteType;
|
|
1220
1221
|
existingAccessory.context.deviceID = device.deviceId;
|
|
1221
|
-
existingAccessory.displayName = device.deviceName;
|
|
1222
|
+
existingAccessory.displayName = device.configDeviceName || device.deviceName;
|
|
1222
1223
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1223
1224
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1224
1225
|
await this.connectionTypeExistingIRAccessory(existingAccessory);
|
|
@@ -1269,7 +1270,7 @@ class SwitchBotPlatform {
|
|
|
1269
1270
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
1270
1271
|
existingAccessory.context.model = device.remoteType;
|
|
1271
1272
|
existingAccessory.context.deviceID = device.deviceId;
|
|
1272
|
-
existingAccessory.displayName = device.deviceName;
|
|
1273
|
+
existingAccessory.displayName = device.configDeviceName || device.deviceName;
|
|
1273
1274
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1274
1275
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1275
1276
|
await this.connectionTypeExistingIRAccessory(existingAccessory);
|
|
@@ -1320,7 +1321,7 @@ class SwitchBotPlatform {
|
|
|
1320
1321
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
1321
1322
|
existingAccessory.context.model = device.remoteType;
|
|
1322
1323
|
existingAccessory.context.deviceID = device.deviceId;
|
|
1323
|
-
existingAccessory.displayName = device.deviceName;
|
|
1324
|
+
existingAccessory.displayName = device.configDeviceName || device.deviceName;
|
|
1324
1325
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1325
1326
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1326
1327
|
await this.connectionTypeExistingIRAccessory(existingAccessory);
|
|
@@ -1371,7 +1372,7 @@ class SwitchBotPlatform {
|
|
|
1371
1372
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
1372
1373
|
existingAccessory.context.model = device.remoteType;
|
|
1373
1374
|
existingAccessory.context.deviceID = device.deviceId;
|
|
1374
|
-
existingAccessory.displayName = device.deviceName;
|
|
1375
|
+
existingAccessory.displayName = device.configDeviceName || device.deviceName;
|
|
1375
1376
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1376
1377
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1377
1378
|
await this.connectionTypeExistingIRAccessory(existingAccessory);
|
|
@@ -1422,7 +1423,7 @@ class SwitchBotPlatform {
|
|
|
1422
1423
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
1423
1424
|
existingAccessory.context.model = device.remoteType;
|
|
1424
1425
|
existingAccessory.context.deviceID = device.deviceId;
|
|
1425
|
-
existingAccessory.displayName = device.deviceName;
|
|
1426
|
+
existingAccessory.displayName = device.configDeviceName || device.deviceName;
|
|
1426
1427
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1427
1428
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1428
1429
|
await this.connectionTypeExistingIRAccessory(existingAccessory);
|
|
@@ -1473,7 +1474,7 @@ class SwitchBotPlatform {
|
|
|
1473
1474
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
1474
1475
|
existingAccessory.context.model = device.remoteType;
|
|
1475
1476
|
existingAccessory.context.deviceID = device.deviceId;
|
|
1476
|
-
existingAccessory.displayName = device.deviceName;
|
|
1477
|
+
existingAccessory.displayName = device.configDeviceName || device.deviceName;
|
|
1477
1478
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1478
1479
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1479
1480
|
await this.connectionTypeExistingIRAccessory(existingAccessory);
|
|
@@ -1524,7 +1525,7 @@ class SwitchBotPlatform {
|
|
|
1524
1525
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
1525
1526
|
existingAccessory.context.model = device.remoteType;
|
|
1526
1527
|
existingAccessory.context.deviceID = device.deviceId;
|
|
1527
|
-
existingAccessory.displayName = device.deviceName;
|
|
1528
|
+
existingAccessory.displayName = device.configDeviceName || device.deviceName;
|
|
1528
1529
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1529
1530
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1530
1531
|
await this.connectionTypeExistingIRAccessory(existingAccessory);
|
|
@@ -1575,7 +1576,7 @@ class SwitchBotPlatform {
|
|
|
1575
1576
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
1576
1577
|
existingAccessory.context.model = device.remoteType;
|
|
1577
1578
|
existingAccessory.context.deviceID = device.deviceId;
|
|
1578
|
-
existingAccessory.displayName = device.deviceName;
|
|
1579
|
+
existingAccessory.displayName = device.configDeviceName || device.deviceName;
|
|
1579
1580
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1580
1581
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1581
1582
|
await this.connectionTypeExistingIRAccessory(existingAccessory);
|
|
@@ -1676,12 +1677,12 @@ class SwitchBotPlatform {
|
|
|
1676
1677
|
}
|
|
1677
1678
|
deviceListInfo(devices) {
|
|
1678
1679
|
if (this.platformLogging?.includes('debug')) {
|
|
1679
|
-
this.warnLog(`deviceListInfoStatus: ${
|
|
1680
|
+
this.warnLog(`deviceListInfoStatus: ${(0, super_stringify_1.default)(devices)}`);
|
|
1680
1681
|
}
|
|
1681
1682
|
}
|
|
1682
1683
|
async deviceInfo(device) {
|
|
1683
1684
|
if (this.platformLogging?.includes('debug')) {
|
|
1684
|
-
this.warnLog(
|
|
1685
|
+
this.warnLog((0, super_stringify_1.default)(device));
|
|
1685
1686
|
const t = Date.now();
|
|
1686
1687
|
const nonce = 'requestID';
|
|
1687
1688
|
const data = this.config.credentials?.token + t + nonce;
|
|
@@ -1713,10 +1714,10 @@ class SwitchBotPlatform {
|
|
|
1713
1714
|
req.end();
|
|
1714
1715
|
this.deviceStatus = req;
|
|
1715
1716
|
if (this.deviceStatus.message === 'success') {
|
|
1716
|
-
this.warnLog(`${device.deviceName} deviceInfoStatus: ${
|
|
1717
|
+
this.warnLog(`${device.deviceName} deviceInfoStatus: ${(0, super_stringify_1.default)(this.deviceStatus)}`);
|
|
1717
1718
|
}
|
|
1718
1719
|
else {
|
|
1719
|
-
this.warnLog(`${device.deviceName} deviceInfoStatus: ${
|
|
1720
|
+
this.warnLog(`${device.deviceName} deviceInfoStatus: ${(0, super_stringify_1.default)(this.deviceStatus.message)}`);
|
|
1720
1721
|
this.warnLog('Unable to retreive deviceInfoStatus.');
|
|
1721
1722
|
}
|
|
1722
1723
|
}
|