node-switchbot 3.6.0-beta.0 → 3.6.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.
Files changed (317) hide show
  1. package/.github/copilot-instructions.md +165 -0
  2. package/CHANGELOG.md +26 -0
  3. package/dist/device.d.ts +247 -13
  4. package/dist/device.d.ts.map +1 -1
  5. package/dist/device.js +658 -78
  6. package/dist/device.js.map +1 -1
  7. package/dist/device.test.d.ts +2 -0
  8. package/dist/device.test.d.ts.map +1 -0
  9. package/dist/device.test.js +152 -0
  10. package/dist/device.test.js.map +1 -0
  11. package/dist/index.d.ts +4 -7
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +6 -7
  14. package/dist/index.js.map +1 -1
  15. package/dist/parameter-checker.d.ts +1 -0
  16. package/dist/parameter-checker.d.ts.map +1 -1
  17. package/dist/parameter-checker.js +19 -11
  18. package/dist/parameter-checker.js.map +1 -1
  19. package/dist/parameter-checker.test.d.ts +2 -0
  20. package/dist/parameter-checker.test.d.ts.map +1 -0
  21. package/dist/parameter-checker.test.js +56 -0
  22. package/dist/parameter-checker.test.js.map +1 -0
  23. package/dist/settings.d.ts.map +1 -1
  24. package/dist/settings.js +21 -16
  25. package/dist/settings.js.map +1 -1
  26. package/dist/settings.test.js +13 -1
  27. package/dist/settings.test.js.map +1 -1
  28. package/dist/switchbot-ble.d.ts +8 -11
  29. package/dist/switchbot-ble.d.ts.map +1 -1
  30. package/dist/switchbot-ble.js +88 -73
  31. package/dist/switchbot-ble.js.map +1 -1
  32. package/dist/switchbot-ble.test.d.ts +2 -0
  33. package/dist/switchbot-ble.test.d.ts.map +1 -0
  34. package/dist/switchbot-ble.test.js +32 -0
  35. package/dist/switchbot-ble.test.js.map +1 -0
  36. package/dist/switchbot-openapi.d.ts +4 -7
  37. package/dist/switchbot-openapi.d.ts.map +1 -1
  38. package/dist/switchbot-openapi.js +19 -10
  39. package/dist/switchbot-openapi.js.map +1 -1
  40. package/dist/switchbot-openapi.test.d.ts +2 -0
  41. package/dist/switchbot-openapi.test.d.ts.map +1 -0
  42. package/dist/switchbot-openapi.test.js +36 -0
  43. package/dist/switchbot-openapi.test.js.map +1 -0
  44. package/dist/types/ble-guards.d.ts +12 -0
  45. package/dist/types/ble-guards.d.ts.map +1 -0
  46. package/dist/types/ble-guards.js +10 -0
  47. package/dist/types/ble-guards.js.map +1 -0
  48. package/dist/types/ble-guards.test.d.ts +2 -0
  49. package/dist/types/ble-guards.test.d.ts.map +1 -0
  50. package/dist/types/ble-guards.test.js +62 -0
  51. package/dist/types/ble-guards.test.js.map +1 -0
  52. package/dist/types/{bledevicestatus.d.ts → ble.d.ts} +135 -116
  53. package/dist/types/ble.d.ts.map +1 -0
  54. package/dist/types/ble.js +2 -0
  55. package/dist/types/ble.js.map +1 -0
  56. package/dist/types/openapi.d.ts +623 -0
  57. package/dist/types/openapi.d.ts.map +1 -0
  58. package/dist/types/openapi.js +3 -0
  59. package/dist/types/openapi.js.map +1 -0
  60. package/docs/assets/hierarchy.js +1 -1
  61. package/docs/assets/navigation.js +1 -1
  62. package/docs/assets/search.js +1 -1
  63. package/docs/classes/Advertising.html +4 -4
  64. package/docs/classes/ErrorUtils.html +25 -0
  65. package/docs/classes/ParameterChecker.html +69 -0
  66. package/docs/classes/SwitchBotBLE.html +9 -11
  67. package/docs/classes/SwitchBotOpenAPI.html +9 -9
  68. package/docs/classes/SwitchbotDevice.html +12 -12
  69. package/docs/classes/ValidationUtils.html +51 -0
  70. package/docs/classes/WoAirPurifier.html +83 -0
  71. package/docs/classes/WoAirPurifierTable.html +83 -0
  72. package/docs/classes/WoBlindTilt.html +21 -21
  73. package/docs/classes/WoBulb.html +19 -19
  74. package/docs/classes/WoCeilingLight.html +22 -22
  75. package/docs/classes/WoContact.html +13 -13
  76. package/docs/classes/WoCurtain.html +18 -18
  77. package/docs/classes/WoHand.html +18 -18
  78. package/docs/classes/WoHub2.html +13 -13
  79. package/docs/classes/WoHub3.html +52 -0
  80. package/docs/classes/WoHumi.html +20 -20
  81. package/docs/classes/WoHumi2.html +20 -20
  82. package/docs/classes/WoIOSensorTH.html +13 -13
  83. package/docs/classes/WoKeypad.html +13 -13
  84. package/docs/classes/WoLeak.html +13 -13
  85. package/docs/classes/WoPlugMiniJP.html +18 -18
  86. package/docs/classes/WoPlugMiniUS.html +18 -18
  87. package/docs/classes/WoPresence.html +13 -13
  88. package/docs/classes/WoRelaySwitch1.html +15 -15
  89. package/docs/classes/WoRelaySwitch1PM.html +15 -15
  90. package/docs/classes/WoRemote.html +13 -13
  91. package/docs/classes/WoSensorTH.html +12 -12
  92. package/docs/classes/WoSensorTHPlus.html +12 -12
  93. package/docs/classes/WoSensorTHPro.html +12 -12
  94. package/docs/classes/WoSensorTHProCO2.html +12 -12
  95. package/docs/classes/WoSmartLock.html +23 -23
  96. package/docs/classes/WoSmartLockPro.html +23 -23
  97. package/docs/classes/WoStrip.html +20 -20
  98. package/docs/enums/LogLevel.html +2 -2
  99. package/docs/enums/SwitchBotBLEModel.html +5 -2
  100. package/docs/enums/SwitchBotBLEModelFriendlyName.html +9 -2
  101. package/docs/enums/SwitchBotBLEModelName.html +5 -2
  102. package/docs/enums/SwitchBotModel.html +5 -2
  103. package/docs/functions/updateBaseURL.html +3 -0
  104. package/docs/hierarchy.html +1 -1
  105. package/docs/interfaces/AdvertisementData.html +2 -2
  106. package/docs/interfaces/Chars.html +2 -2
  107. package/docs/interfaces/ColorLightServiceDataBase.html +17 -0
  108. package/docs/interfaces/ErrorObject.html +2 -2
  109. package/docs/interfaces/LockBaseServiceData.html +15 -0
  110. package/docs/interfaces/NobleTypes.html +2 -3
  111. package/docs/interfaces/Params.html +2 -2
  112. package/docs/interfaces/PlugMiniServiceDataBase.html +12 -0
  113. package/docs/interfaces/Rule.html +2 -2
  114. package/docs/interfaces/ServiceData.html +2 -2
  115. package/docs/interfaces/SwitchBotBLEDevice.html +5 -2
  116. package/docs/interfaces/SwitchBotScanner.html +6 -0
  117. package/docs/interfaces/TemperatureServiceDataBase.html +10 -0
  118. package/docs/interfaces/WebhookDetail.html +2 -2
  119. package/docs/interfaces/ad.html +2 -2
  120. package/docs/interfaces/body.html +2 -2
  121. package/docs/interfaces/bodyChange.html +2 -2
  122. package/docs/interfaces/deleteWebhookResponse.html +2 -2
  123. package/docs/interfaces/device.html +2 -2
  124. package/docs/interfaces/deviceList.html +2 -2
  125. package/docs/interfaces/deviceStatus.html +2 -2
  126. package/docs/interfaces/deviceStatusRequest.html +2 -2
  127. package/docs/interfaces/deviceWebhook.html +2 -2
  128. package/docs/interfaces/deviceWebhookContext.html +2 -2
  129. package/docs/interfaces/devices.html +2 -2
  130. package/docs/interfaces/infraredRemoteList.html +2 -2
  131. package/docs/interfaces/irdevice.html +2 -2
  132. package/docs/interfaces/pushRequest.html +5 -0
  133. package/docs/interfaces/pushResponse.html +3 -2
  134. package/docs/interfaces/pushResponseBody.html +3 -0
  135. package/docs/interfaces/queryWebhookResponse.html +2 -2
  136. package/docs/interfaces/setupWebhookResponse.html +2 -2
  137. package/docs/interfaces/updateWebhookResponse.html +2 -2
  138. package/docs/interfaces/webhookRequest.html +2 -2
  139. package/docs/modules.html +1 -1
  140. package/docs/types/BLEDeviceServiceData.html +1 -0
  141. package/docs/types/{indoorCam.html → IndoorCam.html} +1 -1
  142. package/docs/types/MacAddress.html +1 -1
  143. package/docs/types/airPurifier.html +1 -0
  144. package/docs/types/airPurifierPM25WebhookContext.html +1 -0
  145. package/docs/types/airPurifierServiceData.html +1 -0
  146. package/docs/types/airPurifierStatus.html +1 -0
  147. package/docs/types/airPurifierTable.html +1 -0
  148. package/docs/types/airPurifierTablePM25WebhookContext.html +1 -0
  149. package/docs/types/airPurifierTableServiceData.html +1 -0
  150. package/docs/types/airPurifierTableStatus.html +1 -0
  151. package/docs/types/airPurifierTableVOC.html +1 -0
  152. package/docs/types/airPurifierTableVOCStatus.html +1 -0
  153. package/docs/types/airPurifierTableVOCWebhookContext.html +1 -0
  154. package/docs/types/airPurifierTableWebhookContext.html +1 -0
  155. package/docs/types/airPurifierVOC.html +1 -0
  156. package/docs/types/airPurifierVOCStatus.html +1 -0
  157. package/docs/types/airPurifierVOCWebhookContext.html +1 -0
  158. package/docs/types/airPurifierWebhookContext.html +1 -0
  159. package/docs/types/batteryCirculatorFan.html +1 -1
  160. package/docs/types/batteryCirculatorFanServiceData.html +1 -1
  161. package/docs/types/batteryCirculatorFanStatus.html +1 -1
  162. package/docs/types/batteryCirculatorFanWebhookContext.html +1 -1
  163. package/docs/types/blindTilt.html +1 -1
  164. package/docs/types/blindTiltServiceData.html +1 -1
  165. package/docs/types/blindTiltStatus.html +1 -1
  166. package/docs/types/blindTiltWebhookContext.html +1 -1
  167. package/docs/types/bot.html +1 -1
  168. package/docs/types/botServiceData.html +1 -1
  169. package/docs/types/botStatus.html +1 -1
  170. package/docs/types/botWebhookContext.html +1 -1
  171. package/docs/types/ceilingLight.html +1 -1
  172. package/docs/types/ceilingLightPro.html +1 -1
  173. package/docs/types/ceilingLightProServiceData.html +1 -1
  174. package/docs/types/ceilingLightProStatus.html +1 -1
  175. package/docs/types/ceilingLightProWebhookContext.html +1 -1
  176. package/docs/types/ceilingLightServiceData.html +1 -1
  177. package/docs/types/ceilingLightStatus.html +1 -1
  178. package/docs/types/ceilingLightWebhookContext.html +1 -1
  179. package/docs/types/circulatorFanStatus.html +1 -1
  180. package/docs/types/circulatorFanWebhookContext.html +1 -1
  181. package/docs/types/colorBulb.html +1 -1
  182. package/docs/types/colorBulbServiceData.html +1 -1
  183. package/docs/types/colorBulbStatus.html +1 -1
  184. package/docs/types/colorBulbWebhookContext.html +1 -1
  185. package/docs/types/commandType.html +2 -0
  186. package/docs/types/contactSensor.html +1 -1
  187. package/docs/types/contactSensorServiceData.html +1 -1
  188. package/docs/types/contactSensorStatus.html +1 -1
  189. package/docs/types/contactSensorWebhookContext.html +1 -1
  190. package/docs/types/curtain.html +1 -1
  191. package/docs/types/curtain3.html +1 -1
  192. package/docs/types/curtain3ServiceData.html +1 -1
  193. package/docs/types/curtain3WebhookContext.html +1 -1
  194. package/docs/types/curtainServiceData.html +1 -1
  195. package/docs/types/curtainStatus.html +1 -1
  196. package/docs/types/curtainWebhookContext.html +1 -1
  197. package/docs/types/floorCleaningRobotS10.html +1 -1
  198. package/docs/types/floorCleaningRobotS10Status.html +1 -1
  199. package/docs/types/floorCleaningRobotS10WebhookContext.html +1 -1
  200. package/docs/types/hub2.html +1 -1
  201. package/docs/types/hub2ServiceData.html +1 -1
  202. package/docs/types/hub2Status.html +1 -1
  203. package/docs/types/hub2WebhookContext.html +1 -1
  204. package/docs/types/hub3ServiceData.html +1 -0
  205. package/docs/types/humidifier.html +1 -1
  206. package/docs/types/humidifier2ServiceData.html +1 -1
  207. package/docs/types/humidifier2Status.html +1 -1
  208. package/docs/types/humidifier2WebhookContext.html +1 -1
  209. package/docs/types/humidifierServiceData.html +1 -1
  210. package/docs/types/humidifierStatus.html +1 -1
  211. package/docs/types/humidifierWebhookContext.html +1 -1
  212. package/docs/types/indoorCameraWebhookContext.html +1 -1
  213. package/docs/types/keypad.html +1 -1
  214. package/docs/types/keypadDetectorServiceData.html +1 -1
  215. package/docs/types/keypadTouch.html +1 -1
  216. package/docs/types/keypadTouchWebhookContext.html +1 -1
  217. package/docs/types/keypadWebhookContext.html +1 -1
  218. package/docs/types/lock.html +1 -1
  219. package/docs/types/lockPro.html +1 -1
  220. package/docs/types/lockProServiceData.html +1 -1
  221. package/docs/types/lockProStatus.html +1 -1
  222. package/docs/types/lockProWebhookContext.html +1 -1
  223. package/docs/types/lockServiceData.html +1 -1
  224. package/docs/types/lockStatus.html +1 -1
  225. package/docs/types/lockWebhookContext.html +1 -1
  226. package/docs/types/meter.html +1 -1
  227. package/docs/types/meterPlus.html +1 -1
  228. package/docs/types/meterPlusServiceData.html +1 -1
  229. package/docs/types/meterPlusStatus.html +1 -1
  230. package/docs/types/meterPlusWebhookContext.html +1 -1
  231. package/docs/types/meterPro.html +1 -1
  232. package/docs/types/meterProCO2ServiceData.html +1 -1
  233. package/docs/types/meterProCO2Status.html +1 -1
  234. package/docs/types/meterProCO2WebhookContext.html +1 -1
  235. package/docs/types/meterProServiceData.html +1 -1
  236. package/docs/types/meterProStatus.html +1 -1
  237. package/docs/types/meterProWebhookContext.html +1 -1
  238. package/docs/types/meterServiceData.html +1 -1
  239. package/docs/types/meterStatus.html +1 -1
  240. package/docs/types/meterWebhookContext.html +1 -1
  241. package/docs/types/motionSensor.html +1 -1
  242. package/docs/types/motionSensorServiceData.html +1 -1
  243. package/docs/types/motionSensorStatus.html +1 -1
  244. package/docs/types/motionSensorWebhookContext.html +1 -1
  245. package/docs/types/onadvertisement.html +1 -1
  246. package/docs/types/ondiscover.html +1 -1
  247. package/docs/types/outdoorMeter.html +1 -1
  248. package/docs/types/outdoorMeterServiceData.html +1 -1
  249. package/docs/types/outdoorMeterStatus.html +1 -1
  250. package/docs/types/outdoorMeterWebhookContext.html +1 -1
  251. package/docs/types/panTiltCamWebhookContext.html +1 -1
  252. package/docs/types/pantiltCam.html +1 -1
  253. package/docs/types/pantiltCam2k.html +1 -1
  254. package/docs/types/plug.html +1 -1
  255. package/docs/types/plugMini.html +1 -1
  256. package/docs/types/plugMiniJPServiceData.html +1 -1
  257. package/docs/types/plugMiniJPWebhookContext.html +1 -1
  258. package/docs/types/plugMiniStatus.html +1 -1
  259. package/docs/types/plugMiniUSServiceData.html +1 -1
  260. package/docs/types/plugMiniUSWebhookContext.html +1 -1
  261. package/docs/types/plugStatus.html +1 -1
  262. package/docs/types/plugWebhookContext.html +1 -1
  263. package/docs/types/relaySwitch1Context.html +1 -1
  264. package/docs/types/relaySwitch1PMContext.html +1 -1
  265. package/docs/types/relaySwitch1PMServiceData.html +1 -1
  266. package/docs/types/relaySwitch1PMStatus.html +1 -1
  267. package/docs/types/relaySwitch1ServiceData.html +1 -1
  268. package/docs/types/relaySwitch1Status.html +1 -1
  269. package/docs/types/remote.html +1 -1
  270. package/docs/types/remoteServiceData.html +1 -1
  271. package/docs/types/robotVacuumCleanerS1.html +1 -1
  272. package/docs/types/robotVacuumCleanerS1Plus.html +1 -1
  273. package/docs/types/robotVacuumCleanerS1PlusStatus.html +1 -1
  274. package/docs/types/robotVacuumCleanerS1PlusWebhookContext.html +1 -1
  275. package/docs/types/robotVacuumCleanerS1Status.html +1 -1
  276. package/docs/types/robotVacuumCleanerS1WebhookContext.html +1 -1
  277. package/docs/types/robotVacuumCleanerServiceData.html +1 -1
  278. package/docs/types/stripLight.html +1 -1
  279. package/docs/types/stripLightServiceData.html +1 -1
  280. package/docs/types/stripLightStatus.html +1 -1
  281. package/docs/types/stripLightWebhookContext.html +1 -1
  282. package/docs/types/waterLeakDetector.html +1 -1
  283. package/docs/types/waterLeakDetectorServiceData.html +1 -1
  284. package/docs/types/waterLeakDetectorStatus.html +1 -1
  285. package/docs/types/waterLeakDetectorWebhookContext.html +1 -1
  286. package/docs/variables/parameterChecker.html +1 -0
  287. package/docs/variables/urls.html +1 -0
  288. package/package.json +6 -6
  289. package/dist/types/bledevicestatus.d.ts.map +0 -1
  290. package/dist/types/bledevicestatus.js +0 -2
  291. package/dist/types/bledevicestatus.js.map +0 -1
  292. package/dist/types/devicelist.d.ts +0 -90
  293. package/dist/types/devicelist.d.ts.map +0 -1
  294. package/dist/types/devicelist.js +0 -2
  295. package/dist/types/devicelist.js.map +0 -1
  296. package/dist/types/devicepush.d.ts +0 -13
  297. package/dist/types/devicepush.d.ts.map +0 -1
  298. package/dist/types/devicepush.js +0 -2
  299. package/dist/types/devicepush.js.map +0 -1
  300. package/dist/types/deviceresponse.d.ts +0 -12
  301. package/dist/types/deviceresponse.d.ts.map +0 -1
  302. package/dist/types/deviceresponse.js +0 -2
  303. package/dist/types/deviceresponse.js.map +0 -1
  304. package/dist/types/devicestatus.d.ts +0 -194
  305. package/dist/types/devicestatus.d.ts.map +0 -1
  306. package/dist/types/devicestatus.js +0 -3
  307. package/dist/types/devicestatus.js.map +0 -1
  308. package/dist/types/devicewebhookstatus.d.ts +0 -236
  309. package/dist/types/devicewebhookstatus.d.ts.map +0 -1
  310. package/dist/types/devicewebhookstatus.js +0 -2
  311. package/dist/types/devicewebhookstatus.js.map +0 -1
  312. package/dist/types/irdevicelist.d.ts +0 -10
  313. package/dist/types/irdevicelist.d.ts.map +0 -1
  314. package/dist/types/irdevicelist.js +0 -2
  315. package/dist/types/irdevicelist.js.map +0 -1
  316. package/docs/interfaces/switchbot.html +0 -3
  317. package/jest.config.js +0 -3
