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

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 (397) 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 +31 -20
  11. package/dist/advertising.d.ts.map +1 -1
  12. package/dist/advertising.js +72 -75
  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 +39 -98
  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 +71 -127
  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 -169
  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 +22 -21
  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 +68 -102
  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 +54 -88
  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 +20 -28
  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 +51 -82
  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 +24 -28
  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 +69 -75
  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 +20 -26
  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 +32 -48
  61. package/dist/device/wosensorth.js.map +1 -1
  62. package/dist/device/wosmartlock.d.ts +56 -13
  63. package/dist/device/wosmartlock.d.ts.map +1 -1
  64. package/dist/device/wosmartlock.js +106 -194
  65. package/dist/device/wosmartlock.js.map +1 -1
  66. package/dist/device/wosmartlockpro.d.ts +61 -18
  67. package/dist/device/wosmartlockpro.d.ts.map +1 -1
  68. package/dist/device/wosmartlockpro.js +114 -203
  69. package/dist/device/wosmartlockpro.js.map +1 -1
  70. package/dist/device/wostrip.d.ts +37 -18
  71. package/dist/device/wostrip.d.ts.map +1 -1
  72. package/dist/device/wostrip.js +78 -124
  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} +7 -8
  91. package/dist/switchbot-ble.d.ts.map +1 -0
  92. package/dist/switchbot-ble.js +412 -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 +60 -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 +34 -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 +48 -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 +95 -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 +97 -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 +104 -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 +95 -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 +38 -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 +76 -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 +76 -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/{device/wohand2.test.js → test/wohub2.test.js} +10 -8
  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/{device → test}/wohumi.test.js +5 -2
  150. package/dist/test/wohumi.test.js.map +1 -0
  151. package/dist/test/woiosensorth.test.d.ts.map +1 -0
  152. package/dist/{device → test}/woiosensorth.test.js +11 -9
  153. package/dist/test/woiosensorth.test.js.map +1 -0
  154. package/dist/test/woplugmini.test.d.ts.map +1 -0
  155. package/dist/{device → test}/woplugmini.test.js +10 -5
  156. package/dist/test/woplugmini.test.js.map +1 -0
  157. package/dist/test/wopresence.test.d.ts.map +1 -0
  158. package/dist/{device → test}/wopresence.test.js +5 -1
  159. package/dist/test/wopresence.test.js.map +1 -0
  160. package/dist/test/wosensorth.test.d.ts.map +1 -0
  161. package/dist/{device → test}/wosensorth.test.js +5 -14
  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 +147 -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/{device → test}/wosmartlockpro.test.js +30 -26
  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/{device → test}/wostrip.test.js +18 -19
  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 +8 -6
  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.map +0 -1
  360. package/dist/device/wohumi.test.js.map +0 -1
  361. package/dist/device/woiosensorth.test.d.ts.map +0 -1
  362. package/dist/device/woiosensorth.test.js.map +0 -1
  363. package/dist/device/woplugmini.test.d.ts.map +0 -1
  364. package/dist/device/woplugmini.test.js.map +0 -1
  365. package/dist/device/wopresence.test.d.ts.map +0 -1
  366. package/dist/device/wopresence.test.js.map +0 -1
  367. package/dist/device/wosensorth.test.d.ts.map +0 -1
  368. package/dist/device/wosensorth.test.js.map +0 -1
  369. package/dist/device/wosmartlock.test.d.ts.map +0 -1
  370. package/dist/device/wosmartlock.test.js +0 -84
  371. package/dist/device/wosmartlock.test.js.map +0 -1
  372. package/dist/device/wosmartlockpro.test.d.ts.map +0 -1
  373. package/dist/device/wosmartlockpro.test.js.map +0 -1
  374. package/dist/device/wostrip.test.js.map +0 -1
  375. package/dist/switchbot.d.ts.map +0 -1
  376. package/dist/switchbot.js +0 -259
  377. package/dist/switchbot.js.map +0 -1
  378. package/dist/types/pushbody.d.ts +0 -6
  379. package/dist/types/pushbody.d.ts.map +0 -1
  380. package/dist/types/pushbody.js +0 -2
  381. package/dist/types/pushbody.js.map +0 -1
  382. package/docs/classes/SwitchBot.html +0 -16
  383. package/docs/types/SwitchBotBLEDevice.html +0 -1
  384. /package/dist/{device → test}/woblindtilt.test.d.ts +0 -0
  385. /package/dist/{device → test}/wobulb.test.d.ts +0 -0
  386. /package/dist/{device → test}/woceilinglight.test.d.ts +0 -0
  387. /package/dist/{device → test}/wocontact.test.d.ts +0 -0
  388. /package/dist/{device → test}/wocurtain.test.d.ts +0 -0
  389. /package/dist/{device → test}/wohand.test.d.ts +0 -0
  390. /package/dist/{device → test}/wohumi.test.d.ts +0 -0
  391. /package/dist/{device → test}/woiosensorth.test.d.ts +0 -0
  392. /package/dist/{device → test}/woplugmini.test.d.ts +0 -0
  393. /package/dist/{device → test}/wopresence.test.d.ts +0 -0
  394. /package/dist/{device → test}/wosensorth.test.d.ts +0 -0
  395. /package/dist/{device → test}/wosmartlock.test.d.ts +0 -0
  396. /package/dist/{device → test}/wosmartlockpro.test.d.ts +0 -0
  397. /package/dist/{device → test}/wostrip.test.d.ts +0 -0
