@switchbot/homebridge-switchbot 2.2.2-beta.9 → 2.2.3-beta.0

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.
Files changed (107) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/config.schema.json +18 -42
  3. package/dist/device/bot.d.ts +1 -3
  4. package/dist/device/bot.d.ts.map +1 -1
  5. package/dist/device/bot.js +1 -1
  6. package/dist/device/bot.js.map +1 -1
  7. package/dist/device/ceilinglight.d.ts +1 -3
  8. package/dist/device/ceilinglight.d.ts.map +1 -1
  9. package/dist/device/ceilinglight.js +1 -1
  10. package/dist/device/ceilinglight.js.map +1 -1
  11. package/dist/device/colorbulb.d.ts +1 -3
  12. package/dist/device/colorbulb.d.ts.map +1 -1
  13. package/dist/device/colorbulb.js +3 -3
  14. package/dist/device/colorbulb.js.map +1 -1
  15. package/dist/device/contact.d.ts +6 -7
  16. package/dist/device/contact.d.ts.map +1 -1
  17. package/dist/device/contact.js +17 -2
  18. package/dist/device/contact.js.map +1 -1
  19. package/dist/device/humidifier.d.ts +7 -9
  20. package/dist/device/humidifier.d.ts.map +1 -1
  21. package/dist/device/humidifier.js +13 -15
  22. package/dist/device/humidifier.js.map +1 -1
  23. package/dist/device/meter.d.ts +1 -3
  24. package/dist/device/meter.d.ts.map +1 -1
  25. package/dist/device/meter.js +1 -1
  26. package/dist/device/meter.js.map +1 -1
  27. package/dist/device/meterplus.d.ts +1 -3
  28. package/dist/device/meterplus.d.ts.map +1 -1
  29. package/dist/device/meterplus.js +1 -1
  30. package/dist/device/meterplus.js.map +1 -1
  31. package/dist/device/motion.d.ts +2 -3
  32. package/dist/device/motion.d.ts.map +1 -1
  33. package/dist/device/motion.js +15 -3
  34. package/dist/device/motion.js.map +1 -1
  35. package/dist/device/plug.d.ts +1 -3
  36. package/dist/device/plug.d.ts.map +1 -1
  37. package/dist/device/plug.js +1 -1
  38. package/dist/device/plug.js.map +1 -1
  39. package/dist/device/striplight.d.ts +1 -3
  40. package/dist/device/striplight.d.ts.map +1 -1
  41. package/dist/device/striplight.js +9 -7
  42. package/dist/device/striplight.js.map +1 -1
  43. package/dist/irdevice/airconditioner.d.ts +10 -6
  44. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  45. package/dist/irdevice/airconditioner.js +65 -54
  46. package/dist/irdevice/airconditioner.js.map +1 -1
  47. package/dist/irdevice/airpurifier.d.ts +8 -8
  48. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  49. package/dist/irdevice/airpurifier.js +29 -29
  50. package/dist/irdevice/airpurifier.js.map +1 -1
  51. package/dist/irdevice/camera.d.ts +4 -4
  52. package/dist/irdevice/camera.d.ts.map +1 -1
  53. package/dist/irdevice/camera.js +20 -24
  54. package/dist/irdevice/camera.js.map +1 -1
  55. package/dist/irdevice/fan.d.ts +4 -4
  56. package/dist/irdevice/fan.d.ts.map +1 -1
  57. package/dist/irdevice/fan.js +22 -26
  58. package/dist/irdevice/fan.js.map +1 -1
  59. package/dist/irdevice/light.d.ts +4 -4
  60. package/dist/irdevice/light.d.ts.map +1 -1
  61. package/dist/irdevice/light.js +20 -20
  62. package/dist/irdevice/light.js.map +1 -1
  63. package/dist/irdevice/other.d.ts +4 -4
  64. package/dist/irdevice/other.d.ts.map +1 -1
  65. package/dist/irdevice/other.js +20 -24
  66. package/dist/irdevice/other.js.map +1 -1
  67. package/dist/irdevice/tv.d.ts +10 -6
  68. package/dist/irdevice/tv.d.ts.map +1 -1
  69. package/dist/irdevice/tv.js +128 -90
  70. package/dist/irdevice/tv.js.map +1 -1
  71. package/dist/irdevice/vacuumcleaner.d.ts +4 -4
  72. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  73. package/dist/irdevice/vacuumcleaner.js +20 -24
  74. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  75. package/dist/irdevice/waterheater.d.ts +4 -4
  76. package/dist/irdevice/waterheater.d.ts.map +1 -1
  77. package/dist/irdevice/waterheater.js +26 -31
  78. package/dist/irdevice/waterheater.js.map +1 -1
  79. package/dist/platform.d.ts +0 -1
  80. package/dist/platform.d.ts.map +1 -1
  81. package/dist/platform.js +29 -35
  82. package/dist/platform.js.map +1 -1
  83. package/dist/settings.d.ts +10 -19
  84. package/dist/settings.d.ts.map +1 -1
  85. package/dist/settings.js.map +1 -1
  86. package/package.json +9 -9
  87. package/src/device/bot.ts +1 -1
  88. package/src/device/ceilinglight.ts +1 -1
  89. package/src/device/colorbulb.ts +3 -3
  90. package/src/device/contact.ts +24 -10
  91. package/src/device/humidifier.ts +11 -15
  92. package/src/device/meter.ts +1 -1
  93. package/src/device/meterplus.ts +1 -1
  94. package/src/device/motion.ts +18 -7
  95. package/src/device/plug.ts +1 -1
  96. package/src/device/striplight.ts +5 -5
  97. package/src/irdevice/airconditioner.ts +71 -58
  98. package/src/irdevice/airpurifier.ts +34 -33
  99. package/src/irdevice/camera.ts +23 -26
  100. package/src/irdevice/fan.ts +25 -28
  101. package/src/irdevice/light.ts +23 -22
  102. package/src/irdevice/other.ts +23 -26
  103. package/src/irdevice/tv.ts +132 -93
  104. package/src/irdevice/vacuumcleaner.ts +23 -26
  105. package/src/irdevice/waterheater.ts +28 -32
  106. package/src/platform.ts +28 -34
  107. package/src/settings.ts +13 -28