@@ -0,0 +1,165 @@
1
+ # Node-SwitchBot Development Instructions
2
+
3
+ Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
4
+
5
+ ## Working Effectively
6
+
7
+ ### Bootstrap and Setup
8
+ - Install Node.js (^20 || ^22 || ^24): Use the existing version if available
9
+ - Install dependencies: `npm install` -- takes ~5-25 seconds (varies by cache). **NEVER CANCEL**
10
+ - Build the project: `npm run build` -- takes ~5 seconds. **NEVER CANCEL**
11
+ - Run tests: `npm run test` -- takes ~1 second with 12 tests. **NEVER CANCEL**
12
+
13
+ ### Development Workflow
14
+ - **ALWAYS run these commands in order when starting work:**
15
+ 1. `npm install`
16
+ 2. `npm run build`
17
+ 3. `npm run test`
18
+ 4. `npm run lint`
19
+ - **Build and validate EVERY change**: After any code modification, always run `npm run build && npm run test && npm run lint`
20
+ - **NEVER skip linting**: Run `npm run lint` before committing or the CI (.github/workflows/build.yml) will fail
21
+ - **Use lint:fix for automatic fixes**: `npm run lint:fix` to automatically fix ESLint issues
22
+
23
+ ### Platform Requirements and Constraints
24
+ - **BLE functionality requires Linux-based OS only** (Raspbian, Ubuntu, etc.)
25
+ - **Windows and macOS are NOT supported** for BLE operations (use OpenAPI instead)
26
+ - **Node.js versions**: Must use ^20, ^22, or ^24 (currently using v20.19.4)
27
+ - **ES Modules**: This project uses `"type": "module"` - always use ES import/export syntax
28
+
29
+ ### Testing and Validation
30
+ - **Basic functionality test**: After any changes to core classes, run this validation:
31
+ ```javascript
32
+ const { SwitchBotBLE, SwitchBotOpenAPI } = require('./dist/index.js');
33
+ const ble = new SwitchBotBLE(); // Should not throw
34
+ const api = new SwitchBotOpenAPI('test', 'test'); // Should not throw
35
+ ```
36
+ - **Complete test suite**: `npm run test` (12 tests) -- should always pass before committing
37
+ - **Test coverage**: `npm run test-coverage` to see coverage report (~15% coverage is normal)
38
+ - **Documentation generation**: `npm run docs` generates TypeDoc documentation in ./docs/
39
+
40
+ ### Build and Timing Expectations
41
+ - **npm install**: ~5-25 seconds (varies by cache) -- **NEVER CANCEL**. Set timeout to 5+ minutes for safety
42
+ - **npm run build**: ~5 seconds -- **NEVER CANCEL**. Set timeout to 2+ minutes for safety
43
+ - **npm run test**: ~1 second (12 tests) -- **NEVER CANCEL**. Set timeout to 2+ minutes for safety
44
+ - **npm run lint**: ~3 seconds -- **NEVER CANCEL**. Set timeout to 2+ minutes for safety
45
+ - **npm run docs**: ~2 seconds -- **NEVER CANCEL**. Set timeout to 2+ minutes for safety
46
+
47
+ ## Project Structure and Key Files
48
+
49
+ ### Source Code Organization
50
+ - **src/index.ts**: Main export file - exports SwitchBotBLE, SwitchBotOpenAPI, and device classes
51
+ - **src/switchbot-ble.ts**: Bluetooth Low Energy interface for direct device control
52
+ - **src/switchbot-openapi.ts**: HTTP API interface for cloud-based SwitchBot control
53
+ - **src/device.ts**: Individual device classes (WoHand, WoCurtain, WoSmartLock, etc.)
54
+ - **src/types/**: TypeScript type definitions for all device interfaces
55
+ - **src/settings.ts**: Configuration constants and API URLs
56
+ - **dist/**: Compiled JavaScript output (generated by `npm run build`)
57
+
58
+ ### Configuration Files
59
+ - **package.json**: Main project config - scripts, dependencies, ES module config
60
+ - **tsconfig.json**: TypeScript compilation settings (target: ES2022, module: ES2022)
61
+ - **eslint.config.js**: ESLint configuration using @antfu/eslint-config
62
+ - **jest.config.js**: Test configuration (uses Vitest, not Jest)
63
+ - **.gitignore**: Excludes dist/, node_modules/, coverage/, and build artifacts
64
+
65
+ ### Documentation
66
+ - **README.md**: Main project documentation and installation instructions
67
+ - **BLE.md**: Comprehensive BLE usage documentation and device examples
68
+ - **OpenAPI.md**: OpenAPI usage documentation and authentication setup
69
+ - **CHANGELOG.md**: Version history and release notes
70
+ - **docs/**: Generated TypeDoc API documentation (HTML format)
71
+
72
+ ## Common Development Tasks
73
+
74
+ ### Adding New Device Support
75
+ - **Add device class**: Create new class in src/device.ts extending SwitchbotDevice
76
+ - **Update exports**: Add export to src/index.ts
77
+ - **Add type definitions**: Create types in src/types/ if needed
78
+ - **Test basic instantiation**: Ensure the device class can be imported and instantiated
79
+ - **Always run full build and test cycle**: `npm run build && npm run test && npm run lint`
80
+
81
+ ### API Changes and Extensions
82
+ - **OpenAPI changes**: Modify src/switchbot-openapi.ts
83
+ - **BLE changes**: Modify src/switchbot-ble.ts
84
+ - **Update type definitions**: Modify corresponding files in src/types/
85
+ - **Always verify exports**: Check that new functionality is exported in src/index.ts
86
+ - **Test import functionality**: Verify new exports can be imported correctly
87
+
88
+ ### Working with Dependencies
89
+ - **Noble (BLE)**: @stoprocent/noble for Bluetooth functionality - Linux only
90
+ - **HTTP requests**: Uses undici for HTTP calls (not axios or fetch)
91
+ - **Async operations**: Uses async-mutex for concurrency control
92
+ - **Adding dependencies**: Use `npm install --save` for runtime deps, `--save-dev` for dev deps
93
+
94
+ ## Validation and Quality Assurance
95
+
96
+ ### Pre-commit Checklist
97
+ 1. **Build succeeds**: `npm run build` completes without errors
98
+ 2. **All tests pass**: `npm run test` shows all 12 tests passing
99
+ 3. **Linting passes**: `npm run lint` shows no errors
100
+ 4. **Documentation builds**: `npm run docs` generates without warnings
101
+ 5. **Basic import works**: Can import and instantiate main classes
102
+
103
+ ### Manual Testing Scenarios
104
+ - **SwitchBotBLE instantiation**: `new SwitchBotBLE()` should not throw errors
105
+ - **SwitchBotOpenAPI instantiation**: `new SwitchBotOpenAPI('token', 'secret')` should not throw
106
+ - **Module exports**: All exported classes should be importable from main package
107
+ - **TypeScript compilation**: No TypeScript errors in dist/ output
108
+ - **Documentation completeness**: Check that new public APIs appear in generated docs
109
+
110
+ ### CI/CD Integration
111
+ - **GitHub Actions**: Build runs on push to 'latest' branch and PRs
112
+ - **External workflows**: Uses OpenWonderLabs/.github/.github/workflows/nodejs-build-and-test.yml
113
+ - **Required checks**: Build, test, and lint must all pass
114
+ - **Coverage reporting**: Test coverage is tracked and reported
115
+
116
+ ## Troubleshooting Common Issues
117
+
118
+ ### BLE Not Working
119
+ - **Check OS**: BLE only works on Linux-based systems
120
+ - **Install noble prerequisites**: May need additional system libraries for @stoprocent/noble
121
+ - **Use OpenAPI instead**: For Windows/macOS development, use SwitchBotOpenAPI class
122
+
123
+ ### Build Failures
124
+ - **Check Node.js version**: Must be ^20, ^22, or ^24
125
+ - **Clean and rebuild**: `npm run clean && npm install && npm run build`
126
+ - **TypeScript errors**: Check tsconfig.json settings and type definitions
127
+
128
+ ### Test Failures
129
+ - **Run individual tests**: Use `npm run test:watch` for interactive testing
130
+ - **Check imports**: Ensure all imports use correct ES module syntax
131
+ - **Verify exports**: Check that src/index.ts exports all necessary components
132
+
133
+ ### Linting Errors
134
+ - **Auto-fix**: Use `npm run lint:fix` to automatically fix many issues
135
+ - **ESLint config**: Review eslint.config.js for current rules
136
+ - **Import sorting**: ESLint enforces specific import order - use lint:fix
137
+
138
+ ## Frequently Referenced Information
139
+
140
+ ### Package Scripts (from package.json)
141
+ ```bash
142
+ npm run build # Clean and compile TypeScript
143
+ npm run test # Run test suite with Vitest
144
+ npm run lint # Run ESLint on src/**/*.ts
145
+ npm run lint:fix # Auto-fix ESLint issues
146
+ npm run docs # Generate TypeDoc documentation
147
+ npm run clean # Remove dist/ directory
148
+ npm run watch # Build and link for development
149
+ ```
150
+
151
+ ### Main Exports (from src/index.ts)
152
+ - **SwitchBotBLE**: Bluetooth interface class
153
+ - **SwitchBotOpenAPI**: HTTP API interface class
154
+ - **SwitchbotDevice**: Base device class
155
+ - **Device classes**: WoHand, WoCurtain, WoSmartLock, etc.
156
+ - **Type definitions**: All device status and response types
157
+
158
+ ### Dependencies Summary
159
+ - **@stoprocent/noble**: BLE functionality (Linux only)
160
+ - **undici**: HTTP client for API requests
161
+ - **async-mutex**: Concurrency control
162
+ - **TypeScript**: Language and compilation
163
+ - **Vitest**: Testing framework
164
+ - **ESLint**: Code linting with @antfu/eslint-config
165
+ - **TypeDoc**: API documentation generation
package/CHANGELOG.md CHANGED
@@ -2,6 +2,32 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/)
4
4
 
5
+ ## [3.6.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v3.6.0) (2025-07-27)
6
+
7
+ ### What's Changed
8
+ - Housekeeping and update dependencies
9
+ - **BREAKING**: Fixed compatibility with `@stoprocent/noble` v2.3.4 and `@stoprocent/bluetooth-hci-socket` v2.2.3
10
+ - **Enhancement**: Added comprehensive input validation utilities (`ValidationUtils` class)
11
+ - **Enhancement**: Improved error handling with more descriptive error messages
12
+ - **Enhancement**: Added command constants to replace magic numbers for better maintainability
13
+ - **Enhancement**: Enhanced type safety with proper TypeScript assertions
14
+ - **Enhancement**: Improved buffer validation with configurable minimum length
15
+ - **Enhancement**: Better resource cleanup in error scenarios with try-catch-finally blocks
16
+ - **Enhancement**: Removed deprecated parameter checker in favor of modern validation
17
+ - **Fix**: Updated `noble._state` to `noble.state` for compatibility with newer noble versions
18
+ - **Fix**: Enhanced NobleTypes interface to properly support newer noble version
19
+ - **Code Quality**: Improved JSDoc documentation throughout device classes
20
+ - **Code Quality**: Standardized validation across all device classes
21
+
22
+ **Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v3.5.1...v3.6.0
23
+
24
+ ## [3.5.1](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v3.5.1) (2025-07-25)
25
+
26
+ ### What's Changed
27
+ - Support current Meter Pro CO2 with firmware 1.6 [#293](https://github.com/OpenWonderLabs/node-switchbot/pull/293), Thanks [@wweich](https://github.com/wweich)
28
+
29
+ **Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v3.5.0...v3.5.1
30
+
5
31
  ## [3.5.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v3.5.0) (2025-03-04)
6
32
 
7
33
  # *No New Releases During Lent*
package/dist/device.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import type Noble from '@stoprocent/noble';
2
- import type { Characteristic, Peripheral } from '@stoprocent/noble';
3
- import type { batteryCirculatorFanServiceData, blindTiltServiceData, botServiceData, ceilingLightProServiceData, ceilingLightServiceData, colorBulbServiceData, contactSensorServiceData, curtain3ServiceData, curtainServiceData, hub2ServiceData, humidifier2ServiceData, humidifierServiceData, keypadDetectorServiceData, lockProServiceData, lockServiceData, meterPlusServiceData, meterProCO2ServiceData, meterProServiceData, meterServiceData, motionSensorServiceData, outdoorMeterServiceData, plugMiniJPServiceData, plugMiniUSServiceData, relaySwitch1PMServiceData, relaySwitch1ServiceData, remoteServiceData, robotVacuumCleanerServiceData, stripLightServiceData, waterLeakDetectorServiceData } from './types/bledevicestatus.js';
1
+ import type { Characteristic, Noble, Peripheral } from '@stoprocent/noble';
2
+ import type { airPurifierServiceData, airPurifierTableServiceData, batteryCirculatorFanServiceData, blindTiltServiceData, botServiceData, ceilingLightProServiceData, ceilingLightServiceData, colorBulbServiceData, contactSensorServiceData, curtain3ServiceData, curtainServiceData, hub2ServiceData, hub3ServiceData, humidifier2ServiceData, humidifierServiceData, keypadDetectorServiceData, lockProServiceData, lockServiceData, meterPlusServiceData, meterProCO2ServiceData, meterProServiceData, meterServiceData, motionSensorServiceData, outdoorMeterServiceData, plugMiniJPServiceData, plugMiniUSServiceData, relaySwitch1PMServiceData, relaySwitch1ServiceData, remoteServiceData, robotVacuumCleanerServiceData, stripLightServiceData, waterLeakDetectorServiceData } from './types/ble.js';
4
3
  import { Buffer } from 'node:buffer';
5
4
  import { EventEmitter } from 'node:events';
6
5
  export type MacAddress = string;
@@ -8,7 +7,7 @@ export interface ad {
8
7
  id: string;
9
8
  address: string;
10
9
  rssi: number;
11
- serviceData: botServiceData | colorBulbServiceData | contactSensorServiceData | curtainServiceData | curtain3ServiceData | stripLightServiceData | lockServiceData | lockProServiceData | meterServiceData | meterPlusServiceData | meterProServiceData | meterProCO2ServiceData | motionSensorServiceData | outdoorMeterServiceData | plugMiniUSServiceData | plugMiniJPServiceData | blindTiltServiceData | ceilingLightServiceData | ceilingLightProServiceData | hub2ServiceData | batteryCirculatorFanServiceData | waterLeakDetectorServiceData | humidifierServiceData | humidifier2ServiceData | robotVacuumCleanerServiceData | keypadDetectorServiceData | relaySwitch1PMServiceData | relaySwitch1ServiceData | remoteServiceData;
10
+ serviceData: airPurifierServiceData | airPurifierTableServiceData | botServiceData | colorBulbServiceData | contactSensorServiceData | curtainServiceData | curtain3ServiceData | stripLightServiceData | lockServiceData | lockProServiceData | meterServiceData | meterPlusServiceData | meterProServiceData | meterProCO2ServiceData | motionSensorServiceData | outdoorMeterServiceData | plugMiniUSServiceData | plugMiniJPServiceData | blindTiltServiceData | ceilingLightServiceData | ceilingLightProServiceData | hub2ServiceData | hub3ServiceData | batteryCirculatorFanServiceData | waterLeakDetectorServiceData | humidifierServiceData | humidifier2ServiceData | robotVacuumCleanerServiceData | keypadDetectorServiceData | relaySwitch1PMServiceData | relaySwitch1ServiceData | remoteServiceData;
12
11
  [key: string]: unknown;
13
12
  }
14
13
  export type ondiscover = (device: SwitchbotDevice) => Promise<void> | void;
@@ -29,6 +28,7 @@ export declare interface SwitchBotBLEDevice {
29
28
  MeterPro: DeviceInfo;
30
29
  MeterProCO2: DeviceInfo;
31
30
  Hub2: DeviceInfo;
31
+ Hub3: DeviceInfo;
32
32
  OutdoorMeter: DeviceInfo;
33
33
  MotionSensor: DeviceInfo;
34
34
  ContactSensor: DeviceInfo;
@@ -42,11 +42,14 @@ export declare interface SwitchBotBLEDevice {
42
42
  CeilingLightPro: DeviceInfo;
43
43
  BlindTilt: DeviceInfo;
44
44
  Unknown: DeviceInfo;
45
+ AirPurifier: DeviceInfo;
46
+ AirPurifierTable: DeviceInfo;
45
47
  }
46
48
  export declare enum SwitchBotModel {
47
49
  HubMini = "W0202200",
48
50
  HubPlus = "SwitchBot Hub S1",
49
51
  Hub2 = "W3202100",
52
+ Hub3 = "W3302100",
50
53
  Bot = "SwitchBot S1",
51
54
  Curtain = "W0701600",
52
55
  Curtain3 = "W2400000",
@@ -89,7 +92,9 @@ export declare enum SwitchBotModel {
89
92
  WaterDetector = "W4402000",
90
93
  RelaySwitch1 = "W5502300",
91
94
  RelaySwitch1PM = "W5502310",
92
- Unknown = "Unknown"
95
+ Unknown = "Unknown",
96
+ AirPurifier = "W5302300",
97
+ AirPurifierTable = "W5302310"
93
98
  }
94
99
  export declare enum SwitchBotBLEModel {
95
100
  Bot = "H",
@@ -102,6 +107,7 @@ export declare enum SwitchBotBLEModel {
102
107
  MeterPro = "4",
103
108
  MeterProCO2 = "5",
104
109
  Hub2 = "v",
110
+ Hub3 = "V",
105
111
  OutdoorMeter = "w",
106
112
  MotionSensor = "s",
107
113
  ContactSensor = "d",
@@ -119,11 +125,14 @@ export declare enum SwitchBotBLEModel {
119
125
  RelaySwitch1 = ";",
120
126
  RelaySwitch1PM = "<",
121
127
  Remote = "b",
122
- Unknown = "Unknown"
128
+ Unknown = "Unknown",
129
+ AirPurifier = "+",
130
+ AirPurifierTable = "7"
123
131
  }
124
132
  export declare enum SwitchBotBLEModelName {
125
133
  Bot = "WoHand",
126
134
  Hub2 = "WoHub2",
135
+ Hub3 = "WoHub3",
127
136
  ColorBulb = "WoBulb",
128
137
  Curtain = "WoCurtain",
129
138
  Curtain3 = "WoCurtain3",
@@ -148,11 +157,14 @@ export declare enum SwitchBotBLEModelName {
148
157
  RelaySwitch1 = "WoRelaySwitch1Plus",
149
158
  RelaySwitch1PM = "WoRelaySwitch1PM",
150
159
  Remote = "WoRemote",
160
+ AirPurifier = "WoAirPurifier",
161
+ AirPurifierTable = "WoAirPurifierTable",
151
162
  Unknown = "Unknown"
152
163
  }
153
164
  export declare enum SwitchBotBLEModelFriendlyName {
154
165
  Bot = "Bot",
155
166
  Hub2 = "Hub 2",
167
+ Hub3 = "Hub 3",
156
168
  ColorBulb = "Color Bulb",
157
169
  Curtain = "Curtain",
158
170
  Curtain3 = "Curtain 3",
@@ -179,14 +191,20 @@ export declare enum SwitchBotBLEModelFriendlyName {
179
191
  RelaySwitch1 = "Relay Switch 1",
180
192
  RelaySwitch1PM = "Relay Switch 1PM",
181
193
  Remote = "Remote",
182
- Unknown = "Unknown"
194
+ AirPurifier = "Air Purifier",
195
+ AirPurifierTable = "Air Purifier Table",
196
+ Unknown = "Unknown",
197
+ AirPurifierVOC = "Air Purifier VOC",
198
+ AirPurifierTableVOC = "Air Purifier Table VOC",
199
+ AirPurifierPM2_5 = "Air Purifier PM2.5",
200
+ AirPurifierTablePM2_5 = "Air Purifier Table PM2.5"
183
201
  }
184
202
  export interface Params {
185
203
  duration?: number;
186
204
  model?: string;
187
205
  id?: string;
188
206
  quick?: boolean;
189
- noble?: typeof Noble;
207
+ noble?: Noble;
190
208
  }
191
209
  export interface ErrorObject {
192
210
  code: string;
@@ -198,8 +216,7 @@ export interface Chars {
198
216
  device: Characteristic | null;
199
217
  }
200
218
  export interface NobleTypes {
201
- noble: typeof Noble;
202
- state: 'unknown' | 'resetting' | 'unsupported' | 'unauthorized' | 'poweredOff' | 'poweredOn';
219
+ noble: Noble;
203
220
  peripheral: Peripheral;
204
221
  }
205
222
  export interface ServiceData {
@@ -233,6 +250,108 @@ export declare enum LogLevel {
233
250
  DEBUG = "debug",
234
251
  INFO = "info"
235
252
  }
253
+ /**
254
+ * Utility class for comprehensive input validation with improved error messages.
255
+ */
256
+ export declare class ValidationUtils {
257
+ /**
258
+ * Validates percentage value (0-100).
259
+ * @param value - The value to validate
260
+ * @param paramName - The parameter name for error reporting
261
+ * @throws {RangeError} When value is not within valid range
262
+ * @throws {TypeError} When value is not a number
263
+ */
264
+ static validatePercentage(value: number, paramName?: string): void;
265
+ /**
266
+ * Validates RGB color value (0-255).
267
+ * @param value - The color value to validate
268
+ * @param colorName - The color name for error reporting
269
+ * @throws {RangeError} When value is not within valid range
270
+ * @throws {TypeError} When value is not a number
271
+ */
272
+ static validateRGB(value: number, colorName?: string): void;
273
+ /**
274
+ * Validates buffer and throws descriptive error.
275
+ * @param buffer - The buffer to validate
276
+ * @param expectedLength - Optional expected length
277
+ * @param paramName - The parameter name for error reporting
278
+ * @throws {TypeError} When buffer is not a Buffer
279
+ * @throws {RangeError} When buffer length doesn't match expected
280
+ */
281
+ static validateBuffer(buffer: any, expectedLength?: number, paramName?: string): asserts buffer is Buffer;
282
+ /**
283
+ * Validates string input with comprehensive checks.
284
+ * @param value - The value to validate
285
+ * @param paramName - The parameter name for error reporting
286
+ * @param minLength - Minimum required length
287
+ * @param maxLength - Optional maximum length
288
+ * @throws {TypeError} When value is not a string
289
+ * @throws {RangeError} When string length is invalid
290
+ */
291
+ static validateString(value: any, paramName?: string, minLength?: number, maxLength?: number): asserts value is string;
292
+ /**
293
+ * Validates numeric range with enhanced checks.
294
+ * @param value - The value to validate
295
+ * @param min - Minimum allowed value
296
+ * @param max - Maximum allowed value
297
+ * @param paramName - The parameter name for error reporting
298
+ * @param mustBeInteger - Whether the value must be an integer
299
+ * @throws {TypeError} When value is not a number
300
+ * @throws {RangeError} When value is outside valid range
301
+ */
302
+ static validateRange(value: number, min: number, max: number, paramName?: string, mustBeInteger?: boolean): void;
303
+ /**
304
+ * Validates MAC address format.
305
+ * @param address - The MAC address to validate
306
+ * @param paramName - The parameter name for error reporting
307
+ * @throws {TypeError} When address is not a string
308
+ * @throws {Error} When address format is invalid
309
+ */
310
+ static validateMacAddress(address: any, paramName?: string): asserts address is string;
311
+ /**
312
+ * Validates that a value is one of the allowed enum values.
313
+ * @param value - The value to validate
314
+ * @param allowedValues - Array of allowed values
315
+ * @param paramName - The parameter name for error reporting
316
+ * @throws {Error} When value is not in allowed values
317
+ */
318
+ static validateEnum<T>(value: any, allowedValues: readonly T[], paramName?: string): asserts value is T;
319
+ }
320
+ /**
321
+ * Enhanced error handling utilities.
322
+ */
323
+ export declare class ErrorUtils {
324
+ /**
325
+ * Creates a timeout error with context.
326
+ * @param operation - The operation that timed out
327
+ * @param timeoutMs - The timeout duration in milliseconds
328
+ * @returns A descriptive timeout error
329
+ */
330
+ static createTimeoutError(operation: string, timeoutMs: number): Error;
331
+ /**
332
+ * Creates a connection error with context.
333
+ * @param deviceId - The device ID that failed to connect
334
+ * @param cause - The underlying cause of the connection failure
335
+ * @returns A descriptive connection error
336
+ */
337
+ static createConnectionError(deviceId: string, cause?: Error): Error;
338
+ /**
339
+ * Creates a command error with context.
340
+ * @param command - The command that failed
341
+ * @param deviceId - The device ID
342
+ * @param cause - The underlying cause
343
+ * @returns A descriptive command error
344
+ */
345
+ static createCommandError(command: string, deviceId: string, cause?: Error): Error;
346
+ /**
347
+ * Wraps an async operation with timeout and enhanced error handling.
348
+ * @param operation - The async operation to wrap
349
+ * @param timeoutMs - Timeout in milliseconds
350
+ * @param operationName - Name of the operation for error messages
351
+ * @returns Promise that resolves with the operation result or rejects with timeout
352
+ */
353
+ static withTimeout<T>(operation: Promise<T>, timeoutMs: number, operationName: string): Promise<T>;
354
+ }
236
355
  /**
237
356
  * Represents a Switchbot Device.
238
357
  */
@@ -255,7 +374,7 @@ export declare class SwitchbotDevice extends EventEmitter {
255
374
  * @param peripheral The peripheral object from noble.
256
375
  * @param noble The Noble object.
257
376
  */
258
- constructor(peripheral: NobleTypes['peripheral'], noble: typeof Noble);
377
+ constructor(peripheral: NobleTypes['peripheral'], noble: Noble);
259
378
  /**
260
379
  * Logs a message with the specified log level.
261
380
  * @param level The severity level of the log (e.g., 'info', 'warn', 'error').
@@ -341,13 +460,13 @@ export declare class SwitchbotDevice extends EventEmitter {
341
460
  */
342
461
  private waitForCommandResponse;
343
462
  /**
344
- * Reads data from a characteristic with a timeout.
463
+ * Reads data from a characteristic with enhanced timeout and error handling.
345
464
  * @param char The characteristic to read from.
346
465
  * @returns A Promise that resolves with the data buffer.
347
466
  */
348
467
  private readCharacteristic;
349
468
  /**
350
- * Writes data to a characteristic with a timeout.
469
+ * Writes data to a characteristic with enhanced timeout and error handling.
351
470
  * @param char The characteristic to write to.
352
471
  * @param buf The data buffer.
353
472
  * @returns A Promise that resolves when the write is complete.
@@ -374,6 +493,7 @@ export declare class Advertising {
374
493
  * Validates if the buffer is a valid Buffer object with a minimum length.
375
494
  *
376
495
  * @param {any} buffer - The buffer to validate.
496
+ * @param {number} minLength - The minimum required length.
377
497
  * @returns {boolean} - True if the buffer is valid, false otherwise.
378
498
  */
379
499
  private static validateBuffer;
@@ -722,6 +842,20 @@ export declare class WoHub2 extends SwitchbotDevice {
722
842
  static parseServiceData(manufacturerData: Buffer, emitLog: (level: string, message: string) => void): Promise<hub2ServiceData | null>;
723
843
  constructor(peripheral: NobleTypes['peripheral'], noble: NobleTypes['noble']);
724
844
  }
845
+ /**
846
+ * Class representing a WoHub3 device.
847
+ * @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/meter.md
848
+ */
849
+ export declare class WoHub3 extends SwitchbotDevice {
850
+ /**
851
+ * Parses the service data for WoHub3.
852
+ * @param {Buffer} manufacturerData - The manufacturer data buffer.
853
+ * @param {Function} emitLog - The function to emit log messages.
854
+ * @returns {Promise<hub3ServiceData | null>} - Parsed service data or null if invalid.
855
+ */
856
+ static parseServiceData(manufacturerData: Buffer, emitLog: (level: string, message: string) => void): Promise<hub3ServiceData | null>;
857
+ constructor(peripheral: NobleTypes['peripheral'], noble: NobleTypes['noble']);
858
+ }
725
859
  /**
726
860
  * Class representing a WoHumi device.
727
861
  * @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/tree/latest/devicetypes
@@ -1314,5 +1448,105 @@ export declare class WoStrip extends SwitchbotDevice {
1314
1448
  */
1315
1449
  operateStripLight(bytes: number[]): Promise<boolean>;
1316
1450
  }
1451
+ /**
1452
+ * Class representing a SwitchBot Air Purifier device.
1453
+ * @extends SwitchbotDevice
1454
+ */
1455
+ export declare class WoAirPurifier extends SwitchbotDevice {
1456
+ /**
1457
+ * Parses service data for air purifier devices.
1458
+ * @param {Buffer | null} serviceData - The service data buffer.
1459
+ * @param {Buffer | null} manufacturerData - The manufacturer data buffer.
1460
+ * @param {Function} emitLog - The function to emit log messages.
1461
+ * @returns {airPurifierServiceData | null} - The parsed service data or null.
1462
+ */
1463
+ static parseServiceData(serviceData: Buffer | null, manufacturerData: Buffer | null, emitLog?: (level: string, message: string) => void): airPurifierServiceData | null;
1464
+ /**
1465
+ * Sets the state of the air purifier.
1466
+ * @param {number[]} reqByteArray - The request byte array.
1467
+ * @returns {Promise<boolean>} - Resolves with a boolean indicating whether the operation was successful.
1468
+ * @private
1469
+ */
1470
+ setState(reqByteArray: number[]): Promise<boolean>;
1471
+ /**
1472
+ * Turns the air purifier on.
1473
+ * @returns {Promise<boolean>} - Resolves with true if the air purifier is turned on.
1474
+ */
1475
+ turnOn(): Promise<boolean>;
1476
+ /**
1477
+ * Turns the air purifier off.
1478
+ * @returns {Promise<boolean>} - Resolves with true if the air purifier is turned off.
1479
+ */
1480
+ turnOff(): Promise<boolean>;
1481
+ /**
1482
+ * Sets the speed of the air purifier.
1483
+ * @param {number} speed - The speed value (0-100).
1484
+ * @returns {Promise<boolean>} - Resolves with true if the operation was successful.
1485
+ */
1486
+ setSpeed(speed: number): Promise<boolean>;
1487
+ /**
1488
+ * Sets the mode of the air purifier.
1489
+ * @param {number} mode - The mode value (1-4).
1490
+ * @returns {Promise<boolean>} - Resolves with true if the operation was successful.
1491
+ */
1492
+ setMode(mode: number): Promise<boolean>;
1493
+ /**
1494
+ * Operates the air purifier with the given byte array.
1495
+ * @public
1496
+ * @param {number[]} bytes - The byte array to send.
1497
+ * @returns {Promise<boolean>} - Resolves with true if the operation was successful.
1498
+ */
1499
+ operateAirPurifier(bytes: number[]): Promise<boolean>;
1500
+ }
1501
+ /**
1502
+ * Class representing a SwitchBot Air Purifier Table device.
1503
+ * @extends SwitchbotDevice
1504
+ */
1505
+ export declare class WoAirPurifierTable extends SwitchbotDevice {
1506
+ /**
1507
+ * Parses service data for air purifier table devices.
1508
+ * @param {Buffer | null} serviceData - The service data buffer.
1509
+ * @param {Buffer | null} manufacturerData - The manufacturer data buffer.
1510
+ * @param {Function} emitLog - The function to emit log messages.
1511
+ * @returns {airPurifierTableServiceData | null} - The parsed service data or null.
1512
+ */
1513
+ static parseServiceData(serviceData: Buffer | null, manufacturerData: Buffer | null, emitLog?: (level: string, message: string) => void): airPurifierTableServiceData | null;
1514
+ /**
1515
+ * Sets the state of the air purifier table.
1516
+ * @param {number[]} reqByteArray - The request byte array.
1517
+ * @returns {Promise<boolean>} - Resolves with a boolean indicating whether the operation was successful.
1518
+ * @private
1519
+ */
1520
+ setState(reqByteArray: number[]): Promise<boolean>;
1521
+ /**
1522
+ * Turns the air purifier table on.
1523
+ * @returns {Promise<boolean>} - Resolves with true if the air purifier table is turned on.
1524
+ */
1525
+ turnOn(): Promise<boolean>;
1526
+ /**
1527
+ * Turns the air purifier table off.
1528
+ * @returns {Promise<boolean>} - Resolves with true if the air purifier table is turned off.
1529
+ */
1530
+ turnOff(): Promise<boolean>;
1531
+ /**
1532
+ * Sets the speed of the air purifier table.
1533
+ * @param {number} speed - The speed value (0-100).
1534
+ * @returns {Promise<boolean>} - Resolves with true if the operation was successful.
1535
+ */
1536
+ setSpeed(speed: number): Promise<boolean>;
1537
+ /**
1538
+ * Sets the mode of the air purifier table.
1539
+ * @param {number} mode - The mode value (1-4).
1540
+ * @returns {Promise<boolean>} - Resolves with true if the operation was successful.
1541
+ */
1542
+ setMode(mode: number): Promise<boolean>;
1543
+ /**
1544
+ * Operates the air purifier table with the given byte array.
1545
+ * @public
1546
+ * @param {number[]} bytes - The byte array to send.
1547
+ * @returns {Promise<boolean>} - Resolves with true if the operation was successful.
1548
+ */
1549
+ operateAirPurifierTable(bytes: number[]): Promise<boolean>;
1550
+ }
1317
1551
  export {};
1318
1552
  //# sourceMappingURL=device.d.ts.map