node-switchbot 2.5.0-beta.8 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (406) hide show
  1. package/.github/workflows/beta-release.yml +25 -2
  2. package/.github/workflows/release.yml +13 -0
  3. package/BLE.md +1144 -0
  4. package/CHANGELOG.md +14 -0
  5. package/OpenAPI.md +185 -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 +3 -3
  11. package/dist/advertising.d.ts.map +1 -1
  12. package/dist/advertising.js +26 -26
  13. package/dist/advertising.js.map +1 -1
  14. package/dist/device/woblindtilt.d.ts +19 -50
  15. package/dist/device/woblindtilt.d.ts.map +1 -1
  16. package/dist/device/woblindtilt.js +41 -100
  17. package/dist/device/woblindtilt.js.map +1 -1
  18. package/dist/device/wobulb.d.ts +41 -15
  19. package/dist/device/wobulb.d.ts.map +1 -1
  20. package/dist/device/wobulb.js +72 -128
  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 +96 -171
  25. package/dist/device/woceilinglight.js.map +1 -1
  26. package/dist/device/wocontact.d.ts +11 -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 +39 -1
  31. package/dist/device/wocurtain.d.ts.map +1 -1
  32. package/dist/device/wocurtain.js +69 -103
  33. package/dist/device/wocurtain.js.map +1 -1
  34. package/dist/device/wohand.d.ts +37 -2
  35. package/dist/device/wohand.d.ts.map +1 -1
  36. package/dist/device/wohand.js +55 -89
  37. package/dist/device/wohand.js.map +1 -1
  38. package/dist/device/wohub2.d.ts +11 -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 +37 -2
  43. package/dist/device/wohumi.d.ts.map +1 -1
  44. package/dist/device/wohumi.js +52 -83
  45. package/dist/device/wohumi.js.map +1 -1
  46. package/dist/device/woiosensorth.d.ts +12 -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 +45 -12
  51. package/dist/device/woplugmini.d.ts.map +1 -1
  52. package/dist/device/woplugmini.js +71 -77
  53. package/dist/device/woplugmini.js.map +1 -1
  54. package/dist/device/wopresence.d.ts +11 -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 +34 -50
  61. package/dist/device/wosensorth.js.map +1 -1
  62. package/dist/device/wosmartlock.d.ts +63 -13
  63. package/dist/device/wosmartlock.d.ts.map +1 -1
  64. package/dist/device/wosmartlock.js +114 -195
  65. package/dist/device/wosmartlock.js.map +1 -1
  66. package/dist/device/wosmartlockpro.d.ts +16 -12
  67. package/dist/device/wosmartlockpro.d.ts.map +1 -1
  68. package/dist/device/wosmartlockpro.js +34 -29
  69. package/dist/device/wosmartlockpro.js.map +1 -1
  70. package/dist/device/wostrip.d.ts +4 -3
  71. package/dist/device/wostrip.d.ts.map +1 -1
  72. package/dist/device/wostrip.js +5 -4
  73. package/dist/device/wostrip.js.map +1 -1
  74. package/dist/device.d.ts +13 -5
  75. package/dist/device.d.ts.map +1 -1
  76. package/dist/device.js +13 -2
  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 +10 -13
  83. package/dist/parameter-checker.d.ts.map +1 -1
  84. package/dist/parameter-checker.js +16 -1
  85. package/dist/parameter-checker.js.map +1 -1
  86. package/dist/settings.d.ts +41 -0
  87. package/dist/settings.d.ts.map +1 -1
  88. package/dist/settings.js +43 -0
  89. package/dist/settings.js.map +1 -1
  90. package/dist/{switchbot.d.ts → switchbot-ble.d.ts} +13 -8
  91. package/dist/switchbot-ble.d.ts.map +1 -0
  92. package/dist/switchbot-ble.js +427 -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 +99 -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 +76 -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 +95 -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 +81 -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 +65 -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 +75 -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 +56 -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 +80 -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 +82 -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 +40 -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 +114 -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 +68 -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 +51 -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 +151 -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 +151 -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 +102 -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 +23 -0
  188. package/dist/types/types.d.ts.map +1 -1
  189. package/dist/types/types.js +14 -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 +64 -0
  196. package/docs/classes/SwitchBotOpenAPI.html +47 -0
  197. package/docs/classes/SwitchbotDevice.html +32 -33
  198. package/docs/enums/LogLevel.html +10 -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 +185 -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 +13 -11
  341. package/.github/npm-version-script.cjs +0 -81
  342. package/dist/device/woblindtilt.test.d.ts.map +0 -1
  343. package/dist/device/woblindtilt.test.js +0 -26
  344. package/dist/device/woblindtilt.test.js.map +0 -1
  345. package/dist/device/wobulb.test.js +0 -52
  346. package/dist/device/wobulb.test.js.map +0 -1
  347. package/dist/device/woceilinglight.test.d.ts.map +0 -1
  348. package/dist/device/woceilinglight.test.js +0 -63
  349. package/dist/device/woceilinglight.test.js.map +0 -1
  350. package/dist/device/wocontact.test.d.ts.map +0 -1
  351. package/dist/device/wocontact.test.js +0 -34
  352. package/dist/device/wocontact.test.js.map +0 -1
  353. package/dist/device/wocurtain.test.d.ts.map +0 -1
  354. package/dist/device/wocurtain.test.js +0 -33
  355. package/dist/device/wocurtain.test.js.map +0 -1
  356. package/dist/device/wohand.test.js +0 -62
  357. package/dist/device/wohand.test.js.map +0 -1
  358. package/dist/device/wohand2.test.d.ts +0 -2
  359. package/dist/device/wohand2.test.d.ts.map +0 -1
  360. package/dist/device/wohand2.test.js +0 -50
  361. package/dist/device/wohand2.test.js.map +0 -1
  362. package/dist/device/wohumi.test.js +0 -61
  363. package/dist/device/wohumi.test.js.map +0 -1
  364. package/dist/device/woiosensorth.test.d.ts.map +0 -1
  365. package/dist/device/woiosensorth.test.js +0 -39
  366. package/dist/device/woiosensorth.test.js.map +0 -1
  367. package/dist/device/woplugmini.test.d.ts.map +0 -1
  368. package/dist/device/woplugmini.test.js +0 -91
  369. package/dist/device/woplugmini.test.js.map +0 -1
  370. package/dist/device/wopresence.test.d.ts.map +0 -1
  371. package/dist/device/wopresence.test.js +0 -42
  372. package/dist/device/wopresence.test.js.map +0 -1
  373. package/dist/device/wosensorth.test.d.ts.map +0 -1
  374. package/dist/device/wosensorth.test.js +0 -59
  375. package/dist/device/wosensorth.test.js.map +0 -1
  376. package/dist/device/wosmartlock.test.d.ts.map +0 -1
  377. package/dist/device/wosmartlock.test.js +0 -84
  378. package/dist/device/wosmartlock.test.js.map +0 -1
  379. package/dist/device/wosmartlockpro.test.d.ts.map +0 -1
  380. package/dist/device/wosmartlockpro.test.js +0 -124
  381. package/dist/device/wosmartlockpro.test.js.map +0 -1
  382. package/dist/device/wostrip.test.js +0 -115
  383. package/dist/device/wostrip.test.js.map +0 -1
  384. package/dist/switchbot.d.ts.map +0 -1
  385. package/dist/switchbot.js +0 -259
  386. package/dist/switchbot.js.map +0 -1
  387. package/dist/types/pushbody.d.ts +0 -6
  388. package/dist/types/pushbody.d.ts.map +0 -1
  389. package/dist/types/pushbody.js +0 -2
  390. package/dist/types/pushbody.js.map +0 -1
  391. package/docs/classes/SwitchBot.html +0 -16
  392. package/docs/types/SwitchBotBLEDevice.html +0 -1
  393. /package/dist/{device → test}/woblindtilt.test.d.ts +0 -0
  394. /package/dist/{device → test}/wobulb.test.d.ts +0 -0
  395. /package/dist/{device → test}/woceilinglight.test.d.ts +0 -0
  396. /package/dist/{device → test}/wocontact.test.d.ts +0 -0
  397. /package/dist/{device → test}/wocurtain.test.d.ts +0 -0
  398. /package/dist/{device → test}/wohand.test.d.ts +0 -0
  399. /package/dist/{device → test}/wohumi.test.d.ts +0 -0
  400. /package/dist/{device → test}/woiosensorth.test.d.ts +0 -0
  401. /package/dist/{device → test}/woplugmini.test.d.ts +0 -0
  402. /package/dist/{device → test}/wopresence.test.d.ts +0 -0
  403. /package/dist/{device → test}/wosensorth.test.d.ts +0 -0
  404. /package/dist/{device → test}/wosmartlock.test.d.ts +0 -0
  405. /package/dist/{device → test}/wosmartlockpro.test.d.ts +0 -0
  406. /package/dist/{device → test}/wostrip.test.d.ts +0 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "node-switchbot",
