@switchbot/homebridge-switchbot 4.3.2-beta.9 → 4.3.3

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 (222) hide show
  1. package/.github/copilot-instructions.md +328 -0
  2. package/.github/scripts/npm-version-script-esm-auto.js +207 -0
  3. package/.github/workflows/beta-release.yml +8 -12
  4. package/.github/workflows/release.yml +54 -22
  5. package/CHANGELOG.md +11 -1
  6. package/README.md +13 -10
  7. package/config.schema.json +248 -5
  8. package/coverage/base.css +224 -0
  9. package/coverage/block-navigation.js +87 -0
  10. package/coverage/clover.xml +15847 -0
  11. package/coverage/coverage-final.json +42 -0
  12. package/coverage/docs/assets/dmt/dmt-component-data.js.html +85 -0
  13. package/coverage/docs/assets/dmt/dmt-components.js.html +286 -0
  14. package/coverage/docs/assets/dmt/index.html +131 -0
  15. package/coverage/docs/assets/hierarchy.js.html +85 -0
  16. package/coverage/docs/assets/icons.js.html +136 -0
  17. package/coverage/docs/assets/index.html +146 -0
  18. package/coverage/docs/assets/main.js.html +265 -0
  19. package/coverage/favicon.png +0 -0
  20. package/coverage/index.html +191 -0
  21. package/coverage/prettify.css +1 -0
  22. package/coverage/prettify.js +2 -0
  23. package/coverage/sort-arrow-sprite.png +0 -0
  24. package/coverage/sorter.js +196 -0
  25. package/coverage/src/device/blindtilt.ts.html +3238 -0
  26. package/coverage/src/device/bot.ts.html +2803 -0
  27. package/coverage/src/device/ceilinglight.ts.html +2338 -0
  28. package/coverage/src/device/colorbulb.ts.html +2824 -0
  29. package/coverage/src/device/contact.ts.html +1465 -0
  30. package/coverage/src/device/curtain.ts.html +2869 -0
  31. package/coverage/src/device/device.ts.html +2500 -0
  32. package/coverage/src/device/fan.ts.html +2242 -0
  33. package/coverage/src/device/hub.ts.html +1408 -0
  34. package/coverage/src/device/humidifier.ts.html +2116 -0
  35. package/coverage/src/device/index.html +416 -0
  36. package/coverage/src/device/iosensor.ts.html +1375 -0
  37. package/coverage/src/device/lightstrip.ts.html +2617 -0
  38. package/coverage/src/device/lock.ts.html +1963 -0
  39. package/coverage/src/device/meter.ts.html +1372 -0
  40. package/coverage/src/device/meterplus.ts.html +1384 -0
  41. package/coverage/src/device/meterpro.ts.html +1618 -0
  42. package/coverage/src/device/motion.ts.html +1264 -0
  43. package/coverage/src/device/plug.ts.html +1372 -0
  44. package/coverage/src/device/relayswitch.ts.html +2284 -0
  45. package/coverage/src/device/robotvacuumcleaner.ts.html +1810 -0
  46. package/coverage/src/device/waterdetector.ts.html +1294 -0
  47. package/coverage/src/homebridge-ui/index.html +116 -0
  48. package/coverage/src/homebridge-ui/server.ts.html +229 -0
  49. package/coverage/src/index.html +161 -0
  50. package/coverage/src/index.ts.html +124 -0
  51. package/coverage/src/irdevice/airconditioner.ts.html +1687 -0
  52. package/coverage/src/irdevice/airpurifier.ts.html +844 -0
  53. package/coverage/src/irdevice/camera.ts.html +475 -0
  54. package/coverage/src/irdevice/fan.ts.html +766 -0
  55. package/coverage/src/irdevice/index.html +251 -0
  56. package/coverage/src/irdevice/irdevice.ts.html +1117 -0
  57. package/coverage/src/irdevice/light.ts.html +826 -0
  58. package/coverage/src/irdevice/other.ts.html +2458 -0
  59. package/coverage/src/irdevice/tv.ts.html +1222 -0
  60. package/coverage/src/irdevice/vacuumcleaner.ts.html +466 -0
  61. package/coverage/src/irdevice/waterheater.ts.html +469 -0
  62. package/coverage/src/platform.ts.html +8776 -0
  63. package/coverage/src/settings.ts.html +934 -0
  64. package/coverage/src/utils.ts.html +2092 -0
  65. package/dist/device/blindtilt.d.ts.map +1 -1
  66. package/dist/device/blindtilt.js +12 -4
  67. package/dist/device/blindtilt.js.map +1 -1
  68. package/dist/device/bot.d.ts.map +1 -1
  69. package/dist/device/bot.js +12 -4
  70. package/dist/device/bot.js.map +1 -1
  71. package/dist/device/ceilinglight.d.ts.map +1 -1
  72. package/dist/device/ceilinglight.js +18 -7
  73. package/dist/device/ceilinglight.js.map +1 -1
  74. package/dist/device/colorbulb.d.ts.map +1 -1
  75. package/dist/device/colorbulb.js +18 -7
  76. package/dist/device/colorbulb.js.map +1 -1
  77. package/dist/device/contact.d.ts.map +1 -1
  78. package/dist/device/contact.js +6 -2
  79. package/dist/device/contact.js.map +1 -1
  80. package/dist/device/curtain.d.ts.map +1 -1
  81. package/dist/device/curtain.js +12 -4
  82. package/dist/device/curtain.js.map +1 -1
  83. package/dist/device/device.d.ts +5 -7
  84. package/dist/device/device.d.ts.map +1 -1
  85. package/dist/device/device.js +11 -5
  86. package/dist/device/device.js.map +1 -1
  87. package/dist/device/fan.d.ts.map +1 -1
  88. package/dist/device/fan.js +16 -6
  89. package/dist/device/fan.js.map +1 -1
  90. package/dist/device/hub.d.ts +2 -2
  91. package/dist/device/hub.d.ts.map +1 -1
  92. package/dist/device/hub.js +8 -3
  93. package/dist/device/hub.js.map +1 -1
  94. package/dist/device/humidifier.d.ts.map +1 -1
  95. package/dist/device/humidifier.js +16 -6
  96. package/dist/device/humidifier.js.map +1 -1
  97. package/dist/device/iosensor.d.ts.map +1 -1
  98. package/dist/device/iosensor.js +6 -2
  99. package/dist/device/iosensor.js.map +1 -1
  100. package/dist/device/lightstrip.d.ts.map +1 -1
  101. package/dist/device/lightstrip.js +16 -6
  102. package/dist/device/lightstrip.js.map +1 -1
  103. package/dist/device/lock.d.ts.map +1 -1
  104. package/dist/device/lock.js +12 -4
  105. package/dist/device/lock.js.map +1 -1
  106. package/dist/device/meter.d.ts.map +1 -1
  107. package/dist/device/meter.js +6 -2
  108. package/dist/device/meter.js.map +1 -1
  109. package/dist/device/meterplus.d.ts.map +1 -1
  110. package/dist/device/meterplus.js +6 -2
  111. package/dist/device/meterplus.js.map +1 -1
  112. package/dist/device/meterpro.d.ts.map +1 -1
  113. package/dist/device/meterpro.js +7 -4
  114. package/dist/device/meterpro.js.map +1 -1
  115. package/dist/device/motion.d.ts.map +1 -1
  116. package/dist/device/motion.js +6 -2
  117. package/dist/device/motion.js.map +1 -1
  118. package/dist/device/plug.d.ts.map +1 -1
  119. package/dist/device/plug.js +12 -4
  120. package/dist/device/plug.js.map +1 -1
  121. package/dist/device/presence.d.ts +42 -0
  122. package/dist/device/presence.d.ts.map +1 -0
  123. package/dist/device/presence.js +349 -0
  124. package/dist/device/presence.js.map +1 -0
  125. package/dist/device/relayswitch.d.ts.map +1 -1
  126. package/dist/device/relayswitch.js +12 -4
  127. package/dist/device/relayswitch.js.map +1 -1
  128. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  129. package/dist/device/robotvacuumcleaner.js +14 -5
  130. package/dist/device/robotvacuumcleaner.js.map +1 -1
  131. package/dist/device/waterdetector.d.ts.map +1 -1
  132. package/dist/device/waterdetector.js +6 -2
  133. package/dist/device/waterdetector.js.map +1 -1
  134. package/dist/homebridge-ui/public/index.html +1 -1
  135. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  136. package/dist/irdevice/airconditioner.js +2 -1
  137. package/dist/irdevice/airconditioner.js.map +1 -1
  138. package/dist/irdevice/airpurifier.d.ts +1 -1
  139. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  140. package/dist/irdevice/airpurifier.js +6 -5
  141. package/dist/irdevice/airpurifier.js.map +1 -1
  142. package/dist/irdevice/camera.d.ts.map +1 -1
  143. package/dist/irdevice/camera.js +2 -1
  144. package/dist/irdevice/camera.js.map +1 -1
  145. package/dist/irdevice/fan.d.ts.map +1 -1
  146. package/dist/irdevice/fan.js +2 -1
  147. package/dist/irdevice/fan.js.map +1 -1
  148. package/dist/irdevice/irdevice.d.ts +2 -6
  149. package/dist/irdevice/irdevice.d.ts.map +1 -1
  150. package/dist/irdevice/irdevice.js.map +1 -1
  151. package/dist/irdevice/light.d.ts.map +1 -1
  152. package/dist/irdevice/light.js +2 -1
  153. package/dist/irdevice/light.js.map +1 -1
  154. package/dist/irdevice/other.d.ts.map +1 -1
  155. package/dist/irdevice/other.js +2 -1
  156. package/dist/irdevice/other.js.map +1 -1
  157. package/dist/irdevice/tv.d.ts.map +1 -1
  158. package/dist/irdevice/tv.js +2 -1
  159. package/dist/irdevice/tv.js.map +1 -1
  160. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  161. package/dist/irdevice/vacuumcleaner.js +2 -1
  162. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  163. package/dist/irdevice/waterheater.d.ts.map +1 -1
  164. package/dist/irdevice/waterheater.js +2 -1
  165. package/dist/irdevice/waterheater.js.map +1 -1
  166. package/dist/platform.d.ts +2 -2
  167. package/dist/platform.d.ts.map +1 -1
  168. package/dist/platform.js +77 -78
  169. package/dist/platform.js.map +1 -1
  170. package/dist/settings.d.ts +6 -0
  171. package/dist/settings.d.ts.map +1 -1
  172. package/dist/settings.js +1 -0
  173. package/dist/settings.js.map +1 -1
  174. package/docs/index.html +20 -11
  175. package/docs/variables/default.html +1 -1
  176. package/eslint.config.js +0 -1
  177. package/package.json +9 -10
  178. package/src/device/blindtilt.ts +10 -4
  179. package/src/device/bot.ts +10 -4
  180. package/src/device/ceilinglight.ts +16 -7
  181. package/src/device/colorbulb.ts +16 -7
  182. package/src/device/contact.ts +5 -2
  183. package/src/device/curtain.ts +12 -6
  184. package/src/device/device.ts +14 -8
  185. package/src/device/fan.ts +14 -6
  186. package/src/device/hub.ts +10 -6
  187. package/src/device/humidifier.ts +14 -6
  188. package/src/device/iosensor.ts +5 -2
  189. package/src/device/lightstrip.ts +14 -6
  190. package/src/device/lock.ts +10 -4
  191. package/src/device/meter.ts +6 -3
  192. package/src/device/meterplus.ts +5 -2
  193. package/src/device/meterpro.ts +7 -5
  194. package/src/device/motion.ts +5 -2
  195. package/src/device/plug.ts +10 -4
  196. package/src/device/presence.ts +393 -0
  197. package/src/device/relayswitch.ts +10 -4
  198. package/src/device/robotvacuumcleaner.ts +12 -5
  199. package/src/device/waterdetector.ts +5 -2
  200. package/src/homebridge-ui/public/index.html +1 -1
  201. package/src/irdevice/airconditioner.ts +2 -1
  202. package/src/irdevice/airpurifier.ts +6 -5
  203. package/src/irdevice/camera.ts +2 -1
  204. package/src/irdevice/fan.ts +2 -1
  205. package/src/irdevice/irdevice.ts +2 -2
  206. package/src/irdevice/light.ts +2 -1
  207. package/src/irdevice/other.ts +2 -1
  208. package/src/irdevice/tv.ts +2 -1
  209. package/src/irdevice/vacuumcleaner.ts +2 -1
  210. package/src/irdevice/waterheater.ts +2 -1
  211. package/src/platform.ts +80 -88
  212. package/src/settings.ts +7 -0
  213. package/.github/npm-version-script-esm.js +0 -97
  214. package/.github/workflows/build.yml +0 -18
  215. package/.github/workflows/changerelease.yml +0 -11
  216. package/.github/workflows/labeler.yml +0 -16
  217. package/.github/workflows/release-drafter.yml +0 -14
  218. package/dist/device/airpurifier.d.ts +0 -54
  219. package/dist/device/airpurifier.d.ts.map +0 -1
  220. package/dist/device/airpurifier.js +0 -527
  221. package/dist/device/airpurifier.js.map +0 -1
  222. package/src/device/airpurifier.ts +0 -563
