node-switchbot 3.5.0-beta.0 → 3.5.0-beta.1

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 (452) hide show
  1. package/.github/npm-version-script-esm.js +97 -0
  2. package/.github/workflows/beta-release.yml +1 -1
  3. package/.github/workflows/release.yml +1 -1
  4. package/BLE.md +14 -13
  5. package/CHANGELOG.md +68 -1
  6. package/OpenAPI.md +13 -12
  7. package/branding/Node_x_SwitchBot.svg +2 -3
  8. package/dist/device.d.ts +1193 -3
  9. package/dist/device.d.ts.map +1 -1
  10. package/dist/device.js +2478 -2
  11. package/dist/device.js.map +1 -1
  12. package/dist/index.d.ts +0 -17
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +0 -17
  15. package/dist/index.js.map +1 -1
  16. package/dist/{test/index.test.d.ts.map → index.test.d.ts.map} +1 -1
  17. package/dist/{test/index.test.js → index.test.js} +1 -1
  18. package/dist/index.test.js.map +1 -0
  19. package/dist/parameter-checker.d.ts +1 -1
  20. package/dist/parameter-checker.d.ts.map +1 -1
  21. package/dist/settings.d.ts +12 -28
  22. package/dist/settings.d.ts.map +1 -1
  23. package/dist/settings.js +24 -22
  24. package/dist/settings.js.map +1 -1
  25. package/dist/{test/settings.test.d.ts.map → settings.test.d.ts.map} +1 -1
  26. package/dist/{test/settings.test.js → settings.test.js} +6 -6
  27. package/dist/{test/settings.test.js.map → settings.test.js.map} +1 -1
  28. package/dist/switchbot-ble.d.ts +1 -1
  29. package/dist/switchbot-ble.d.ts.map +1 -1
  30. package/dist/switchbot-ble.js +8 -27
  31. package/dist/switchbot-ble.js.map +1 -1
  32. package/dist/switchbot-openapi.d.ts +33 -22
  33. package/dist/switchbot-openapi.d.ts.map +1 -1
  34. package/dist/switchbot-openapi.js +104 -64
  35. package/dist/switchbot-openapi.js.map +1 -1
  36. package/dist/types/bledevicestatus.d.ts +32 -8
  37. package/dist/types/bledevicestatus.d.ts.map +1 -1
  38. package/dist/types/devicestatus.d.ts +35 -1
  39. package/dist/types/devicestatus.d.ts.map +1 -1
  40. package/dist/types/devicewebhookstatus.d.ts +38 -1
  41. package/dist/types/devicewebhookstatus.d.ts.map +1 -1
  42. package/dist/types/types.d.ts +0 -223
  43. package/dist/types/types.d.ts.map +1 -1
  44. package/dist/types/types.js +1 -144
  45. package/dist/types/types.js.map +1 -1
  46. package/docs/assets/hierarchy.js +1 -0
  47. package/docs/assets/icons.js +1 -1
  48. package/docs/assets/icons.svg +1 -1
  49. package/docs/assets/main.js +5 -5
  50. package/docs/assets/navigation.js +1 -1
  51. package/docs/assets/search.js +1 -1
  52. package/docs/assets/style.css +1405 -1288
  53. package/docs/classes/Advertising.html +10 -10
  54. package/docs/classes/SwitchBotBLE.html +13 -13
  55. package/docs/classes/SwitchBotOpenAPI.html +38 -28
  56. package/docs/classes/SwitchbotDevice.html +26 -23
  57. package/docs/classes/WoBlindTilt.html +45 -42
  58. package/docs/classes/WoBulb.html +42 -39
  59. package/docs/classes/WoCeilingLight.html +50 -47
  60. package/docs/classes/WoContact.html +30 -27
  61. package/docs/classes/WoCurtain.html +40 -37
  62. package/docs/classes/WoHand.html +37 -34
  63. package/docs/classes/WoHub2.html +30 -27
  64. package/docs/classes/WoHumi.html +45 -40
  65. package/docs/classes/WoHumi2.html +67 -0
  66. package/docs/classes/WoIOSensorTH.html +30 -27
  67. package/docs/classes/WoKeypad.html +52 -0
  68. package/docs/classes/WoLeak.html +53 -0
  69. package/docs/classes/WoPlugMiniJP.html +78 -0
  70. package/docs/classes/WoPlugMiniUS.html +39 -36
  71. package/docs/classes/WoPresence.html +30 -27
  72. package/docs/classes/WoRelaySwitch1.html +57 -0
  73. package/docs/classes/WoRelaySwitch1PM.html +57 -0
  74. package/docs/classes/WoRemote.html +52 -0
  75. package/docs/classes/WoSensorTH.html +27 -24
  76. package/docs/classes/WoSensorTHPlus.html +46 -0
  77. package/docs/classes/WoSensorTHPro.html +46 -0
  78. package/docs/classes/WoSensorTHProCO2.html +46 -0
  79. package/docs/classes/WoSmartLock.html +49 -46
  80. package/docs/classes/WoSmartLockPro.html +49 -46
  81. package/docs/classes/WoStrip.html +44 -41
  82. package/docs/enums/LogLevel.html +10 -10
  83. package/docs/enums/SwitchBotBLEModel.html +29 -27
  84. package/docs/enums/SwitchBotBLEModelFriendlyName.html +30 -26
  85. package/docs/enums/SwitchBotBLEModelName.html +28 -26
  86. package/docs/enums/SwitchBotModel.html +47 -43
  87. package/docs/hierarchy.html +1 -1
  88. package/docs/index.html +13 -13
  89. package/docs/interfaces/AdvertisementData.html +3 -3
  90. package/docs/interfaces/Chars.html +2 -2
  91. package/docs/interfaces/ErrorObject.html +2 -2
  92. package/docs/interfaces/NobleTypes.html +2 -2
  93. package/docs/interfaces/Params.html +2 -2
  94. package/docs/interfaces/Rule.html +4 -4
  95. package/docs/interfaces/ServiceData.html +2 -2
  96. package/docs/interfaces/SwitchBotBLEDevice.html +23 -23
  97. package/docs/interfaces/WebhookDetail.html +4 -4
  98. package/docs/interfaces/ad.html +3 -3
  99. package/docs/interfaces/body.html +3 -3
  100. package/docs/interfaces/bodyChange.html +3 -3
  101. package/docs/interfaces/deleteWebhookResponse.html +3 -3
  102. package/docs/interfaces/device.html +6 -6
  103. package/docs/interfaces/deviceList.html +2 -2
  104. package/docs/interfaces/deviceStatus.html +6 -6
  105. package/docs/interfaces/deviceStatusRequest.html +3 -3
  106. package/docs/interfaces/deviceWebhook.html +4 -4
  107. package/docs/interfaces/deviceWebhookContext.html +4 -4
  108. package/docs/interfaces/devices.html +3 -3
  109. package/docs/interfaces/infraredRemoteList.html +2 -2
  110. package/docs/interfaces/irdevice.html +5 -5
  111. package/docs/interfaces/pushResponse.html +3 -3
  112. package/docs/interfaces/queryWebhookResponse.html +3 -3
  113. package/docs/interfaces/setupWebhookResponse.html +3 -3
  114. package/docs/interfaces/switchbot.html +2 -2
  115. package/docs/interfaces/updateWebhookResponse.html +3 -3
  116. package/docs/interfaces/webhookRequest.html +3 -3
  117. package/docs/media/BLE.md +14 -13
  118. package/docs/media/OpenAPI.md +13 -12
  119. package/docs/modules.html +1 -170
  120. package/docs/types/MacAddress.html +1 -1
  121. package/docs/types/batteryCirculatorFan.html +1 -1
  122. package/docs/types/batteryCirculatorFanServiceData.html +1 -1
  123. package/docs/types/batteryCirculatorFanStatus.html +1 -1
  124. package/docs/types/batteryCirculatorFanWebhookContext.html +1 -1
  125. package/docs/types/blindTilt.html +1 -1
  126. package/docs/types/blindTiltServiceData.html +1 -1
  127. package/docs/types/blindTiltStatus.html +1 -1
  128. package/docs/types/blindTiltWebhookContext.html +1 -1
  129. package/docs/types/bot.html +1 -1
  130. package/docs/types/botServiceData.html +1 -1
  131. package/docs/types/botStatus.html +1 -1
  132. package/docs/types/botWebhookContext.html +1 -1
  133. package/docs/types/ceilingLight.html +1 -1
  134. package/docs/types/ceilingLightPro.html +1 -1
  135. package/docs/types/ceilingLightProServiceData.html +1 -1
  136. package/docs/types/ceilingLightProStatus.html +1 -1
  137. package/docs/types/ceilingLightProWebhookContext.html +1 -1
  138. package/docs/types/ceilingLightServiceData.html +1 -1
  139. package/docs/types/ceilingLightStatus.html +1 -1
  140. package/docs/types/ceilingLightWebhookContext.html +1 -1
  141. package/docs/types/circulatorFanStatus.html +1 -0
  142. package/docs/types/circulatorFanWebhookContext.html +1 -0
  143. package/docs/types/colorBulb.html +1 -1
  144. package/docs/types/colorBulbServiceData.html +1 -1
  145. package/docs/types/colorBulbStatus.html +1 -1
  146. package/docs/types/colorBulbWebhookContext.html +1 -1
  147. package/docs/types/contactSensor.html +1 -1
  148. package/docs/types/contactSensorServiceData.html +1 -1
  149. package/docs/types/contactSensorStatus.html +1 -1
  150. package/docs/types/contactSensorWebhookContext.html +1 -1
  151. package/docs/types/curtain.html +1 -1
  152. package/docs/types/curtain3.html +1 -1
  153. package/docs/types/curtain3ServiceData.html +1 -1
  154. package/docs/types/curtain3WebhookContext.html +1 -1
  155. package/docs/types/curtainServiceData.html +1 -1
  156. package/docs/types/curtainStatus.html +1 -1
  157. package/docs/types/curtainWebhookContext.html +1 -1
  158. package/docs/types/floorCleaningRobotS10.html +1 -1
  159. package/docs/types/floorCleaningRobotS10Status.html +1 -1
  160. package/docs/types/floorCleaningRobotS10WebhookContext.html +1 -1
  161. package/docs/types/hub2.html +1 -1
  162. package/docs/types/hub2ServiceData.html +1 -1
  163. package/docs/types/hub2Status.html +1 -1
  164. package/docs/types/hub2WebhookContext.html +1 -1
  165. package/docs/types/humidifier.html +1 -1
  166. package/docs/types/humidifier2ServiceData.html +1 -0
  167. package/docs/types/humidifier2Status.html +1 -0
  168. package/docs/types/humidifier2WebhookContext.html +1 -0
  169. package/docs/types/humidifierServiceData.html +1 -1
  170. package/docs/types/humidifierStatus.html +1 -1
  171. package/docs/types/humidifierWebhookContext.html +1 -1
  172. package/docs/types/indoorCam.html +1 -1
  173. package/docs/types/indoorCameraWebhookContext.html +1 -1
  174. package/docs/types/keypad.html +1 -1
  175. package/docs/types/keypadDetectorServiceData.html +1 -1
  176. package/docs/types/keypadTouch.html +1 -1
  177. package/docs/types/keypadTouchWebhookContext.html +1 -1
  178. package/docs/types/keypadWebhookContext.html +1 -1
  179. package/docs/types/lock.html +1 -1
  180. package/docs/types/lockPro.html +1 -1
  181. package/docs/types/lockProServiceData.html +1 -1
  182. package/docs/types/lockProStatus.html +1 -1
  183. package/docs/types/lockProWebhookContext.html +1 -1
  184. package/docs/types/lockServiceData.html +1 -1
  185. package/docs/types/lockStatus.html +1 -1
  186. package/docs/types/lockWebhookContext.html +1 -1
  187. package/docs/types/meter.html +1 -1
  188. package/docs/types/meterPlus.html +1 -1
  189. package/docs/types/meterPlusServiceData.html +1 -1
  190. package/docs/types/meterPlusStatus.html +1 -1
  191. package/docs/types/meterPlusWebhookContext.html +1 -1
  192. package/docs/types/meterPro.html +1 -1
  193. package/docs/types/meterProCO2ServiceData.html +1 -1
  194. package/docs/types/meterProCO2Status.html +1 -1
  195. package/docs/types/meterProCO2WebhookContext.html +1 -1
  196. package/docs/types/meterProServiceData.html +1 -1
  197. package/docs/types/meterProStatus.html +1 -1
  198. package/docs/types/meterProWebhookContext.html +1 -1
  199. package/docs/types/meterServiceData.html +1 -1
  200. package/docs/types/meterStatus.html +1 -1
  201. package/docs/types/meterWebhookContext.html +1 -1
  202. package/docs/types/motionSensor.html +1 -1
  203. package/docs/types/motionSensorServiceData.html +1 -1
  204. package/docs/types/motionSensorStatus.html +1 -1
  205. package/docs/types/motionSensorWebhookContext.html +1 -1
  206. package/docs/types/onadvertisement.html +1 -1
  207. package/docs/types/ondiscover.html +1 -1
  208. package/docs/types/outdoorMeter.html +1 -1
  209. package/docs/types/outdoorMeterServiceData.html +1 -1
  210. package/docs/types/outdoorMeterStatus.html +1 -1
  211. package/docs/types/outdoorMeterWebhookContext.html +1 -1
  212. package/docs/types/panTiltCamWebhookContext.html +1 -1
  213. package/docs/types/pantiltCam.html +1 -1
  214. package/docs/types/pantiltCam2k.html +1 -1
  215. package/docs/types/plug.html +1 -1
  216. package/docs/types/plugMini.html +1 -1
  217. package/docs/types/plugMiniJPServiceData.html +1 -1
  218. package/docs/types/plugMiniJPWebhookContext.html +1 -1
  219. package/docs/types/plugMiniStatus.html +1 -1
  220. package/docs/types/plugMiniUSServiceData.html +1 -1
  221. package/docs/types/plugMiniUSWebhookContext.html +1 -1
  222. package/docs/types/plugStatus.html +1 -1
  223. package/docs/types/plugWebhookContext.html +1 -1
  224. package/docs/types/relaySwitch1Context.html +1 -0
  225. package/docs/types/relaySwitch1PMContext.html +1 -0
  226. package/docs/types/relaySwitch1PMServiceData.html +1 -1
  227. package/docs/types/relaySwitch1PMStatus.html +1 -0
  228. package/docs/types/relaySwitch1ServiceData.html +1 -0
  229. package/docs/types/relaySwitch1Status.html +1 -0
  230. package/docs/types/remote.html +1 -1
  231. package/docs/types/remoteServiceData.html +1 -0
  232. package/docs/types/robotVacuumCleanerS1.html +1 -1
  233. package/docs/types/robotVacuumCleanerS1Plus.html +1 -1
  234. package/docs/types/robotVacuumCleanerS1PlusStatus.html +1 -1
  235. package/docs/types/robotVacuumCleanerS1PlusWebhookContext.html +1 -1
  236. package/docs/types/robotVacuumCleanerS1Status.html +1 -1
  237. package/docs/types/robotVacuumCleanerS1WebhookContext.html +1 -1
  238. package/docs/types/robotVacuumCleanerServiceData.html +1 -1
  239. package/docs/types/stripLight.html +1 -1
  240. package/docs/types/stripLightServiceData.html +1 -1
  241. package/docs/types/stripLightStatus.html +1 -1
  242. package/docs/types/stripLightWebhookContext.html +1 -1
  243. package/docs/types/waterLeakDetector.html +1 -1
  244. package/docs/types/waterLeakDetectorServiceData.html +1 -1
  245. package/docs/types/waterLeakDetectorStatus.html +1 -1
  246. package/docs/types/waterLeakDetectorWebhookContext.html +1 -1
  247. package/package.json +16 -19
  248. package/.github/npm-version-script.cjs +0 -81
  249. package/dist/advertising.d.ts +0 -44
  250. package/dist/advertising.d.ts.map +0 -1
  251. package/dist/advertising.js +0 -163
  252. package/dist/advertising.js.map +0 -1
  253. package/dist/device/woblindtilt.d.ts +0 -78
  254. package/dist/device/woblindtilt.d.ts.map +0 -1
  255. package/dist/device/woblindtilt.js +0 -181
  256. package/dist/device/woblindtilt.js.map +0 -1
  257. package/dist/device/wobulb.d.ts +0 -70
  258. package/dist/device/wobulb.d.ts.map +0 -1
  259. package/dist/device/wobulb.js +0 -136
  260. package/dist/device/wobulb.js.map +0 -1
  261. package/dist/device/woceilinglight.d.ts +0 -74
  262. package/dist/device/woceilinglight.d.ts.map +0 -1
  263. package/dist/device/woceilinglight.js +0 -161
  264. package/dist/device/woceilinglight.js.map +0 -1
  265. package/dist/device/wocontact.d.ts +0 -19
  266. package/dist/device/wocontact.d.ts.map +0 -1
  267. package/dist/device/wocontact.js +0 -48
  268. package/dist/device/wocontact.js.map +0 -1
  269. package/dist/device/wocurtain.d.ts +0 -52
  270. package/dist/device/wocurtain.d.ts.map +0 -1
  271. package/dist/device/wocurtain.js +0 -135
  272. package/dist/device/wocurtain.js.map +0 -1
  273. package/dist/device/wohand.d.ts +0 -50
  274. package/dist/device/wohand.d.ts.map +0 -1
  275. package/dist/device/wohand.js +0 -82
  276. package/dist/device/wohand.js.map +0 -1
  277. package/dist/device/wohub2.d.ts +0 -19
  278. package/dist/device/wohub2.d.ts.map +0 -1
  279. package/dist/device/wohub2.js +0 -40
  280. package/dist/device/wohub2.js.map +0 -1
  281. package/dist/device/wohumi.d.ts +0 -50
  282. package/dist/device/wohumi.d.ts.map +0 -1
  283. package/dist/device/wohumi.js +0 -89
  284. package/dist/device/wohumi.js.map +0 -1
  285. package/dist/device/woiosensorth.d.ts +0 -20
  286. package/dist/device/woiosensorth.d.ts.map +0 -1
  287. package/dist/device/woiosensorth.js +0 -49
  288. package/dist/device/woiosensorth.js.map +0 -1
  289. package/dist/device/wokeypad.d.ts +0 -19
  290. package/dist/device/wokeypad.d.ts.map +0 -1
  291. package/dist/device/wokeypad.js +0 -51
  292. package/dist/device/wokeypad.js.map +0 -1
  293. package/dist/device/woleak.d.ts +0 -20
  294. package/dist/device/woleak.d.ts.map +0 -1
  295. package/dist/device/woleak.js +0 -52
  296. package/dist/device/woleak.js.map +0 -1
  297. package/dist/device/woplugmini.d.ts +0 -52
  298. package/dist/device/woplugmini.d.ts.map +0 -1
  299. package/dist/device/woplugmini.js +0 -110
  300. package/dist/device/woplugmini.js.map +0 -1
  301. package/dist/device/woplugmini_jp.d.ts +0 -52
  302. package/dist/device/woplugmini_jp.d.ts.map +0 -1
  303. package/dist/device/woplugmini_jp.js +0 -110
  304. package/dist/device/woplugmini_jp.js.map +0 -1
  305. package/dist/device/wopresence.d.ts +0 -19
  306. package/dist/device/wopresence.d.ts.map +0 -1
  307. package/dist/device/wopresence.js +0 -39
  308. package/dist/device/wopresence.js.map +0 -1
  309. package/dist/device/worelayswitch1plus.d.ts +0 -36
  310. package/dist/device/worelayswitch1plus.d.ts.map +0 -1
  311. package/dist/device/worelayswitch1plus.js +0 -141
  312. package/dist/device/worelayswitch1plus.js.map +0 -1
  313. package/dist/device/worelayswitch1pm.d.ts +0 -36
  314. package/dist/device/worelayswitch1pm.d.ts.map +0 -1
  315. package/dist/device/worelayswitch1pm.js +0 -144
  316. package/dist/device/worelayswitch1pm.js.map +0 -1
  317. package/dist/device/wosensorth.d.ts +0 -13
  318. package/dist/device/wosensorth.d.ts.map +0 -1
  319. package/dist/device/wosensorth.js +0 -38
  320. package/dist/device/wosensorth.js.map +0 -1
  321. package/dist/device/wosensorthplus.d.ts +0 -13
  322. package/dist/device/wosensorthplus.d.ts.map +0 -1
  323. package/dist/device/wosensorthplus.js +0 -38
  324. package/dist/device/wosensorthplus.js.map +0 -1
  325. package/dist/device/wosensorthpro.d.ts +0 -13
  326. package/dist/device/wosensorthpro.d.ts.map +0 -1
  327. package/dist/device/wosensorthpro.js +0 -38
  328. package/dist/device/wosensorthpro.js.map +0 -1
  329. package/dist/device/wosensorthproco2.d.ts +0 -13
  330. package/dist/device/wosensorthproco2.d.ts.map +0 -1
  331. package/dist/device/wosensorthproco2.js +0 -40
  332. package/dist/device/wosensorthproco2.js.map +0 -1
  333. package/dist/device/wosmartlock.d.ts +0 -86
  334. package/dist/device/wosmartlock.d.ts.map +0 -1
  335. package/dist/device/wosmartlock.js +0 -198
  336. package/dist/device/wosmartlock.js.map +0 -1
  337. package/dist/device/wosmartlockpro.d.ts +0 -86
  338. package/dist/device/wosmartlockpro.d.ts.map +0 -1
  339. package/dist/device/wosmartlockpro.js +0 -200
  340. package/dist/device/wosmartlockpro.js.map +0 -1
  341. package/dist/device/wostrip.d.ts +0 -63
  342. package/dist/device/wostrip.d.ts.map +0 -1
  343. package/dist/device/wostrip.js +0 -131
  344. package/dist/device/wostrip.js.map +0 -1
  345. package/dist/test/advertising.test.d.ts +0 -2
  346. package/dist/test/advertising.test.d.ts.map +0 -1
  347. package/dist/test/advertising.test.js +0 -99
  348. package/dist/test/advertising.test.js.map +0 -1
  349. package/dist/test/device.test.d.ts +0 -2
  350. package/dist/test/device.test.d.ts.map +0 -1
  351. package/dist/test/device.test.js +0 -38
  352. package/dist/test/device.test.js.map +0 -1
  353. package/dist/test/index.test.js.map +0 -1
  354. package/dist/test/parameter-checker.test.d.ts +0 -2
  355. package/dist/test/parameter-checker.test.d.ts.map +0 -1
  356. package/dist/test/parameter-checker.test.js +0 -108
  357. package/dist/test/parameter-checker.test.js.map +0 -1
  358. package/dist/test/switchbot-ble.test.d.ts +0 -2
  359. package/dist/test/switchbot-ble.test.d.ts.map +0 -1
  360. package/dist/test/switchbot-ble.test.js +0 -45
  361. package/dist/test/switchbot-ble.test.js.map +0 -1
  362. package/dist/test/switchbot-openapi.test.d.ts +0 -2
  363. package/dist/test/switchbot-openapi.test.d.ts.map +0 -1
  364. package/dist/test/switchbot-openapi.test.js +0 -96
  365. package/dist/test/switchbot-openapi.test.js.map +0 -1
  366. package/dist/test/woblindtilt.test.d.ts +0 -2
  367. package/dist/test/woblindtilt.test.d.ts.map +0 -1
  368. package/dist/test/woblindtilt.test.js +0 -76
  369. package/dist/test/woblindtilt.test.js.map +0 -1
  370. package/dist/test/wobulb.test.d.ts +0 -2
  371. package/dist/test/wobulb.test.d.ts.map +0 -1
  372. package/dist/test/wobulb.test.js +0 -95
  373. package/dist/test/wobulb.test.js.map +0 -1
  374. package/dist/test/woceilinglight.test.d.ts +0 -2
  375. package/dist/test/woceilinglight.test.d.ts.map +0 -1
  376. package/dist/test/woceilinglight.test.js +0 -81
  377. package/dist/test/woceilinglight.test.js.map +0 -1
  378. package/dist/test/wocontact.test.d.ts +0 -2
  379. package/dist/test/wocontact.test.d.ts.map +0 -1
  380. package/dist/test/wocontact.test.js +0 -65
  381. package/dist/test/wocontact.test.js.map +0 -1
  382. package/dist/test/wocurtain.test.d.ts +0 -2
  383. package/dist/test/wocurtain.test.d.ts.map +0 -1
  384. package/dist/test/wocurtain.test.js +0 -75
  385. package/dist/test/wocurtain.test.js.map +0 -1
  386. package/dist/test/wohand.test.d.ts +0 -2
  387. package/dist/test/wohand.test.d.ts.map +0 -1
  388. package/dist/test/wohand.test.js +0 -56
  389. package/dist/test/wohand.test.js.map +0 -1
  390. package/dist/test/wohub2.test.d.ts +0 -2
  391. package/dist/test/wohub2.test.d.ts.map +0 -1
  392. package/dist/test/wohub2.test.js +0 -80
  393. package/dist/test/wohub2.test.js.map +0 -1
  394. package/dist/test/wohumi.test.d.ts +0 -2
  395. package/dist/test/wohumi.test.d.ts.map +0 -1
  396. package/dist/test/wohumi.test.js +0 -82
  397. package/dist/test/wohumi.test.js.map +0 -1
  398. package/dist/test/woiosensorth.test.d.ts +0 -2
  399. package/dist/test/woiosensorth.test.d.ts.map +0 -1
  400. package/dist/test/woiosensorth.test.js +0 -40
  401. package/dist/test/woiosensorth.test.js.map +0 -1
  402. package/dist/test/wokeypad.test.d.ts +0 -2
  403. package/dist/test/wokeypad.test.d.ts.map +0 -1
  404. package/dist/test/wokeypad.test.js +0 -46
  405. package/dist/test/wokeypad.test.js.map +0 -1
  406. package/dist/test/woleak.test.d.ts +0 -2
  407. package/dist/test/woleak.test.d.ts.map +0 -1
  408. package/dist/test/woleak.test.js +0 -51
  409. package/dist/test/woleak.test.js.map +0 -1
  410. package/dist/test/woplugmini.test.d.ts +0 -2
  411. package/dist/test/woplugmini.test.d.ts.map +0 -1
  412. package/dist/test/woplugmini.test.js +0 -90
  413. package/dist/test/woplugmini.test.js.map +0 -1
  414. package/dist/test/woplugmini_jp.test.d.ts +0 -2
  415. package/dist/test/woplugmini_jp.test.d.ts.map +0 -1
  416. package/dist/test/woplugmini_jp.test.js +0 -90
  417. package/dist/test/woplugmini_jp.test.js.map +0 -1
  418. package/dist/test/wopresence.test.d.ts +0 -2
  419. package/dist/test/wopresence.test.d.ts.map +0 -1
  420. package/dist/test/wopresence.test.js +0 -68
  421. package/dist/test/wopresence.test.js.map +0 -1
  422. package/dist/test/wosensorth.test.d.ts +0 -2
  423. package/dist/test/wosensorth.test.d.ts.map +0 -1
  424. package/dist/test/wosensorth.test.js +0 -29
  425. package/dist/test/wosensorth.test.js.map +0 -1
  426. package/dist/test/wosensorthplus.test.d.ts +0 -2
  427. package/dist/test/wosensorthplus.test.d.ts.map +0 -1
  428. package/dist/test/wosensorthplus.test.js +0 -29
  429. package/dist/test/wosensorthplus.test.js.map +0 -1
  430. package/dist/test/wosensorthpro.test.d.ts +0 -2
  431. package/dist/test/wosensorthpro.test.d.ts.map +0 -1
  432. package/dist/test/wosensorthpro.test.js +0 -29
  433. package/dist/test/wosensorthpro.test.js.map +0 -1
  434. package/dist/test/wosensorthproco2.test.d.ts +0 -2
  435. package/dist/test/wosensorthproco2.test.d.ts.map +0 -1
  436. package/dist/test/wosensorthproco2.test.js +0 -32
  437. package/dist/test/wosensorthproco2.test.js.map +0 -1
  438. package/dist/test/wosmartlock.test.d.ts +0 -2
  439. package/dist/test/wosmartlock.test.d.ts.map +0 -1
  440. package/dist/test/wosmartlock.test.js +0 -151
  441. package/dist/test/wosmartlock.test.js.map +0 -1
  442. package/dist/test/wosmartlockpro.test.d.ts +0 -2
  443. package/dist/test/wosmartlockpro.test.d.ts.map +0 -1
  444. package/dist/test/wosmartlockpro.test.js +0 -150
  445. package/dist/test/wosmartlockpro.test.js.map +0 -1
  446. package/dist/test/wostrip.test.d.ts +0 -2
  447. package/dist/test/wostrip.test.d.ts.map +0 -1
  448. package/dist/test/wostrip.test.js +0 -102
  449. package/dist/test/wostrip.test.js.map +0 -1
  450. package/docs/types/relaySwitch1PlusServiceData.html +0 -1
  451. /package/dist/{test/index.test.d.ts → index.test.d.ts} +0 -0
  452. /package/dist/{test/settings.test.d.ts → settings.test.d.ts} +0 -0