@@ -0,0 +1,104 @@
1
+ /* Copyright(C) 2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
2
+ *
3
+ * wobulb.test.ts: Switchbot BLE API registration.
4
+ */
5
+ import { Buffer } from 'node:buffer';
6
+ import { WoBulb } from '../device/wobulb.js';
7
+ describe('woBulb', () => {
8
+ let onlog;
9
+ beforeEach(() => {
10
+ onlog = jest.fn();
11
+ });
12
+ it('should return null if serviceData length is not 18', async () => {
13
+ const serviceData = Buffer.alloc(17); // Invalid length
14
+ const manufacturerData = Buffer.alloc(13);
15
+ const result = await WoBulb.parseServiceData(serviceData, manufacturerData, onlog);
16
+ expect(result).toBeNull();
17
+ expect(onlog).toHaveBeenCalledWith('[parseServiceDataForWoBulb] Buffer length 17 !== 18!');
18
+ });
19
+ it('should return null if manufacturerData length is not 13', async () => {
20
+ const serviceData = Buffer.alloc(18);
21
+ const manufacturerData = Buffer.alloc(12); // Invalid length
22
+ const result = await WoBulb.parseServiceData(serviceData, manufacturerData, onlog);
23
+ expect(result).toBeNull();
24
+ expect(onlog).toHaveBeenCalledWith('[parseServiceDataForWoBulb] Buffer length 12 !== 13!');
25
+ });
26
+ it('should parse valid serviceData and manufacturerData correctly', async () => {
27
+ const serviceData = Buffer.alloc(18);
28
+ const manufacturerData = Buffer.from([0x00, 0x01, 0x00, 0xFF, 0x00, 0x00, 0x64, 0x7F, 0x80, 0x00, 0x00, 0x00, 0x00]);
29
+ const result = await WoBulb.parseServiceData(serviceData, manufacturerData, onlog);
30
+ expect(result).toEqual({
31
+ model: 'ColorBulb',
32
+ modelName: 'ColorBulb',
33
+ modelFriendlyName: 'ColorBulb',
34
+ power: 1,
35
+ red: 255,
36
+ green: 0,
37
+ blue: 0,
38
+ color_temperature: 100,
39
+ state: true,
40
+ brightness: 127,
41
+ delay: true,
42
+ preset: false,
43
+ color_mode: 0,
44
+ speed: 0,
45
+ loop_index: 0,
46
+ });
47
+ expect(onlog).not.toHaveBeenCalled();
48
+ });
49
+ describe('operateBulb', () => {
50
+ let woBulb;
51
+ beforeEach(() => {
52
+ const peripheral = {}; // Replace with the actual peripheral object (e.g. from Noble)
53
+ woBulb = new WoBulb(peripheral, {});
54
+ jest.spyOn(woBulb, 'command').mockResolvedValue(Buffer.from([0x00, 0x80]));
55
+ });
56
+ it('readState should call operateBulb with correct bytes', async () => {
57
+ const operateBulbSpy = jest.spyOn(woBulb, 'operateBulb');
58
+ await woBulb.readState();
59
+ expect(operateBulbSpy).toHaveBeenCalledWith([0x57, 0x0F, 0x48, 0x01]);
60
+ });
61
+ it('setState should call operateBulb with correct bytes', async () => {
62
+ const operateBulbSpy = jest.spyOn(woBulb, 'operateBulb');
63
+ await woBulb.setState([0x01, 0x01]);
64
+ expect(operateBulbSpy).toHaveBeenCalledWith([0x57, 0x0F, 0x47, 0x01, 0x01, 0x01]);
65
+ });
66
+ it('turnOn should call setState with correct arguments', async () => {
67
+ const setStateSpy = jest.spyOn(woBulb, 'setState');
68
+ await woBulb.turnOn();
69
+ expect(setStateSpy).toHaveBeenCalledWith([0x01, 0x01]);
70
+ });
71
+ it('turnOff should call setState with correct arguments', async () => {
72
+ const setStateSpy = jest.spyOn(woBulb, 'setState');
73
+ await woBulb.turnOff();
74
+ expect(setStateSpy).toHaveBeenCalledWith([0x01, 0x02]);
75
+ });
76
+ it('setBrightness should call setState with correct arguments', async () => {
77
+ const setStateSpy = jest.spyOn(woBulb, 'setState');
78
+ await woBulb.setBrightness(50);
79
+ expect(setStateSpy).toHaveBeenCalledWith([0x02, 0x14, 50]);
80
+ });
81
+ it('setColorTemperature should call setState with correct arguments', async () => {
82
+ const setStateSpy = jest.spyOn(woBulb, 'setState');
83
+ await woBulb.setColorTemperature(50);
84
+ expect(setStateSpy).toHaveBeenCalledWith([0x02, 0x17, 50]);
85
+ });
86
+ it('setRGB should call setState with correct arguments', async () => {
87
+ const setStateSpy = jest.spyOn(woBulb, 'setState');
88
+ await woBulb.setRGB(50, 255, 0, 0);
89
+ expect(setStateSpy).toHaveBeenCalledWith([0x02, 0x12, 50, 255, 0, 0]);
90
+ });
91
+ it('operateBulb should handle successful response', async () => {
92
+ await expect(woBulb.operateBulb([0x57, 0x0F, 0x48, 0x01])).resolves.toBe(true);
93
+ });
94
+ it('operateBulb should handle error response', async () => {
95
+ jest.spyOn(woBulb, 'command').mockResolvedValue(Buffer.from([0x00, 0x01]));
96
+ await expect(woBulb.operateBulb([0x57, 0x0F, 0x48, 0x01])).rejects.toThrow('The device returned an error: 0x0001');
97
+ });
98
+ it('operateBulb should handle command rejection', async () => {
99
+ jest.spyOn(woBulb, 'command').mockRejectedValue(new Error('Command failed'));
100
+ await expect(woBulb.operateBulb([0x57, 0x0F, 0x48, 0x01])).rejects.toThrow('Command failed');
101
+ });
102
+ });
103
+ });
104
+ //# sourceMappingURL=wobulb.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wobulb.test.js","sourceRoot":"","sources":["../../src/test/wobulb.test.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAE5C,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,IAAI,KAAgB,CAAA;IAEpB,UAAU,CAAC,GAAG,EAAE;QACd,KAAK,GAAG,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,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAA;YAC1E,MAAM,MAAM,CAAE,MAAc,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,sCAAsC,CAAC,CAAA;QAC7H,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,6CAA6C,EAAE,KAAK,IAAI,EAAE;YAC3D,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,iBAAiB,CAAC,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAA;YAC5E,MAAM,MAAM,CAAE,MAAc,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;QACvG,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"woceilinglight.test.d.ts","sourceRoot":"","sources":["../../src/test/woceilinglight.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,95 @@
1
+ /* Copyright(C) 2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
2
+ *
3
+ * woceiling.test.ts: Switchbot BLE API registration.
4
+ */
5
+ import { Buffer } from 'node:buffer';
6
+ import { WoCeilingLight } from '../device/woceilinglight.js';
7
+ describe('woCeilingLight', () => {
8
+ let onlog;
9
+ beforeEach(() => {
10
+ onlog = jest.fn();
11
+ });
12
+ it('should return null if manufacturerData length is not 13', async () => {
13
+ const manufacturerData = Buffer.alloc(12); // Invalid length
14
+ const result = await WoCeilingLight.parseServiceData(manufacturerData, onlog);
15
+ expect(result).toBeNull();
16
+ expect(onlog).toHaveBeenCalledWith('[parseServiceDataForWoCeilingLight] Buffer length 12 !== 13!');
17
+ });
18
+ it('should parse valid manufacturerData correctly', async () => {
19
+ const manufacturerData = Buffer.from([0x00, 0x01, 0x00, 0xFF, 0x00, 0x00, 0x64, 0x7F, 0x80, 0x00, 0x00, 0x00, 0x00]);
20
+ const result = await WoCeilingLight.parseServiceData(manufacturerData, onlog);
21
+ expect(result).toEqual({
22
+ model: 'CeilingLight',
23
+ modelName: 'CeilingLight',
24
+ modelFriendlyName: 'CeilingLight',
25
+ power: 1,
26
+ red: 255,
27
+ green: 0,
28
+ blue: 0,
29
+ color_temperature: 100,
30
+ state: true,
31
+ brightness: 127,
32
+ delay: true,
33
+ preset: false,
34
+ color_mode: 0,
35
+ speed: 0,
36
+ loop_index: 0,
37
+ });
38
+ expect(onlog).not.toHaveBeenCalled();
39
+ });
40
+ describe('operateCeilingLight', () => {
41
+ let woCeilingLight;
42
+ beforeEach(() => {
43
+ const peripheral = {}; // Replace with the actual peripheral object (e.g. from Noble)
44
+ woCeilingLight = new WoCeilingLight(peripheral, {});
45
+ jest.spyOn(woCeilingLight, 'command').mockResolvedValue(Buffer.from([0x00, 0x80]));
46
+ });
47
+ it('readState should call operateCeilingLight with correct bytes', async () => {
48
+ const operateCeilingLightSpy = jest.spyOn(woCeilingLight, 'operateCeilingLight');
49
+ await woCeilingLight.readState();
50
+ expect(operateCeilingLightSpy).toHaveBeenCalledWith([0x57, 0x0F, 0x48, 0x01]);
51
+ });
52
+ it('setState should call operateCeilingLight with correct bytes', async () => {
53
+ const operateCeilingLightSpy = jest.spyOn(woCeilingLight, 'operateCeilingLight');
54
+ await woCeilingLight.setState([0x01, 0x01]);
55
+ expect(operateCeilingLightSpy).toHaveBeenCalledWith([0x57, 0x0F, 0x47, 0x01, 0x01, 0x01]);
56
+ });
57
+ it('turnOn should call setState with correct arguments', async () => {
58
+ const setStateSpy = jest.spyOn(woCeilingLight, 'setState');
59
+ await woCeilingLight.turnOn();
60
+ expect(setStateSpy).toHaveBeenCalledWith([0x01, 0x01]);
61
+ });
62
+ it('turnOff should call setState with correct arguments', async () => {
63
+ const setStateSpy = jest.spyOn(woCeilingLight, 'setState');
64
+ await woCeilingLight.turnOff();
65
+ expect(setStateSpy).toHaveBeenCalledWith([0x01, 0x02]);
66
+ });
67
+ it('setBrightness should call setState with correct arguments', async () => {
68
+ const setStateSpy = jest.spyOn(woCeilingLight, 'setState');
69
+ await woCeilingLight.setBrightness(50);
70
+ expect(setStateSpy).toHaveBeenCalledWith([0x02, 0x14, 50]);
71
+ });
72
+ it('setColorTemperature should call setState with correct arguments', async () => {
73
+ const setStateSpy = jest.spyOn(woCeilingLight, 'setState');
74
+ await woCeilingLight.setColorTemperature(50);
75
+ expect(setStateSpy).toHaveBeenCalledWith([0x02, 0x17, 50]);
76
+ });
77
+ it('setRGB should call setState with correct arguments', async () => {
78
+ const setStateSpy = jest.spyOn(woCeilingLight, 'setState');
79
+ await woCeilingLight.setRGB(50, 255, 0, 0);
80
+ expect(setStateSpy).toHaveBeenCalledWith([0x02, 0x12, 50, 255, 0, 0]);
81
+ });
82
+ it('operateCeilingLight should handle successful response', async () => {
83
+ await expect(woCeilingLight.operateCeilingLight([0x57, 0x0F, 0x48, 0x01])).resolves.toBe(true);
84
+ });
85
+ it('operateCeilingLight should handle error response', async () => {
86
+ jest.spyOn(woCeilingLight, 'command').mockResolvedValue(Buffer.from([0x00, 0x01]));
87
+ await expect(woCeilingLight.operateCeilingLight([0x57, 0x0F, 0x48, 0x01])).rejects.toThrow('The device returned an error: 0x0001');
88
+ });
89
+ it('operateCeilingLight should handle command rejection', async () => {
90
+ jest.spyOn(woCeilingLight, 'command').mockRejectedValue(new Error('Command failed'));
91
+ await expect(woCeilingLight.operateCeilingLight([0x57, 0x0F, 0x48, 0x01])).rejects.toThrow('Command failed');
92
+ });
93
+ });
94
+ });
95
+ //# sourceMappingURL=woceilinglight.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"woceilinglight.test.js","sourceRoot":"","sources":["../../src/test/woceilin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AK,IAAI,EAAE;YACnE,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC,iBAAiB,CAAC,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAA;YACpF,MAAM,MAAM,CAAE,cAAsB,CAAC,mBAAmB,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;QACvH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wocontact.test.d.ts","sourceRoot":"","sources":["../../src/test/wocontact.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,38 @@
1
+ /* Copyright(C) 2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
2
+ *
3
+ * wocontact.test.ts: Switchbot BLE API registration.
4
+ */
5
+ import { Buffer } from 'node:buffer';
6
+ import { WoContact } from '../device/wocontact.js';
7
+ describe('woContact', () => {
8
+ let onlog;
9
+ beforeEach(() => {
10
+ onlog = jest.fn();
11
+ });
12
+ it('should return null if serviceData length is not 9', async () => {
13
+ const serviceData = Buffer.alloc(8); // Invalid length
14
+ const result = await WoContact.parseServiceData(serviceData, onlog);
15
+ expect(result).toBeNull();
16
+ expect(onlog).toHaveBeenCalledWith('[parseServiceDataForWoContact] Buffer length 8 !== 9!');
17
+ });
18
+ it('should parse valid serviceData correctly', async () => {
19
+ const serviceData = Buffer.from([0x00, 0x80, 0x7F, 0x02, 0x00, 0x00, 0x00, 0x00, 0x0F]); // Example valid data
20
+ const result = await WoContact.parseServiceData(serviceData, onlog);
21
+ expect(result).toEqual({
22
+ model: 'ContactSensor',
23
+ modelName: 'ContactSensor',
24
+ modelFriendlyName: 'ContactSensor',
25
+ movement: true,
26
+ tested: true,
27
+ battery: 127,
28
+ contact_open: true,
29
+ contact_timeout: false,
30
+ lightLevel: 'dark',
31
+ button_count: 15,
32
+ doorState: 'open',
33
+ });
34
+ expect(onlog).not.toHaveBeenCalled();
35
+ });
36
+ // Add more test cases as needed
37
+ });
38
+ //# sourceMappingURL=wocontact.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wocontact.test.js","sourceRoot":"","sources":["../../src/test/wocontact.test.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAElD,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,IAAI,KAAgB,CAAA;IAEpB,UAAU,CAAC,GAAG,EAAE;QACd,KAAK,GAAG,IAAI,CAAC,EAAE,EAAE,CAAA;IACnB,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,mDAAmD,EAAE,KAAK,IAAI,EAAE;QACjE,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA,CAAC,iBAAiB;QACrD,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,gBAAgB,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;QACnE,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAA;QACzB,MAAM,CAAC,KAAK,CAAC,CAAC,oBAAoB,CAAC,uDAAuD,CAAC,CAAA;IAC7F,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,0CAA0C,EAAE,KAAK,IAAI,EAAE;QACxD,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA,CAAC,qBAAqB;QAC7G,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,gBAAgB,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;QACnE,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,KAAK,EAAE,eAAe;YACtB,SAAS,EAAE,eAAe;YAC1B,iBAAiB,EAAE,eAAe;YAClC,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,IAAI;YACZ,OAAO,EAAE,GAAG;YACZ,YAAY,EAAE,IAAI;YAClB,eAAe,EAAE,KAAK;YACtB,UAAU,EAAE,MAAM;YAClB,YAAY,EAAE,EAAE;YAChB,SAAS,EAAE,MAAM;SAClB,CAAC,CAAA;QACF,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAA;IACtC,CAAC,CAAC,CAAA;IAEF,gCAAgC;AAClC,CAAC,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wocurtain.test.d.ts","sourceRoot":"","sources":["../../src/test/wocurtain.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,76 @@
1
+ /* Copyright(C) 2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
2
+ *
3
+ * wocurtain.test.ts: Switchbot BLE API registration.
4
+ */
5
+ import { Buffer } from 'node:buffer';
6
+ import { WoCurtain } from '../device/wocurtain.js';
7
+ describe('woCurtain', () => {
8
+ let onlog;
9
+ beforeEach(() => {
10
+ onlog = jest.fn();
11
+ });
12
+ it('should return null if serviceData length is not 5 or 6', async () => {
13
+ const serviceData = Buffer.alloc(4); // Invalid length
14
+ const manufacturerData = Buffer.alloc(13);
15
+ const result = await WoCurtain.parseServiceData(serviceData, manufacturerData, onlog);
16
+ expect(result).toBeNull();
17
+ expect(onlog).toHaveBeenCalledWith('[parseServiceDataForWoCurtain] Buffer length 4 !== 5 or 6!');
18
+ });
19
+ it('should parse valid serviceData and manufacturerData correctly', async () => {
20
+ const serviceData = Buffer.from([0x63, 0x40, 0x7F, 0x00, 0x00, 0x00]); // Example valid data
21
+ const manufacturerData = Buffer.from([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x7F]);
22
+ const result = await WoCurtain.parseServiceData(serviceData, manufacturerData, onlog);
23
+ expect(result).toEqual({
24
+ model: 'c',
25
+ modelName: 'Curtain',
26
+ modelFriendlyName: 'Curtain',
27
+ calibration: true,
28
+ battery: 127,
29
+ inMotion: false,
30
+ position: 0,
31
+ lightLevel: 0,
32
+ deviceChain: 0,
33
+ });
34
+ expect(onlog).not.toHaveBeenCalled();
35
+ });
36
+ describe('operateCurtain', () => {
37
+ let wocurtain;
38
+ beforeEach(() => {
39
+ const peripheral = {}; // Replace with the actual peripheral object (e.g. from Noble)
40
+ wocurtain = new WoCurtain(peripheral, {});
41
+ jest.spyOn(wocurtain, 'command').mockResolvedValue(Buffer.from([0x01, 0x00, 0x00]));
42
+ });
43
+ it('open should call runToPos with correct arguments', async () => {
44
+ const runToPosSpy = jest.spyOn(wocurtain, 'runToPos');
45
+ await wocurtain.open();
46
+ expect(runToPosSpy).toHaveBeenCalledWith(0, 0xFF);
47
+ });
48
+ it('close should call runToPos with correct arguments', async () => {
49
+ const runToPosSpy = jest.spyOn(wocurtain, 'runToPos');
50
+ await wocurtain.close();
51
+ expect(runToPosSpy).toHaveBeenCalledWith(100, 0xFF);
52
+ });
53
+ it('pause should call operateCurtain with correct bytes', async () => {
54
+ const operateCurtainSpy = jest.spyOn(wocurtain, 'operateCurtain');
55
+ await wocurtain.pause();
56
+ expect(operateCurtainSpy).toHaveBeenCalledWith([0x57, 0x0F, 0x45, 0x01, 0x00, 0xFF]);
57
+ });
58
+ it('runToPos should call operateCurtain with correct bytes', async () => {
59
+ const operateCurtainSpy = jest.spyOn(wocurtain, 'operateCurtain');
60
+ await wocurtain.runToPos(50);
61
+ expect(operateCurtainSpy).toHaveBeenCalledWith([0x57, 0x0F, 0x45, 0x01, 0x05, 0xFF, 50]);
62
+ });
63
+ it('operateCurtain should handle successful response', async () => {
64
+ await expect(wocurtain.operateCurtain([0x57, 0x0F, 0x45, 0x01, 0x05, 0xFF, 50])).resolves.toBeUndefined();
65
+ });
66
+ it('operateCurtain should handle error response', async () => {
67
+ jest.spyOn(wocurtain, 'command').mockResolvedValue(Buffer.from([0x02, 0x00, 0x00]));
68
+ await expect(wocurtain.operateCurtain([0x57, 0x0F, 0x45, 0x01, 0x05, 0xFF, 50])).rejects.toThrow('The device returned an error: 0x020000');
69
+ });
70
+ it('operateCurtain should handle command rejection', async () => {
71
+ jest.spyOn(wocurtain, 'command').mockRejectedValue(new Error('Command failed'));
72
+ await expect(wocurtain.operateCurtain([0x57, 0x0F, 0x45, 0x01, 0x05, 0xFF, 50])).rejects.toThrow('Command failed');
73
+ });
74
+ });
75
+ });
76
+ //# sourceMappingURL=wocurtain.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wocurtain.test.js","sourceRoot":"","sources":["../../src/test/wocurtain.test.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAElD,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,IAAI,KAAgB,CAAA;IAEpB,UAAU,CAAC,GAAG,EAAE;QACd,KAAK,GAAG,IAAI,CAAC,EAAE,EAAE,CAAA;IACnB,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,wDAAwD,EAAE,KAAK,IAAI,EAAE;QACtE,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA,CAAC,iBAAiB;QACrD,MAAM,gBAAgB,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QACzC,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,gBAAgB,CAAC,WAAW,EAAE,gBAAgB,EAAE,KAAK,CAAC,CAAA;QACrF,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAA;QACzB,MAAM,CAAC,KAAK,CAAC,CAAC,oBAAoB,CAAC,4DAA4D,C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C,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"wohand.test.d.ts","sourceRoot":"","sources":["../../src/device/wohand.test.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"wohand.test.d.ts","sourceRoot":"","sources":["../../src/test/wohand.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,76 @@
1
+ /* Copyright(C) 2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
2
+ *
3
+ * wohand.test.ts: Switchbot BLE API registration.
4
+ */
5
+ import { Buffer } from 'node:buffer';
6
+ import { WoHand } from '../device/wohand.js';
7
+ describe('woHand', () => {
8
+ let onlog;
9
+ beforeEach(() => {
10
+ onlog = jest.fn();
11
+ });
12
+ it('should return null if serviceData length is not 3', async () => {
13
+ const serviceData = Buffer.alloc(2); // Invalid length
14
+ const result = await WoHand.parseServiceData(serviceData, onlog);
15
+ expect(result).toBeNull();
16
+ expect(onlog).toHaveBeenCalledWith('[parseServiceData] Buffer length 2 !== 3!');
17
+ });
18
+ it('should parse valid serviceData correctly', async () => {
19
+ const serviceData = Buffer.from([0x00, 0x80, 0x7F]); // Example valid data
20
+ const result = await WoHand.parseServiceData(serviceData, onlog);
21
+ expect(result).toEqual({
22
+ model: 'Bot',
23
+ modelName: 'Bot',
24
+ modelFriendlyName: 'Bot',
25
+ mode: true,
26
+ state: false,
27
+ battery: 127,
28
+ });
29
+ expect(onlog).not.toHaveBeenCalled();
30
+ });
31
+ describe('operateBot', () => {
32
+ let wohand;
33
+ beforeEach(() => {
34
+ const peripheral = {}; // Replace with the actual peripheral object (e.g. from Noble)
35
+ wohand = new WoHand(peripheral, {});
36
+ jest.spyOn(wohand, 'command').mockResolvedValue(Buffer.from([0x01, 0x00, 0x00]));
37
+ });
38
+ it('press should call operateBot with correct bytes', async () => {
39
+ const operateBotSpy = jest.spyOn(wohand, 'operateBot');
40
+ await wohand.press();
41
+ expect(operateBotSpy).toHaveBeenCalledWith([0x57, 0x01, 0x00]);
42
+ });
43
+ it('turnOn should call operateBot with correct bytes', async () => {
44
+ const operateBotSpy = jest.spyOn(wohand, 'operateBot');
45
+ await wohand.turnOn();
46
+ expect(operateBotSpy).toHaveBeenCalledWith([0x57, 0x01, 0x01]);
47
+ });
48
+ it('turnOff should call operateBot with correct bytes', async () => {
49
+ const operateBotSpy = jest.spyOn(wohand, 'operateBot');
50
+ await wohand.turnOff();
51
+ expect(operateBotSpy).toHaveBeenCalledWith([0x57, 0x01, 0x02]);
52
+ });
53
+ it('down should call operateBot with correct bytes', async () => {
54
+ const operateBotSpy = jest.spyOn(wohand, 'operateBot');
55
+ await wohand.down();
56
+ expect(operateBotSpy).toHaveBeenCalledWith([0x57, 0x01, 0x03]);
57
+ });
58
+ it('up should call operateBot with correct bytes', async () => {
59
+ const operateBotSpy = jest.spyOn(wohand, 'operateBot');
60
+ await wohand.up();
61
+ expect(operateBotSpy).toHaveBeenCalledWith([0x57, 0x01, 0x04]);
62
+ });
63
+ it('operateBot should handle successful response', async () => {
64
+ await expect(wohand.operateBot([0x57, 0x01, 0x00])).resolves.toBeUndefined();
65
+ });
66
+ it('operateBot should handle error response', async () => {
67
+ jest.spyOn(wohand, 'command').mockResolvedValue(Buffer.from([0x02, 0x00, 0x00]));
68
+ await expect(wohand.operateBot([0x57, 0x01, 0x00])).rejects.toThrow('The device returned an error: 0x020000');
69
+ });
70
+ it('operateBot should handle command rejection', async () => {
71
+ jest.spyOn(wohand, 'command').mockRejectedValue(new Error('Command failed'));
72
+ await expect(wohand.operateBot([0x57, 0x01, 0x00])).rejects.toThrow('Command failed');
73
+ });
74
+ });
75
+ });
76
+ //# sourceMappingURL=wohand.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wohand.test.js","sourceRoot":"","sources":["../../src/test/wohand.test.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,EA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D,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,iBAAiB,CAAC,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAA;YAC5E,MAAM,MAAM,CAAE,MAAc,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;QAChG,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=wohub2.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wohub2.test.d.ts","sourceRoot":"","sources":["../../src/test/wohub2.test.ts"],"names":[],"mappings":""}
@@ -1,5 +1,9 @@
1
+ /* Copyright(C) 2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
2
+ *
3
+ * wohub2.test.ts: Switchbot BLE API registration.
4
+ */
1
5
  import { Buffer } from 'node:buffer';