package/dist/platform.js CHANGED
@@ -5,7 +5,6 @@ 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';
9
8
  import { BlindTilt } from './device/blindtilt.js';
10
9
  import { Bot } from './device/bot.js';
11
10
  import { CeilingLight } from './device/ceilinglight.js';
@@ -23,11 +22,12 @@ import { MeterPlus } from './device/meterplus.js';
23
22
  import { MeterPro } from './device/meterpro.js';
24
23
  import { Motion } from './device/motion.js';
25
24
  import { Plug } from './device/plug.js';
25
+ import { Presence } from './device/presence.js';
26
26
  import { RelaySwitch } from './device/relayswitch.js';
27
27
  import { RobotVacuumCleaner } from './device/robotvacuumcleaner.js';
28
28
  import { WaterDetector } from './device/waterdetector.js';
29
29
  import { AirConditioner } from './irdevice/airconditioner.js';
30
- import { AirPurifierIR } from './irdevice/airpurifier.js';
30
+ import { AirPurifier } from './irdevice/airpurifier.js';
31
31
  import { Camera } from './irdevice/camera.js';
32
32
  import { IRFan } from './irdevice/fan.js';
33
33
  import { Light } from './irdevice/light.js';
@@ -202,7 +202,7 @@ export class SwitchBotPlatform {
202
202
  this.webhookEventHandler[context.deviceMac]?.(context);
203
203
  }
