@switchbot/homebridge-switchbot 2.1.2-beta.0 → 2.1.2-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/CHANGELOG.md +10 -0
- package/config.schema.json +8 -0
- package/dist/device/bot.d.ts +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +10 -10
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +10 -5
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +10 -5
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +8 -4
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +7 -2
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +18 -12
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/lock.d.ts +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +11 -6
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +8 -12
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +9 -13
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +8 -4
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +9 -4
- package/dist/device/plug.js.map +1 -1
- package/dist/device/striplight.d.ts.map +1 -1
- package/dist/device/striplight.js +9 -4
- 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 +53 -29
- package/dist/platform.js.map +1 -1
- package/package.json +2 -2
- package/src/device/bot.ts +10 -9
- package/src/device/ceilinglight.ts +10 -5
- package/src/device/colorbulb.ts +10 -5
- package/src/device/contact.ts +8 -4
- package/src/device/curtain.ts +7 -2
- package/src/device/humidifier.ts +19 -14
- package/src/device/lock.ts +11 -6
- package/src/device/meter.ts +8 -13
- package/src/device/meterplus.ts +9 -14
- package/src/device/motion.ts +8 -4
- package/src/device/plug.ts +9 -4
- package/src/device/striplight.ts +9 -4
- package/src/platform.ts +58 -30
package/src/platform.ts
CHANGED
|
@@ -22,11 +22,13 @@ import { AirConditioner } from './irdevice/airconditioner';
|
|
|
22
22
|
import https from 'https';
|
|
23
23
|
import crypto from 'crypto';
|
|
24
24
|
import { Buffer } from 'buffer';
|
|
25
|
+
import { queueScheduler } from 'rxjs';
|
|
25
26
|
import fakegato from 'fakegato-history';
|
|
26
27
|
import superStringify from 'super-stringify';
|
|
27
28
|
import { readFileSync, writeFileSync } from 'fs';
|
|
28
29
|
import { API, DynamicPlatformPlugin, Logger, PlatformAccessory, Service, Characteristic } from 'homebridge';
|
|
29
|
-
import {
|
|
30
|
+
import {
|
|
31
|
+
PLATFORM_NAME, PLUGIN_NAME, irdevice, device, SwitchBotPlatformConfig, devicesConfig, DevicePath, HostDomain, irDevicesConfig } from './settings';
|
|
30
32
|
import { IncomingMessage } from 'http';
|
|
31
33
|
|
|
32
34
|
/**
|
|
@@ -41,7 +43,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
41
43
|
// this is used to track restored cached accessories
|
|
42
44
|
public readonly accessories: PlatformAccessory[] = [];
|
|
43
45
|
|
|
44
|
-
version = process.env.npm_package_version
|
|
46
|
+
version = process.env.npm_package_version || '2.1.1';
|
|
45
47
|
debugMode!: boolean;
|
|
46
48
|
platformLogging?: string;
|
|
47
49
|
|
|
@@ -1239,7 +1241,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1239
1241
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1240
1242
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1241
1243
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1242
|
-
existingAccessory.context.connectionType = await this.
|
|
1244
|
+
existingAccessory.context.connectionType = await this.connectionTypeIR(device);
|
|
1243
1245
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1244
1246
|
// create the accessory handler for the restored accessory
|
|
1245
1247
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1261,7 +1263,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1261
1263
|
accessory.context.deviceID = device.deviceId;
|
|
1262
1264
|
accessory.context.firmwareRevision = device.firmware;
|
|
1263
1265
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1264
|
-
accessory.context.connectionType = await this.
|
|
1266
|
+
accessory.context.connectionType = await this.connectionTypeIR(device);
|
|
1265
1267
|
// create the accessory handler for the newly create accessory
|
|
1266
1268
|
// this is imported from `platformAccessory.ts`
|
|
1267
1269
|
new TV(this, accessory, device);
|
|
@@ -1272,7 +1274,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1272
1274
|
* Only one TV can exist per bridge, to bypass this limitation, you should
|
|
1273
1275
|
* publish your TV as an external accessory.
|
|
1274
1276
|
*/
|
|
1275
|
-
this.
|
|
1277
|
+
this.externalOrPlatformIR(device, accessory);
|
|
1276
1278
|
this.accessories.push(accessory);
|
|
1277
1279
|
} else {
|
|
1278
1280
|
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
@@ -1296,7 +1298,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1296
1298
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1297
1299
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1298
1300
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1299
|
-
existingAccessory.context.connectionType = await this.
|
|
1301
|
+
existingAccessory.context.connectionType = await this.connectionTypeIR(device);
|
|
1300
1302
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1301
1303
|
// create the accessory handler for the restored accessory
|
|
1302
1304
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1321,14 +1323,14 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1321
1323
|
accessory.context.deviceID = device.deviceId;
|
|
1322
1324
|
accessory.context.firmwareRevision = device.firmware;
|
|
1323
1325
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1324
|
-
accessory.context.connectionType = await this.
|
|
1326
|
+
accessory.context.connectionType = await this.connectionTypeIR(device);
|
|
1325
1327
|
// create the accessory handler for the newly create accessory
|
|
1326
1328
|
// this is imported from `platformAccessory.ts`
|
|
1327
1329
|
new Fan(this, accessory, device);
|
|
1328
1330
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1329
1331
|
|
|
1330
1332
|
// publish device externally or link the accessory to your platform
|
|
1331
|
-
this.
|
|
1333
|
+
this.externalOrPlatformIR(device, accessory);
|
|
1332
1334
|
this.accessories.push(accessory);
|
|
1333
1335
|
} else {
|
|
1334
1336
|
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
@@ -1352,7 +1354,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1352
1354
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1353
1355
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1354
1356
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1355
|
-
existingAccessory.context.connectionType = await this.
|
|
1357
|
+
existingAccessory.context.connectionType = await this.connectionTypeIR(device);
|
|
1356
1358
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1357
1359
|
// create the accessory handler for the restored accessory
|
|
1358
1360
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1377,14 +1379,14 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1377
1379
|
accessory.context.deviceID = device.deviceId;
|
|
1378
1380
|
accessory.context.firmwareRevision = device.firmware;
|
|
1379
1381
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1380
|
-
accessory.context.connectionType = await this.
|
|
1382
|
+
accessory.context.connectionType = await this.connectionTypeIR(device);
|
|
1381
1383
|
// create the accessory handler for the newly create accessory
|
|
1382
1384
|
// this is imported from `platformAccessory.ts`
|
|
1383
1385
|
new Light(this, accessory, device);
|
|
1384
1386
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1385
1387
|
|
|
1386
1388
|
// publish device externally or link the accessory to your platform
|
|
1387
|
-
this.
|
|
1389
|
+
this.externalOrPlatformIR(device, accessory);
|
|
1388
1390
|
this.accessories.push(accessory);
|
|
1389
1391
|
} else {
|
|
1390
1392
|
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
@@ -1408,7 +1410,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1408
1410
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1409
1411
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1410
1412
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1411
|
-
existingAccessory.context.connectionType = await this.
|
|
1413
|
+
existingAccessory.context.connectionType = await this.connectionTypeIR(device);
|
|
1412
1414
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1413
1415
|
// create the accessory handler for the restored accessory
|
|
1414
1416
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1433,14 +1435,14 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1433
1435
|
accessory.context.deviceID = device.deviceId;
|
|
1434
1436
|
accessory.context.firmwareRevision = device.firmware;
|
|
1435
1437
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1436
|
-
accessory.context.connectionType = await this.
|
|
1438
|
+
accessory.context.connectionType = await this.connectionTypeIR(device);
|
|
1437
1439
|
// create the accessory handler for the newly create accessory
|
|
1438
1440
|
// this is imported from `platformAccessory.ts`
|
|
1439
1441
|
new AirConditioner(this, accessory, device);
|
|
1440
1442
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1441
1443
|
|
|
1442
1444
|
// publish device externally or link the accessory to your platform
|
|
1443
|
-
this.
|
|
1445
|
+
this.externalOrPlatformIR(device, accessory);
|
|
1444
1446
|
this.accessories.push(accessory);
|
|
1445
1447
|
} else {
|
|
1446
1448
|
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
@@ -1464,7 +1466,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1464
1466
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1465
1467
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1466
1468
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1467
|
-
existingAccessory.context.connectionType = await this.
|
|
1469
|
+
existingAccessory.context.connectionType = await this.connectionTypeIR(device);
|
|
1468
1470
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1469
1471
|
// create the accessory handler for the restored accessory
|
|
1470
1472
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1489,14 +1491,14 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1489
1491
|
accessory.context.deviceID = device.deviceId;
|
|
1490
1492
|
accessory.context.firmwareRevision = device.firmware;
|
|
1491
1493
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1492
|
-
accessory.context.connectionType = await this.
|
|
1494
|
+
accessory.context.connectionType = await this.connectionTypeIR(device);
|
|
1493
1495
|
// create the accessory handler for the newly create accessory
|
|
1494
1496
|
// this is imported from `platformAccessory.ts`
|
|
1495
1497
|
new AirPurifier(this, accessory, device);
|
|
1496
1498
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1497
1499
|
|
|
1498
1500
|
// publish device externally or link the accessory to your platform
|
|
1499
|
-
this.
|
|
1501
|
+
this.externalOrPlatformIR(device, accessory);
|
|
1500
1502
|
this.accessories.push(accessory);
|
|
1501
1503
|
} else {
|
|
1502
1504
|
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
@@ -1520,7 +1522,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1520
1522
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1521
1523
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1522
1524
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1523
|
-
existingAccessory.context.connectionType = await this.
|
|
1525
|
+
existingAccessory.context.connectionType = await this.connectionTypeIR(device);
|
|
1524
1526
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1525
1527
|
// create the accessory handler for the restored accessory
|
|
1526
1528
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1545,14 +1547,14 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1545
1547
|
accessory.context.deviceID = device.deviceId;
|
|
1546
1548
|
accessory.context.firmwareRevision = device.firmware;
|
|
1547
1549
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1548
|
-
accessory.context.connectionType = await this.
|
|
1550
|
+
accessory.context.connectionType = await this.connectionTypeIR(device);
|
|
1549
1551
|
// create the accessory handler for the newly create accessory
|
|
1550
1552
|
// this is imported from `platformAccessory.ts`
|
|
1551
1553
|
new WaterHeater(this, accessory, device);
|
|
1552
1554
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1553
1555
|
|
|
1554
1556
|
// publish device externally or link the accessory to your platform
|
|
1555
|
-
this.
|
|
1557
|
+
this.externalOrPlatformIR(device, accessory);
|
|
1556
1558
|
this.accessories.push(accessory);
|
|
1557
1559
|
} else {
|
|
1558
1560
|
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
@@ -1576,7 +1578,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1576
1578
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1577
1579
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1578
1580
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1579
|
-
existingAccessory.context.connectionType = await this.
|
|
1581
|
+
existingAccessory.context.connectionType = await this.connectionTypeIR(device);
|
|
1580
1582
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1581
1583
|
// create the accessory handler for the restored accessory
|
|
1582
1584
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1601,14 +1603,14 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1601
1603
|
accessory.context.deviceID = device.deviceId;
|
|
1602
1604
|
accessory.context.firmwareRevision = device.firmware;
|
|
1603
1605
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1604
|
-
accessory.context.connectionType = await this.
|
|
1606
|
+
accessory.context.connectionType = await this.connectionTypeIR(device);
|
|
1605
1607
|
// create the accessory handler for the newly create accessory
|
|
1606
1608
|
// this is imported from `platformAccessory.ts`
|
|
1607
1609
|
new VacuumCleaner(this, accessory, device);
|
|
1608
1610
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1609
1611
|
|
|
1610
1612
|
// publish device externally or link the accessory to your platform
|
|
1611
|
-
this.
|
|
1613
|
+
this.externalOrPlatformIR(device, accessory);
|
|
1612
1614
|
this.accessories.push(accessory);
|
|
1613
1615
|
} else {
|
|
1614
1616
|
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
@@ -1632,7 +1634,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1632
1634
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1633
1635
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1634
1636
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1635
|
-
existingAccessory.context.connectionType = await this.
|
|
1637
|
+
existingAccessory.context.connectionType = await this.connectionTypeIR(device);
|
|
1636
1638
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1637
1639
|
// create the accessory handler for the restored accessory
|
|
1638
1640
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1657,14 +1659,14 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1657
1659
|
accessory.context.deviceID = device.deviceId;
|
|
1658
1660
|
accessory.context.firmwareRevision = device.firmware;
|
|
1659
1661
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1660
|
-
accessory.context.connectionType = await this.
|
|
1662
|
+
accessory.context.connectionType = await this.connectionTypeIR(device);
|
|
1661
1663
|
// create the accessory handler for the newly create accessory
|
|
1662
1664
|
// this is imported from `platformAccessory.ts`
|
|
1663
1665
|
new Camera(this, accessory, device);
|
|
1664
1666
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1665
1667
|
|
|
1666
1668
|
// publish device externally or link the accessory to your platform
|
|
1667
|
-
this.
|
|
1669
|
+
this.externalOrPlatformIR(device, accessory);
|
|
1668
1670
|
this.accessories.push(accessory);
|
|
1669
1671
|
} else {
|
|
1670
1672
|
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
@@ -1688,7 +1690,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1688
1690
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1689
1691
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1690
1692
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1691
|
-
existingAccessory.context.connectionType = await this.
|
|
1693
|
+
existingAccessory.context.connectionType = await this.connectionTypeIR(device);
|
|
1692
1694
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1693
1695
|
// create the accessory handler for the restored accessory
|
|
1694
1696
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1713,14 +1715,14 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1713
1715
|
accessory.context.deviceID = device.deviceId;
|
|
1714
1716
|
accessory.context.firmwareRevision = device.firmware;
|
|
1715
1717
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1716
|
-
accessory.context.connectionType = await this.
|
|
1718
|
+
accessory.context.connectionType = await this.connectionTypeIR(device);
|
|
1717
1719
|
// create the accessory handler for the newly create accessory
|
|
1718
1720
|
// this is imported from `platformAccessory.ts`
|
|
1719
1721
|
new Others(this, accessory, device);
|
|
1720
1722
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1721
1723
|
|
|
1722
1724
|
// publish device externally or link the accessory to your platform
|
|
1723
|
-
this.
|
|
1725
|
+
this.externalOrPlatformIR(device, accessory);
|
|
1724
1726
|
this.accessories.push(accessory);
|
|
1725
1727
|
} else {
|
|
1726
1728
|
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
@@ -1764,6 +1766,16 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1764
1766
|
return registerCurtain;
|
|
1765
1767
|
}
|
|
1766
1768
|
|
|
1769
|
+
async connectionTypeIR(device: device & irDevicesConfig): Promise<any> {
|
|
1770
|
+
let connectionType: string;
|
|
1771
|
+
if (!device.connectionType && device.remoteType) {
|
|
1772
|
+
connectionType = 'OpenAPI';
|
|
1773
|
+
} else {
|
|
1774
|
+
connectionType = device.connectionType!;
|
|
1775
|
+
}
|
|
1776
|
+
return connectionType;
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1767
1779
|
async connectionType(device: device & devicesConfig): Promise<any> {
|
|
1768
1780
|
let connectionType: string;
|
|
1769
1781
|
if (!device.connectionType && this.config.credentials?.token && this.config.credentials.secret) {
|
|
@@ -1828,6 +1840,18 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1828
1840
|
return registerDevice;
|
|
1829
1841
|
}
|
|
1830
1842
|
|
|
1843
|
+
public async externalOrPlatformIR(device: device & irDevicesConfig, accessory: PlatformAccessory) {
|
|
1844
|
+
if (device.external === undefined && device.remoteType === 'TV') {
|
|
1845
|
+
device.external = true;
|
|
1846
|
+
} else if (device.external) {
|
|
1847
|
+
this.debugWarnLog(`${accessory.displayName} External Accessory Mode`);
|
|
1848
|
+
this.externalAccessory(accessory);
|
|
1849
|
+
} else {
|
|
1850
|
+
this.debugLog(`${accessory.displayName} External Accessory Mode: ${device.external}`);
|
|
1851
|
+
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1831
1855
|
public async externalOrPlatform(device: device & devicesConfig, accessory: PlatformAccessory) {
|
|
1832
1856
|
if (device.external) {
|
|
1833
1857
|
this.debugWarnLog(`${accessory.displayName} External Accessory Mode`);
|
|
@@ -1880,13 +1904,17 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1880
1904
|
}
|
|
1881
1905
|
}
|
|
1882
1906
|
|
|
1907
|
+
|
|
1908
|
+
|
|
1883
1909
|
// BLE Connection
|
|
1884
1910
|
connectBLE() {
|
|
1885
1911
|
let Switchbot: new () => any;
|
|
1886
1912
|
let switchbot: any;
|
|
1887
1913
|
try {
|
|
1888
1914
|
Switchbot = require('node-switchbot');
|
|
1889
|
-
|
|
1915
|
+
queueScheduler.schedule(() =>
|
|
1916
|
+
switchbot = new Switchbot(),
|
|
1917
|
+
);
|
|
1890
1918
|
} catch (e: any) {
|
|
1891
1919
|
switchbot = false;
|
|
1892
1920
|
this.errorLog(`Was 'node-switchbot' found: ${switchbot}`);
|