3
3
  "type": "module",
4
- "version": "2.5.0-beta.8",
4
+ "version": "3.0.0",
5
5
  "description": "The node-switchbot is a Node.js module which allows you to control your Switchbot Devices through Bluetooth (BLE).",
6
6
  "author": "OpenWonderLabs (https://github.com/OpenWonderLabs)",
7
7
  "license": "MIT",
@@ -27,8 +27,9 @@
27
27
  "Bluetooth"
28
28
  ],
29
29
  "main": "dist/index.js",
30
+ "types": "dist/index.d.ts",
30
31
  "engines": {
31
- "node": "^18 || ^20 || ^22"
32
+ "node": "^20 || ^22"
32
33
  },
33
34
  "scripts": {
34
35
  "check": "npm install && npm outdated",
@@ -38,22 +39,21 @@
38
39
  "watch": "npm run build && npm link && nodemon",
39
40
  "build": "npm run clean && tsc",
40
41
  "prepublishOnly": "npm run lint && npm run build",
41
- "postpublish": "npm run clean",
42
+ "postpublish": "npm run clean && npm ci",
42
43
  "clean": "shx rm -rf ./dist",
43
- "test-coverage": "jest --coverage --forceExit --detectOpenHandles",
44
- "test": "npm run lint",
44
+ "test": "vitest run",
45
+ "test-coverage": "npm run test -- --coverage",
45
46
  "docs": "typedoc",
46
47
  "lint-docs": "typedoc --emit none --treatWarningsAsErrors"
47
48
  },