204
204
  catch (e) {
205
- this.errorLog(`Failed to handle webhook event. Error:${e.message ?? e}`);
205
+ this.errorLog(`Failed to handle webhook event. Error: ${e.message ?? e}`);
206
206
  }
207
207
  });
208
208
  }
@@ -230,14 +230,14 @@ export class SwitchBotPlatform {
230
230
  });
231
231
  }
232
232
  catch (e) {
233
- this.errorLog(`Failed to setup webhook. Error:${e.message ?? e}`);
233
+ this.errorLog(`Failed to setup webhook. Error: ${e.message ?? e}`);
234
234
  }
235
235
  this.api.on('shutdown', async () => {
236
236
  try {
237
237
  this.switchBotAPI.deleteWebhook(url);
238
238
  }
239
239
  catch (e) {
240
- this.errorLog(`Failed to delete webhook. Error:${e.message ?? e}`);
240
+ this.errorLog(`Failed to delete webhook. Error: ${e.message ?? e}`);
241
241
  }
242
242
  });
243
243
  }
@@ -289,7 +289,7 @@ export class SwitchBotPlatform {
289
289
  await this.switchBotBLE.startScan();
290
290
  }
291
291
  catch (e) {
292
- this.errorLog(`Failed to start BLE scanning. Error:${e.message ?? e}`);
292
+ this.errorLog(`Failed to start BLE scanning. Error: ${e.message ?? e}`);
293
293
  }
