@switchbot/homebridge-switchbot 2.8.1-beta.9 → 2.8.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/.github/dependabot.yml +2 -2
- package/CHANGELOG.md +9 -0
- package/config.schema.json +4 -4
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +37 -23
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +26 -10
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +78 -29
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +78 -29
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +22 -19
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +36 -20
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts +3 -3
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +205 -172
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +66 -28
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +21 -11
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +63 -25
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +35 -19
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +2 -2
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +41 -31
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +21 -11
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +21 -16
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +32 -16
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +48 -21
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +15 -9
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +15 -9
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +15 -9
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +15 -9
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +16 -10
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +15 -4
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +15 -9
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +15 -9
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +15 -9
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +27 -10
- package/dist/platform.js.map +1 -1
- package/package.json +3 -3
- package/src/device/blindtilt.ts +35 -25
- package/src/device/bot.ts +25 -10
- package/src/device/ceilinglight.ts +73 -30
- package/src/device/colorbulb.ts +73 -30
- package/src/device/contact.ts +21 -20
- package/src/device/curtain.ts +34 -21
- package/src/device/hub.ts +211 -188
- package/src/device/humidifier.ts +62 -29
- package/src/device/iosensor.ts +20 -11
- package/src/device/lightstrip.ts +59 -26
- package/src/device/lock.ts +33 -20
- package/src/device/meter.ts +42 -34
- package/src/device/meterplus.ts +20 -11
- package/src/device/motion.ts +20 -17
- package/src/device/plug.ts +30 -17
- package/src/device/robotvacuumcleaner.ts +45 -22
- package/src/irdevice/airconditioner.ts +14 -10
- package/src/irdevice/airpurifier.ts +14 -10
- package/src/irdevice/camera.ts +14 -10
- package/src/irdevice/fan.ts +14 -10
- package/src/irdevice/light.ts +15 -11
- package/src/irdevice/other.ts +14 -4
- package/src/irdevice/tv.ts +14 -10
- package/src/irdevice/vacuumcleaner.ts +14 -10
- package/src/irdevice/waterheater.ts +14 -10
- package/src/platform.ts +24 -10
- package/.github/npm-version-script.js +0 -81
|
@@ -77,12 +77,6 @@ export class RobotVacuumCleaner {
|
|
|
77
77
|
(this.robotVacuumCleanerService = accessory.getService(this.platform.Service.Lightbulb) || accessory.addService(this.platform.Service.Lightbulb)),
|
|
78
78
|
`${device.deviceName} ${device.deviceType}`;
|
|
79
79
|
|
|
80
|
-
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
81
|
-
// when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
|
|
82
|
-
// accessory.getService('NAME') ?? accessory.addService(this.platform.Service.Lightbulb, 'NAME', 'USER_DEFINED_SUBTYPE');
|
|
83
|
-
|
|
84
|
-
// set the service name, this is what is displayed as the default name on the Home app
|
|
85
|
-
// in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
|
|
86
80
|
this.robotVacuumCleanerService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
87
81
|
if (!this.robotVacuumCleanerService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
88
82
|
this.robotVacuumCleanerService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
|
|
@@ -293,16 +287,25 @@ export class RobotVacuumCleaner {
|
|
|
293
287
|
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/status`, {
|
|
294
288
|
headers: this.platform.generateHeaders(),
|
|
295
289
|
});
|
|
290
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
291
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
292
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
296
293
|
const deviceStatus: any = await body.json();
|
|
297
|
-
this.
|
|
298
|
-
this.
|
|
299
|
-
this.
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
294
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
295
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
296
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
297
|
+
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
298
|
+
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
299
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
300
|
+
this.OpenAPI_On = deviceStatus.body.power;
|
|
301
|
+
this.OpenAPI_BatteryLevel = deviceStatus.body.battery;
|
|
302
|
+
this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
|
|
303
|
+
this.openAPIparseStatus();
|
|
304
|
+
this.updateHomeKitCharacteristics();
|
|
305
|
+
} else {
|
|
306
|
+
this.statusCode(statusCode);
|
|
307
|
+
this.statusCode(deviceStatus.statusCode);
|
|
308
|
+
}
|
|
306
309
|
} catch (e: any) {
|
|
307
310
|
this.apiError(e);
|
|
308
311
|
this.errorLog(
|
|
@@ -412,10 +415,20 @@ export class RobotVacuumCleaner {
|
|
|
412
415
|
method: 'POST',
|
|
413
416
|
headers: this.platform.generateHeaders(),
|
|
414
417
|
});
|
|
418
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
419
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
420
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
415
421
|
const deviceStatus: any = await body.json();
|
|
416
|
-
this.
|
|
417
|
-
this.
|
|
418
|
-
this.
|
|
422
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
423
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
424
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
425
|
+
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
426
|
+
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
427
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
428
|
+
} else {
|
|
429
|
+
this.statusCode(statusCode);
|
|
430
|
+
this.statusCode(deviceStatus.statusCode);
|
|
431
|
+
}
|
|
419
432
|
} catch (e: any) {
|
|
420
433
|
this.apiError(e);
|
|
421
434
|
this.errorLog(
|
|
@@ -441,10 +454,20 @@ export class RobotVacuumCleaner {
|
|
|
441
454
|
method: 'POST',
|
|
442
455
|
headers: this.platform.generateHeaders(),
|
|
443
456
|
});
|
|
457
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
458
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
459
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
444
460
|
const deviceStatus: any = await body.json();
|
|
445
|
-
this.
|
|
446
|
-
this.
|
|
447
|
-
this.
|
|
461
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
462
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
463
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
464
|
+
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
465
|
+
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
466
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
467
|
+
} else {
|
|
468
|
+
this.statusCode(statusCode);
|
|
469
|
+
this.statusCode(deviceStatus.statusCode);
|
|
470
|
+
}
|
|
448
471
|
} catch (e: any) {
|
|
449
472
|
this.apiError(e);
|
|
450
473
|
this.errorLog(
|
|
@@ -566,7 +589,7 @@ export class RobotVacuumCleaner {
|
|
|
566
589
|
this.accessory.getService(this.platform.Service.AccessoryInformation)!
|
|
567
590
|
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
|
|
568
591
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
569
|
-
+ `updateCharacteristic
|
|
592
|
+
+ `updateCharacteristic FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
|
|
570
593
|
}
|
|
571
594
|
}
|
|
572
595
|
|
|
@@ -71,12 +71,6 @@ export class AirConditioner {
|
|
|
71
71
|
(this.coolerService = accessory.getService(this.platform.Service.HeaterCooler) || accessory.addService(this.platform.Service.HeaterCooler)),
|
|
72
72
|
`${accessory.displayName} ${device.remoteType}`;
|
|
73
73
|
|
|
74
|
-
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
75
|
-
// when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
|
|
76
|
-
// accessory.getService('NAME') ?? accessory.addService(this.platform.Service.Outlet, 'NAME', 'USER_DEFINED_SUBTYPE');
|
|
77
|
-
|
|
78
|
-
// set the service name, this is what is displayed as the default name on the Home app
|
|
79
|
-
// in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
|
|
80
74
|
this.coolerService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
81
75
|
if (!this.coolerService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
82
76
|
this.coolerService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
|
|
@@ -262,11 +256,21 @@ export class AirConditioner {
|
|
|
262
256
|
method: 'POST',
|
|
263
257
|
headers: this.platform.generateHeaders(),
|
|
264
258
|
});
|
|
259
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
260
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
261
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
265
262
|
const deviceStatus: any = await body.json();
|
|
266
|
-
this.
|
|
267
|
-
this.
|
|
268
|
-
this.
|
|
269
|
-
|
|
263
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
264
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
265
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
266
|
+
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
267
|
+
this.debugErrorLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
268
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
269
|
+
this.updateHomeKitCharacteristics();
|
|
270
|
+
} else {
|
|
271
|
+
this.statusCode(statusCode);
|
|
272
|
+
this.statusCode(deviceStatus.statusCode);
|
|
273
|
+
}
|
|
270
274
|
} catch (e: any) {
|
|
271
275
|
this.apiError(e);
|
|
272
276
|
this.errorLog(
|
|
@@ -65,12 +65,6 @@ export class AirPurifier {
|
|
|
65
65
|
(this.airPurifierService = accessory.getService(this.platform.Service.AirPurifier) || accessory.addService(this.platform.Service.AirPurifier)),
|
|
66
66
|
`${accessory.displayName} Air Purifier`;
|
|
67
67
|
|
|
68
|
-
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
69
|
-
// when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
|
|
70
|
-
// accessory.getService('NAME') ?? accessory.addService(this.platform.Service.Outlet, 'NAME', 'USER_DEFINED_SUBTYPE');
|
|
71
|
-
|
|
72
|
-
// set the service name, this is what is displayed as the default name on the Home app
|
|
73
|
-
// in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
|
|
74
68
|
this.airPurifierService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
75
69
|
if (!this.airPurifierService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
76
70
|
this.airPurifierService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
|
|
@@ -218,11 +212,21 @@ export class AirPurifier {
|
|
|
218
212
|
method: 'POST',
|
|
219
213
|
headers: this.platform.generateHeaders(),
|
|
220
214
|
});
|
|
215
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
216
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
217
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
221
218
|
const deviceStatus: any = await body.json();
|
|
222
|
-
this.
|
|
223
|
-
this.
|
|
224
|
-
this.
|
|
225
|
-
|
|
219
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
220
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
221
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
222
|
+
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
223
|
+
this.debugErrorLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
224
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
225
|
+
this.updateHomeKitCharacteristics();
|
|
226
|
+
} else {
|
|
227
|
+
this.statusCode(statusCode);
|
|
228
|
+
this.statusCode(deviceStatus.statusCode);
|
|
229
|
+
}
|
|
226
230
|
} catch (e: any) {
|
|
227
231
|
this.apiError(e);
|
|
228
232
|
this.errorLog(
|
package/src/irdevice/camera.ts
CHANGED
|
@@ -47,12 +47,6 @@ export class Camera {
|
|
|
47
47
|
(this.switchService = accessory.getService(this.platform.Service.Switch) || accessory.addService(this.platform.Service.Switch)),
|
|
48
48
|
`${accessory.displayName} Camera`;
|
|
49
49
|
|
|
50
|
-
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
51
|
-
// when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
|
|
52
|
-
// accessory.getService('NAME') ?? accessory.addService(this.platform.Service.Outlet, 'NAME', 'USER_DEFINED_SUBTYPE');
|
|
53
|
-
|
|
54
|
-
// set the service name, this is what is displayed as the default name on the Home app
|
|
55
|
-
// in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
|
|
56
50
|
this.switchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
57
51
|
if (!this.switchService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
58
52
|
this.switchService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
|
|
@@ -123,11 +117,21 @@ export class Camera {
|
|
|
123
117
|
method: 'POST',
|
|
124
118
|
headers: this.platform.generateHeaders(),
|
|
125
119
|
});
|
|
120
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
121
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
122
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
126
123
|
const deviceStatus: any = await body.json();
|
|
127
|
-
this.
|
|
128
|
-
this.
|
|
129
|
-
this.
|
|
130
|
-
|
|
124
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
125
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
126
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
127
|
+
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
128
|
+
this.debugErrorLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
129
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
130
|
+
this.updateHomeKitCharacteristics();
|
|
131
|
+
} else {
|
|
132
|
+
this.statusCode(statusCode);
|
|
133
|
+
this.statusCode(deviceStatus.statusCode);
|
|
134
|
+
}
|
|
131
135
|
} catch (e: any) {
|
|
132
136
|
this.apiError(e);
|
|
133
137
|
this.errorLog(
|
package/src/irdevice/fan.ts
CHANGED
|
@@ -54,12 +54,6 @@ export class Fan {
|
|
|
54
54
|
(this.fanService = accessory.getService(this.platform.Service.Fanv2) || accessory.addService(this.platform.Service.Fanv2)),
|
|
55
55
|
`${accessory.displayName} Fan`;
|
|
56
56
|
|
|
57
|
-
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
58
|
-
// when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
|
|
59
|
-
// accessory.getService('NAME') ?? accessory.addService(this.platform.Service.Outlet, 'NAME', 'USER_DEFINED_SUBTYPE');
|
|
60
|
-
|
|
61
|
-
// set the service name, this is what is displayed as the default name on the Home app
|
|
62
|
-
// in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
|
|
63
57
|
this.fanService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
64
58
|
if (!this.fanService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
65
59
|
this.fanService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
|
|
@@ -240,11 +234,21 @@ export class Fan {
|
|
|
240
234
|
method: 'POST',
|
|
241
235
|
headers: this.platform.generateHeaders(),
|
|
242
236
|
});
|
|
237
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
238
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
239
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
243
240
|
const deviceStatus: any = await body.json();
|
|
244
|
-
this.
|
|
245
|
-
this.
|
|
246
|
-
this.
|
|
247
|
-
|
|
241
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
242
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
243
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
244
|
+
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
245
|
+
this.debugErrorLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
246
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
247
|
+
this.updateHomeKitCharacteristics();
|
|
248
|
+
} else {
|
|
249
|
+
this.statusCode(statusCode);
|
|
250
|
+
this.statusCode(deviceStatus.statusCode);
|
|
251
|
+
}
|
|
248
252
|
} catch (e: any) {
|
|
249
253
|
this.apiError(e);
|
|
250
254
|
this.errorLog(
|
package/src/irdevice/light.ts
CHANGED
|
@@ -47,12 +47,6 @@ export class Light {
|
|
|
47
47
|
(this.lightBulbService = accessory.getService(this.platform.Service.Lightbulb) || accessory.addService(this.platform.Service.Lightbulb)),
|
|
48
48
|
`${accessory.displayName} ${device.remoteType}`;
|
|
49
49
|
|
|
50
|
-
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
51
|
-
// when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
|
|
52
|
-
// accessory.getService('NAME') ?? accessory.addService(this.platform.Service.Outlet, 'NAME', 'USER_DEFINED_SUBTYPE');
|
|
53
|
-
|
|
54
|
-
// set the service name, this is what is displayed as the default name on the Home app
|
|
55
|
-
// in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
|
|
56
50
|
this.lightBulbService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
57
51
|
if (!this.lightBulbService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
58
52
|
this.lightBulbService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
|
|
@@ -147,12 +141,22 @@ export class Light {
|
|
|
147
141
|
method: 'POST',
|
|
148
142
|
headers: this.platform.generateHeaders(),
|
|
149
143
|
});
|
|
144
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
145
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
146
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
150
147
|
const deviceStatus: any = await body.json();
|
|
151
|
-
this.
|
|
152
|
-
this.
|
|
153
|
-
this.
|
|
154
|
-
|
|
155
|
-
|
|
148
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
149
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
150
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
151
|
+
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
152
|
+
this.debugErrorLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
153
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
154
|
+
this.accessory.context.On = this.On;
|
|
155
|
+
this.updateHomeKitCharacteristics();
|
|
156
|
+
} else {
|
|
157
|
+
this.statusCode(statusCode);
|
|
158
|
+
this.statusCode(deviceStatus.statusCode);
|
|
159
|
+
}
|
|
156
160
|
} catch (e: any) {
|
|
157
161
|
this.apiError(e);
|
|
158
162
|
this.errorLog(
|
package/src/irdevice/other.ts
CHANGED
|
@@ -142,11 +142,21 @@ export class Others {
|
|
|
142
142
|
method: 'POST',
|
|
143
143
|
headers: this.platform.generateHeaders(),
|
|
144
144
|
});
|
|
145
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
146
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
147
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
145
148
|
const deviceStatus: any = await body.json();
|
|
146
|
-
this.
|
|
147
|
-
this.
|
|
148
|
-
this.
|
|
149
|
-
|
|
149
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
150
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
151
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
152
|
+
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
153
|
+
this.debugErrorLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
154
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
155
|
+
this.updateHomeKitCharacteristics();
|
|
156
|
+
} else {
|
|
157
|
+
this.statusCode(statusCode);
|
|
158
|
+
this.statusCode(deviceStatus.statusCode);
|
|
159
|
+
}
|
|
150
160
|
} catch (e: any) {
|
|
151
161
|
this.apiError(e);
|
|
152
162
|
this.errorLog(
|
package/src/irdevice/tv.ts
CHANGED
|
@@ -78,12 +78,6 @@ export class TV {
|
|
|
78
78
|
`${accessory.displayName} ${device.remoteType}`;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
82
|
-
// when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
|
|
83
|
-
// accessory.getService('NAME') ?? accessory.addService(this.platform.Service.Outlet, 'NAME', 'USER_DEFINED_SUBTYPE');
|
|
84
|
-
|
|
85
|
-
// set the service name, this is what is displayed as the default name on the Home app
|
|
86
|
-
// in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
|
|
87
81
|
this.tvService.getCharacteristic(this.platform.Characteristic.ConfiguredName);
|
|
88
82
|
|
|
89
83
|
// set sleep discovery characteristic
|
|
@@ -372,11 +366,21 @@ export class TV {
|
|
|
372
366
|
method: 'POST',
|
|
373
367
|
headers: this.platform.generateHeaders(),
|
|
374
368
|
});
|
|
369
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
370
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
371
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
375
372
|
const deviceStatus: any = await body.json();
|
|
376
|
-
this.
|
|
377
|
-
this.
|
|
378
|
-
this.
|
|
379
|
-
|
|
373
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
374
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
375
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
376
|
+
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
377
|
+
this.debugErrorLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
378
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
379
|
+
this.updateHomeKitCharacteristics();
|
|
380
|
+
} else {
|
|
381
|
+
this.statusCode(statusCode);
|
|
382
|
+
this.statusCode(deviceStatus.statusCode);
|
|
383
|
+
}
|
|
380
384
|
} catch (e: any) {
|
|
381
385
|
this.apiError(e);
|
|
382
386
|
this.errorLog(
|
|
@@ -47,12 +47,6 @@ export class VacuumCleaner {
|
|
|
47
47
|
(this.switchService = accessory.getService(this.platform.Service.Switch) || accessory.addService(this.platform.Service.Switch)),
|
|
48
48
|
`${accessory.displayName} ${device.remoteType}`;
|
|
49
49
|
|
|
50
|
-
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
51
|
-
// when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
|
|
52
|
-
// accessory.getService('NAME') ?? accessory.addService(this.platform.Service.Outlet, 'NAME', 'USER_DEFINED_SUBTYPE');
|
|
53
|
-
|
|
54
|
-
// set the service name, this is what is displayed as the default name on the Home app
|
|
55
|
-
// in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
|
|
56
50
|
this.switchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
57
51
|
if (!this.switchService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
58
52
|
this.switchService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
|
|
@@ -119,11 +113,21 @@ export class VacuumCleaner {
|
|
|
119
113
|
method: 'POST',
|
|
120
114
|
headers: this.platform.generateHeaders(),
|
|
121
115
|
});
|
|
116
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
117
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
118
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
122
119
|
const deviceStatus: any = await body.json();
|
|
123
|
-
this.
|
|
124
|
-
this.
|
|
125
|
-
this.
|
|
126
|
-
|
|
120
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
121
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
122
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
123
|
+
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
124
|
+
this.debugErrorLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
125
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
126
|
+
this.updateHomeKitCharacteristics();
|
|
127
|
+
} else {
|
|
128
|
+
this.statusCode(statusCode);
|
|
129
|
+
this.statusCode(deviceStatus.statusCode);
|
|
130
|
+
}
|
|
127
131
|
} catch (e: any) {
|
|
128
132
|
this.apiError(e);
|
|
129
133
|
this.errorLog(
|
|
@@ -47,12 +47,6 @@ export class WaterHeater {
|
|
|
47
47
|
(this.valveService = accessory.getService(this.platform.Service.Valve) || accessory.addService(this.platform.Service.Valve)),
|
|
48
48
|
`${accessory.displayName} ${device.remoteType}`;
|
|
49
49
|
|
|
50
|
-
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
51
|
-
// when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
|
|
52
|
-
// accessory.getService('NAME') ?? accessory.addService(this.platform.Service.Outlet, 'NAME', 'USER_DEFINED_SUBTYPE');
|
|
53
|
-
|
|
54
|
-
// set the service name, this is what is displayed as the default name on the Home app
|
|
55
|
-
// in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
|
|
56
50
|
this.valveService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
57
51
|
if (!this.valveService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
58
52
|
this.valveService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
|
|
@@ -128,11 +122,21 @@ export class WaterHeater {
|
|
|
128
122
|
method: 'POST',
|
|
129
123
|
headers: this.platform.generateHeaders(),
|
|
130
124
|
});
|
|
125
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
126
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
127
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
131
128
|
const deviceStatus: any = await body.json();
|
|
132
|
-
this.
|
|
133
|
-
this.
|
|
134
|
-
this.
|
|
135
|
-
|
|
129
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
130
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
131
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
132
|
+
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
133
|
+
this.debugErrorLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
134
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
135
|
+
this.updateHomeKitCharacteristics();
|
|
136
|
+
} else {
|
|
137
|
+
this.statusCode(statusCode);
|
|
138
|
+
this.statusCode(deviceStatus.statusCode);
|
|
139
|
+
}
|
|
136
140
|
} catch (e: any) {
|
|
137
141
|
this.apiError(e);
|
|
138
142
|
this.errorLog(
|
package/src/platform.ts
CHANGED
|
@@ -301,14 +301,15 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
301
301
|
headers: this.generateHeaders(),
|
|
302
302
|
});
|
|
303
303
|
this.debugWarnLog(`body: ${JSON.stringify(body)}`);
|
|
304
|
-
this.debugWarnLog(`
|
|
305
|
-
this.debugWarnLog(`
|
|
304
|
+
this.debugWarnLog(`statusCode: ${statusCode}`);
|
|
305
|
+
this.debugWarnLog(`headers: ${JSON.stringify(headers)}`);
|
|
306
306
|
const devicesAPI: any = await body.json();
|
|
307
|
-
|
|
308
|
-
|
|
307
|
+
this.debugWarnLog(`devicesAPI: ${JSON.stringify(devicesAPI)}`);
|
|
308
|
+
this.debugWarnLog(`devicesAPI Body: ${JSON.stringify(devicesAPI.body)}`);
|
|
309
|
+
this.debugWarnLog(`devicesAPI StatusCode: ${devicesAPI.statusCode}`);
|
|
310
|
+
if ((statusCode === 200 || statusCode === 100) && (devicesAPI.statusCode === 200 || devicesAPI.statusCode === 100)) {
|
|
311
|
+
this.debugErrorLog(`statusCode: ${statusCode} & devicesAPI StatusCode: ${devicesAPI.statusCode}`);
|
|
309
312
|
// SwitchBot Devices
|
|
310
|
-
this.debugWarnLog(`devicesAPI: ${JSON.stringify(devicesAPI)}`);
|
|
311
|
-
this.debugWarnLog(`devicesAPI Length: ${devicesAPI.length}`);
|
|
312
313
|
const deviceLists = devicesAPI.body.deviceList;
|
|
313
314
|
this.debugWarnLog(`DeviceLists: ${JSON.stringify(deviceLists)}`);
|
|
314
315
|
this.debugWarnLog(`DeviceLists Length: ${deviceLists.length}`);
|
|
@@ -399,6 +400,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
399
400
|
}
|
|
400
401
|
} else {
|
|
401
402
|
this.statusCode(statusCode);
|
|
403
|
+
this.statusCode(devicesAPI.statusCode);
|
|
402
404
|
}
|
|
403
405
|
} catch (e: any) {
|
|
404
406
|
this.debugErrorLog(
|
|
@@ -2085,7 +2087,11 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2085
2087
|
registerDevice = true;
|
|
2086
2088
|
this.debugWarnLog(`Device: ${device.deviceName} registerDevice: ${registerDevice}`);
|
|
2087
2089
|
}
|
|
2088
|
-
|
|
2090
|
+
if (registerDevice === true) {
|
|
2091
|
+
this.debugWarnLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will display in HomeKit`);
|
|
2092
|
+
} else {
|
|
2093
|
+
this.debugErrorLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will not display in HomeKit`);
|
|
2094
|
+
}
|
|
2089
2095
|
} else if (!device.hide_device && device.deviceId && device.configDeviceType && device.configDeviceName && device.connectionType === 'BLE') {
|
|
2090
2096
|
if (device.deviceType === 'Curtain' || device.deviceType === 'Blind Tilt') {
|
|
2091
2097
|
registerDevice = await this.registerCurtains(device);
|
|
@@ -2094,7 +2100,11 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2094
2100
|
registerDevice = true;
|
|
2095
2101
|
this.debugWarnLog(`Device: ${device.deviceName} registerDevice: ${registerDevice}`);
|
|
2096
2102
|
}
|
|
2097
|
-
|
|
2103
|
+
if (registerDevice === true) {
|
|
2104
|
+
this.debugWarnLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will display in HomeKit`);
|
|
2105
|
+
} else {
|
|
2106
|
+
this.debugErrorLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will not display in HomeKit`);
|
|
2107
|
+
}
|
|
2098
2108
|
} else if (!device.hide_device && device.connectionType === 'OpenAPI') {
|
|
2099
2109
|
if (device.deviceType === 'Curtain' || device.deviceType === 'Blind Tilt') {
|
|
2100
2110
|
registerDevice = await this.registerCurtains(device);
|
|
@@ -2103,7 +2113,11 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2103
2113
|
registerDevice = true;
|
|
2104
2114
|
this.debugWarnLog(`Device: ${device.deviceName} registerDevice: ${registerDevice}`);
|
|
2105
2115
|
}
|
|
2106
|
-
|
|
2116
|
+
if (registerDevice === true) {
|
|
2117
|
+
this.debugWarnLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will display in HomeKit`);
|
|
2118
|
+
} else {
|
|
2119
|
+
this.debugErrorLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will not display in HomeKit`);
|
|
2120
|
+
}
|
|
2107
2121
|
} else if (!device.hide_device && device.connectionType === 'Disabled') {
|
|
2108
2122
|
if (device.deviceType === 'Curtain' || device.deviceType === 'Blind Tilt') {
|
|
2109
2123
|
registerDevice = await this.registerCurtains(device);
|
|
@@ -2194,7 +2208,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2194
2208
|
this.debugLog(`Request successful, statusCode: ${statusCode}`);
|
|
2195
2209
|
break;
|
|
2196
2210
|
default:
|
|
2197
|
-
this.
|
|
2211
|
+
this.errorLog(`Unknown statusCode, statusCode: ${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
|
|
2198
2212
|
}
|
|
2199
2213
|
}
|
|
2200
2214
|
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
#!/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This scripts queries the npm registry to pull out the latest version for a given tag.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const fs = require("fs");
|
|
8
|
-
const semver = require("semver");
|
|
9
|
-
const child_process = require("child_process");
|
|
10
|
-
const assert = require("assert");
|
|
11
|
-
|
|
12
|
-
const BRANCH_VERSION_PATTERN = /^([A-Za-z]*)-(\d+.\d+.\d+)$/
|
|
13
|
-
|
|
14
|
-
// Load the contents of the package.json file
|
|
15
|
-
const packageJSON = JSON.parse(fs.readFileSync("package.json", "utf8"));
|
|
16
|
-
|
|
17
|
-
let refArgument = process.argv[2];
|
|
18
|
-
let tagArgument = process.argv[3] || "latest";
|
|
19
|
-
|
|
20
|
-
if (refArgument == null) {
|
|
21
|
-
console.error("ref argument is missing");
|
|
22
|
-
console.error("Usage: npm-version-script.js <ref> [tag]");
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Queries the NPM registry for the latest version for the provided tag.
|
|
28
|
-
* @param tag The tag to query for.
|
|
29
|
-
* @returns {string} Returns the version.
|
|
30
|
-
*/
|
|
31
|
-
function getTagVersionFromNpm(tag) {
|
|
32
|
-
try {
|
|
33
|
-
return child_process.execSync(`npm info ${packageJSON.name} version --tag="${tag}"`).toString("utf8").trim();
|
|
34
|
-
} catch (e) {
|
|
35
|
-
throw e;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function desiredTargetVersion(ref) {
|
|
40
|
-
// ref is a GitHub action ref string
|
|
41
|
-
if (ref.startsWith("refs/pull/")) {
|
|
42
|
-
throw Error("The version script was executed inside a PR!");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
assert(ref.startsWith("refs/heads/"))
|
|
46
|
-
let branchName = ref.slice("refs/heads/".length);
|
|
47
|
-
|
|
48
|
-
let results = branchName.match(BRANCH_VERSION_PATTERN);
|
|
49
|
-
if (results != null) {
|
|
50
|
-
if (results[1] !== tagArgument) {
|
|
51
|
-
console.warn(`The base branch name (${results[1]}) differs from the tag name ${tagArgument}`);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return results[2];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// legacy mode were we use the `betaVersion` property in the package.json
|
|
58
|
-
if (branchName === "beta" && packageJSON.betaVersion) {
|
|
59
|
-
return packageJSON.betaVersion
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
throw new Error("Malformed branch name for ref: " + ref + ". Can't derive the base version. Use a branch name like: beta-x.x.x!");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// derive the base version from the branch ref
|
|
66
|
-
const baseVersion = desiredTargetVersion(refArgument);
|
|
67
|
-
|
|
68
|
-
// query the npm registry for the latest version of the provided tag name
|
|
69
|
-
const latestReleasedVersion = getTagVersionFromNpm(tagArgument); // e.g. 0.7.0-beta.12
|
|
70
|
-
const latestReleaseBase = semver.inc(latestReleasedVersion, "patch"); // will produce 0.7.0 (removing the preid, needed for the equality check below)
|
|
71
|
-
|
|
72
|
-
let publishTag;
|
|
73
|
-
if (semver.eq(baseVersion, latestReleaseBase)) { // check if we are releasing another version for the latest beta
|
|
74
|
-
publishTag = latestReleasedVersion; // set the current latest beta to be incremented
|
|
75
|
-
} else {
|
|
76
|
-
publishTag = baseVersion; // start of with a new beta version
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// save the package.json
|
|
80
|
-
packageJSON.version = publishTag;
|
|
81
|
-
fs.writeFileSync("package.json", JSON.stringify(packageJSON, null, 2));
|