48
49
  "readmeFilename": "README.md",
49
50
  "dependencies": {
50
- "@types/sinon": "^17.0.3",
51
+ "@stoprocent/noble": "^1.15.1",
51
52
  "async-mutex": "^0.5.0",
52
- "sinon": "^19.0.2"
53
+ "undici": "^6.19.8"
53
54
  },
54
55
  "optionalDependencies": {
55
- "@stoprocent/bluetooth-hci-socket": "^1.4.0",
56
- "@stoprocent/noble": "^1.15.0"
56
+ "@stoprocent/bluetooth-hci-socket": "^1.4.1"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@antfu/eslint-config": "^3.7.3",
@@ -64,17 +64,19 @@
64
64
  "@types/mdast": "^4.0.4",
65
65
  "@types/node": "^22.7.4",
66
66
  "@types/semver": "^7.5.8",
67
+ "@types/sinon": "^17.0.3",
67
68
  "@types/source-map-support": "^0.5.10",
68
- "@vitest/coverage-v8": "^2.1.1",
69
+ "@vitest/coverage-v8": "^2.1.2",
69
70
  "eslint": "^9.11.1",
70
71
  "eslint-plugin-format": "^0.1.2",
71
72
  "jest": "^29.7.0",
72
73
  "nodemon": "^3.1.7",
73
74
  "npm-check-updates": "^17.1.3",
74
75
  "shx": "^0.3.4",
76
+ "sinon": "^19.0.2",
75
77
  "ts-node": "^10.9.2",
76
78
  "typedoc": "^0.26.7",
77
79
  "typescript": "^5.6.2",
78
- "vitest": "^2.1.1"
80
+ "vitest": "^2.1.2"
79
81
  }
80
82
  }