2
- import { WoHub2 } from './wohub2.js';
6
+ import { WoHub2 } from '../device/wohub2.js';
3
7
  describe('woHub2', () => {
4
8
  let onlog;
5
9
  beforeEach(() => {
@@ -9,7 +13,7 @@ describe('woHub2', () => {
9
13
  const manufacturerData = Buffer.alloc(15); // Invalid length
10
14
  const result = await WoHub2.parseServiceData(manufacturerData, onlog);
11
15
  expect(result).toBeNull();
12
- expect(onlog).toHaveBeenCalledWith('[parseServiceDataForWoSensorTH] Buffer length 15 !== 16!');
16
+ expect(onlog).toHaveBeenCalledWith('[parseServiceDataForWoHub2] Buffer length 15 !== 16!');
13
17
  });
14
18
  it('should parse valid manufacturerData correctly', async () => {
15
19
  const manufacturerData = Buffer.from([
@@ -35,11 +39,9 @@ describe('woHub2', () => {
35
39
  model: 'Hub2',
36
40
  modelName: 'Hub2',
37
41
  modelFriendlyName: 'Hub2',
38
- temperature: {
39
- c: 2.1,
40
- f: 35.8,
41
- },
42
- fahrenheit: true,
42
+ celsius: 2.1,
43
+ fahrenheit: 35.8,
44
+ fahrenheit_mode: true,
43
45
  humidity: 127,
44
46
  lightLevel: 31,
45
47
  });
@@ -47,4 +49,4 @@ describe('woHub2', () => {
47
49
  });
48
50
  // Add more test cases as needed
49
51
  });
50
- //# sourceMappingURL=wohand2.test.js.map
52
+ //# sourceMappingURL=wohub2.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wohub2.test.js","sourceRoot":"","sources":["../../src/test/wohub2.test.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAE5C,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,IAAI,KAAgB,CAAA;IAEpB,UAAU,CAAC,GAAG,EAAE;QACd,KAAK,GAAG,IAAI,CAAC,EAAE,EAAE,CAAA;IACnB,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,yDAAyD,EAAE,KAAK,IAAI,EAAE;QACvE,MAAM,gBAAgB,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA,CAAC,iBAAiB;QAC3D,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA;QACrE,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAA;QACzB,MAAM,CAAC,KAAK,CAAC,CAAC,oBAAoB,CAAC,sDAAsD,CAAC,CAAA;IAC5F,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,+CAA+C,EAAE,KAAK,IAAI,EAAE;QAC7D,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC;YACnC,IAAI;YACJ,IAAI;YACJ,IAAI;YACJ,IAAI;YACJ,IAAI;YACJ,IAAI;YACJ,IAAI;YACJ,IAAI;YACJ,IAAI;YACJ,IAAI;YACJ,IAAI;YACJ,IAAI;YACJ,IAAI;YACJ,IAAI;YACJ,IAAI;YACJ,IAAI;SACL,CAAC,CAAA,CAAC,qBAAqB;QACxB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA;QACrE,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,KAAK,EAAE,MAAM;YACb,SAAS,EAAE,MAAM;YACjB,iBAAiB,EAAE,MAAM;YACzB,OAAO,EAAE,GAAG;YACZ,UAAU,EAAE,IAAI;YAChB,eAAe,EAAE,IAAI;YACrB,QAAQ,EAAE,GAAG;YACb,UAAU,EAAE,EAAE;SACf,CAAC,CAAA;QACF,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAA;IACtC,CAAC,CAAC,CAAA;IAEF,gCAAgC;AAClC,CAAC,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"wohumi.test.d.ts","sourceRoot":"","sources":["../../src/device/wohumi.test.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"wohumi.test.d.ts","sourceRoot":"","sources":["../../src/test/wohumi.test.ts"],"names":[],"mappings":""}
@@ -1,7 +1,10 @@
1
+ /* Copyright(C) 2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
2
+ *
3
+ * wohumi.test.ts: Switchbot BLE API registration.
4
+ */
1
5
  import { Buffer } from 'node:buffer';
2
6
  import * as Noble from '@stoprocent/noble';
3
- // wohumi.test.ts
4
- import { WoHumi } from './wohumi.js';
7
+ import { WoHumi } from '../device/wohumi.js';
5
8
  jest.mock('../device.js', () => {
6
9
  return {
7
10
  SwitchbotDevice: jest.fn().mockImplementation(() => {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wohumi.test.js","sourceRoot":"","sources":["../../src/test/wohumi.test.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,C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AA;IACxF,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,0CAA0C,EAAE,KAAK,IAAI,EAAE;QACxD,MAAM,WAAW,GAAG,MAAM,CAAC,OAAoB,CAAA;QAC/C,WAAW,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAA;QAE9D,MAAM,MAAM,CAAE,MAAc,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,wCAAwC,CAAC,CAAA;IACzH,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,6CAA6C,EAAE,KAAK,IAAI,EAAE;QAC3D,MAAM,WAAW,GAAG,MAAM,CAAC,OAAoB,CAAA;QAC/C,WAAW,CAAC,iBAAiB,CAAC,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAA;QAE1D,MAAM,MAAM,CAAE,MAAc,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;IACjG,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"woiosensorth.test.d.ts","sourceRoot":"","sources":["../../src/test/woiosensorth.test.ts"],"names":[],"mappings":""}
@@ -1,29 +1,31 @@
1
+ /* Copyright(C) 2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
2
+ *
3
+ * woiosensorth.test.ts: Switchbot BLE API registration.
4
+ */
1
5
  import { Buffer } from 'node:buffer';
2
- import { WoIOSensorTH } from './woiosensorth.js';
6
+ import { WoIOSensorTH } from '../device/woiosensorth.js';
3
7
  describe('woIOSensorTH', () => {
4
8
  const validServiceData = Buffer.from([0x00, 0x00, 0x7F]);
5
9
  const validManufacturerData = Buffer.from([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x8F, 0x50, 0x00]);
6
10
  const invalidServiceData = Buffer.from([0x00, 0x00]);
7
11
  const invalidManufacturerData = Buffer.from([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A]);
8
12
  it('should return null for incorrect serviceData length', async () => {
9
- const result = await WoIOSensorTH.parseServiceData(invalidServiceData, validManufacturerData, undefined);
13
+ const result = await WoIOSensorTH.parseServiceData(invalidServiceData, validManufacturerData);
10
14
  expect(result).toBeNull();
11
15
  });
12
16
  it('should return null for incorrect manufacturerData length', async () => {
13
- const result = await WoIOSensorTH.parseServiceData(validServiceData, invalidManufacturerData, undefined);
17
+ const result = await WoIOSensorTH.parseServiceData(validServiceData, invalidManufacturerData);
14
18
  expect(result).toBeNull();
15
19
  });
16
20
  it('should return correct parsed data for valid inputs', async () => {
17
- const result = await WoIOSensorTH.parseServiceData(validServiceData, validManufacturerData, undefined);
21
+ const result = await WoIOSensorTH.parseServiceData(validServiceData, validManufacturerData);
18
22
  expect(result).toEqual({
19
23
  model: 'OutdoorMeter',
20
24
  modelName: 'OutdoorMeter',
21
25
  modelFriendlyName: 'OutdoorMeter',
22
- temperature: {
23
- c: 1.5,
24
- f: 34.7,
25
- },
26
- fahrenheit: true,
26
+ celsius: 1.5,
27
+ fahrenheit: 34.7,
28
+ fahrenheit_mode: true,
27
29
  humidity: 80,
28
30
  battery: 127,
29
31
  });
@@ -0,0 +1 @@
1
+ {"version":3,"file":"woiosensorth.test.js","sourceRoot":"","sources":["../../src/test/woiosensorth.test.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAExD,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,MAAM,gBAAgB,GAAG,MAAM,CAAC,IA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