package/src/platform.ts CHANGED
@@ -471,6 +471,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
471
471
  }
472
472
 
473
473
  private createIRDevice(device: irdevice & devicesConfig) {
474
+ if (device.connectionType === undefined) {
475
+ device.connectionType = 'OpenAPI';
476
+ }
474
477
  switch (device.remoteType) {
475
478
  case 'TV':
476
479
  case 'DIY TV':
@@ -485,7 +488,12 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
485
488
  case 'Speaker':
486
489
  case 'DIY Speaker':
487
490
  this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
488
- this.createTV(device);
491
+ if (device.external === undefined) {
492
+ device.external = true;
493
+ this.createTV(device);
494
+ } else {
495
+ this.createTV(device);
496
+ }
489
497
  break;
490
498
  case 'Fan':
491
499
  case 'DIY Fan':
@@ -1233,7 +1241,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1233
1241
  existingAccessory.context.firmwareRevision = device.firmware;
1234
1242
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1235
1243
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1236
- existingAccessory.context.connectionType = await this.connectionTypeIR(device);
1244
+ existingAccessory.context.connectionType = device.connectionType;
1237
1245
  this.api.updatePlatformAccessories([existingAccessory]);
1238
1246
  // create the accessory handler for the restored accessory
1239
1247
  // this is imported from `platformAccessory.ts`
@@ -1255,7 +1263,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1255
1263
  accessory.context.deviceID = device.deviceId;
1256
1264
  accessory.context.firmwareRevision = device.firmware;
1257
1265
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1258
- accessory.context.connectionType = await this.connectionTypeIR(device);
1266
+ accessory.context.connectionType = device.connectionType;
1259
1267
  // create the accessory handler for the newly create accessory
1260
1268
  // this is imported from `platformAccessory.ts`
1261
1269
  new TV(this, accessory, device);
@@ -1285,7 +1293,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1285
1293
  existingAccessory.context.firmwareRevision = device.firmware;
1286
1294
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1287
1295
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1288
- existingAccessory.context.connectionType = await this.connectionTypeIR(device);
1296
+ existingAccessory.context.connectionType = device.connectionType;
1289
1297
  this.api.updatePlatformAccessories([existingAccessory]);
1290
1298
  // create the accessory handler for the restored accessory
1291
1299
  // this is imported from `platformAccessory.ts`
@@ -1310,7 +1318,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1310
1318
  accessory.context.deviceID = device.deviceId;
1311
1319
  accessory.context.firmwareRevision = device.firmware;
1312
1320
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1313
- accessory.context.connectionType = await this.connectionTypeIR(device);
1321
+ accessory.context.connectionType = device.connectionType;
1314
1322
  // create the accessory handler for the newly create accessory
1315
1323
  // this is imported from `platformAccessory.ts`
1316
1324
  new Fan(this, accessory, device);
@@ -1341,7 +1349,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1341
1349
  existingAccessory.context.firmwareRevision = device.firmware;
1342
1350
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1343
1351
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1344
- existingAccessory.context.connectionType = await this.connectionTypeIR(device);
1352
+ existingAccessory.context.connectionType = device.connectionType;
1345
1353
  this.api.updatePlatformAccessories([existingAccessory]);
1346
1354
  // create the accessory handler for the restored accessory
1347
1355
  // this is imported from `platformAccessory.ts`
@@ -1366,7 +1374,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1366
1374
  accessory.context.deviceID = device.deviceId;
1367
1375
  accessory.context.firmwareRevision = device.firmware;
1368
1376
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1369
- accessory.context.connectionType = await this.connectionTypeIR(device);
1377
+ accessory.context.connectionType = device.connectionType;
1370
1378
  // create the accessory handler for the newly create accessory
1371
1379
  // this is imported from `platformAccessory.ts`
1372
1380
  new Light(this, accessory, device);
@@ -1397,7 +1405,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1397
1405
  existingAccessory.context.firmwareRevision = device.firmware;
1398
1406
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1399
1407
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1400
- existingAccessory.context.connectionType = await this.connectionTypeIR(device);
1408
+ existingAccessory.context.connectionType = device.connectionType;
1401
1409
  this.api.updatePlatformAccessories([existingAccessory]);
1402
1410
  // create the accessory handler for the restored accessory
1403
1411
  // this is imported from `platformAccessory.ts`
@@ -1422,7 +1430,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1422
1430
  accessory.context.deviceID = device.deviceId;
1423
1431
  accessory.context.firmwareRevision = device.firmware;
1424
1432
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1425
- accessory.context.connectionType = await this.connectionTypeIR(device);
1433
+ accessory.context.connectionType = device.connectionType;
1426
1434
  // create the accessory handler for the newly create accessory
1427
1435
  // this is imported from `platformAccessory.ts`
1428
1436
  new AirConditioner(this, accessory, device);
@@ -1453,7 +1461,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1453
1461
  existingAccessory.context.firmwareRevision = device.firmware;
1454
1462
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1455
1463
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1456
- existingAccessory.context.connectionType = await this.connectionTypeIR(device);
1464
+ existingAccessory.context.connectionType = device.connectionType;
1457
1465
  this.api.updatePlatformAccessories([existingAccessory]);
1458
1466
  // create the accessory handler for the restored accessory
1459
1467
  // this is imported from `platformAccessory.ts`
@@ -1478,7 +1486,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1478
1486
  accessory.context.deviceID = device.deviceId;
1479
1487
  accessory.context.firmwareRevision = device.firmware;
1480
1488
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1481
- accessory.context.connectionType = await this.connectionTypeIR(device);
1489
+ accessory.context.connectionType = device.connectionType;
1482
1490
  // create the accessory handler for the newly create accessory
1483
1491
  // this is imported from `platformAccessory.ts`
1484
1492
  new AirPurifier(this, accessory, device);
@@ -1509,7 +1517,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1509
1517
  existingAccessory.context.firmwareRevision = device.firmware;
1510
1518
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1511
1519
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1512
- existingAccessory.context.connectionType = await this.connectionTypeIR(device);
1520
+ existingAccessory.context.connectionType = device.connectionType;
1513
1521
  this.api.updatePlatformAccessories([existingAccessory]);
1514
1522
  // create the accessory handler for the restored accessory
1515
1523
  // this is imported from `platformAccessory.ts`
@@ -1534,7 +1542,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1534
1542
  accessory.context.deviceID = device.deviceId;
1535
1543
  accessory.context.firmwareRevision = device.firmware;
1536
1544
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1537
- accessory.context.connectionType = await this.connectionTypeIR(device);
1545
+ accessory.context.connectionType = device.connectionType;
1538
1546
  // create the accessory handler for the newly create accessory
1539
1547
  // this is imported from `platformAccessory.ts`
1540
1548
  new WaterHeater(this, accessory, device);
@@ -1565,7 +1573,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1565
1573
  existingAccessory.context.firmwareRevision = device.firmware;
1566
1574
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1567
1575
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1568
- existingAccessory.context.connectionType = await this.connectionTypeIR(device);
1576
+ existingAccessory.context.connectionType = device.connectionType;
1569
1577
  this.api.updatePlatformAccessories([existingAccessory]);
1570
1578
  // create the accessory handler for the restored accessory
1571
1579
  // this is imported from `platformAccessory.ts`
@@ -1590,7 +1598,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1590
1598
  accessory.context.deviceID = device.deviceId;
1591
1599
  accessory.context.firmwareRevision = device.firmware;
1592
1600
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1593
- accessory.context.connectionType = await this.connectionTypeIR(device);
1601
+ accessory.context.connectionType = device.connectionType;
1594
1602
  // create the accessory handler for the newly create accessory
1595
1603
  // this is imported from `platformAccessory.ts`
1596
1604
  new VacuumCleaner(this, accessory, device);
@@ -1621,7 +1629,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1621
1629
  existingAccessory.context.firmwareRevision = device.firmware;
1622
1630
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1623
1631
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1624
- existingAccessory.context.connectionType = await this.connectionTypeIR(device);
1632
+ existingAccessory.context.connectionType = device.connectionType;
1625
1633
  this.api.updatePlatformAccessories([existingAccessory]);
1626
1634
  // create the accessory handler for the restored accessory
1627
1635
  // this is imported from `platformAccessory.ts`
@@ -1646,7 +1654,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1646
1654
  accessory.context.deviceID = device.deviceId;
1647
1655
  accessory.context.firmwareRevision = device.firmware;
1648
1656
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1649
- accessory.context.connectionType = await this.connectionTypeIR(device);
1657
+ accessory.context.connectionType = device.connectionType;
1650
1658
  // create the accessory handler for the newly create accessory
1651
1659
  // this is imported from `platformAccessory.ts`
1652
1660
  new Camera(this, accessory, device);
@@ -1677,7 +1685,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1677
1685
  existingAccessory.context.firmwareRevision = device.firmware;
1678
1686
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1679
1687
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1680
- existingAccessory.context.connectionType = await this.connectionTypeIR(device);
1688
+ existingAccessory.context.connectionType = device.connectionType;
1681
1689
  this.api.updatePlatformAccessories([existingAccessory]);
1682
1690
  // create the accessory handler for the restored accessory
1683
1691
  // this is imported from `platformAccessory.ts`
@@ -1702,7 +1710,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1702
1710
  accessory.context.deviceID = device.deviceId;
1703
1711
  accessory.context.firmwareRevision = device.firmware;
1704
1712
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1705
- accessory.context.connectionType = await this.connectionTypeIR(device);
1713
+ accessory.context.connectionType = device.connectionType;
1706
1714
  // create the accessory handler for the newly create accessory
1707
1715
  // this is imported from `platformAccessory.ts`
1708
1716
  new Others(this, accessory, device);
@@ -1753,16 +1761,6 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1753
1761
  return registerCurtain;
1754
1762
  }
1755
1763
 
1756
- async connectionTypeIR(device: device & irDevicesConfig): Promise<any> {
1757
- let connectionType: string;
1758
- if (!device.connectionType && device.remoteType) {
1759
- connectionType = 'OpenAPI';
1760
- } else {
1761
- connectionType = device.connectionType!;
1762
- }
1763
- return connectionType;
1764
- }
1765
-
1766
1764
  async connectionType(device: device & devicesConfig): Promise<any> {
1767
1765
  let connectionType: string;
1768
1766
  if (!device.connectionType && this.config.credentials?.token && this.config.credentials.secret) {
@@ -1833,11 +1831,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1833
1831
  * Only one TV can exist per bridge, to bypass this limitation, you should
1834
1832
  * publish your TV as an external accessory.
1835
1833
  */
1836
- if (device.external === undefined && device.remoteType === 'TV') {
1837
- device.external = true;
1838
- this.debugWarnLog(`${accessory.displayName} External TV Accessory Mode`);
1839
- this.externalAccessory(accessory);
1840
- } else if (device.external) {
1834
+ if (device.external) {
1841
1835
  this.debugWarnLog(`${accessory.displayName} External Accessory Mode`);
1842
1836
  this.externalAccessory(accessory);
1843
1837
  } else {
package/src/settings.ts CHANGED
@@ -140,8 +140,9 @@ export interface irDevicesConfig extends irdevice {
140
140
  customOn?: string;
141
141
  customOff?: string;
142
142
  customize?: boolean;
143
- allowPushOn?: boolean;
144
- allowPushOff?: boolean;
143
+ disablePushOn?: boolean;
144
+ disablePushOff?: boolean;
145
+ disablePushDetail?: boolean;
145
146
  irfan?: irfan;
146
147
  irair?: irair;
147
148
  irpur?: Record<any, any>;
@@ -149,7 +150,7 @@ export interface irDevicesConfig extends irdevice {
149
150
  irlight?: Record<any, any>;
150
151
  irvc?: Record<any, any>;
151
152
  irwh?: Record<any, any>;
152
- irtv?: irtv;
153
+ irtv?: Record<any, any>;
153
154
  other?: other;
154
155
  }
155
156
 
@@ -161,36 +162,20 @@ export type irfan = {
161
162
  set_min?: number; //set_min
162
163
  };
163
164
 
164
- //For Potential Future Use
165
- export type set_minStep = {
166
- set_minStep_device?: boolean;
167
- set_minStep?: number;
168
- };
169
-
170
- //For Potential Future Use
171
- export type set_max = {
172
- set_max_device?: boolean;
173
- set_max?: number;
174
- };
175
-
176
- //For Potential Future Use
177
- export type set_min = {
178
- set_min_device?: boolean;
179
- set_min?: number;
180
- };
181
-
182
165
  export type irair = {
183
166
  hide_automode?: boolean;
184
167
  };
185
168
 
186
- export type irtv = {
187
- disable_power?: boolean;
188
- };
189
-
190
169
  export type other = {
191
170
  deviceType?: string;
192
171
  };
193
172
 
173
+ export type body = {
174
+ command: string;
175
+ parameter: string;
176
+ commandType: string;
177
+ }
178
+
194
179
  //a list of physical devices.
195
180
  export type deviceList = {
196
181
  device: Array<device>;
@@ -381,7 +366,7 @@ export type switchbot = {
381
366
  wait: (arg0: number) => any;
382
367
  };
383
368
 
384
- export function rgb2hs(r, g, b) {
369
+ export function rgb2hs(r: any, g: any, b: any) {
385
370
  /*
386
371
  Credit:
387
372
  https://github.com/WickyNilliams/pure-color
@@ -416,7 +401,7 @@ export function rgb2hs(r, g, b) {
416
401
  return [Math.round(h), Math.round(s)];
417
402
  }
418
403
 
419
- export function hs2rgb(h, s) {
404
+ export function hs2rgb(h: any, s: any) {
420
405
  /*
421
406
  Credit:
422
407
  https://github.com/WickyNilliams/pure-color
@@ -459,7 +444,7 @@ export function hs2rgb(h, s) {
459
444
  return [Math.round(rgb[0]), Math.round(rgb[1]), Math.round(rgb[2])];
460
445
  }
461
446
 
462
- export function k2rgb(k) {
447
+ export function k2rgb(k: number) {
463
448
  // Set kelvin to nearest 100, between 2000 and 7100
464
449
  k = Math.round(k / 100) * 100;
465
450
  k = Math.max(Math.min(k, 7100), 2000);