@@ -1,81 +0,0 @@
1
- #!/bin/env node
2
-
3
- /**
4
- * This scripts queries the npm registry to pull out the latest version for a given tag.
5
- */
6
-
7
- const fs = require("fs");
8
- const semver = require("semver");
9
- const child_process = require("child_process");
10
- const assert = require("assert");
11
-
12
- const BRANCH_VERSION_PATTERN = /^([A-Za-z]*)-(\d+.\d+.\d+)$/
13
-
14
- // Load the contents of the package.json file
15
- const packageJSON = JSON.parse(fs.readFileSync("package.json", "utf8"));
16
-
17
- let refArgument = process.argv[2];
18
- let tagArgument = process.argv[3] || "latest";
19
-
20
- if (refArgument == null) {
21
- console.error("ref argument is missing");
22
- console.error("Usage: npm-version-script.cjs <ref> [tag]");
23
- process.exit(1);
24
- }
25
-
26
- /**
27
- * Queries the NPM registry for the latest version for the provided tag.
28
- * @param tag The tag to query for.
29
- * @returns {string} Returns the version.
30
- */
31
- function getTagVersionFromNpm(tag) {
32
- try {
33
- return child_process.execSync(`npm info ${packageJSON.name} version --tag="${tag}"`).toString("utf8").trim();
34
- } catch (e) {
35
- throw e;
36
- }
37
- }
38
-
39
- function desiredTargetVersion(ref) {
40
- // ref is a GitHub action ref string
41
- if (ref.startsWith("refs/pull/")) {
42
- throw Error("The version script was executed inside a PR!");
43
- }
44
-
45
- assert(ref.startsWith("refs/heads/"))
46
- let branchName = ref.slice("refs/heads/".length);
47
-
48
- let results = branchName.match(BRANCH_VERSION_PATTERN);
49
- if (results != null) {
50
- if (results[1] !== tagArgument) {
51
- console.warn(`The base branch name (${results[1]}) differs from the tag name ${tagArgument}`);
52
- }
53
-
54
- return results[2];
55
- }
56
-
57
- // legacy mode were we use the `betaVersion` property in the package.json
58
- if (branchName === "beta" && packageJSON.betaVersion) {
59
- return packageJSON.betaVersion
60
- }
61
-
62
- throw new Error("Malformed branch name for ref: " + ref + ". Can't derive the base version. Use a branch name like: beta-x.x.x!");
63
- }
64
-
65
- // derive the base version from the branch ref
66
- const baseVersion = desiredTargetVersion(refArgument);
67
-
68
- // query the npm registry for the latest version of the provided tag name
69
- const latestReleasedVersion = getTagVersionFromNpm(tagArgument); // e.g. 0.7.0-beta.12
70
- const latestReleaseBase = semver.inc(latestReleasedVersion, "patch"); // will produce 0.7.0 (removing the preid, needed for the equality check below)
71
-
72
- let publishTag;
73
- if (semver.eq(baseVersion, latestReleaseBase)) { // check if we are releasing another version for the latest beta
74
- publishTag = latestReleasedVersion; // set the current latest beta to be incremented
75
- } else {
76
- publishTag = baseVersion; // start of with a new beta version
77
- }
78
-
79
- // save the package.json
80
- packageJSON.version = publishTag;
81
- fs.writeFileSync("package.json", JSON.stringify(packageJSON, null, 2));
@@ -1 +0,0 @@
1
- {"version":3,"file":"woblindtilt.test.d.ts","sourceRoot":"","sources":["../../src/device/woblindtilt.test.ts"],"names":[],"mappings":""}
@@ -1,26 +0,0 @@
1
- import * as Noble from '@stoprocent/noble';
2
- import { beforeEach, describe, it } from 'vitest';
3
- import { WoBlindTilt } from './woblindtilt.js';
4
- describe('woBlindTilt', () => {
5
- let woBlindTilt;
6
- beforeEach(() => {
7
- const peripheral = {}; // Replace with the actual peripheral object
8
- woBlindTilt = new WoBlindTilt(peripheral, Noble); // Replace 'noble' with the actual Noble object
9
- });
10
- describe('pause', () => {
11
- it('should pause the blind tilt operation', async () => {
12
- // Mock the _operateBlindTilt method
13
- const operateBlindTiltMock = jest.spyOn(woBlindTilt, 'operateBlindTilt')
14
- .mockResolvedValueOnce(undefined);
15
- await woBlindTilt.pause();
16
- expect(operateBlindTiltMock).toHaveBeenCalledWith([0x57, 0x0F, 0x45, 0x01, 0x00, 0xFF]);
17
- });
18
- it('should handle errors correctly', async () => {
19
- // Mock the _operateBlindTilt method to throw an error
20
- jest.spyOn(woBlindTilt, 'operateBlindTilt')
21
- .mockRejectedValueOnce(new Error('Operation failed'));
22
- await expect(woBlindTilt.pause()).rejects.toThrow('Operation failed');
23
- });
24
- });
25
- });
26
- //# sourceMappingURL=woblindtilt.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"woblindtilt.test.js","sourceRoot":"","sources":["../../src/device/woblindtilt.test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,IAAI,WAAwB,CAAA;IAE5B,UAAU,CAAC,GAAG,EAAE;QACd,MAAM,UAAU,GAAG,EAAE,CAAA,CAAC,4CAA4C;QAClE,WAAW,GAAG,IAAI,WAAW,CAAC,UAA8B,EAAE,KAAK,CAAC,CAAA,CAAC,+CAA+C;IACtH,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;QACrB,EAAE,CAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;YACrD,oCAAoC;YACpC,MAAM,oBAAoB,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,kBAAkB,CAAC;iBACrE,qBAAqB,CAAC,SAAS,CAAC,CAAA;YAEnC,MAAM,WAAW,CAAC,KAAK,EAAE,CAAA;YAEzB,MAAM,CAAC,oBAAoB,CAAC,CAAC,oBAAoB,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;QACzF,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,gCAAgC,EAAE,KAAK,IAAI,EAAE;YAC9C,sDAAsD;YACtD,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,kBAAkB,CAAC;iBACxC,qBAAqB,CAAC,IAAI,KAAK,CAAC,kBAAkB,CAAU,CAAC,CAAA;YAEhE,MAAM,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAA;QACvE,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -1,52 +0,0 @@
1
- import { Buffer } from 'node:buffer';
2
- import * as Noble from '@stoprocent/noble';
3
- /* eslint-disable no-console */
4
- import { beforeEach, describe, it } from 'vitest';
5
- import { WoBulb } from './wobulb.js';
6
- describe('woBulb', () => {
7
- let bulb;
8
- beforeEach(() => {
9
- const peripheral = {}; // Replace with the actual peripheral object (e.g. from Noble)
10
- bulb = new WoBulb(peripheral, Noble);
11
- });
12
- it('should parse service data correctly', () => {
13
- const manufacturerData = Buffer.from([0x57, 0x0F, 0x47, 0x01, 0x64, 0x32, 0x19, 0x80, 0x08, 0x7F, 0xFE, 0x00, 0x00]);
14
- const result = WoBulb.parseServiceData(manufacturerData, manufacturerData, console.log);
15
- expect(result).toHaveBeenCalledWith({
16
- model: 'ColorBulb',
17
- power: 0x47,
18
- red: 0x01,
19
- green: 0x64,
20
- blue: 0x32,
21
- color_temperature: 0x19,
22
- state: true,
23
- brightness: 0x80,
24
- delay: 0x80,
25
- preset: 0x08,
26
- color_mode: 0x08,
27
- speed: 0x7F,
28
- loop_index: 0xFE,
29
- });
30
- });
31
- it('should turn on the bulb', async () => {
32
- const result = await bulb.turnOn();
33
- expect(result).toHaveBeenCalledWith(true);
34
- });
35
- it('should turn off the bulb', async () => {
36
- const result = await bulb.turnOff();
37
- expect(result).toHaveBeenCalledWith(false);
38
- });
39
- it('should set brightness correctly', async () => {
40
- const result = await bulb.setBrightness(50);
41
- expect(result).toHaveBeenCalledWith(50);
42
- });
43
- it('should set color temperature correctly', async () => {
44
- const result = await bulb.setColorTemperature(75);
45
- expect(result).toHaveBeenCalledWith(75);
46
- });
47
- it('should set RGB values correctly', async () => {
48
- const result = await bulb.setRGB(50, 255, 100, 50);
49
- expect(result).toHaveBeenCalledWith({ brightness: 50, red: 255, green: 100, blue: 50 });
50
- });
51
- });
52
- //# sourceMappingURL=wobulb.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wobulb.test.js","sourceRoot":"","sources":["../../src/device/wobulb.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAA;AAC1C,+BAA+B;AAC/B,OAAO,EAA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63 +0,0 @@
1
- import { Buffer } from 'node:buffer';
2
- import * as Noble from '@stoprocent/noble';
3
- /* eslint-disable no-console */
4
- import { WoCeilingLight } from './woceilinglight.js';
5
- describe('woCeilingLight', () => {
6
- let ceilingLight;
7
- beforeEach(() => {
8
- const peripheral = {}; // Replace with the actual peripheral object (e.g. from Noble)
9
- ceilingLight = new WoCeilingLight(peripheral, Noble);
10
- });
11
- it('parseServiceData should return null for incorrect buffer length', async () => {
12
- const manufacturerData = Buffer.alloc(10);
13
- const result = await WoCeilingLight.parseServiceData(manufacturerData, console.log);
14
- expect(result).toBeNull();
15
- });
16
- it('parseServiceData should return correct data for valid buffer', async () => {
17
- const manufacturerData = Buffer.from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]);
18
- const result = await WoCeilingLight.parseServiceData(manufacturerData, console.log);
19
- expect(result).toEqual({
20
- model: 'CeilingLight',
21
- modelName: 'CeilingLight',
22
- modelFriendlyName: 'CeilingLight',
23
- color_temperature: 6,
24
- power: 1,
25
- state: false,
26
- red: 3,
27
- green: 4,
28
- blue: 5,
29
- brightness: 7,
30
- delay: 128,
31
- preset: 8,
32
- color_mode: 0,
33
- speed: 9,
34
- loop_index: 10,
35
- });
36
- });
37
- it('turnOn should call setState with correct parameters', async () => {
38
- const setStateSpy = jest.spyOn(ceilingLight, 'setState').mockResolvedValue(undefined);
39
- await ceilingLight.turnOn();
40
- expect(setStateSpy).toHaveBeenCalledWith([0x01, 0x01]);
41
- });
42
- it('turnOff should call setState with correct parameters', async () => {
43
- const setStateSpy = jest.spyOn(ceilingLight, 'setState').mockResolvedValue(undefined);
44
- await ceilingLight.turnOff();
45
- expect(setStateSpy).toHaveBeenCalledWith([0x01, 0x02]);
46
- });
47
- it('setBrightness should call setState with correct parameters', async () => {
48
- const setStateSpy = jest.spyOn(ceilingLight, 'setState').mockResolvedValue(undefined);
49
- await ceilingLight.setBrightness(50);
50
- expect(setStateSpy).toHaveBeenCalledWith([0x02, 0x14]);
51
- });
52
- it('setColorTemperature should call setState with correct parameters', async () => {
53
- const setStateSpy = jest.spyOn(ceilingLight, 'setState').mockResolvedValue(undefined);
54
- await ceilingLight.setColorTemperature(50);
55
- expect(setStateSpy).toHaveBeenCalledWith([0x02, 0x17, 50]);
56
- });
57
- it('setRGB should call setState with correct parameters', async () => {
58
- const setStateSpy = jest.spyOn(ceilingLight, 'setState').mockResolvedValue(undefined);
59
- await ceilingLight.setRGB(50, 100, 150, 200);
60
- expect(setStateSpy).toHaveBeenCalledWith([0x02, 0x12, 50, 100, 150, 200]);
61
- });
62
- });
63
- //# sourceMappingURL=woceilinglight.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"woceilinglight.test.js","sourceRoot":"","sources":["../../src/device/woceilinglight.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAA;AAE1C,+BAA+B;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,IAAI,YAA4B,CAAA;IAEhC,UAAU,CAAC,GAAG,EAAE;QACd,MAAM,UAAU,GAAG,EAAE,CAAA,CAAC,8DAA8D;QACpF,YAAY,GAAG,IAAI,cAAc,CAAC,UAA8B,EAAE,KAAK,CAAC,CAAA;IAC1E,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,iEAAiE,EAAE,KAAK,IAAI,EAAE;QAC/E,MAAM,gBAAgB,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QACzC,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;QACnF,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAA;IAC3B,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,8DAA8D,EAA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AG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;IAC3E,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"wocontact.test.d.ts","sourceRoot":"","sources":["../../src/device/wocontact.test.ts"],"names":[],"mappings":""}
@@ -1,34 +0,0 @@
1
- import { Buffer } from 'node:buffer';
2
- /* eslint-disable no-console */
3
- import { WoContact } from './wocontact.js';
4
- describe('woContact', () => {
5
- it('parseServiceData should return null for incorrect buffer length', async () => {
6
- const serviceData = Buffer.alloc(8); // Incorrect length
7
- const result = await WoContact.parseServiceData(serviceData, console.log);
8
- expect(result).toBeNull();
9
- });
10
- it('parseServiceData should return correct data for valid buffer', async () => {
11
- const serviceData = Buffer.from([0, 0b11000000, 0b01111111, 0b00000111, 0, 0, 0, 0, 0b00001111]);
12
- const result = await WoContact.parseServiceData(serviceData, console.log);
13
- expect(result).toEqual({
14
- model: 'ContactSensor',
15
- modelName: 'ContactSensor',
16
- modelFriendlyName: 'ContactSensor',
17
- movement: true,
18
- tested: 128,
19
- battery: 127,
20
- contact_open: true,
21
- contact_timeout: true,
22
- lightLevel: 'bright',
23
- button_count: 15,
24
- doorState: 'timeout no closed',
25
- });
26
- });
27
- it('parseServiceData should log message for incorrect buffer length', async () => {
28
- const serviceData = Buffer.alloc(8); // Incorrect length
29
- const logSpy = jest.fn();
30
- await WoContact.parseServiceData(serviceData, logSpy);
31
- expect(logSpy).toHaveBeenCalledWith('[parseServiceDataForWoContact] Buffer length 8 !== 9!');
32
- });
33
- });
34
- //# sourceMappingURL=wocontact.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wocontact.test.js","sourceRoot":"","sources":["../../src/device/wocontact.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,+BAA+B;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,QAAQ,CAAC,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,gBAAgB,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;QACrD,MAAM,CAAC,MAAM,CAAC,CAAC,oBAAoB,CAAC,uDAAuD,CAAC,CAAA;IAC9F,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"wocurtain.test.d.ts","sourceRoot":"","sources":["../../src/device/wocurtain.test.ts"],"names":[],"mappings":""}
@@ -1,33 +0,0 @@
1
- import { Buffer } from 'node:buffer';
2
- import * as Noble from '@stoprocent/noble';
3
- import { WoCurtain } from './wocurtain.js';
4
- describe('woCurtain', () => {
5
- let curtain;
6
- beforeEach(() => {
7
- const peripheral = {}; // Replace with the actual peripheral object (e.g. from Noble)
8
- curtain = new WoCurtain(peripheral, Noble);
9
- curtain.command = jest.fn().mockResolvedValue(Buffer.from([0x01, 0x00, 0x00]));
10
- });
11
- it('runToPos should throw error for incorrect percent type', async () => {
12
- await expect(curtain.runToPos('50')).rejects.toThrow('The type of target position percentage is incorrect: string');
13
- });
14
- it('runToPos should throw error for incorrect mode type', async () => {
15
- await expect(curtain.runToPos(50, '0xff')).rejects.toThrow('The type of running mode is incorrect: string');
16
- });
17
- it('runToPos should set percent to 100 if greater than 100', async () => {
18
- await curtain.runToPos(150);
19
- expect(curtain.command).toHaveBeenCalledWith(Buffer.from([0x57, 0x0F, 0x45, 0x01, 0x05, 0xFF, 100]));
20
- });
21
- it('runToPos should set percent to 0 if less than 0', async () => {
22
- await curtain.runToPos(-10);
23
- expect(curtain.command).toHaveBeenCalledWith(Buffer.from([0x57, 0x0F, 0x45, 0x01, 0x05, 0xFF, 0]));
24
- });
25
- it('operateCurtain should throw error for incorrect response', async () => {
26
- curtain.command = jest.fn().mockResolvedValue(Buffer.from([0x02, 0x00, 0x00]));
27
- await expect(curtain.operateCurtain([0x57, 0x0F, 0x45, 0x01, 0x05, 0xFF, 50])).rejects.toThrow('The device returned an error: 0x020000');
28
- });
29
- it('operateCurtain should not throw error for correct response', async () => {
30
- await expect(curtain.operateCurtain([0x57, 0x0F, 0x45, 0x01, 0x05, 0xFF, 50])).resolves.not.toThrow();
31
- });
32
- });
33
- //# sourceMappingURL=wocurtain.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wocurtain.test.js","sourceRoot":"","sources":["../../src/device/wocurtain.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAA;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,IAAI,OAAkB,CAAA;IAEtB,UAAU,CAAC,GAAG,EAAE;QACd,MAAM,UAAU,GAAG,EAAE,CAAA,CAAC,8DAA8D;QACpF,OAAO,GAAG,IAAI,SAAS,CAAC,UAA8B,EAAE,KAAK,CAAC,CAAA;QAC9D,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAA;IAChF,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,wDAAwD,EAAE,KAAK,IAAI,EAAE;QACtE,MAAM,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAW,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,6DAA6D,CAAC,CAAA;IAC5H,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,qDAAqD,EAAE,KAAK,IAAI,EAAE;QACnE,MAAM,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAa,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,+CAA+C,CAAC,CAAA;IACpH,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,wDAAwD,EAAE,KAAK,IAAI,EAAE;QACtE,MAAM,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AC,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,CAAA;IACvG,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -1,62 +0,0 @@
1
- import { Buffer } from 'node:buffer';
2
- import * as Noble from '@stoprocent/noble';
3
- import { SwitchBotBLEModel, SwitchBotBLEModelFriendlyName, SwitchBotBLEModelName } from '../types/types.js';
4
- /* eslint-disable no-console */
5
- // wohand.test.ts
6
- import { WoHand } from './wohand.js';
7
- describe('woHand', () => {
8
- describe('parseServiceData', () => {
9
- it('should return null if serviceData length is not 3', async () => {
10
- const serviceData = Buffer.from([0x01, 0x02]);
11
- const result = await WoHand.parseServiceData(serviceData, console.log);
12
- expect(result).toBeNull();
13
- });
14
- it('should parse service data correctly', async () => {
15
- const serviceData = Buffer.from([0x00, 0b11000000, 0b01111111]);
16
- const result = await WoHand.parseServiceData(serviceData, console.log);
17
- expect(result).toEqual({
18
- model: SwitchBotBLEModel.Bot,
19
- modelName: SwitchBotBLEModelName.Bot,
20
- modelFriendlyName: SwitchBotBLEModelFriendlyName.Bot,
21
- mode: true,
22
- state: false,
23
- battery: 127,
24
- });
25
- });
26
- });
27
- describe('woHand operations', () => {
28
- let wohand;
29
- beforeEach(() => {
30
- const peripheral = {}; // Replace with the actual peripheral object (e.g. from Noble)
31
- wohand = new WoHand(peripheral, Noble);
32
- jest.spyOn(wohand, 'command').mockImplementation(async () => {
33
- return Buffer.from([0x01, 0x00, 0x00]);
34
- });
35
- });
36
- it('should press the button', async () => {
37
- await expect(wohand.press()).resolves.toBeUndefined();
38
- });
39
- it('should turn on the device', async () => {
40
- await expect(wohand.turnOn()).resolves.toBeUndefined();
41
- });
42
- it('should turn off the device', async () => {
43
- await expect(wohand.turnOff()).resolves.toBeUndefined();
44
- });
45
- it('should move the device down', async () => {
46
- await expect(wohand.down()).resolves.toBeUndefined();
47
- });
48
- it('should move the device up', async () => {
49
- await expect(wohand.up()).resolves.toBeUndefined();
50
- });
51
- it('should handle operateBot correctly', async () => {
52
- await expect(wohand.operateBot([0x57, 0x01, 0x00])).resolves.toBeUndefined();
53
- });
54
- it('should throw an error if the device returns an error', async () => {
55
- jest.spyOn(wohand, 'command').mockImplementation(async () => {
56
- return Buffer.from([0x00, 0x00, 0x00]);
57
- });
58
- await expect(wohand.operateBot([0x57, 0x01, 0x00])).rejects.toThrow('The device returned an error: 0x000000');
59
- });
60
- });
61
- });
62
- //# sourceMappingURL=wohand.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wohand.test.js","sourceRoot":"","sources":["../../src/device/wohand.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAA;AAE1C,OAAO,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAC3G,+BAA+B;AAC/B,iBAAiB;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,EAAE,CAAC,mDAAmD,EAAE,KAAK,IAAI,EAAE;YACjE,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;YAC7C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;YACtE,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAA;QAC3B,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;YACnD,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAA;YAC/D,MAAM,MAAM,GAAG,MAAM,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.test.d.ts","sourceRoot":"","sources":["../../src/device/wohand2.test.ts"],"names":[],"mappings":""}
@@ -1,50 +0,0 @@
1
- import { Buffer } from 'node:buffer';
2
- import { WoHub2 } from './wohub2.js';
3
- describe('woHub2', () => {
4
- let onlog;
5
- beforeEach(() => {
6
- onlog = jest.fn();
7
- });
8
- it('should return null if manufacturerData length is not 16', async () => {
9
- const manufacturerData = Buffer.alloc(15); // Invalid length
10
- const result = await WoHub2.parseServiceData(manufacturerData, onlog);
11
- expect(result).toBeNull();
12
- expect(onlog).toHaveBeenCalledWith('[parseServiceDataForWoSensorTH] Buffer length 15 !== 16!');
13
- });
14
- it('should parse valid manufacturerData correctly', async () => {
15
- const manufacturerData = Buffer.from([
16
- 0x01,
17
- 0x82,
18
- 0x7F,
19
- 0x00,
20
- 0x00,
21
- 0x00,
22
- 0x00,
23
- 0x00,
24
- 0x00,
25
- 0x00,
26
- 0x00,
27
- 0x00,
28
- 0x1F,
29
- 0x00,
30
- 0x00,
31
- 0x00,
32
- ]); // Example valid data
33
- const result = await WoHub2.parseServiceData(manufacturerData, onlog);
34
- expect(result).toEqual({
35
- model: 'Hub2',
36
- modelName: 'Hub2',
37
- modelFriendlyName: 'Hub2',
38
- temperature: {
39
- c: 2.1,
40
- f: 35.8,
41
- },
42
- fahrenheit: true,
43
- humidity: 127,
44
- lightLevel: 31,
45
- });
46
- expect(onlog).not.toHaveBeenCalled();
47
- });
48
- // Add more test cases as needed
49
- });
50
- //# sourceMappingURL=wohand2.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wohand2.test.js","sourceRoot":"","sources":["../../src/device/wohand2.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,IAAI,KAAgB,CAAA;IAEpB,UAAU,CAAC,GAAG,EAAE;QACd,KA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CAAgC;AAClC,CAAC,CAAC,CAAA"}
@@ -1,61 +0,0 @@
1
- import { Buffer } from 'node:buffer';
2
- import * as Noble from '@stoprocent/noble';
3
- // wohumi.test.ts
4
- import { WoHumi } from './wohumi.js';
5
- jest.mock('../device.js', () => {
6
- return {
7
- SwitchbotDevice: jest.fn().mockImplementation(() => {
8
- return {
9
- command: jest.fn(),
10
- };
11
- }),
12
- };
13
- });
14
- describe('woHumi', () => {
15
- let wohumi;
16
- beforeEach(() => {
17
- const peripheral = {}; // Replace with the actual peripheral object (e.g. from Noble)
18
- wohumi = new WoHumi(peripheral, Noble);
19
- });
20
- it('press should call operateHumi with correct bytes', async () => {
21
- const operateHumiSpy = jest.spyOn(wohumi, 'operateHumi');
22
- await wohumi.press();
23
- expect(operateHumiSpy).toHaveBeenCalledWith([0x57, 0x01, 0x00]);
24
- });
25
- it('turnOn should call operateHumi with correct bytes', async () => {
26
- const operateHumiSpy = jest.spyOn(wohumi, 'operateHumi');
27
- await wohumi.turnOn();
28
- expect(operateHumiSpy).toHaveBeenCalledWith([0x57, 0x01, 0x01]);
29
- });
30
- it('turnOff should call operateHumi with correct bytes', async () => {
31
- const operateHumiSpy = jest.spyOn(wohumi, 'operateHumi');
32
- await wohumi.turnOff();
33
- expect(operateHumiSpy).toHaveBeenCalledWith([0x57, 0x01, 0x02]);
34
- });
35
- it('down should call operateHumi with correct bytes', async () => {
36
- const operateHumiSpy = jest.spyOn(wohumi, 'operateHumi');
37
- await wohumi.down();
38
- expect(operateHumiSpy).toHaveBeenCalledWith([0x57, 0x01, 0x03]);
39
- });
40
- it('up should call operateHumi with correct bytes', async () => {
41
- const operateHumiSpy = jest.spyOn(wohumi, 'operateHumi');
42
- await wohumi.up();
43
- expect(operateHumiSpy).toHaveBeenCalledWith([0x57, 0x01, 0x04]);
44
- });
45
- it('operateHumi should handle successful response', async () => {
46
- const mockCommand = wohumi.command;
47
- mockCommand.mockResolvedValue(Buffer.from([0x01, 0x00, 0x00]));
48
- await expect(wohumi.operateHumi([0x57, 0x01, 0x00])).resolves.toBeUndefined();
49
- });
50
- it('operateHumi should handle error response', async () => {
51
- const mockCommand = wohumi.command;
52
- mockCommand.mockResolvedValue(Buffer.from([0x02, 0x00, 0x00]));
53
- await expect(wohumi.operateHumi([0x57, 0x01, 0x00])).rejects.toThrow('The device returned an error: 0x020000');
54
- });
55
- it('operateHumi should handle command rejection', async () => {
56
- const mockCommand = wohumi.command;
57
- mockCommand.mockRejectedValue(new Error('Command failed'));
58
- await expect(wohumi.operateHumi([0x57, 0x01, 0x00])).rejects.toThrow('Command failed');
59
- });
60
- });
61
- //# sourceMappingURL=wohumi.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wohumi.test.js","sourceRoot":"","sources":["../../src/device/wohumi.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAA;AAE1C,iBAAiB;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;IAC7B,OAAO;QACL,eAAe,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,GAAG,EAAE;YACjD,OAAO;gBACL,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;aACnB,CAAA;QACH,CAAC,CAAC;KACH,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,IAAI,MAAc,CAAA;IAElB,UAAU,CAAC,GAAG,EAAE;QACd,MAAM,UAAU,GAAG,EAAE,CAAA,CAAC,8DAA8D;QACpF,MAAM,GAAG,IAAI,MAAM,CAAC,UAA8B,EAAE,KAAK,CAAC,CAAA;IAC5D,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,kDAAkD,EAAE,KAAK,IAAI,EAAE;QAChE,MAAM,cAAc,GAAG,I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