@@ -1,86 +0,0 @@
1
- import type { lockServiceData } from '../types/bledevicestatus.js';
2
- import type { NobleTypes } from '../types/types.js';
3
- import { Buffer } from 'node:buffer';
4
- import { SwitchbotDevice } from '../device.js';
5
- /**
6
- * Class representing a WoSmartLock device.
7
- * @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/lock.md
8
- */
9
- export declare class WoSmartLock extends SwitchbotDevice {
10
- iv: Buffer | null;
11
- key_id: string;
12
- encryption_key: Buffer | null;
13
- static Result: {
14
- ERROR: number;
15
- SUCCESS: number;
16
- SUCCESS_LOW_BATTERY: number;
17
- };
18
- static validateResponse(res: Buffer): Promise<number>;
19
- static getLockStatus(code: number): string;
20
- /**
21
- * Parses the service data from the SwitchBot Strip Light.
22
- * @param {Buffer} serviceData - The service data buffer.
23
- * @param {Buffer} manufacturerData - The manufacturer data buffer.
24
- * @param {Function} emitLog - The function to emit log messages.
25
- * @returns {Promise<lockServiceData | null>} - Parsed service data or null if invalid.
26
- */
27
- static parseServiceData(serviceData: Buffer, manufacturerData: Buffer, emitLog: (level: string, message: string) => void): Promise<lockServiceData | null>;
28
- constructor(peripheral: NobleTypes['peripheral'], noble: NobleTypes['noble']);
29
- /**
30
- * Initializes the encryption key info for valid lock communication.
31
- * @param {string} keyId - The key ID.
32
- * @param {string} encryptionKey - The encryption key.
33
- */
34
- setKey(keyId: string, encryptionKey: string): Promise<void>;
35
- /**
36
- * Unlocks the Smart Lock.
37
- * @returns {Promise<number>} - The result of the unlock operation.
38
- */
39
- unlock(): Promise<number>;
40
- /**
41
- * Unlocks the Smart Lock without unlatching the door.
42
- * @returns {Promise<number>} - The result of the unlock operation.
43
- */
44
- unlockNoUnlatch(): Promise<number>;
45
- /**
46
- * Locks the Smart Lock.
47
- * @returns {Promise<number>} - The result of the lock operation.
48
- */
49
- lock(): Promise<number>;
50
- /**
51
- * Gets general state info from the Smart Lock.
52
- * @returns {Promise<object | null>} - The state object or null if an error occurred.
53
- */
54
- info(): Promise<object | null>;
55
- /**
56
- * Encrypts a string using AES-128-CTR.
57
- * @param {string} str - The string to encrypt.
58
- * @returns {Promise<string>} - The encrypted string in hex format.
59
- */
60
- encrypt(str: string): Promise<string>;
61
- /**
62
- * Decrypts a buffer using AES-128-CTR.
63
- * @param {Buffer} data - The data to decrypt.
64
- * @returns {Promise<Buffer>} - The decrypted data.
65
- */
66
- decrypt(data: Buffer): Promise<Buffer>;
67
- /**
68
- * Retrieves the IV from the device.
69
- * @returns {Promise<Buffer>} - The IV buffer.
70
- */
71
- getIv(): Promise<Buffer>;
72
- /**
73
- * Sends an encrypted command to the device.
74
- * @param {string} key - The command key.
75
- * @returns {Promise<Buffer>} - The response buffer.
76
- */
77
- encryptedCommand(key: string): Promise<Buffer>;
78
- /**
79
- * Operates the lock with the given command.
80
- * @param {string} key - The command key.
81
- * @param {boolean} [encrypt] - Whether to encrypt the command.
82
- * @returns {Promise<Buffer>} - The response buffer.
83
- */
84
- operateLock(key: string, encrypt?: boolean): Promise<Buffer>;
85
- }
86
- //# sourceMappingURL=wosmartlock.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wosmartlock.d.ts","sourceRoot":"","sources":["../../src/device/wosmartlock.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAGpC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAI9C;;;GAGG;AACH,qBAAa,WAAY,SAAQ,eAAe;IACvC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAO;IACxB,MAAM,EAAE,MAAM,CAAK;IACnB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAO;IAE3C,MAAM,CAAC,MAAM;;;;MAIZ;WAEY,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAU3D,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAa1C;;;;;;OAMG;WACU,gBAAgB,CAC3B,WAAW,EAAE,MAAM,EACnB,gBAAgB,EAAE,MAAM,EACxB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,GAChD,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;gBA6BtB,UAAU,EAAE,UAAU,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC;IAI5E;;;;OAIG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMjE;;;OAGG;IACG,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;IAK/B;;;OAGG;IACG,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC;IAKxC;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAK7B;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAcpC;;;;OAIG;IACG,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAK3C;;;;OAIG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAK5C;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;IAY9B;;;;OAIG;IACG,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAkBpD;;;;;OAKG;IACG,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,OAAc,GAAG,OAAO,CAAC,MAAM,CAAC;CAczE"}
@@ -1,198 +0,0 @@
1
- import { Buffer } from 'node:buffer';
2
- import * as Crypto from 'node:crypto';
3
- import { SwitchbotDevice } from '../device.js';
4
- import { WoSmartLockCommands } from '../settings.js';
5
- import { SwitchBotBLEModel, SwitchBotBLEModelFriendlyName, SwitchBotBLEModelName } from '../types/types.js';
6
- /**
7
- * Class representing a WoSmartLock device.
8
- * @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/lock.md
9
- */
10
- export class WoSmartLock extends SwitchbotDevice {
11
- iv = null;
12
- key_id = '';
13
- encryption_key = null;
14
- static Result = {
15
- ERROR: 0x00,
16
- SUCCESS: 0x01,
17
- SUCCESS_LOW_BATTERY: 0x06,
18
- };
19
- static async validateResponse(res) {
20
- if (res.length >= 3) {
21
- const result = res.readUInt8(0);
22
- if (result === WoSmartLock.Result.SUCCESS || result === WoSmartLock.Result.SUCCESS_LOW_BATTERY) {
23
- return result;
24
- }
25
- }
26
- return WoSmartLock.Result.ERROR;
27
- }
28
- static getLockStatus(code) {
29
- const statusMap = {
30
- 0b0000000: 'LOCKED',
31
- 0b0010000: 'UNLOCKED',
32
- 0b0100000: 'LOCKING',
33
- 0b0110000: 'UNLOCKING',
34
- 0b1000000: 'LOCKING_STOP',
35
- 0b1010000: 'UNLOCKING_STOP',
36
- 0b1100000: 'NOT_FULLY_LOCKED', // Only EU lock type
37
- };
38
- return statusMap[code] || 'UNKNOWN';
39
- }
40
- /**
41
- * Parses the service data from the SwitchBot Strip Light.
42
- * @param {Buffer} serviceData - The service data buffer.
43
- * @param {Buffer} manufacturerData - The manufacturer data buffer.
44
- * @param {Function} emitLog - The function to emit log messages.
45
- * @returns {Promise<lockServiceData | null>} - Parsed service data or null if invalid.
46
- */
47
- static async parseServiceData(serviceData, manufacturerData, emitLog) {
48
- if (manufacturerData.length < 11) {
49
- emitLog('debugerror', `[parseServiceDataForWoSmartLock] Buffer length ${manufacturerData.length} is too short!`);
50
- return null;
51
- }
52
- const byte2 = serviceData.readUInt8(2);
53
- const byte15 = manufacturerData.readUInt8(9);
54
- const byte16 = manufacturerData.readUInt8(10);
55
- const data = {
56
- model: SwitchBotBLEModel.Lock,
57
- modelName: SwitchBotBLEModelName.Lock,
58
- modelFriendlyName: SwitchBotBLEModelFriendlyName.Lock,
59
- battery: byte2 & 0b01111111,
60
- calibration: !!(byte15 & 0b10000000),
61
- status: WoSmartLock.getLockStatus(byte15 & 0b01110000),
62
- update_from_secondary_lock: !!(byte15 & 0b00001000),
63
- door_open: !!(byte15 & 0b00000100),
64
- double_lock_mode: !!(byte16 & 0b10000000),
65
- unclosed_alarm: !!(byte16 & 0b00100000),
66
- unlocked_alarm: !!(byte16 & 0b00010000),
67
- auto_lock_paused: !!(byte16 & 0b00000010),
68
- night_latch: !!(manufacturerData.length > 11 && manufacturerData.readUInt8(11) & 0b00000001),
69
- };
70
- return data;
71
- }
72
- constructor(peripheral, noble) {
73
- super(peripheral, noble);
74
- }
75
- /**
76
- * Initializes the encryption key info for valid lock communication.
77
- * @param {string} keyId - The key ID.
78
- * @param {string} encryptionKey - The encryption key.
79
- */
80
- async setKey(keyId, encryptionKey) {
81
- this.iv = null;
82
- this.key_id = keyId;
83
- this.encryption_key = Buffer.from(encryptionKey, 'hex');
84
- }
85
- /**
86
- * Unlocks the Smart Lock.
87
- * @returns {Promise<number>} - The result of the unlock operation.
88
- */
89
- async unlock() {
90
- const resBuf = await this.operateLock(WoSmartLockCommands.UNLOCK);
91
- return resBuf ? WoSmartLock.validateResponse(resBuf) : WoSmartLock.Result.ERROR;
92
- }
93
- /**
94
- * Unlocks the Smart Lock without unlatching the door.
95
- * @returns {Promise<number>} - The result of the unlock operation.
96
- */
97
- async unlockNoUnlatch() {
98
- const resBuf = await this.operateLock(WoSmartLockCommands.UNLOCK_NO_UNLATCH);
99
- return resBuf ? WoSmartLock.validateResponse(resBuf) : WoSmartLock.Result.ERROR;
100
- }
101
- /**
102
- * Locks the Smart Lock.
103
- * @returns {Promise<number>} - The result of the lock operation.
104
- */
105
- async lock() {
106
- const resBuf = await this.operateLock(WoSmartLockCommands.LOCK);
107
- return resBuf ? WoSmartLock.validateResponse(resBuf) : WoSmartLock.Result.ERROR;
108
- }
109
- /**
110
- * Gets general state info from the Smart Lock.
111
- * @returns {Promise<object | null>} - The state object or null if an error occurred.
112
- */
113
- async info() {
114
- const resBuf = await this.operateLock(WoSmartLockCommands.LOCK_INFO);
115
- if (resBuf) {
116
- return {
117
- calibration: Boolean(resBuf[1] & 0b10000000),
118
- status: WoSmartLock.getLockStatus((resBuf[1] & 0b01110000)),
119
- door_open: Boolean(resBuf[1] & 0b00000100),
120
- unclosed_alarm: Boolean(resBuf[2] & 0b00100000),
121
- unlocked_alarm: Boolean(resBuf[2] & 0b00010000),
122
- };
123
- }
124
- return null;
125
- }
126
- /**
127
- * Encrypts a string using AES-128-CTR.
128
- * @param {string} str - The string to encrypt.
129
- * @returns {Promise<string>} - The encrypted string in hex format.
130
- */
131
- async encrypt(str) {
132
- const cipher = Crypto.createCipheriv('aes-128-ctr', this.encryption_key, this.iv);
133
- return Buffer.concat([cipher.update(str, 'hex'), cipher.final()]).toString('hex');
134
- }
135
- /**
136
- * Decrypts a buffer using AES-128-CTR.
137
- * @param {Buffer} data - The data to decrypt.
138
- * @returns {Promise<Buffer>} - The decrypted data.
139
- */
140
- async decrypt(data) {
141
- const decipher = Crypto.createDecipheriv('aes-128-ctr', this.encryption_key, this.iv);
142
- return Buffer.concat([decipher.update(data), decipher.final()]);
143
- }
144
- /**
145
- * Retrieves the IV from the device.
146
- * @returns {Promise<Buffer>} - The IV buffer.
147
- */
148
- async getIv() {
149
- if (!this.iv) {
150
- const res = await this.operateLock(WoSmartLockCommands.GET_CKIV + this.key_id, false);
151
- if (res) {
152
- this.iv = res.subarray(4);
153
- }
154
- else {
155
- throw new Error('Failed to retrieve IV from the device.');
156
- }
157
- }
158
- return this.iv;
159
- }
160
- /**
161
- * Sends an encrypted command to the device.
162
- * @param {string} key - The command key.
163
- * @returns {Promise<Buffer>} - The response buffer.
164
- */
165
- async encryptedCommand(key) {
166
- const iv = await this.getIv();
167
- const req = Buffer.from(key.substring(0, 2) + this.key_id + Buffer.from(iv.subarray(0, 2)).toString('hex') + await this.encrypt(key.substring(2)), 'hex');
168
- const bytes = await this.command(req);
169
- const buf = Buffer.from(bytes);
170
- const code = WoSmartLock.validateResponse(buf);
171
- if (await code !== WoSmartLock.Result.ERROR) {
172
- return Buffer.concat([buf.subarray(0, 1), await this.decrypt(buf.subarray(4))]);
173
- }
174
- else {
175
- throw new Error(`The device returned an error: 0x${buf.toString('hex')}`);
176
- }
177
- }
178
- /**
179
- * Operates the lock with the given command.
180
- * @param {string} key - The command key.
181
- * @param {boolean} [encrypt] - Whether to encrypt the command.
182
- * @returns {Promise<Buffer>} - The response buffer.
183
- */
184
- async operateLock(key, encrypt = true) {
185
- if (encrypt) {
186
- return this.encryptedCommand(key);
187
- }
188
- const req = Buffer.from(`${key.substring(0, 2)}000000${key.substring(2)}`, 'hex');
189
- const bytes = await this.command(req);
190
- const buf = Buffer.from(bytes);
191
- const code = WoSmartLock.validateResponse(buf);
192
- if (await code === WoSmartLock.Result.ERROR) {
193
- throw new Error(`The device returned an error: 0x${buf.toString('hex')}`);
194
- }
195
- return buf;
196
- }
197
- }
198
- //# sourceMappingURL=wosmartlock.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wosmartlock.js","sourceRoot":"","sources":["../../src/device/wosmartlock.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAE3G;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,eAAe;IACvC,EAAE,GAAkB,IAAI,CAAA;IACxB,MAAM,GAAW,EAAE,CAAA;IACnB,cAAc,GAAkB,IAAI,CAAA;IAE3C,MAAM,CAAC,MAAM,GAAG;QACd,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,IAAI;QACb,mBAAmB,EAAE,IAAI;KAC1B,CAAA;IAED,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,GAAW;QACvC,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;YACpB,MAAM,MAAM,GAAG,G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AAE,KAAK,CAAC,CAAA;QACjF,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QACrC,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,KAAmB,CAAC,CAAA;QAC5C,MAAM,IAAI,GAAG,WAAW,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAA;QAE9C,IAAI,MAAM,IAAI,KAAK,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAC5C,MAAM,IAAI,KAAK,CAAC,mCAAmC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAC3E,CAAC;QACD,OAAO,GAAG,CAAA;IACZ,CAAC"}
@@ -1,86 +0,0 @@
1
- import type { lockProServiceData } from '../types/bledevicestatus.js';
2
- import type { NobleTypes } from '../types/types.js';
3
- import { Buffer } from 'node:buffer';
4
- import { SwitchbotDevice } from '../device.js';
5
- /**
6
- * Class representing a WoSmartLockPro device.
7
- * @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/lock.md
8
- */
9
- export declare class WoSmartLockPro extends SwitchbotDevice {
10
- iv: Buffer | null;
11
- key_id: string;
12
- encryption_key: Buffer | null;
13
- static Result: {
14
- ERROR: number;
15
- SUCCESS: number;
16
- SUCCESS_LOW_BATTERY: number;
17
- };
18
- static validateResponse(res: Buffer): Promise<number>;
19
- static getLockStatus(code: number): string;
20
- /**
21
- * Parses the service data from the SwitchBot Strip Light.
22
- * @param {Buffer} serviceData - The service data buffer.
23
- * @param {Buffer} manufacturerData - The manufacturer data buffer.
24
- * @param {Function} emitLog - The function to emit log messages.
25
- * @returns {Promise<lockProServiceData | null>} - Parsed service data or null if invalid.
26
- */
27
- static parseServiceData(serviceData: Buffer, manufacturerData: Buffer, emitLog: (level: string, message: string) => void): Promise<lockProServiceData | null>;
28
- constructor(peripheral: NobleTypes['peripheral'], noble: NobleTypes['noble']);
29
- /**
30
- * Initializes the encryption key info for valid lock communication.
31
- * @param {string} keyId - The key ID.
32
- * @param {string} encryptionKey - The encryption key.
33
- */
34
- setKey(keyId: string, encryptionKey: string): Promise<void>;
35
- /**
36
- * Unlocks the Smart Lock.
37
- * @returns {Promise<number>} - The result of the unlock operation.
38
- */
39
- unlock(): Promise<number>;
40
- /**
41
- * Unlocks the Smart Lock without unlatching the door.
42
- * @returns {Promise<number>} - The result of the unlock operation.
43
- */
44
- unlockNoUnlatch(): Promise<number>;
45
- /**
46
- * Locks the Smart Lock.
47
- * @returns {Promise<number>} - The result of the lock operation.
48
- */
49
- lock(): Promise<number>;
50
- /**
51
- * Gets general state info from the Smart Lock.
52
- * @returns {Promise<object | null>} - The state object or null if an error occurred.
53
- */
54
- info(): Promise<object | null>;
55
- /**
56
- * Encrypts a string using AES-128-CTR.
57
- * @param {string} str - The string to encrypt.
58
- * @returns {Promise<string>} - The encrypted string in hex format.
59
- */
60
- encrypt(str: string): Promise<string>;
61
- /**
62
- * Decrypts a buffer using AES-128-CTR.
63
- * @param {Buffer} data - The data to decrypt.
64
- * @returns {Promise<Buffer>} - The decrypted data.
65
- */
66
- decrypt(data: Buffer): Promise<Buffer>;
67
- /**
68
- * Retrieves the IV from the device.
69
- * @returns {Promise<Buffer>} - The IV buffer.
70
- */
71
- getIv(): Promise<Buffer>;
72
- /**
73
- * Sends an encrypted command to the device.
74
- * @param {string} key - The command key.
75
- * @returns {Promise<Buffer>} - The response buffer.
76
- */
77
- encryptedCommand(key: string): Promise<Buffer>;
78
- /**
79
- * Operates the lock with the given command.
80
- * @param {string} key - The command key.
81
- * @param {boolean} [encrypt] - Whether to encrypt the command.
82
- * @returns {Promise<Buffer>} - The response buffer.
83
- */
84
- operateLockPro(key: string, encrypt?: boolean): Promise<Buffer>;
85
- }
86
- //# sourceMappingURL=wosmartlockpro.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wosmartlockpro.d.ts","sourceRoot":"","sources":["../../src/device/wosmartlockpro.ts"],"names":[],"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AI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAK5C;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;IAY9B;;;;OAIG;IACG,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAkBpD;;;;;OAKG;IACG,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,OAAc,GAAG,OAAO,CAAC,MAAM,CAAC;CAc5E"}
@@ -1,200 +0,0 @@
1
- import { Buffer } from 'node:buffer';
2
- import * as Crypto from 'node:crypto';
3
- import { SwitchbotDevice } from '../device.js';
4
- import { WoSmartLockProCommands } from '../settings.js';
5
- import { SwitchBotBLEModel, SwitchBotBLEModelFriendlyName, SwitchBotBLEModelName } from '../types/types.js';
6
- /**
7
- * Class representing a WoSmartLockPro device.
8
- * @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/lock.md
9
- */
10
- export class WoSmartLockPro extends SwitchbotDevice {
11
- iv = null;
12
- key_id = '';
13
- encryption_key = null;
14
- static Result = {
15
- ERROR: 0x00,
16
- SUCCESS: 0x01,
17
- SUCCESS_LOW_BATTERY: 0x06,
18
- };
19
- static async validateResponse(res) {
20
- if (res.length >= 3) {
21
- const result = res.readUInt8(0);
22
- if (result === WoSmartLockPro.Result.SUCCESS || result === WoSmartLockPro.Result.SUCCESS_LOW_BATTERY) {
23
- return result;
24
- }
25
- }
26
- return WoSmartLockPro.Result.ERROR;
27
- }
28
- static getLockStatus(code) {
29
- const statusMap = {
30
- 0b0000000: 'LOCKED',
31
- 0b0010000: 'UNLOCKED',
32
- 0b0100000: 'LOCKING',
33
- 0b0110000: 'UNLOCKING',
34
- 0b1000000: 'LOCKING_STOP',
35
- 0b1010000: 'UNLOCKING_STOP',
36
- 0b01100000: 'NOT_FULLY_LOCKED', // Only EU lock type
37
- };
38
- return statusMap[code] || 'UNKNOWN';
39
- }
40
- /**
41
- * Parses the service data from the SwitchBot Strip Light.
42
- * @param {Buffer} serviceData - The service data buffer.
43
- * @param {Buffer} manufacturerData - The manufacturer data buffer.
44
- * @param {Function} emitLog - The function to emit log messages.
45
- * @returns {Promise<lockProServiceData | null>} - Parsed service data or null if invalid.
46
- */
47
- static async parseServiceData(serviceData, manufacturerData, emitLog) {
48
- if (manufacturerData.length < 11) {
49
- emitLog('debugerror', `[parseServiceDataForWoSmartLockPro] Buffer length ${manufacturerData.length} is too short!`);
50
- return null;
51
- }
52
- const byte2 = serviceData.readUInt8(2);
53
- const byte7 = manufacturerData.readUInt8(7);
54
- const byte8 = manufacturerData.readUInt8(8);
55
- const byte9 = manufacturerData.readUInt8(9);
56
- const byte11 = manufacturerData.readUInt8(11);
57
- const data = {
58
- model: SwitchBotBLEModel.LockPro,
59
- modelName: SwitchBotBLEModelName.LockPro,
60
- modelFriendlyName: SwitchBotBLEModelFriendlyName.LockPro,
61
- battery: byte2 & 0b01111111,
62
- calibration: !!(byte7 & 0b10000000),
63
- status: WoSmartLockPro.getLockStatus((byte7 & 0b00111000) >> 3),
64
- door_open: !!(byte8 & 0b01100000),
65
- update_from_secondary_lock: false,
66
- double_lock_mode: false,
67
- unclosed_alarm: !!(byte11 & 0b10000000),
68
- unlocked_alarm: !!(byte11 & 0b01000000),
69
- auto_lock_paused: !!(byte8 & 0b100000),
70
- night_latch: !!(byte9 & 0b00000001),
71
- };
72
- return data;
73
- }
74
- constructor(peripheral, noble) {
75
- super(peripheral, noble);
76
- }
77
- /**
78
- * Initializes the encryption key info for valid lock communication.
79
- * @param {string} keyId - The key ID.
80
- * @param {string} encryptionKey - The encryption key.
81
- */
82
- async setKey(keyId, encryptionKey) {
83
- this.iv = null;
84
- this.key_id = keyId;
85
- this.encryption_key = Buffer.from(encryptionKey, 'hex');
86
- }
87
- /**
88
- * Unlocks the Smart Lock.
89
- * @returns {Promise<number>} - The result of the unlock operation.
90
- */
91
- async unlock() {
92
- const resBuf = await this.operateLockPro(WoSmartLockProCommands.UNLOCK);
93
- return resBuf ? WoSmartLockPro.validateResponse(resBuf) : WoSmartLockPro.Result.ERROR;
94
- }
95
- /**
96
- * Unlocks the Smart Lock without unlatching the door.
97
- * @returns {Promise<number>} - The result of the unlock operation.
98
- */
99
- async unlockNoUnlatch() {
100
- const resBuf = await this.operateLockPro(WoSmartLockProCommands.UNLOCK_NO_UNLATCH);
101
- return resBuf ? WoSmartLockPro.validateResponse(resBuf) : WoSmartLockPro.Result.ERROR;
102
- }
103
- /**
104
- * Locks the Smart Lock.
105
- * @returns {Promise<number>} - The result of the lock operation.
106
- */
107
- async lock() {
108
- const resBuf = await this.operateLockPro(WoSmartLockProCommands.LOCK);
109
- return resBuf ? WoSmartLockPro.validateResponse(resBuf) : WoSmartLockPro.Result.ERROR;
110
- }
111
- /**
112
- * Gets general state info from the Smart Lock.
113
- * @returns {Promise<object | null>} - The state object or null if an error occurred.
114
- */
115
- async info() {
116
- const resBuf = await this.operateLockPro(WoSmartLockProCommands.LOCK_INFO);
117
- if (resBuf) {
118
- return {
119
- calibration: Boolean(resBuf[0] & 0b10000000),
120
- status: WoSmartLockPro.getLockStatus((resBuf[0] & 0b01110000) >> 4),
121
- door_open: Boolean(resBuf[0] & 0b00000100),
122
- unclosed_alarm: Boolean(resBuf[1] & 0b00100000),
123
- unlocked_alarm: Boolean(resBuf[1] & 0b00010000),
124
- };
125
- }
126
- return null;
127
- }
128
- /**
129
- * Encrypts a string using AES-128-CTR.
130
- * @param {string} str - The string to encrypt.
131
- * @returns {Promise<string>} - The encrypted string in hex format.
132
- */
133
- async encrypt(str) {
134
- const cipher = Crypto.createCipheriv('aes-128-ctr', this.encryption_key, this.iv);
135
- return Buffer.concat([cipher.update(str, 'hex'), cipher.final()]).toString('hex');
136
- }
137
- /**
138
- * Decrypts a buffer using AES-128-CTR.
139
- * @param {Buffer} data - The data to decrypt.
140
- * @returns {Promise<Buffer>} - The decrypted data.
141
- */
142
- async decrypt(data) {
143
- const decipher = Crypto.createDecipheriv('aes-128-ctr', this.encryption_key, this.iv);
144
- return Buffer.concat([decipher.update(data), decipher.final()]);
145
- }
146
- /**
147
- * Retrieves the IV from the device.
148
- * @returns {Promise<Buffer>} - The IV buffer.
149
- */
150
- async getIv() {
151
- if (!this.iv) {
152
- const res = await this.operateLockPro(WoSmartLockProCommands.GET_CKIV + this.key_id, false);
153
- if (res) {
154
- this.iv = res.subarray(4);
155
- }
156
- else {
157
- throw new Error('Failed to retrieve IV from the device.');
158
- }
159
- }
160
- return this.iv;
161
- }
162
- /**
163
- * Sends an encrypted command to the device.
164
- * @param {string} key - The command key.
165
- * @returns {Promise<Buffer>} - The response buffer.
166
- */
167
- async encryptedCommand(key) {
168
- const iv = await this.getIv();
169
- const req = Buffer.from(key.substring(0, 2) + this.key_id + Buffer.from(iv.subarray(0, 2)).toString('hex') + await this.encrypt(key.substring(2)), 'hex');
170
- const bytes = await this.command(req);
171
- const buf = Buffer.from(bytes);
172
- const code = WoSmartLockPro.validateResponse(buf);
173
- if (await code !== WoSmartLockPro.Result.ERROR) {
174
- return Buffer.concat([buf.subarray(0, 1), await this.decrypt(buf.subarray(4))]);
175
- }
176
- else {
177
- throw new Error(`The device returned an error: 0x${buf.toString('hex')}`);
178
- }
179
- }
180
- /**
181
- * Operates the lock with the given command.
182
- * @param {string} key - The command key.
183
- * @param {boolean} [encrypt] - Whether to encrypt the command.
184
- * @returns {Promise<Buffer>} - The response buffer.
185
- */
186
- async operateLockPro(key, encrypt = true) {
187
- if (encrypt) {
188
- return this.encryptedCommand(key);
189
- }
190
- const req = Buffer.from(`${key.substring(0, 2)}000000${key.substring(2)}`, 'hex');
191
- const bytes = await this.command(req);
192
- const buf = Buffer.from(bytes);
193
- const code = WoSmartLockPro.validateResponse(buf);
194
- if (await code === WoSmartLockPro.Result.ERROR) {
195
- throw new Error(`The device returned an error: 0x${buf.toString('hex')}`);
196
- }
197
- return buf;
198
- }
199
- }
200
- //# sourceMappingURL=wosmartlockpro.js.map
@@ -1 +0,0 @@
1
- {"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