294
294
  // Set an event handler to monitor advertisement packets
295
295
  this.switchBotBLE.onadvertisement = async (ad) => {
@@ -297,7 +297,7 @@ export class SwitchBotPlatform {
297
297
  this.bleEventHandler[ad.address]?.(ad.serviceData);
298
298
  }
299
299
  catch (e) {
300
- this.errorLog(`Failed to handle BLE event. Error:${e.message ?? e}`);
300
+ this.errorLog(`Failed to handle BLE event. Error: ${e.message ?? e}`);
301
301
  }
302
302
  };
303
303
  })();
@@ -307,7 +307,7 @@ export class SwitchBotPlatform {
307
307
  this.infoLog('Stopped BLE scanning to close listening.');
308
308
  }
309
309
  catch (e) {
310
- this.errorLog(`Failed to stop Platform BLE scanning. Error:${e.message ?? e}`);
310
+ this.errorLog(`Failed to stop Platform BLE scanning. Error: ${e.message ?? e}`);
311
311
  }
312
312
  });
313
313
  }
@@ -536,17 +536,19 @@ export class SwitchBotPlatform {
536
536
  'Humidifier': this.createHumidifier.bind(this),
537
537
  'Humidifier2': this.createHumidifier.bind(this),
538
538
  'Hub 2': this.createHub2.bind(this),
539
+ 'Hub 3': this.createHub2.bind(this),
539
540
  'Bot': this.createBot.bind(this),
540
541
  'Relay Switch 1': this.createRelaySwitch.bind(this),
541
542
  'Relay Switch 1PM': this.createRelaySwitch.bind(this),
542
543
  'Meter': this.createMeter.bind(this),
543
544
  'MeterPlus': this.createMeterPlus.bind(this),
544
545
  'Meter Plus (JP)': this.createMeterPlus.bind(this),
545
- 'MeterPro': this.createMeterPro.bind(this),
546
+ 'Meter Pro': this.createMeterPro.bind(this),
546
547
  'MeterPro(CO2)': this.createMeterPro.bind(this),
547
548
  'WoIOSensor': this.createIOSensor.bind(this),
548
549
  'Water Detector': this.createWaterDetector.bind(this),
549
550
  'Motion Sensor': this.createMotion.bind(this),
551
+ 'Presence Sensor': this.createPresence.bind(this),
550
552
  'Contact Sensor': this.createContact.bind(this),
551
553
  'Curtain': this.createCurtain.bind(this),
552
554
  'Curtain3': this.createCurtain.bind(this),
@@ -570,10 +572,6 @@ export class SwitchBotPlatform {
570
572
  'Ceiling Light Pro': this.createCeilingLight.bind(this),
571
573
  'Strip Light': this.createStripLight.bind(this),
572
574
  '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),
577
575
  };
578
576
  if (deviceTypeHandlers[device.deviceType]) {
579
577
  this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
@@ -607,8 +605,8 @@ export class SwitchBotPlatform {
607
605
  'DIY Air Conditioner': this.createAirConditioner.bind(this),
608
606
  'Light': this.createLight.bind(this),
609
607
  'DIY Light': this.createLight.bind(this),
610
- 'Air Purifier': this.createAirPurifierIR.bind(this),
611
- 'DIY Air Purifier': this.createAirPurifierIR.bind(this),
608
+ 'Air Purifier': this.createAirPurifier.bind(this),
609
+ 'DIY Air Purifier': this.createAirPurifier.bind(this),
612
610
  'Water Heater': this.createWaterHeater.bind(this),
613
611
  'DIY Water Heater': this.createWaterHeater.bind(this),
614
612
  'Vacuum Cleaner': this.createVacuumCleaner.bind(this),
@@ -1232,6 +1230,66 @@ export class SwitchBotPlatform {
1232
1230
  this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} deviceId: ${device.deviceId}`);
1233
1231
  }
1234
1232
  }
1233
+ async createPresence(device) {
1234
+ const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
1235
+ // see if an accessory with the same uuid has already been registered and restored from
1236
+ // the cached devices we stored in the `configureAccessory` method above
1237
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
1238
+ if (existingAccessory) {
1239
+ // the accessory already exists
1240
+ if (await this.registerDevice(device)) {
1241
+ // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1242
+ existingAccessory.context.device = device;
1243
+ existingAccessory.context.deviceId = device.deviceId;
1244
+ existingAccessory.context.deviceType = device.deviceType;
1245
+ existingAccessory.context.model = SwitchBotModel.PresenceSensor;
1246
+ existingAccessory.displayName = device.configDeviceName
1247
+ ? await this.validateAndCleanDisplayName(device.configDeviceName, 'configDeviceName', device.configDeviceName)
1248
+ : await this.validateAndCleanDisplayName(device.deviceName, 'deviceName', device.deviceName);
1249
+ existingAccessory.context.connectionType = await this.connectionType(device);
1250
+ existingAccessory.context.version = device.firmware ?? device.version ?? this.version ?? '0.0.0';
1251
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} deviceId: ${device.deviceId}`);
1252
+ this.api.updatePlatformAccessories([existingAccessory]);
1253
+ // create the accessory handler for the restored accessory
1254
+ // this is imported from `platformAccessory.ts`
1255
+ new Presence(this, existingAccessory, device);
1256
+ this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
1257
+ }
1258
+ else {
1259
+ this.unregisterPlatformAccessories(existingAccessory);
1260
+ }
1261
+ }
1262
+ else if (await this.registerDevice(device)) {
1263
+ // create a new accessory
1264
+ const accessory = new this.api.platformAccessory(device.configDeviceName
1265
+ ? await this.validateAndCleanDisplayName(device.configDeviceName, 'configDeviceName', device.configDeviceName)
1266
+ : await this.validateAndCleanDisplayName(device.deviceName, 'deviceName', device.deviceName), uuid);
1267
+ // store a copy of the device object in the `accessory.context`
1268
+ // the `context` property can be used to store any data about the accessory you may need
1269
+ accessory.context.device = device;
1270
+ accessory.context.deviceId = device.deviceId;
1271
+ accessory.context.deviceType = device.deviceType;
1272
+ accessory.context.model = SwitchBotModel.PresenceSensor;
1273
+ accessory.displayName = device.configDeviceName
1274
+ ? await this.validateAndCleanDisplayName(device.configDeviceName, 'configDeviceName', device.configDeviceName)
1275
+ : await this.validateAndCleanDisplayName(device.deviceName, 'deviceName', device.deviceName);
1276
+ accessory.context.connectionType = await this.connectionType(device);
1277
+ accessory.context.connectionType = await this.connectionType(device);
1278
+ accessory.context.version = device.firmware ?? device.version ?? this.version ?? '0.0.0';
1279
+ const newOrExternal = !device.external ? 'Adding new' : 'Loading external';
1280
+ this.infoLog(`${newOrExternal} accessory: ${accessory.displayName} deviceId: ${device.deviceId}`);
1281
+ // create the accessory handler for the newly create accessory
1282
+ // this is imported from `platformAccessory.ts`
1283
+ new Presence(this, accessory, device);
1284
+ this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
1285
+ // publish device externally or link the accessory to your platform
1286
+ this.externalOrPlatform(device, accessory);
1287
+ this.accessories.push(accessory);
1288
+ }
1289
+ else {
1290
+ this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} deviceId: ${device.deviceId}`);
1291
+ }
1292
+ }
1235
1293
  async createContact(device) {
1236
1294
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
1237
1295
  // see if an accessory with the same uuid has already been registered and restored from
@@ -1808,66 +1866,6 @@ export class SwitchBotPlatform {
1808
1866
  this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} deviceId: ${device.deviceId}`);
