node-switchbot 2.5.0-beta.3 → 2.5.0-beta.31

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 (405) hide show
  1. package/.github/workflows/beta-release.yml +25 -2
  2. package/.github/workflows/release.yml +13 -0
  3. package/BLE.md +1109 -0
  4. package/CHANGELOG.md +14 -0
  5. package/OpenAPI.md +172 -0
  6. package/README.md +20 -1189
  7. package/branding/Node_x_SwitchBot.svg +9 -0
  8. package/branding/icon.png +0 -0
  9. package/branding/switchbot.png +0 -0
  10. package/dist/advertising.d.ts +32 -21
  11. package/dist/advertising.d.ts.map +1 -1
  12. package/dist/advertising.js +72 -76
  13. package/dist/advertising.js.map +1 -1
  14. package/dist/device/woblindtilt.d.ts +21 -51
  15. package/dist/device/woblindtilt.d.ts.map +1 -1
  16. package/dist/device/woblindtilt.js +40 -103
  17. package/dist/device/woblindtilt.js.map +1 -1
  18. package/dist/device/wobulb.d.ts +42 -15
  19. package/dist/device/wobulb.d.ts.map +1 -1
  20. package/dist/device/wobulb.js +71 -131
  21. package/dist/device/wobulb.js.map +1 -1
  22. package/dist/device/woceilinglight.d.ts +47 -21
  23. package/dist/device/woceilinglight.d.ts.map +1 -1
  24. package/dist/device/woceilinglight.js +94 -174
  25. package/dist/device/woceilinglight.js.map +1 -1
  26. package/dist/device/wocontact.d.ts +12 -1
  27. package/dist/device/wocontact.d.ts.map +1 -1
  28. package/dist/device/wocontact.js +23 -22
  29. package/dist/device/wocontact.js.map +1 -1
  30. package/dist/device/wocurtain.d.ts +40 -1
  31. package/dist/device/wocurtain.d.ts.map +1 -1
  32. package/dist/device/wocurtain.js +68 -106
  33. package/dist/device/wocurtain.js.map +1 -1
  34. package/dist/device/wohand.d.ts +38 -2
  35. package/dist/device/wohand.d.ts.map +1 -1
  36. package/dist/device/wohand.js +54 -92
  37. package/dist/device/wohand.js.map +1 -1
  38. package/dist/device/wohub2.d.ts +12 -1
  39. package/dist/device/wohub2.d.ts.map +1 -1
  40. package/dist/device/wohub2.js +21 -29
  41. package/dist/device/wohub2.js.map +1 -1
  42. package/dist/device/wohumi.d.ts +38 -2
  43. package/dist/device/wohumi.d.ts.map +1 -1
  44. package/dist/device/wohumi.js +51 -86
  45. package/dist/device/wohumi.js.map +1 -1
  46. package/dist/device/woiosensorth.d.ts +13 -1
  47. package/dist/device/woiosensorth.d.ts.map +1 -1
  48. package/dist/device/woiosensorth.js +25 -29
  49. package/dist/device/woiosensorth.js.map +1 -1
  50. package/dist/device/woplugmini.d.ts +44 -12
  51. package/dist/device/woplugmini.d.ts.map +1 -1
  52. package/dist/device/woplugmini.js +68 -80
  53. package/dist/device/woplugmini.js.map +1 -1
  54. package/dist/device/wopresence.d.ts +12 -1
  55. package/dist/device/wopresence.d.ts.map +1 -1
  56. package/dist/device/wopresence.js +21 -27
  57. package/dist/device/wopresence.js.map +1 -1
  58. package/dist/device/wosensorth.d.ts +18 -2
  59. package/dist/device/wosensorth.d.ts.map +1 -1
  60. package/dist/device/wosensorth.js +33 -50
  61. package/dist/device/wosensorth.js.map +1 -1
  62. package/dist/device/wosmartlock.d.ts +58 -13
  63. package/dist/device/wosmartlock.d.ts.map +1 -1
  64. package/dist/device/wosmartlock.js +108 -195
  65. package/dist/device/wosmartlock.js.map +1 -1
  66. package/dist/device/wosmartlockpro.d.ts +63 -18
  67. package/dist/device/wosmartlockpro.d.ts.map +1 -1
  68. package/dist/device/wosmartlockpro.js +116 -204
  69. package/dist/device/wosmartlockpro.js.map +1 -1
  70. package/dist/device/wostrip.d.ts +38 -18
  71. package/dist/device/wostrip.d.ts.map +1 -1
  72. package/dist/device/wostrip.js +79 -125
  73. package/dist/device/wostrip.js.map +1 -1
  74. package/dist/device.d.ts +85 -222
  75. package/dist/device.d.ts.map +1 -1
  76. package/dist/device.js +123 -407
  77. package/dist/device.js.map +1 -1
  78. package/dist/index.d.ts +9 -1
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/index.js +9 -1
  81. package/dist/index.js.map +1 -1
  82. package/dist/parameter-checker.d.ts +79 -19
  83. package/dist/parameter-checker.d.ts.map +1 -1
  84. package/dist/parameter-checker.js +140 -335
  85. package/dist/parameter-checker.js.map +1 -1
  86. package/dist/settings.d.ts +46 -0
  87. package/dist/settings.d.ts.map +1 -1
  88. package/dist/settings.js +46 -2
  89. package/dist/settings.js.map +1 -1
  90. package/dist/{switchbot.d.ts → switchbot-ble.d.ts} +14 -8
  91. package/dist/switchbot-ble.d.ts.map +1 -0
  92. package/dist/switchbot-ble.js +428 -0
  93. package/dist/switchbot-ble.js.map +1 -0
  94. package/dist/switchbot-openapi.d.ts +131 -0
  95. package/dist/switchbot-openapi.d.ts.map +1 -0
  96. package/dist/switchbot-openapi.js +311 -0
  97. package/dist/switchbot-openapi.js.map +1 -0
  98. package/dist/test/advertising.test.d.ts +2 -0
  99. package/dist/test/advertising.test.d.ts.map +1 -0
  100. package/dist/test/advertising.test.js +96 -0
  101. package/dist/test/advertising.test.js.map +1 -0
  102. package/dist/test/device.test.d.ts +2 -0
  103. package/dist/test/device.test.d.ts.map +1 -0
  104. package/dist/test/device.test.js +38 -0
  105. package/dist/test/device.test.js.map +1 -0
  106. package/dist/test/index.test.d.ts +2 -0
  107. package/dist/test/index.test.d.ts.map +1 -0
  108. package/dist/test/index.test.js +35 -0
  109. package/dist/test/index.test.js.map +1 -0
  110. package/dist/test/parameter-checker.test.d.ts +2 -0
  111. package/dist/test/parameter-checker.test.d.ts.map +1 -0
  112. package/dist/test/parameter-checker.test.js +108 -0
  113. package/dist/test/parameter-checker.test.js.map +1 -0
  114. package/dist/test/settings.test.d.ts +2 -0
  115. package/dist/test/settings.test.d.ts.map +1 -0
  116. package/dist/test/settings.test.js +49 -0
  117. package/dist/test/settings.test.js.map +1 -0
  118. package/dist/test/switchbot-openapi.test.d.ts +2 -0
  119. package/dist/test/switchbot-openapi.test.d.ts.map +1 -0
  120. package/dist/test/switchbot-openapi.test.js +96 -0
  121. package/dist/test/switchbot-openapi.test.js.map +1 -0
  122. package/dist/test/switchbot.test.d.ts +2 -0
  123. package/dist/test/switchbot.test.d.ts.map +1 -0
  124. package/dist/test/switchbot.test.js +106 -0
  125. package/dist/test/switchbot.test.js.map +1 -0
  126. package/dist/test/woblindtilt.test.d.ts.map +1 -0
  127. package/dist/test/woblindtilt.test.js +2 -0
  128. package/dist/test/woblindtilt.test.js.map +1 -0
  129. package/dist/{device → test}/wobulb.test.d.ts.map +1 -1
  130. package/dist/test/wobulb.test.js +2 -0
  131. package/dist/test/wobulb.test.js.map +1 -0
  132. package/dist/test/woceilinglight.test.d.ts.map +1 -0
  133. package/dist/test/woceilinglight.test.js +2 -0
  134. package/dist/test/woceilinglight.test.js.map +1 -0
  135. package/dist/test/wocontact.test.d.ts.map +1 -0
  136. package/dist/test/wocontact.test.js +2 -0
  137. package/dist/test/wocontact.test.js.map +1 -0
  138. package/dist/test/wocurtain.test.d.ts.map +1 -0
  139. package/dist/test/wocurtain.test.js +2 -0
  140. package/dist/test/wocurtain.test.js.map +1 -0
  141. package/dist/{device → test}/wohand.test.d.ts.map +1 -1
  142. package/dist/test/wohand.test.js +2 -0
  143. package/dist/test/wohand.test.js.map +1 -0
  144. package/dist/test/wohub2.test.d.ts +2 -0
  145. package/dist/test/wohub2.test.d.ts.map +1 -0
  146. package/dist/test/wohub2.test.js +2 -0
  147. package/dist/test/wohub2.test.js.map +1 -0
  148. package/dist/{device → test}/wohumi.test.d.ts.map +1 -1
  149. package/dist/test/wohumi.test.js +2 -0
  150. package/dist/test/wohumi.test.js.map +1 -0
  151. package/dist/test/woiosensorth.test.d.ts.map +1 -0
  152. package/dist/test/woiosensorth.test.js +2 -0
  153. package/dist/test/woiosensorth.test.js.map +1 -0
  154. package/dist/test/woplugmini.test.d.ts.map +1 -0
  155. package/dist/test/woplugmini.test.js +2 -0
  156. package/dist/test/woplugmini.test.js.map +1 -0
  157. package/dist/test/wopresence.test.d.ts.map +1 -0
  158. package/dist/test/wopresence.test.js +2 -0
  159. package/dist/test/wopresence.test.js.map +1 -0
  160. package/dist/test/wosensorth.test.d.ts.map +1 -0
  161. package/dist/test/wosensorth.test.js +2 -0
  162. package/dist/test/wosensorth.test.js.map +1 -0
  163. package/dist/test/wosmartlock.test.d.ts.map +1 -0
  164. package/dist/test/wosmartlock.test.js +2 -0
  165. package/dist/test/wosmartlock.test.js.map +1 -0
  166. package/dist/test/wosmartlockpro.test.d.ts.map +1 -0
  167. package/dist/test/wosmartlockpro.test.js +2 -0
  168. package/dist/test/wosmartlockpro.test.js.map +1 -0
  169. package/dist/{device → test}/wostrip.test.d.ts.map +1 -1
  170. package/dist/test/wostrip.test.js +2 -0
  171. package/dist/test/wostrip.test.js.map +1 -0
  172. package/dist/types/bledevicestatus.d.ts +4 -12
  173. package/dist/types/bledevicestatus.d.ts.map +1 -1
  174. package/dist/types/devicelist.d.ts.map +1 -1
  175. package/dist/types/devicelist.js +0 -4
  176. package/dist/types/devicelist.js.map +1 -1
  177. package/dist/types/devicepush.d.ts +13 -0
  178. package/dist/types/devicepush.d.ts.map +1 -0
  179. package/dist/types/devicepush.js +2 -0
  180. package/dist/types/devicepush.js.map +1 -0
  181. package/dist/types/deviceresponse.d.ts +2 -3
  182. package/dist/types/deviceresponse.d.ts.map +1 -1
  183. package/dist/types/devicestatus.d.ts.map +1 -1
  184. package/dist/types/devicewebhookstatus.d.ts +32 -0
  185. package/dist/types/devicewebhookstatus.d.ts.map +1 -1
  186. package/dist/types/irdevicelist.d.ts.map +1 -1
  187. package/dist/types/types.d.ts +61 -120
  188. package/dist/types/types.d.ts.map +1 -1
  189. package/dist/types/types.js +10 -0
  190. package/dist/types/types.js.map +1 -1
  191. package/docs/assets/highlight.css +12 -47
  192. package/docs/assets/main.js +1 -1
  193. package/docs/assets/navigation.js +1 -1
  194. package/docs/assets/search.js +1 -1
  195. package/docs/classes/SwitchBotBLE.html +61 -0
  196. package/docs/classes/SwitchBotOpenAPI.html +47 -0
  197. package/docs/classes/SwitchbotDevice.html +28 -33
  198. package/docs/enums/LogLevel.html +6 -0
  199. package/docs/enums/SwitchBotBLEModel.html +2 -2
  200. package/docs/enums/SwitchBotBLEModelFriendlyName.html +2 -2
  201. package/docs/enums/SwitchBotBLEModelName.html +2 -2
  202. package/docs/enums/SwitchBotModel.html +2 -2
  203. package/docs/hierarchy.html +1 -0
  204. package/docs/index.html +16 -993
  205. package/docs/interfaces/Ad-1.html +5 -0
  206. package/docs/interfaces/AdvertisementData.html +3 -0
  207. package/docs/interfaces/Chars.html +4 -0
  208. package/docs/interfaces/ErrorObject.html +3 -0
  209. package/docs/interfaces/Params.html +6 -0
  210. package/docs/interfaces/ServiceData.html +2 -0
  211. package/docs/interfaces/SwitchBotBLEDevice.html +21 -0
  212. package/docs/interfaces/WebhookDetail.html +6 -0
  213. package/docs/interfaces/ad.html +5 -0
  214. package/docs/interfaces/body.html +3 -0
  215. package/docs/interfaces/bodyChange.html +4 -0
  216. package/docs/interfaces/deleteWebhookResponse.html +4 -0
  217. package/docs/interfaces/device.html +7 -0
  218. package/docs/interfaces/deviceList.html +2 -0
  219. package/docs/interfaces/deviceStatus.html +7 -0
  220. package/docs/interfaces/deviceStatusRequest.html +4 -0
  221. package/docs/interfaces/deviceWebhook.html +4 -0
  222. package/docs/interfaces/deviceWebhookContext.html +4 -0
  223. package/docs/interfaces/devices.html +4 -0
  224. package/docs/interfaces/infraredRemoteList.html +2 -0
  225. package/docs/interfaces/irdevice.html +5 -0
  226. package/docs/interfaces/pushResponse.html +4 -0
  227. package/docs/interfaces/queryWebhookResponse.html +4 -0
  228. package/docs/interfaces/setupWebhookResponse.html +4 -0
  229. package/docs/interfaces/switchbot.html +3 -0
  230. package/docs/interfaces/updateWebhookResponse.html +4 -0
  231. package/docs/interfaces/webhookRequest.html +4 -0
  232. package/docs/media/BLE.md +1109 -0
  233. package/docs/media/OpenAPI.md +172 -0
  234. package/docs/modules.html +136 -3
  235. package/docs/types/MacAddress.html +1 -0
  236. package/docs/types/batteryCirculatorFan.html +1 -0
  237. package/docs/types/batteryCirculatorFanServiceData.html +1 -0
  238. package/docs/types/batteryCirculatorFanStatus.html +1 -0
  239. package/docs/types/batteryCirculatorFanWebhookContext.html +1 -0
  240. package/docs/types/blindTilt.html +1 -0
  241. package/docs/types/blindTiltServiceData.html +1 -0
  242. package/docs/types/blindTiltStatus.html +1 -0
  243. package/docs/types/blindTiltWebhookContext.html +1 -0
  244. package/docs/types/bot.html +1 -0
  245. package/docs/types/botServiceData.html +1 -0
  246. package/docs/types/botStatus.html +1 -0
  247. package/docs/types/botWebhookContext.html +1 -0
  248. package/docs/types/ceilingLight.html +1 -0
  249. package/docs/types/ceilingLightPro.html +1 -0
  250. package/docs/types/ceilingLightProServiceData.html +1 -0
  251. package/docs/types/ceilingLightProStatus.html +1 -0
  252. package/docs/types/ceilingLightProWebhookContext.html +1 -0
  253. package/docs/types/ceilingLightServiceData.html +1 -0
  254. package/docs/types/ceilingLightStatus.html +1 -0
  255. package/docs/types/ceilingLightWebhookContext.html +1 -0
  256. package/docs/types/colorBulb.html +1 -0
  257. package/docs/types/colorBulbServiceData.html +1 -0
  258. package/docs/types/colorBulbStatus.html +1 -0
  259. package/docs/types/colorBulbWebhookContext.html +1 -0
  260. package/docs/types/contactSensor.html +1 -0
  261. package/docs/types/contactSensorServiceData.html +1 -0
  262. package/docs/types/contactSensorStatus.html +1 -0
  263. package/docs/types/contactSensorWebhookContext.html +1 -0
  264. package/docs/types/curtain.html +1 -0
  265. package/docs/types/curtain3.html +1 -0
  266. package/docs/types/curtain3ServiceData.html +1 -0
  267. package/docs/types/curtain3WebhookContext.html +1 -0
  268. package/docs/types/curtainServiceData.html +1 -0
  269. package/docs/types/curtainStatus.html +1 -0
  270. package/docs/types/curtainWebhookContext.html +1 -0
  271. package/docs/types/floorCleaningRobotS10.html +1 -0
  272. package/docs/types/floorCleaningRobotS10Status.html +1 -0
  273. package/docs/types/floorCleaningRobotS10WebhookContext.html +1 -0
  274. package/docs/types/hub2.html +1 -0
  275. package/docs/types/hub2ServiceData.html +1 -0
  276. package/docs/types/hub2Status.html +1 -0
  277. package/docs/types/hub2WebhookContext.html +1 -0
  278. package/docs/types/humidifier.html +1 -0
  279. package/docs/types/humidifierServiceData.html +1 -0
  280. package/docs/types/humidifierStatus.html +1 -0
  281. package/docs/types/humidifierWebhookContext.html +1 -0
  282. package/docs/types/indoorCam.html +1 -0
  283. package/docs/types/indoorCameraWebhookContext.html +1 -0
  284. package/docs/types/keypad.html +1 -0
  285. package/docs/types/keypadTouch.html +1 -0
  286. package/docs/types/keypadTouchWebhookContext.html +1 -0
  287. package/docs/types/keypadWebhookContext.html +1 -0
  288. package/docs/types/lock.html +1 -0
  289. package/docs/types/lockPro.html +1 -0
  290. package/docs/types/lockProServiceData.html +1 -0
  291. package/docs/types/lockProStatus.html +1 -0
  292. package/docs/types/lockProWebhookContext.html +1 -0
  293. package/docs/types/lockServiceData.html +1 -0
  294. package/docs/types/lockStatus.html +1 -0
  295. package/docs/types/lockWebhookContext.html +1 -0
  296. package/docs/types/meter.html +1 -0
  297. package/docs/types/meterPlus.html +1 -0
  298. package/docs/types/meterPlusServiceData.html +1 -0
  299. package/docs/types/meterPlusStatus.html +1 -0
  300. package/docs/types/meterPlusWebhookContext.html +1 -0
  301. package/docs/types/meterServiceData.html +1 -0
  302. package/docs/types/meterStatus.html +1 -0
  303. package/docs/types/meterWebhookContext.html +1 -0
  304. package/docs/types/motionSensor.html +1 -0
  305. package/docs/types/motionSensorServiceData.html +1 -0
  306. package/docs/types/motionSensorStatus.html +1 -0
  307. package/docs/types/motionSensorWebhookContext.html +1 -0
  308. package/docs/types/outdoorMeter.html +1 -0
  309. package/docs/types/outdoorMeterServiceData.html +1 -0
  310. package/docs/types/outdoorMeterStatus.html +1 -0
  311. package/docs/types/outdoorMeterWebhookContext.html +1 -0
  312. package/docs/types/panTiltCamWebhookContext.html +1 -0
  313. package/docs/types/pantiltCam.html +1 -0
  314. package/docs/types/pantiltCam2k.html +1 -0
  315. package/docs/types/plug.html +1 -0
  316. package/docs/types/plugMini.html +1 -0
  317. package/docs/types/plugMiniJPServiceData.html +1 -0
  318. package/docs/types/plugMiniJPWebhookContext.html +1 -0
  319. package/docs/types/plugMiniStatus.html +1 -0
  320. package/docs/types/plugMiniUSServiceData.html +1 -0
  321. package/docs/types/plugMiniUSWebhookContext.html +1 -0
  322. package/docs/types/plugStatus.html +1 -0
  323. package/docs/types/plugWebhookContext.html +1 -0
  324. package/docs/types/remote.html +1 -0
  325. package/docs/types/robotVacuumCleanerS1.html +1 -0
  326. package/docs/types/robotVacuumCleanerS1Plus.html +1 -0
  327. package/docs/types/robotVacuumCleanerS1PlusStatus.html +1 -0
  328. package/docs/types/robotVacuumCleanerS1PlusWebhookContext.html +1 -0
  329. package/docs/types/robotVacuumCleanerS1Status.html +1 -0
  330. package/docs/types/robotVacuumCleanerS1WebhookContext.html +1 -0
  331. package/docs/types/robotVacuumCleanerServiceData.html +1 -0
  332. package/docs/types/stripLight.html +1 -0
  333. package/docs/types/stripLightServiceData.html +1 -0
  334. package/docs/types/stripLightStatus.html +1 -0
  335. package/docs/types/stripLightWebhookContext.html +1 -0
  336. package/docs/types/waterLeakDetector.html +1 -0
  337. package/docs/types/waterLeakDetectorServiceData.html +1 -0
  338. package/docs/types/waterLeakDetectorStatus.html +1 -0
  339. package/docs/types/waterLeakDetectorWebhookContext.html +1 -0
  340. package/package.json +12 -10
  341. package/dist/device/woblindtilt.test.d.ts.map +0 -1
  342. package/dist/device/woblindtilt.test.js +0 -26
  343. package/dist/device/woblindtilt.test.js.map +0 -1
  344. package/dist/device/wobulb.test.js +0 -52
  345. package/dist/device/wobulb.test.js.map +0 -1
  346. package/dist/device/woceilinglight.test.d.ts.map +0 -1
  347. package/dist/device/woceilinglight.test.js +0 -63
  348. package/dist/device/woceilinglight.test.js.map +0 -1
  349. package/dist/device/wocontact.test.d.ts.map +0 -1
  350. package/dist/device/wocontact.test.js +0 -34
  351. package/dist/device/wocontact.test.js.map +0 -1
  352. package/dist/device/wocurtain.test.d.ts.map +0 -1
  353. package/dist/device/wocurtain.test.js +0 -33
  354. package/dist/device/wocurtain.test.js.map +0 -1
  355. package/dist/device/wohand.test.js +0 -62
  356. package/dist/device/wohand.test.js.map +0 -1
  357. package/dist/device/wohand2.test.d.ts +0 -2
  358. package/dist/device/wohand2.test.d.ts.map +0 -1
  359. package/dist/device/wohand2.test.js +0 -50
  360. package/dist/device/wohand2.test.js.map +0 -1
  361. package/dist/device/wohumi.test.js +0 -61
  362. package/dist/device/wohumi.test.js.map +0 -1
  363. package/dist/device/woiosensorth.test.d.ts.map +0 -1
  364. package/dist/device/woiosensorth.test.js +0 -39
  365. package/dist/device/woiosensorth.test.js.map +0 -1
  366. package/dist/device/woplugmini.test.d.ts.map +0 -1
  367. package/dist/device/woplugmini.test.js +0 -91
  368. package/dist/device/woplugmini.test.js.map +0 -1
  369. package/dist/device/wopresence.test.d.ts.map +0 -1
  370. package/dist/device/wopresence.test.js +0 -42
  371. package/dist/device/wopresence.test.js.map +0 -1
  372. package/dist/device/wosensorth.test.d.ts.map +0 -1
  373. package/dist/device/wosensorth.test.js +0 -59
  374. package/dist/device/wosensorth.test.js.map +0 -1
  375. package/dist/device/wosmartlock.test.d.ts.map +0 -1
  376. package/dist/device/wosmartlock.test.js +0 -84
  377. package/dist/device/wosmartlock.test.js.map +0 -1
  378. package/dist/device/wosmartlockpro.test.d.ts.map +0 -1
  379. package/dist/device/wosmartlockpro.test.js +0 -124
  380. package/dist/device/wosmartlockpro.test.js.map +0 -1
  381. package/dist/device/wostrip.test.js +0 -115
  382. package/dist/device/wostrip.test.js.map +0 -1
  383. package/dist/switchbot.d.ts.map +0 -1
  384. package/dist/switchbot.js +0 -259
  385. package/dist/switchbot.js.map +0 -1
  386. package/dist/types/pushbody.d.ts +0 -6
  387. package/dist/types/pushbody.d.ts.map +0 -1
  388. package/dist/types/pushbody.js +0 -2
  389. package/dist/types/pushbody.js.map +0 -1
  390. package/docs/classes/SwitchBot.html +0 -16
  391. package/docs/types/SwitchBotBLEDevice.html +0 -1
  392. /package/dist/{device → test}/woblindtilt.test.d.ts +0 -0
  393. /package/dist/{device → test}/wobulb.test.d.ts +0 -0
  394. /package/dist/{device → test}/woceilinglight.test.d.ts +0 -0
  395. /package/dist/{device → test}/wocontact.test.d.ts +0 -0
  396. /package/dist/{device → test}/wocurtain.test.d.ts +0 -0
  397. /package/dist/{device → test}/wohand.test.d.ts +0 -0
  398. /package/dist/{device → test}/wohumi.test.d.ts +0 -0
  399. /package/dist/{device → test}/woiosensorth.test.d.ts +0 -0
  400. /package/dist/{device → test}/woplugmini.test.d.ts +0 -0
  401. /package/dist/{device → test}/wopresence.test.d.ts +0 -0
  402. /package/dist/{device → test}/wosensorth.test.d.ts +0 -0
  403. /package/dist/{device → test}/wosmartlock.test.d.ts +0 -0
  404. /package/dist/{device → test}/wosmartlockpro.test.d.ts +0 -0
  405. /package/dist/{device → test}/wostrip.test.d.ts +0 -0
