@switchbot/homebridge-switchbot 4.3.2-beta.3 → 4.3.2-beta.5

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 (97) hide show
  1. package/dist/device/airpurifier.d.ts +54 -0
  2. package/dist/device/airpurifier.d.ts.map +1 -0
  3. package/dist/device/airpurifier.js +527 -0
  4. package/dist/device/airpurifier.js.map +1 -0
  5. package/dist/device/blindtilt.d.ts.map +1 -1
  6. package/dist/device/blindtilt.js +2 -8
  7. package/dist/device/blindtilt.js.map +1 -1
  8. package/dist/device/bot.d.ts.map +1 -1
  9. package/dist/device/bot.js +2 -8
  10. package/dist/device/bot.js.map +1 -1
  11. package/dist/device/ceilinglight.d.ts.map +1 -1
  12. package/dist/device/ceilinglight.js +2 -8
  13. package/dist/device/ceilinglight.js.map +1 -1
  14. package/dist/device/colorbulb.d.ts.map +1 -1
  15. package/dist/device/colorbulb.js +2 -8
  16. package/dist/device/colorbulb.js.map +1 -1
  17. package/dist/device/contact.d.ts.map +1 -1
  18. package/dist/device/contact.js +1 -4
  19. package/dist/device/contact.js.map +1 -1
  20. package/dist/device/curtain.d.ts.map +1 -1
  21. package/dist/device/curtain.js +2 -8
  22. package/dist/device/curtain.js.map +1 -1
  23. package/dist/device/fan.d.ts.map +1 -1
  24. package/dist/device/fan.js +2 -8
  25. package/dist/device/fan.js.map +1 -1
  26. package/dist/device/hub.d.ts.map +1 -1
  27. package/dist/device/hub.js +1 -4
  28. package/dist/device/hub.js.map +1 -1
  29. package/dist/device/humidifier.d.ts.map +1 -1
  30. package/dist/device/humidifier.js +2 -8
  31. package/dist/device/humidifier.js.map +1 -1
  32. package/dist/device/iosensor.d.ts.map +1 -1
  33. package/dist/device/iosensor.js +1 -4
  34. package/dist/device/iosensor.js.map +1 -1
  35. package/dist/device/lightstrip.d.ts.map +1 -1
  36. package/dist/device/lightstrip.js +2 -8
  37. package/dist/device/lightstrip.js.map +1 -1
  38. package/dist/device/lock.d.ts.map +1 -1
  39. package/dist/device/lock.js +2 -8
  40. package/dist/device/lock.js.map +1 -1
  41. package/dist/device/meter.d.ts.map +1 -1
  42. package/dist/device/meter.js +1 -4
  43. package/dist/device/meter.js.map +1 -1
  44. package/dist/device/meterplus.d.ts.map +1 -1
  45. package/dist/device/meterplus.js +1 -4
  46. package/dist/device/meterplus.js.map +1 -1
  47. package/dist/device/meterpro.d.ts.map +1 -1
  48. package/dist/device/meterpro.js +1 -4
  49. package/dist/device/meterpro.js.map +1 -1
  50. package/dist/device/motion.d.ts.map +1 -1
  51. package/dist/device/motion.js +1 -4
  52. package/dist/device/motion.js.map +1 -1
  53. package/dist/device/plug.d.ts.map +1 -1
  54. package/dist/device/plug.js +2 -8
  55. package/dist/device/plug.js.map +1 -1
  56. package/dist/device/relayswitch.d.ts.map +1 -1
  57. package/dist/device/relayswitch.js +2 -8
  58. package/dist/device/relayswitch.js.map +1 -1
  59. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  60. package/dist/device/robotvacuumcleaner.js +2 -8
  61. package/dist/device/robotvacuumcleaner.js.map +1 -1
  62. package/dist/device/waterdetector.d.ts.map +1 -1
  63. package/dist/device/waterdetector.js +1 -4
  64. package/dist/device/waterdetector.js.map +1 -1
  65. package/dist/irdevice/airpurifier.d.ts +1 -1
  66. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  67. package/dist/irdevice/airpurifier.js +4 -4
  68. package/dist/irdevice/airpurifier.js.map +1 -1
  69. package/dist/platform.d.ts +2 -1
  70. package/dist/platform.d.ts.map +1 -1
  71. package/dist/platform.js +71 -7
  72. package/dist/platform.js.map +1 -1
  73. package/docs/variables/default.html +1 -1
  74. package/package.json +2 -2
  75. package/src/device/airpurifier.ts +563 -0
  76. package/src/device/blindtilt.ts +2 -6
  77. package/src/device/bot.ts +2 -6
  78. package/src/device/ceilinglight.ts +2 -6
  79. package/src/device/colorbulb.ts +2 -6
  80. package/src/device/contact.ts +1 -3
  81. package/src/device/curtain.ts +2 -6
  82. package/src/device/fan.ts +2 -6
  83. package/src/device/hub.ts +1 -3
  84. package/src/device/humidifier.ts +2 -6
  85. package/src/device/iosensor.ts +1 -3
  86. package/src/device/lightstrip.ts +2 -6
  87. package/src/device/lock.ts +2 -6
  88. package/src/device/meter.ts +1 -3
  89. package/src/device/meterplus.ts +1 -3
  90. package/src/device/meterpro.ts +1 -3
  91. package/src/device/motion.ts +1 -3
  92. package/src/device/plug.ts +2 -6
  93. package/src/device/relayswitch.ts +2 -6
  94. package/src/device/robotvacuumcleaner.ts +2 -6
  95. package/src/device/waterdetector.ts +1 -3
  96. package/src/irdevice/airpurifier.ts +4 -4
  97. package/src/platform.ts +73 -7
