@switchbot/homebridge-switchbot 2.0.0-beta.0 → 2.0.0-beta.10
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/workflows/{label.yml → labeler.yml} +4 -6
- package/CHANGELOG.md +2 -1
- package/config.schema.json +17 -1
- package/dist/device/bot.d.ts +0 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +14 -29
- package/dist/device/bot.js.map +1 -1
- package/dist/device/colorbulb.d.ts +1 -6
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +19 -19
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +0 -1
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/meter.d.ts +0 -4
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +0 -4
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/plug.d.ts +0 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +3 -8
- package/dist/device/plug.js.map +1 -1
- package/dist/device/striplight.d.ts +16 -5
- package/dist/device/striplight.d.ts.map +1 -1
- package/dist/device/striplight.js +167 -10
- package/dist/device/striplight.js.map +1 -1
- package/dist/platform.d.ts +3 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +93 -79
- 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 +9 -9
- package/src/device/bot.ts +14 -30
- package/src/device/colorbulb.ts +21 -25
- package/src/device/curtain.ts +0 -1
- package/src/device/meter.ts +0 -4
- package/src/device/meterplus.ts +0 -4
- package/src/device/plug.ts +3 -9
- package/src/device/striplight.ts +180 -15
- package/src/platform.ts +88 -73
- package/src/settings.ts +2 -0
- package/.github/labeler.yml +0 -13
package/dist/platform.js
CHANGED
|
@@ -177,32 +177,32 @@ class SwitchBotPlatform {
|
|
|
177
177
|
if (this.platformLogging?.includes('debug')) {
|
|
178
178
|
this.debugLog('Using Default Refresh Rate (2 minutes).');
|
|
179
179
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
180
|
+
}
|
|
181
|
+
if (!this.config.options.pushRate) {
|
|
182
|
+
// default 100 milliseconds
|
|
183
|
+
this.config.options.pushRate = 0.1;
|
|
184
|
+
if (this.platformLogging?.includes('debug')) {
|
|
185
|
+
this.warnLog('Using Default Push Rate.');
|
|
186
186
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
187
|
+
}
|
|
188
|
+
if (!this.config.credentials) {
|
|
189
|
+
if (this.platformLogging?.includes('debug')) {
|
|
190
|
+
this.debugLog('Missing Credentials');
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (!this.config.credentials?.token) {
|
|
194
|
+
if (this.platformLogging?.includes('debug')) {
|
|
195
|
+
this.errorLog('Missing token');
|
|
196
|
+
this.warnLog('Cloud Enabled SwitchBot Devices & IR Devices will not work');
|
|
191
197
|
}
|
|
192
|
-
|
|
198
|
+
}
|
|
199
|
+
if (this.config.credentials?.token) {
|
|
200
|
+
if (!this.config.credentials?.secret) {
|
|
193
201
|
if (this.platformLogging?.includes('debug')) {
|
|
194
|
-
this.errorLog('Missing
|
|
202
|
+
this.errorLog('Missing secret');
|
|
195
203
|
this.warnLog('Cloud Enabled SwitchBot Devices & IR Devices will not work');
|
|
196
204
|
}
|
|
197
|
-
|
|
198
|
-
if (this.config.credentials?.token) {
|
|
199
|
-
if (!this.config.credentials?.secret) {
|
|
200
|
-
if (this.platformLogging?.includes('debug')) {
|
|
201
|
-
this.errorLog('Missing secret');
|
|
202
|
-
this.warnLog('Cloud Enabled SwitchBot Devices & IR Devices will not work');
|
|
203
|
-
}
|
|
204
|
-
throw Error('Missing secret');
|
|
205
|
-
}
|
|
205
|
+
throw Error('Missing secret');
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
}
|
|
@@ -568,25 +568,6 @@ class SwitchBotPlatform {
|
|
|
568
568
|
this.warnLog('Submit Feature Requests Here: https://git.io/JL14Z');
|
|
569
569
|
}
|
|
570
570
|
}
|
|
571
|
-
registerDevice(device) {
|
|
572
|
-
if (!device.hide_device && device.enableCloudService && device.ble) {
|
|
573
|
-
this.registeringDevice = true;
|
|
574
|
-
this.debugLog(`Device: ${device.deviceName} Both OpenAPI and BLE Connections Enabled`);
|
|
575
|
-
}
|
|
576
|
-
else if (!device.hide_device && device.deviceId && device.configDeviceType && device.configDeviceName && !device.enableCloudService) {
|
|
577
|
-
this.registeringDevice = true;
|
|
578
|
-
this.debugLog(`Device: ${device.deviceName} BLE Connection Enabled`);
|
|
579
|
-
}
|
|
580
|
-
else if (!device.hide_device && device.enableCloudService && !device.ble) {
|
|
581
|
-
this.registeringDevice = true;
|
|
582
|
-
this.debugLog(`Device: ${device.deviceName} OpenAPI Connection Enabled`);
|
|
583
|
-
}
|
|
584
|
-
else {
|
|
585
|
-
this.registeringDevice = false;
|
|
586
|
-
this.debugLog(`Device: ${device.deviceName} OpenAPI and BLE Are Not Enabled`);
|
|
587
|
-
}
|
|
588
|
-
return this.registeringDevice;
|
|
589
|
-
}
|
|
590
571
|
async createHumidifier(device) {
|
|
591
572
|
const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
|
|
592
573
|
// see if an accessory with the same uuid has already been registered and restored from
|
|
@@ -631,8 +612,8 @@ class SwitchBotPlatform {
|
|
|
631
612
|
// this is imported from `platformAccessory.ts`
|
|
632
613
|
new humidifier_1.Humidifier(this, accessory, device);
|
|
633
614
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
634
|
-
// link the accessory to your platform
|
|
635
|
-
this.
|
|
615
|
+
// publish device externally or link the accessory to your platform
|
|
616
|
+
this.externalOrPlatform(device, accessory);
|
|
636
617
|
this.accessories.push(accessory);
|
|
637
618
|
}
|
|
638
619
|
else {
|
|
@@ -685,8 +666,8 @@ class SwitchBotPlatform {
|
|
|
685
666
|
// this is imported from `platformAccessory.ts`
|
|
686
667
|
new bot_1.Bot(this, accessory, device);
|
|
687
668
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
688
|
-
// link the accessory to your platform
|
|
689
|
-
this.
|
|
669
|
+
// publish device externally or link the accessory to your platform
|
|
670
|
+
this.externalOrPlatform(device, accessory);
|
|
690
671
|
this.accessories.push(accessory);
|
|
691
672
|
}
|
|
692
673
|
else {
|
|
@@ -736,8 +717,8 @@ class SwitchBotPlatform {
|
|
|
736
717
|
// this is imported from `platformAccessory.ts`
|
|
737
718
|
new meter_1.Meter(this, accessory, device);
|
|
738
719
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
739
|
-
// link the accessory to your platform
|
|
740
|
-
this.
|
|
720
|
+
// publish device externally or link the accessory to your platform
|
|
721
|
+
this.externalOrPlatform(device, accessory);
|
|
741
722
|
this.accessories.push(accessory);
|
|
742
723
|
}
|
|
743
724
|
else {
|
|
@@ -787,8 +768,8 @@ class SwitchBotPlatform {
|
|
|
787
768
|
// this is imported from `platformAccessory.ts`
|
|
788
769
|
new meterplus_1.MeterPlus(this, accessory, device);
|
|
789
770
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
790
|
-
// link the accessory to your platform
|
|
791
|
-
this.
|
|
771
|
+
// publish device externally or link the accessory to your platform
|
|
772
|
+
this.externalOrPlatform(device, accessory);
|
|
792
773
|
this.accessories.push(accessory);
|
|
793
774
|
}
|
|
794
775
|
else {
|
|
@@ -838,8 +819,8 @@ class SwitchBotPlatform {
|
|
|
838
819
|
// this is imported from `platformAccessory.ts`
|
|
839
820
|
new motion_1.Motion(this, accessory, device);
|
|
840
821
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
841
|
-
// link the accessory to your platform
|
|
842
|
-
this.
|
|
822
|
+
// publish device externally or link the accessory to your platform
|
|
823
|
+
this.externalOrPlatform(device, accessory);
|
|
843
824
|
this.accessories.push(accessory);
|
|
844
825
|
}
|
|
845
826
|
else {
|
|
@@ -889,8 +870,8 @@ class SwitchBotPlatform {
|
|
|
889
870
|
// this is imported from `platformAccessory.ts`
|
|
890
871
|
new contact_1.Contact(this, accessory, device);
|
|
891
872
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
892
|
-
// link the accessory to your platform
|
|
893
|
-
this.
|
|
873
|
+
// publish device externally or link the accessory to your platform
|
|
874
|
+
this.externalOrPlatform(device, accessory);
|
|
894
875
|
this.accessories.push(accessory);
|
|
895
876
|
}
|
|
896
877
|
else {
|
|
@@ -952,8 +933,8 @@ class SwitchBotPlatform {
|
|
|
952
933
|
// this is imported from `platformAccessory.ts`
|
|
953
934
|
new curtain_1.Curtain(this, accessory, device);
|
|
954
935
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
955
|
-
// link the accessory to your platform
|
|
956
|
-
this.
|
|
936
|
+
// publish device externally or link the accessory to your platform
|
|
937
|
+
this.externalOrPlatform(device, accessory);
|
|
957
938
|
this.accessories.push(accessory);
|
|
958
939
|
}
|
|
959
940
|
else {
|
|
@@ -1015,8 +996,8 @@ class SwitchBotPlatform {
|
|
|
1015
996
|
// this is imported from `platformAccessory.ts`
|
|
1016
997
|
new plug_1.Plug(this, accessory, device);
|
|
1017
998
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1018
|
-
// link the accessory to your platform
|
|
1019
|
-
this.
|
|
999
|
+
// publish device externally or link the accessory to your platform
|
|
1000
|
+
this.externalOrPlatform(device, accessory);
|
|
1020
1001
|
this.accessories.push(accessory);
|
|
1021
1002
|
}
|
|
1022
1003
|
else {
|
|
@@ -1066,8 +1047,8 @@ class SwitchBotPlatform {
|
|
|
1066
1047
|
// this is imported from `platformAccessory.ts`
|
|
1067
1048
|
new lock_1.Lock(this, accessory, device);
|
|
1068
1049
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1069
|
-
// link the accessory to your platform
|
|
1070
|
-
this.
|
|
1050
|
+
// publish device externally or link the accessory to your platform
|
|
1051
|
+
this.externalOrPlatform(device, accessory);
|
|
1071
1052
|
this.accessories.push(accessory);
|
|
1072
1053
|
}
|
|
1073
1054
|
else {
|
|
@@ -1117,8 +1098,8 @@ class SwitchBotPlatform {
|
|
|
1117
1098
|
// this is imported from `platformAccessory.ts`
|
|
1118
1099
|
new colorbulb_1.ColorBulb(this, accessory, device);
|
|
1119
1100
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1120
|
-
// link the accessory to your platform
|
|
1121
|
-
this.
|
|
1101
|
+
// publish device externally or link the accessory to your platform
|
|
1102
|
+
this.externalOrPlatform(device, accessory);
|
|
1122
1103
|
this.accessories.push(accessory);
|
|
1123
1104
|
}
|
|
1124
1105
|
else {
|
|
@@ -1168,8 +1149,8 @@ class SwitchBotPlatform {
|
|
|
1168
1149
|
// this is imported from `platformAccessory.ts`
|
|
1169
1150
|
new striplight_1.StripLight(this, accessory, device);
|
|
1170
1151
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1171
|
-
// link the accessory to your platform
|
|
1172
|
-
this.
|
|
1152
|
+
// publish device externally or link the accessory to your platform
|
|
1153
|
+
this.externalOrPlatform(device, accessory);
|
|
1173
1154
|
this.accessories.push(accessory);
|
|
1174
1155
|
}
|
|
1175
1156
|
else {
|
|
@@ -1218,7 +1199,7 @@ class SwitchBotPlatform {
|
|
|
1218
1199
|
* Only one TV can exist per bridge, to bypass this limitation, you should
|
|
1219
1200
|
* publish your TV as an external accessory.
|
|
1220
1201
|
*/
|
|
1221
|
-
this.
|
|
1202
|
+
this.externalAccessory(accessory);
|
|
1222
1203
|
this.accessories.push(accessory);
|
|
1223
1204
|
}
|
|
1224
1205
|
else {
|
|
@@ -1268,8 +1249,8 @@ class SwitchBotPlatform {
|
|
|
1268
1249
|
// this is imported from `platformAccessory.ts`
|
|
1269
1250
|
new fan_1.Fan(this, accessory, device);
|
|
1270
1251
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1271
|
-
// link the accessory to your platform
|
|
1272
|
-
this.
|
|
1252
|
+
// publish device externally or link the accessory to your platform
|
|
1253
|
+
this.externalOrPlatform(device, accessory);
|
|
1273
1254
|
this.accessories.push(accessory);
|
|
1274
1255
|
}
|
|
1275
1256
|
else {
|
|
@@ -1319,8 +1300,8 @@ class SwitchBotPlatform {
|
|
|
1319
1300
|
// this is imported from `platformAccessory.ts`
|
|
1320
1301
|
new light_1.Light(this, accessory, device);
|
|
1321
1302
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1322
|
-
// link the accessory to your platform
|
|
1323
|
-
this.
|
|
1303
|
+
// publish device externally or link the accessory to your platform
|
|
1304
|
+
this.externalOrPlatform(device, accessory);
|
|
1324
1305
|
this.accessories.push(accessory);
|
|
1325
1306
|
}
|
|
1326
1307
|
else {
|
|
@@ -1370,8 +1351,8 @@ class SwitchBotPlatform {
|
|
|
1370
1351
|
// this is imported from `platformAccessory.ts`
|
|
1371
1352
|
new airconditioner_1.AirConditioner(this, accessory, device);
|
|
1372
1353
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1373
|
-
// link the accessory to your platform
|
|
1374
|
-
this.
|
|
1354
|
+
// publish device externally or link the accessory to your platform
|
|
1355
|
+
this.externalOrPlatform(device, accessory);
|
|
1375
1356
|
this.accessories.push(accessory);
|
|
1376
1357
|
}
|
|
1377
1358
|
else {
|
|
@@ -1421,8 +1402,8 @@ class SwitchBotPlatform {
|
|
|
1421
1402
|
// this is imported from `platformAccessory.ts`
|
|
1422
1403
|
new airpurifier_1.AirPurifier(this, accessory, device);
|
|
1423
1404
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1424
|
-
// link the accessory to your platform
|
|
1425
|
-
this.
|
|
1405
|
+
// publish device externally or link the accessory to your platform
|
|
1406
|
+
this.externalOrPlatform(device, accessory);
|
|
1426
1407
|
this.accessories.push(accessory);
|
|
1427
1408
|
}
|
|
1428
1409
|
else {
|
|
@@ -1472,8 +1453,8 @@ class SwitchBotPlatform {
|
|
|
1472
1453
|
// this is imported from `platformAccessory.ts`
|
|
1473
1454
|
new waterheater_1.WaterHeater(this, accessory, device);
|
|
1474
1455
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1475
|
-
// link the accessory to your platform
|
|
1476
|
-
this.
|
|
1456
|
+
// publish device externally or link the accessory to your platform
|
|
1457
|
+
this.externalOrPlatform(device, accessory);
|
|
1477
1458
|
this.accessories.push(accessory);
|
|
1478
1459
|
}
|
|
1479
1460
|
else {
|
|
@@ -1523,8 +1504,8 @@ class SwitchBotPlatform {
|
|
|
1523
1504
|
// this is imported from `platformAccessory.ts`
|
|
1524
1505
|
new vacuumcleaner_1.VacuumCleaner(this, accessory, device);
|
|
1525
1506
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1526
|
-
// link the accessory to your platform
|
|
1527
|
-
this.
|
|
1507
|
+
// publish device externally or link the accessory to your platform
|
|
1508
|
+
this.externalOrPlatform(device, accessory);
|
|
1528
1509
|
this.accessories.push(accessory);
|
|
1529
1510
|
}
|
|
1530
1511
|
else {
|
|
@@ -1574,8 +1555,8 @@ class SwitchBotPlatform {
|
|
|
1574
1555
|
// this is imported from `platformAccessory.ts`
|
|
1575
1556
|
new camera_1.Camera(this, accessory, device);
|
|
1576
1557
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1577
|
-
// link the accessory to your platform
|
|
1578
|
-
this.
|
|
1558
|
+
// publish device externally or link the accessory to your platform
|
|
1559
|
+
this.externalOrPlatform(device, accessory);
|
|
1579
1560
|
this.accessories.push(accessory);
|
|
1580
1561
|
}
|
|
1581
1562
|
else {
|
|
@@ -1625,14 +1606,47 @@ class SwitchBotPlatform {
|
|
|
1625
1606
|
// this is imported from `platformAccessory.ts`
|
|
1626
1607
|
new other_1.Others(this, accessory, device);
|
|
1627
1608
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1628
|
-
// link the accessory to your platform
|
|
1629
|
-
this.
|
|
1609
|
+
// publish device externally or link the accessory to your platform
|
|
1610
|
+
this.externalOrPlatform(device, accessory);
|
|
1630
1611
|
this.accessories.push(accessory);
|
|
1631
1612
|
}
|
|
1632
1613
|
else {
|
|
1633
1614
|
this.debugLog(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
|
|
1634
1615
|
}
|
|
1635
1616
|
}
|
|
1617
|
+
registerDevice(device) {
|
|
1618
|
+
if (!device.hide_device && device.enableCloudService && device.ble) {
|
|
1619
|
+
this.registeringDevice = true;
|
|
1620
|
+
this.debugLog(`Device: ${device.deviceName} Both OpenAPI and BLE Connections Enabled`);
|
|
1621
|
+
}
|
|
1622
|
+
else if (!device.hide_device && device.deviceId && device.configDeviceType && device.configDeviceName
|
|
1623
|
+
&& !device.enableCloudService) {
|
|
1624
|
+
this.registeringDevice = true;
|
|
1625
|
+
this.debugLog(`Device: ${device.deviceName} BLE Connection Enabled`);
|
|
1626
|
+
}
|
|
1627
|
+
else if (!device.hide_device && device.enableCloudService && !device.ble) {
|
|
1628
|
+
this.registeringDevice = true;
|
|
1629
|
+
this.debugLog(`Device: ${device.deviceName} OpenAPI Connection Enabled`);
|
|
1630
|
+
}
|
|
1631
|
+
else {
|
|
1632
|
+
this.registeringDevice = false;
|
|
1633
|
+
this.debugLog(`Device: ${device.deviceName} OpenAPI and BLE Are Not Enabled`);
|
|
1634
|
+
}
|
|
1635
|
+
return this.registeringDevice;
|
|
1636
|
+
}
|
|
1637
|
+
async externalOrPlatform(device, accessory) {
|
|
1638
|
+
this.debugLog(`${accessory.displayName} External Accessory Mode: ${device.external}`);
|
|
1639
|
+
if (device.external) {
|
|
1640
|
+
this.warnLog(`${accessory.displayName} External Accessory Mode`);
|
|
1641
|
+
this.externalAccessory(accessory);
|
|
1642
|
+
}
|
|
1643
|
+
else {
|
|
1644
|
+
this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
async externalAccessory(accessory) {
|
|
1648
|
+
this.api.publishExternalAccessories(settings_1.PLUGIN_NAME, [accessory]);
|
|
1649
|
+
}
|
|
1636
1650
|
async connectionTypeNewAccessory(device, accessory) {
|
|
1637
1651
|
if (device.ble) {
|
|
1638
1652
|
accessory.context.connectionType = 'BLE';
|