@@ -1,11 +1,50 @@
1
+ import type { SwitchBotBLE } from '../switchbot-ble.js';
1
2
  import { Buffer } from 'node:buffer';
2
3
  import { SwitchbotDevice } from '../device.js';
4
+ /**
5
+ * Class representing a WoCurtain device.
6
+ * @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/curtain.md
7
+ * @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/curtain3.md
8
+ */
3
9
  export declare class WoCurtain extends SwitchbotDevice {
4
- static parseServiceData(serviceData: Buffer, manufacturerData: Buffer, onlog: ((message: string) => void) | undefined, reverse?: boolean): Promise<object | null>;
10
+ static switchBotBLE: SwitchBotBLE;
11
+ /**
12
+ * Parses the service data for WoCurtain.
13
+ * @param {Buffer} serviceData - The service data buffer.
14
+ * @param {Buffer} manufacturerData - The manufacturer data buffer.
15
+ * @param {boolean} [reverse] - Whether to reverse the position.
16
+ * @returns {Promise<object | null>} - Parsed service data or null if invalid.
17
+ */
18
+ static parseServiceData(serviceData: Buffer, manufacturerData: Buffer, reverse?: boolean): Promise<object | null>;
19
+ /**
20
+ * Opens the curtain.
21
+ * @param {number} [mode] - Running mode (0x01 = QuietDrift, 0xFF = Default).
22
+ * @returns {Promise<void>}
23
+ */
5
24
  open(mode?: number): Promise<void>;
25
+ /**
26
+ * Closes the curtain.
27
+ * @param {number} [mode] - Running mode (0x01 = QuietDrift, 0xFF = Default).
28
+ * @returns {Promise<void>}
29
+ */
6
30
  close(mode?: number): Promise<void>;
31
+ /**
32
+ * Pauses the curtain.
33
+ * @returns {Promise<void>}
34
+ */
7
35
  pause(): Promise<void>;
36
+ /**
37
+ * Runs the curtain to the target position.
38
+ * @param {number} percent - The percentage of the target position.
39
+ * @param {number} [mode] - Running mode (0x01 = QuietDrift, 0xFF = Default).
40
+ * @returns {Promise<void>}
41
+ */
8
42
  runToPos(percent: number, mode?: number): Promise<void>;
43
+ /**
44
+ * Sends a command to the curtain.
45
+ * @param {number[]} bytes - The command bytes.
46
+ * @returns {Promise<void>}
47
+ */
9
48
  operateCurtain(bytes: number[]): Promise<void>;
10
49
  }