package/dist/platform.js CHANGED
@@ -5,6 +5,7 @@ import fakegato from 'fakegato-history';
5
5
  import { EveHomeKitTypes } from 'homebridge-lib/EveHomeKitTypes';
6
6
  import { LogLevel, SwitchBotBLE, SwitchBotModel, SwitchBotOpenAPI } from 'node-switchbot';
7
7
  import { queueScheduler } from 'rxjs';
8
+ import { AirPurifier } from './device/airpurifier.js';
8
9
  import { BlindTilt } from './device/blindtilt.js';
9
10
  import { Bot } from './device/bot.js';
10
11
  import { CeilingLight } from './device/ceilinglight.js';
@@ -26,7 +27,7 @@ import { RelaySwitch } from './device/relayswitch.js';
26
27
  import { RobotVacuumCleaner } from './device/robotvacuumcleaner.js';
27
28
  import { WaterDetector } from './device/waterdetector.js';
28
29
  import { AirConditioner } from './irdevice/airconditioner.js';
29
- import { AirPurifier } from './irdevice/airpurifier.js';
30
+ import { AirPurifierIR } from './irdevice/airpurifier.js';
30
31
  import { Camera } from './irdevice/camera.js';
31
32
  import { IRFan } from './irdevice/fan.js';
32
33
  import { Light } from './irdevice/light.js';
@@ -569,6 +570,10 @@ export class SwitchBotPlatform {
569
570
  'Ceiling Light Pro': this.createCeilingLight.bind(this),
570
571
  'Strip Light': this.createStripLight.bind(this),
571
572
  'Battery Circulator Fan': this.createFan.bind(this),
573
+ 'Air Purifier PM2.5': this.createAirPurifier.bind(this),
574
+ 'Air Purifier Table PM2.5': this.createAirPurifier.bind(this),
575
+ 'Air Purifier VOC': this.createAirPurifier.bind(this),
576
+ 'Air Purifier Table VOC': this.createAirPurifier.bind(this),
572
577
  };