1809
1867
  }
1810
1868
  }
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
- }
1871
1869
  async createRobotVacuumCleaner(device) {
1872
1870
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
1873
1871
  // see if an accessory with the same uuid has already been registered and restored from
@@ -2173,7 +2171,7 @@ export class SwitchBotPlatform {
2173
2171
  this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} deviceId: ${device.deviceId}`);
2174
2172
  }
2175
2173
  }
2176
- async createAirPurifierIR(device) {
2174
+ async createAirPurifier(device) {
2177
2175
  const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.remoteType}`);
2178
2176
  // see if an accessory with the same uuid has already been registered and restored from
2179
2177
  // the cached devices we stored in the `configureAccessory` method above
@@ -2194,7 +2192,7 @@ export class SwitchBotPlatform {
2194
2192
  this.api.updatePlatformAccessories([existingAccessory]);
2195
2193
  // create the accessory handler for the restored accessory
2196
2194
  // this is imported from `platformAccessory.ts`
2197
- new AirPurifierIR(this, existingAccessory, device);
2195
+ new AirPurifier(this, existingAccessory, device);
2198
2196
  this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
2199
2197
  }
2200
2198
  else {
@@ -2221,7 +2219,7 @@ export class SwitchBotPlatform {
2221
2219
  this.infoLog(`${newOrExternal} accessory: ${accessory.displayName} deviceId: ${device.deviceId}`);
2222
2220
  // create the accessory handler for the newly create accessory
2223
2221
  // this is imported from `platformAccessory.ts`
2224
- new AirPurifierIR(this, accessory, device);
2222
+ new AirPurifier(this, accessory, device);
2225
2223
  this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
2226
2224
  // publish device externally or link the accessory to your platform
2227
2225
  this.externalOrPlatform(device, accessory);
@@ -2636,6 +2634,7 @@ export class SwitchBotPlatform {
2636
2634
  hubDeviceId: '',
2637
2635
  version: 0,
2638
2636
  deviceName: '',
2637
+ enableCloudService: false,
2639
2638
  }, statusCode: 500 };
2640
2639
  }
2641
2640
  async retryCommand(device, bodyChange, deviceMaxRetries, deviceDelayBetweenRetries) {