11
50
  //# sourceMappingURL=wocurtain.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wocurtain.d.ts","sourceRoot":"","sources":["../../src/device/wocurtain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAMpC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG9C,qBAAa,SAAU,SAAQ,eAAe;WAC/B,gBAAgB,CAC3B,WAAW,EAAE,MAAM,EACnB,gBAAgB,EAAE,MAAM,EACxB,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,EAClD,OAAO,GAAE,OAAe,GACnB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAiEnB,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM;IAelB,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM;IAenB,KAAK;IAgBL,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,SAAO;IAkBrC,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE;CAerC"}
1
+ {"version":3,"file":"wocurtain.d.ts","sourceRoot":"","sources":["../../src/device/wocurtain.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG9C;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,eAAe;IAC5C,MAAM,CAAC,YAAY,EAAE,YAAY,CAAA;IACjC;;;;;;OAMG;WACU,gBAAgB,CAC3B,WAAW,EAAE,MAAM,EACnB,gBAAgB,EAAE,MAAM,EACxB,OAAO,GAAE,OAAe,GACvB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IA8CzB;;;;OAIG;IACG,IAAI,CAAC,IAAI,GAAE,MAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C;;;;OAIG;IACG,KAAK,CAAC,IAAI,GAAE,MAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B;;;;;OAKG;IACG,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAQnE;;;;OAIG;IACU,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAS5D"}
@@ -1,148 +1,110 @@
1
1
  import { Buffer } from 'node:buffer';
2
- /* Copyright(C) 2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
3
- *
4
- * wocurtain.ts: Switchbot BLE API registration.
5
- */
6
2
  import { SwitchbotDevice } from '../device.js';
7
3
  import { SwitchBotBLEModelFriendlyName, SwitchBotBLEModelName } from '../types/types.js';
4
+ /**
5
+ * Class representing a WoCurtain device.
6
+ * @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/curtain.md
7
+ * @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/curtain3.md
8
+ */
8
9
  export class WoCurtain extends SwitchbotDevice {
9
- static async parseServiceData(serviceData, manufacturerData, onlog, reverse = false) {
10
- if (serviceData.length !== 5 && serviceData.length !== 6) {
11
- if (onlog && typeof onlog === 'function') {
12
- onlog(`[parseServiceDataForWoCurtain] Buffer length ${serviceData.length} !== 5 or 6!`);
13
- }
10
+ static switchBotBLE;
11
+ /**
12
+ * Parses the service data for WoCurtain.
13
+ * @param {Buffer} serviceData - The service data buffer.
14
+ * @param {Buffer} manufacturerData - The manufacturer data buffer.
15
+ * @param {boolean} [reverse] - Whether to reverse the position.
16
+ * @returns {Promise<object | null>} - Parsed service data or null if invalid.
17
+ */
18
+ static async parseServiceData(serviceData, manufacturerData, reverse = false) {
19
+ if (![5, 6].includes(serviceData.length)) {
20
+ this.switchBotBLE.emitLog('error', `[parseServiceDataForWoCurtain] Buffer length ${serviceData.length} !== 5 or 6!`);
14
21
  return null;
15
22
  }
16
23
  const byte1 = serviceData.readUInt8(1);
17
24
  const byte2 = serviceData.readUInt8(2);
18
- // const byte3 = serviceData.readUInt8(3)
19
- // const byte4 = serviceData.readUInt8(4)
20
25
  let deviceData;
21
26
  let batteryData = null;
22
- if (manufacturerData && manufacturerData.length >= 13) { // Curtain 3
27
+ if (manufacturerData.length >= 13) {
23
28
  deviceData = manufacturerData.subarray(8, 11);
24
29
  batteryData = manufacturerData.readUInt8(12);
25
30
  }
26
- else if (manufacturerData && manufacturerData.length >= 11) {
31
+ else if (manufacturerData.length >= 11) {
27
32
  deviceData = manufacturerData.subarray(8, 11);
28
- batteryData = serviceData ? byte2 : null;
29
- }
30
- else if (serviceData) {
31
- deviceData = serviceData.subarray(3, 6);
32
33
  batteryData = byte2;
33
34
  }
34
35
  else {
35
- return {};
36
+ deviceData = serviceData.subarray(3, 6);
37
+ batteryData = byte2;
36
38
  }
37
39
  const model = serviceData.subarray(0, 1).toString('utf8');
38
40
  const modelName = model === 'c' ? SwitchBotBLEModelName.Curtain : SwitchBotBLEModelName.Curtain3;
39
41
  const modelFriendlyName = model === 'c' ? SwitchBotBLEModelFriendlyName.Curtain : SwitchBotBLEModelFriendlyName.Curtain3;
40
- const calibration = serviceData ? Boolean(byte1 & 0b01000000) : null; // Whether the calibration is compconsted /*OLD*/ const calibration = !!(byte1 & 0b01000000)
41
- const position = Math.max(Math.min(deviceData.readUInt8(0) & 0b01111111, 100), 0); // current positon % /*OLD*/ const currPosition = byte3 & 0b01111111 // current positon %
42
- const inMotion = Boolean(deviceData.readUInt8(0) & 0b10000000); //* OLD*/ const inMotion = !!(byte3 & 0b10000000)
43
- const lightLevel = (deviceData.readUInt8(1) >> 4) & 0b00001111; // light sensor level (1-10) /*OLD*/ const lightLevel = (byte4 >> 4) & 0b00001111
44
- const deviceChain = deviceData.readUInt8(1) & 0b00000111; //* OLD*/ const deviceChain = byte4 & 0b00000111
45
- const battery = batteryData !== null ? batteryData & 0b01111111 : null; //* OLD*/ const battery = byte2 & 0b01111111 // %
46
- const data = {
42
+ const calibration = Boolean(byte1 & 0b01000000);
43
+ const position = Math.max(Math.min(deviceData.readUInt8(0) & 0b01111111, 100), 0);
44
+ const inMotion = Boolean(deviceData.readUInt8(0) & 0b10000000);
45
+ const lightLevel = (deviceData.readUInt8(1) >> 4) & 0b00001111;
46
+ const deviceChain = deviceData.readUInt8(1) & 0b00000111;
47
+ const battery = batteryData !== null ? batteryData & 0b01111111 : null;
48
+ return {
47
49
  model,
48
50
  modelName,
49
51
  modelFriendlyName,
50
52
  calibration,
51
53
  battery,
52
54
  inMotion,
53
- position: reverse ? 100 - position : position, //* OLD*/ currPosition,
55
+ position: reverse ? 100 - position : position,
54
56
  lightLevel,
55
57
  deviceChain,
56
58
  };
57
- return data;
58
59
  }
59
- /* ------------------------------------------------------------------
60
- * open()
61
- * - Open the curtain
62
- *
63
- * [Arguments]
64
- * - mode | number | Optional | runing mode (0x01 = QuietDrift, 0xff = Default)
65
- *
66
- * [Return value]
67
- * - Promise object
68
- * Nothing will be passed to the `resolve()`.
69
- * ---------------------------------------------------------------- */
70
- async open(mode) {
71
- return await this.runToPos(0, mode);
60
+ /**
61
+ * Opens the curtain.
62
+ * @param {number} [mode] - Running mode (0x01 = QuietDrift, 0xFF = Default).
63
+ * @returns {Promise<void>}
64
+ */
65
+ async open(mode = 0xFF) {
66
+ await this.runToPos(0, mode);
72
67
  }
73
- /* ------------------------------------------------------------------
74
- * close()
75
- * - close the curtain
76
- *
77
- * [Arguments]
78
- * - mode | number | Optional | runing mode (0x01 = QuietDrift, 0xff = Default)
79
- *
80
- * [Return value]
81
- * - Promise object
82
- * Nothing will be passed to the `resolve()`.
83
- * ---------------------------------------------------------------- */
84
- async close(mode) {
85
- return await this.runToPos(100, mode);
68
+ /**
69
+ * Closes the curtain.
70
+ * @param {number} [mode] - Running mode (0x01 = QuietDrift, 0xFF = Default).
71
+ * @returns {Promise<void>}
72
+ */
73
+ async close(mode = 0xFF) {
74
+ await this.runToPos(100, mode);
86
75
  }
87
- /* ------------------------------------------------------------------
88
- * pause()
89
- * - pause the curtain
90
- *
91
- * [Arguments]
92
- * - none
93
- *
94
- * [Return value]
95
- * - Promise object
96
- * Nothing will be passed to the `resolve()`.
97
- * ---------------------------------------------------------------- */
76
+ /**
77
+ * Pauses the curtain.
78
+ * @returns {Promise<void>}
79
+ */
98
80
  async pause() {
99
- return await this.operateCurtain([0x57, 0x0F, 0x45, 0x01, 0x00, 0xFF]);
81
+ await this.operateCurtain([0x57, 0x0F, 0x45, 0x01, 0x00, 0xFF]);
100
82
  }
101
- /* ------------------------------------------------------------------
102
- * runToPos()
103
- * - run to the target position
104
- *
105
- * [Arguments]
106
- * - percent | number | Required | the percentage of target position
107
- * - mode | number | Optional | runing mode (0x01 = QuietDrift, 0xff = Default)
108
- *
109
- * [Return value]
110
- * - Promise object
111
- * Nothing will be passed to the `resolve()`.
112
- * ---------------------------------------------------------------- */
83
+ /**
84
+ * Runs the curtain to the target position.
85
+ * @param {number} percent - The percentage of the target position.
86
+ * @param {number} [mode] - Running mode (0x01 = QuietDrift, 0xFF = Default).
87
+ * @returns {Promise<void>}
88
+ */
113
89
  async runToPos(percent, mode = 0xFF) {
114
- if (typeof percent !== 'number') {
115
- throw new TypeError(`The type of target position percentage is incorrect: ${typeof percent}`);
90
+ if (typeof percent !== 'number' || typeof mode !== 'number') {
91
+ throw new TypeError('Invalid type for percent or mode');
116
92
  }
117
- if (typeof mode !== 'number') {
118
- throw new TypeError(`The type of running mode is incorrect: ${typeof mode}`);
119
- }
120
- if (mode > 1) {
121
- mode = 0xFF;
122
- }
123
- if (percent > 100) {
124
- percent = 100;
125
- }
126
- else if (percent < 0) {
127
- percent = 0;
128
- }
129
- return await this.operateCurtain([0x57, 0x0F, 0x45, 0x01, 0x05, mode, percent]);
93
+ percent = Math.max(0, Math.min(100, percent));
94
+ await this.operateCurtain([0x57, 0x0F, 0x45, 0x01, 0x05, mode, percent]);
130
95
  }
96
+ /**
97
+ * Sends a command to the curtain.
98
+ * @param {number[]} bytes - The command bytes.
99
+ * @returns {Promise<void>}
100
+ */
131
101
  async operateCurtain(bytes) {
132
- const req_buf = Buffer.from(bytes);
133
- await this.command(req_buf)
134
- .then((res_buf) => {
135
- const code = res_buf.readUInt8(0);
136
- if (res_buf.length === 3 && code === 0x01) {
137
- // Intentionally left empty
138
- }
139
- else {
140
- throw new Error(`The device returned an error: 0x${res_buf.toString('hex')}`);
141
- }
142
- })
143
- .catch((error) => {
144
- throw error;
145
- });
102
+ const reqBuf = Buffer.from(bytes);
103
+ const resBuf = await this.command(reqBuf);
104
+ const code = resBuf.readUInt8(0);
105
+ if (resBuf.length !== 3 || code !== 0x01) {
106
+ throw new Error(`The device returned an error: 0x${resBuf.toString('hex')}`);
107
+ }
146
108
  }
147
109
  }
148
110
  //# sourceMappingURL=wocurtain.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wocurtain.js","sourceRoot":"","sources":["../../src/device/wocurtain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC;;;GAGG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAExF,MAAM,OAAO,SAAU,SAAQ,eAAe;IAC5C,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAC3B,WAAmB,EACnB,gBAAwB,EACxB,KAA8C,EAClD,UAAmB,KAAK;QAEpB,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzD,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;gBACzC,KAAK,CAAC,gDAAgD,WAAW,CAAC,MAAM,cAAc,CAAC,CAAA;YACzF,CAAC;YACD,OAAO,IAAI,CAAA;QACb,CAAC;QAED,MAAM,KAAK,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;QACtC,MAAM,KAAK,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;QACtC,yCAAyC;QACzC,yCAAyC;QAEzC,IAAI,UAAkB,CAAA;QACtB,IAAI,WAAW,GAAkB,IAAI,CAAA;QAErC,IAAI,gBAAgB,IAAI,gBAAgB,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC,CAAC,YAAY;YACnE,UAAU,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;YAC7C,WAAW,GAAG,gBAAgB,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QAC9C,CAAC;aAAM,IAAI,gBAAgB,IAAI,gBAAgB,CAAC,MAAM,IAAI,EAA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IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YACzC,MAAM,IAAI,KAAK,CAAC,mCAAmC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAC9E,CAAC;IACH,CAAC;CACF"}
@@ -1,12 +1,48 @@
1
+ import type { SwitchBotBLE } from '../switchbot-ble.js';
1
2
  import { Buffer } from 'node:buffer';
2
3
  import { SwitchbotDevice } from '../device.js';
4
+ /**
5
+ * Class representing a WoHand device.
6
+ * @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/bot.md
7
+ */
3
8
  export declare class WoHand extends SwitchbotDevice {
4
- static parseServiceData(serviceData: Buffer, onlog: ((message: string) => void) | undefined): Promise<object | null>;
9
+ static switchBotBLE: SwitchBotBLE;
10
+ /**
11
+ * Parses the service data for WoHand.
12
+ * @param {Buffer} serviceData - The service data buffer.
13
+ * @returns {Promise<object | null>} - Parsed service data or null if invalid.
14
+ */
15
+ static parseServiceData(serviceData: Buffer): Promise<object | null>;
16
+ /**
17
+ * Sends a command to the bot.
18
+ * @param {number[]} bytes - The command bytes.
19
+ * @returns {Promise<void>}
20
+ */
21
+ private operateBot;
22
+ /**
23
+ * Presses the bot.
24
+ * @returns {Promise<void>}
25
+ */
5
26
  press(): Promise<void>;
27
+ /**
28
+ * Turns on the bot.
29
+ * @returns {Promise<void>}
30
+ */
6
31
  turnOn(): Promise<void>;
32
+ /**
33
+ * Turns off the bot.
34
+ * @returns {Promise<void>}
35
+ */
7
36
  turnOff(): Promise<void>;
37
+ /**
38
+ * Moves the bot down.
39
+ * @returns {Promise<void>}
40
+ */
8
41
  down(): Promise<void>;
42
+ /**
43
+ * Moves the bot up.
44
+ * @returns {Promise<void>}
45
+ */
9
46
  up(): Promise<void>;
10
- operateBot(bytes: number[]): Promise<void>;
11
47
  }
12
48
  //# sourceMappingURL=wohand.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wohand.d.ts","sourceRoot":"","sources":["../../src/device/wohand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAMpC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG9C,qBAAa,MAAO,SAAQ,eAAe;WAC5B,gBAAgB,CAC3B,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,GAC7C,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAoCnB,KAAK;IAeL,MAAM;IAeN,OAAO;IAeP,IAAI;IAeJ,EAAE;IAIF,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE;CAejC"}
1
+ {"version":3,"file":"wohand.d.ts","sourceRoot":"","sources":["../../src/device/wohand.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG9C;;;GAGG;AACH,qBAAa,MAAO,SAAQ,eAAe;IACzC,MAAM,CAAC,YAAY,EAAE,YAAY,CAAA;IACjC;;;;OAIG;WACU,gBAAgB,CAC3B,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAmBzB;;;;OAIG;YACW,UAAU;IAUxB;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B;;;OAGG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B;;;OAGG;IACG,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;CAG1B"}
@@ -1,118 +1,80 @@
1
1
  import { Buffer } from 'node:buffer';
2
- /* Copyright(C) 2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
3
- *
4
- * wohand.ts: Switchbot BLE API registration.
5
- */
6
2
  import { SwitchbotDevice } from '../device.js';
7
3
  import { SwitchBotBLEModel, SwitchBotBLEModelFriendlyName, SwitchBotBLEModelName } from '../types/types.js';
4
+ /**
5
+ * Class representing a WoHand device.
6
+ * @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/bot.md
7
+ */
8
8
  export class WoHand extends SwitchbotDevice {
9
- static async parseServiceData(serviceData, onlog) {
9
+ static switchBotBLE;
10
+ /**
11
+ * Parses the service data for WoHand.
12
+ * @param {Buffer} serviceData - The service data buffer.
13
+ * @returns {Promise<object | null>} - Parsed service data or null if invalid.
14
+ */
15
+ static async parseServiceData(serviceData) {
10
16
  if (serviceData.length !== 3) {
11
- if (onlog && typeof onlog === 'function') {
12
- onlog(`[parseServiceData] Buffer length ${serviceData.length} !== 3!`);
13
- }
17
+ this.switchBotBLE.emitLog('error', `[parseServiceData] Buffer length ${serviceData.length} !== 3!`);
14
18
  return null;
15
19
  }
16
20
  const byte1 = serviceData.readUInt8(1);
17
21
  const byte2 = serviceData.readUInt8(2);
18
- const mode = !!(byte1 & 0b10000000); // Whether the light switch Add-on is used or not. 0 = press, 1 = switch
19
- const state = !(byte1 & 0b01000000); // Whether the switch status is ON or OFF. 0 = on, 1 = off
20
- const battery = byte2 & 0b01111111; // %
21
- const data = {
22
+ return {
22
23
  model: SwitchBotBLEModel.Bot,
23
24
  modelName: SwitchBotBLEModelName.Bot,
24
25
  modelFriendlyName: SwitchBotBLEModelFriendlyName.Bot,
25
- mode,
26
- state,
27
- battery,
26
+ mode: !!(byte1 & 0b10000000), // Whether the light switch Add-on is used or not. 0 = press, 1 = switch
27
+ state: !(byte1 & 0b01000000), // Whether the switch status is ON or OFF. 0 = on, 1 = off
28
+ battery: byte2 & 0b01111111, // %
28
29
  };
29
- return data;
30
30
  }
31
- /* ------------------------------------------------------------------
32
- * press()
33
- * - Press
34
- *
35
- * [Arguments]
36
- * - none
37
- *
38
- * [Return value]
39
- * - Promise object
40
- * Nothing will be passed to the `resolve()`.
41
- * ---------------------------------------------------------------- */
31
+ /**
32
+ * Sends a command to the bot.
33
+ * @param {number[]} bytes - The command bytes.
34
+ * @returns {Promise<void>}
35
+ */
36
+ async operateBot(bytes) {
37
+ const reqBuf = Buffer.from(bytes);
38
+ const resBuf = await this.command(reqBuf);
39
+ const code = resBuf.readUInt8(0);
40
+ if (resBuf.length !== 3 || (code !== 0x01 && code !== 0x05)) {
41
+ throw new Error(`The device returned an error: 0x${resBuf.toString('hex')}`);
42
+ }
43
+ }
44
+ /**
45
+ * Presses the bot.
46
+ * @returns {Promise<void>}
47
+ */
42
48
  async press() {
43
- return await this.operateBot([0x57, 0x01, 0x00]);
49
+ await this.operateBot([0x57, 0x01, 0x00]);
44
50
  }
45
- /* ------------------------------------------------------------------
46
- * turnOn()
47
- * - Turn on
48
- *
49
- * [Arguments]
50
- * - none
51
- *
52
- * [Return value]
53
- * - Promise object
54
- * Nothing will be passed to the `resolve()`.
55
- * ---------------------------------------------------------------- */
51
+ /**
52
+ * Turns on the bot.
53
+ * @returns {Promise<void>}
54
+ */
56
55
  async turnOn() {
57
- return await this.operateBot([0x57, 0x01, 0x01]);
56
+ await this.operateBot([0x57, 0x01, 0x01]);
58
57
  }
59
- /* ------------------------------------------------------------------
60
- * turnOff()
61
- * - Turn off
62
- *
63
- * [Arguments]
64
- * - none
65
- *
66
- * [Return value]
67
- * - Promise object
68
- * Nothing will be passed to the `resolve()`.
69
- * ---------------------------------------------------------------- */
58
+ /**
59
+ * Turns off the bot.
60
+ * @returns {Promise<void>}
61
+ */
70
62
  async turnOff() {
71
- return await this.operateBot([0x57, 0x01, 0x02]);
63
+ await this.operateBot([0x57, 0x01, 0x02]);
72
64
  }
73
- /* ------------------------------------------------------------------
74
- * down()
75
- * - Down
76
- *
77
- * [Arguments]
78
- * - none
79
- *
80
- * [Return value]
81
- * - Promise object
82
- * Nothing will be passed to the `resolve()`.
83
- * ---------------------------------------------------------------- */
65
+ /**
66
+ * Moves the bot down.
67
+ * @returns {Promise<void>}
68
+ */
84
69
  async down() {
85
- return await this.operateBot([0x57, 0x01, 0x03]);
70
+ await this.operateBot([0x57, 0x01, 0x03]);
86
71
  }
87
- /* ------------------------------------------------------------------
88
- * up()
89
- * - Up
90
- *
91
- * [Arguments]
92
- * - none
93
- *
94
- * [Return value]
95
- * - Promise object
96
- * Nothing will be passed to the `resolve()`.
97
- * ---------------------------------------------------------------- */
72
+ /**
73
+ * Moves the bot up.
74
+ * @returns {Promise<void>}
75
+ */
98
76
  async up() {
99
- return await this.operateBot([0x57, 0x01, 0x04]);
100
- }
101
- async operateBot(bytes) {
102
- const req_buf = Buffer.from(bytes);
103
- await this.command(req_buf)
104
- .then((res_buf) => {
105
- const code = res_buf.readUInt8(0);
106
- if (res_buf.length === 3 && (code === 0x01 || code === 0x05)) {
107
- // Successful operation, no further action needed
108
- }
109
- else {
110
- throw new Error(`The device returned an error: 0x${res_buf.toString('hex')}`);
111
- }
112
- })
113
- .catch((error) => {
114
- throw error;
115
- });
77
+ await this.operateBot([0x57, 0x01, 0x04]);
116
78
  }
117
79
  }
118
80
  //# sourceMappingURL=wohand.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wohand.js","sourceRoot":"","sources":["../../src/device/wohand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC;;;GAGG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAE3G,MAAM,OAAO,MAAO,SAAQ,eAAe;IACzC,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAC3B,WAAmB,EACnB,KAA8C;QAE9C,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7B,IAAI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AC9E,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IAC3C,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM;QACV,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IAC3C,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IAC3C,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IAC3C,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,EAAE;QACN,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IAC3C,CAAC;CACF"}
@@ -1,6 +1,17 @@
1
1
  import type { Buffer } from 'node:buffer';
2
+ import type { SwitchBotBLE } from '../switchbot-ble.js';
2
3
  import { SwitchbotDevice } from '../device.js';
4
+ /**
5
+ * Class representing a WoHub2 device.
6
+ * @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/meter.md
7
+ */
3
8
  export declare class WoHub2 extends SwitchbotDevice {
4
- static parseServiceData(manufacturerData: Buffer, onlog: ((message: string) => void) | undefined): Promise<object | null>;
9
+ static switchBotBLE: SwitchBotBLE;
10
+ /**
11
+ * Parses the service data for WoHub2.
12
+ * @param {Buffer} manufacturerData - The manufacturer data buffer.
13
+ * @returns {Promise<object | null>} - Parsed service data or null if invalid.
14
+ */
15
+ static parseServiceData(manufacturerData: Buffer): Promise<object | null>;
5
16
  }
6
17
  //# sourceMappingURL=wohub2.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wohub2.d.ts","sourceRoot":"","sources":["../../src/device/wohub2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAMzC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG9C,qBAAa,MAAO,SAAQ,eAAe;WAC5B,gBAAgB,CAC3B,gBAAgB,EAAE,MAAM,EACxB,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,GAC7C,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAsC1B"}
1
+ {"version":3,"file":"wohub2.d.ts","sourceRoot":"","sources":["../../src/device/wohub2.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG9C;;;GAGG;AACH,qBAAa,MAAO,SAAQ,eAAe;IACzC,MAAM,CAAC,YAAY,EAAE,YAAY,CAAA;IACjC;;;;OAIG;WACU,gBAAgB,CAC3B,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAwB1B"}
@@ -1,44 +1,36 @@
1
- /* Copyright(C) 2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
2
- *
3
- * wohub2.ts: Switchbot BLE API registration.
4
- */
5
1
  import { SwitchbotDevice } from '../device.js';
6
2
  import { SwitchBotBLEModel, SwitchBotBLEModelFriendlyName, SwitchBotBLEModelName } from '../types/types.js';
3
+ /**
4
+ * Class representing a WoHub2 device.
5
+ * @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/meter.md
6
+ */
7
7
  export class WoHub2 extends SwitchbotDevice {
8
- static async parseServiceData(manufacturerData, onlog) {
8
+ static switchBotBLE;
9
+ /**
10
+ * Parses the service data for WoHub2.
11
+ * @param {Buffer} manufacturerData - The manufacturer data buffer.
12
+ * @returns {Promise<object | null>} - Parsed service data or null if invalid.
13
+ */
14
+ static async parseServiceData(manufacturerData) {
9
15
  if (manufacturerData.length !== 16) {
10
- if (onlog && typeof onlog === 'function') {
11
- onlog(`[parseServiceDataForWoSensorTH] Buffer length ${manufacturerData.length} !== 16!`);
12
- }
16
+ this.switchBotBLE.emitLog('error', `[parseServiceDataForWoHub2] Buffer length ${manufacturerData.length} !== 16!`);
13
17
  return null;
14
18
  }
15
- const byte0 = manufacturerData.readUInt8(0);
16
- const byte1 = manufacturerData.readUInt8(1);
17
- const byte2 = manufacturerData.readUInt8(2);
18
- const byte12 = manufacturerData.readUInt8(12);
19
- const temp_sign = byte1 & 0b10000000 ? 1 : -1;
20
- const temp_c = temp_sign * ((byte1 & 0b01111111) + (byte0 & 0b00001111) / 10);
21
- const temp_f = Math.round(((temp_c * 9 / 5) + 32) * 10) / 10;
22
- const light_level = byte12 & 0b11111;
23
- const data = {
19
+ const [byte0, byte1, byte2, , , , , , , , , , byte12] = manufacturerData;
20
+ const tempSign = byte1 & 0b10000000 ? 1 : -1;
21
+ const tempC = tempSign * ((byte1 & 0b01111111) + (byte0 & 0b00001111) / 10);
22
+ const tempF = Math.round(((tempC * 9) / 5 + 32) * 10) / 10;
23
+ const lightLevel = byte12 & 0b11111;
24
+ return {
24
25
  model: SwitchBotBLEModel.Hub2,
25
26
  modelName: SwitchBotBLEModelName.Hub2,
26
27
  modelFriendlyName: SwitchBotBLEModelFriendlyName.Hub2,
27
- /**
28
- * @deprecated The `temperature` object is deprecated and will be removed in future versions.
29
- * Use the `celsius` and `fahrenheit` properties directly instead.
30
- */
31
- temperature: {
32
- c: temp_c,
33
- f: temp_f,
34
- },
35
- celsius: temp_c,
36
- fahrenheit: temp_f,
28
+ celsius: tempC,
29
+ fahrenheit: tempF,
37
30
  fahrenheit_mode: !!(byte2 & 0b10000000),
38
31
  humidity: byte2 & 0b01111111,
39
- lightLevel: light_level,
32
+ lightLevel,
40
33
  };
41
- return data;
42
34
  }
43
35
  }
44
36
  //# sourceMappingURL=wohub2.js.map