573
578
  if (deviceTypeHandlers[device.deviceType]) {
574
579
  this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
@@ -602,8 +607,8 @@ export class SwitchBotPlatform {
602
607
  'DIY Air Conditioner': this.createAirConditioner.bind(this),
603
608
  'Light': this.createLight.bind(this),
604
609
  'DIY Light': this.createLight.bind(this),
605
- 'Air Purifier': this.createAirPurifier.bind(this),
606
- 'DIY Air Purifier': this.createAirPurifier.bind(this),
610
+ 'Air Purifier': this.createAirPurifierIR.bind(this),
611
+ 'DIY Air Purifier': this.createAirPurifierIR.bind(this),
607
612
  'Water Heater': this.createWaterHeater.bind(this),
608
613
  'DIY Water Heater': this.createWaterHeater.bind(this),
609
614
  'Vacuum Cleaner': this.createVacuumCleaner.bind(this),
@@ -1803,6 +1808,66 @@ export class SwitchBotPlatform {
1803
1808
  this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} deviceId: ${device.deviceId}`);
1804
1809
  }
1805
1810
  }
1811
+ async createAirPurifier(device) {
1812
+ const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
1813
+ // see if an accessory with the same uuid has already been registered and restored from
1814
+ // the cached devices we stored in the `configureAccessory` method above
1815
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
1816
+ if (existingAccessory) {
1817
+ // the accessory already exists
1818
+ if (await this.registerDevice(device)) {
1819
+ // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1820
+ existingAccessory.context.device = device;
1821
+ existingAccessory.context.deviceId = device.deviceId;
1822
+ existingAccessory.context.deviceType = device.deviceType;
1823
+ existingAccessory.context.model = SwitchBotModel.BatteryCirculatorFan;
1824
+ existingAccessory.displayName = device.configDeviceName
1825
+ ? await this.validateAndCleanDisplayName(device.configDeviceName, 'configDeviceName', device.configDeviceName)
1826
+ : await this.validateAndCleanDisplayName(device.deviceName, 'deviceName', device.deviceName);
1827
+ existingAccessory.context.connectionType = await this.connectionType(device);
1828
+ existingAccessory.context.version = device.firmware ?? device.version ?? this.version ?? '0.0.0';
1829
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} deviceId: ${device.deviceId}`);
1830
+ this.api.updatePlatformAccessories([existingAccessory]);
1831
+ // create the accessory handler for the restored accessory
1832
+ // this is imported from `platformAccessory.ts`
1833
+ new AirPurifier(this, existingAccessory, device);
1834
+ this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1835
+ }
1836
+ else {
1837
+ this.unregisterPlatformAccessories(existingAccessory);
1838
+ }
1839
+ }
1840
+ else if (await this.registerDevice(device)) {
1841
+ // create a new accessory
1842
+ const accessory = new this.api.platformAccessory(device.configDeviceName
1843
+ ? await this.validateAndCleanDisplayName(device.configDeviceName, 'configDeviceName', device.configDeviceName)
1844
+ : await this.validateAndCleanDisplayName(device.deviceName, 'deviceName', device.deviceName), uuid);
1845
+ // store a copy of the device object in the `accessory.context`
1846
+ // the `context` property can be used to store any data about the accessory you may need
1847
+ accessory.context.device = device;
1848
+ accessory.context.deviceId = device.deviceId;
1849
+ accessory.context.deviceType = device.deviceType;
1850
+ accessory.context.model = SwitchBotModel.BatteryCirculatorFan;
1851
+ accessory.displayName = device.configDeviceName
1852
+ ? await this.validateAndCleanDisplayName(device.configDeviceName, 'configDeviceName', device.configDeviceName)
1853
+ : await this.validateAndCleanDisplayName(device.deviceName, 'deviceName', device.deviceName);
1854
+ accessory.context.connectionType = await this.connectionType(device);
1855
+ accessory.context.connectionType = await this.connectionType(device);
1856
+ accessory.context.version = device.firmware ?? device.version ?? this.version ?? '0.0.0';
1857
+ const newOrExternal = !device.external ? 'Adding new' : 'Loading external';
1858
+ this.infoLog(`${newOrExternal} accessory: ${accessory.displayName} deviceId: ${device.deviceId}`);
1859
+ // create the accessory handler for the newly create accessory
1860
+ // this is imported from `platformAccessory.ts`
1861
+ new AirPurifier(this, accessory, device);
1862
+ this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1863
+ // publish device externally or link the accessory to your platform
1864
+ this.externalOrPlatform(device, accessory);
1865
+ this.accessories.push(accessory);
1866
+ }
1867
+ else {
1868
+ this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} deviceId: ${device.deviceId}`);
1869
+ }
1870
+ }
1806
1871
  async createRobotVacuumCleaner(device) {
1807
1872
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
1808
1873
  // see if an accessory with the same uuid has already been registered and restored from
@@ -2108,7 +2173,7 @@ export class SwitchBotPlatform {
2108
2173
  this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} deviceId: ${device.deviceId}`);
2109
2174
  }
2110
2175
  }
2111
- async createAirPurifier(device) {
2176
+ async createAirPurifierIR(device) {
2112
2177
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.remoteType}`);
2113
2178
  // see if an accessory with the same uuid has already been registered and restored from
2114
2179
  // the cached devices we stored in the `configureAccessory` method above
@@ -2129,7 +2194,7 @@ export class SwitchBotPlatform {
2129
2194
  this.api.updatePlatformAccessories([existingAccessory]);
2130
2195
  // create the accessory handler for the restored accessory
2131
2196
  // this is imported from `platformAccessory.ts`
2132
- new AirPurifier(this, existingAccessory, device);
2197
+ new AirPurifierIR(this, existingAccessory, device);
2133
2198
  this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
2134
2199
  }
2135
2200
  else {
@@ -2156,7 +2221,7 @@ export class SwitchBotPlatform {
2156
2221
  this.infoLog(`${newOrExternal} accessory: ${accessory.displayName} deviceId: ${device.deviceId}`);
2157
2222
  // create the accessory handler for the newly create accessory
2158
2223
  // this is imported from `platformAccessory.ts`
2159
- new AirPurifier(this, accessory, device);
2224
+ new AirPurifierIR(this, accessory, device);
2160
2225
  this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
2161
2226
  // publish device externally or link the accessory to your platform
2162
2227
  this.externalOrPlatform(device, accessory);
@@ -2571,7 +2636,6 @@ export class SwitchBotPlatform {
2571
2636
  hubDeviceId: '',
2572
2637
  version: 0,
2573
2638
  deviceName: '',
2574
- enableCloudService: false,
2575
2639
  }, statusCode: 500 };
2576
2640
  }
2577
2641
  async retryCommand(device, bodyChange, deviceMaxRetries, deviceDelayBetweenRetries) {