node-switchbot 2.5.0-beta.9 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (340) hide show
  1. package/.github/workflows/beta-release.yml +25 -2
  2. package/.github/workflows/release.yml +13 -0
  3. package/BLE.md +1144 -0
  4. package/CHANGELOG.md +14 -0
  5. package/OpenAPI.md +185 -0
  6. package/README.md +20 -1189
  7. package/branding/Node_x_SwitchBot.svg +9 -0
  8. package/branding/icon.png +0 -0
  9. package/branding/switchbot.png +0 -0
  10. package/dist/advertising.d.ts +3 -3
  11. package/dist/advertising.d.ts.map +1 -1
  12. package/dist/advertising.js +26 -26
  13. package/dist/advertising.js.map +1 -1
  14. package/dist/device/woblindtilt.d.ts +19 -50
  15. package/dist/device/woblindtilt.d.ts.map +1 -1
  16. package/dist/device/woblindtilt.js +41 -100
  17. package/dist/device/woblindtilt.js.map +1 -1
  18. package/dist/device/wobulb.d.ts +41 -15
  19. package/dist/device/wobulb.d.ts.map +1 -1
  20. package/dist/device/wobulb.js +72 -128
  21. package/dist/device/wobulb.js.map +1 -1
  22. package/dist/device/woceilinglight.d.ts +47 -21
  23. package/dist/device/woceilinglight.d.ts.map +1 -1
  24. package/dist/device/woceilinglight.js +96 -171
  25. package/dist/device/woceilinglight.js.map +1 -1
  26. package/dist/device/wocontact.d.ts +11 -1
  27. package/dist/device/wocontact.d.ts.map +1 -1
  28. package/dist/device/wocontact.js +23 -22
  29. package/dist/device/wocontact.js.map +1 -1
  30. package/dist/device/wocurtain.d.ts +39 -1
  31. package/dist/device/wocurtain.d.ts.map +1 -1
  32. package/dist/device/wocurtain.js +69 -103
  33. package/dist/device/wocurtain.js.map +1 -1
  34. package/dist/device/wohand.d.ts +37 -2
  35. package/dist/device/wohand.d.ts.map +1 -1
  36. package/dist/device/wohand.js +55 -89
  37. package/dist/device/wohand.js.map +1 -1
  38. package/dist/device/wohub2.d.ts +11 -1
  39. package/dist/device/wohub2.d.ts.map +1 -1
  40. package/dist/device/wohub2.js +21 -29
  41. package/dist/device/wohub2.js.map +1 -1
  42. package/dist/device/wohumi.d.ts +37 -2
  43. package/dist/device/wohumi.d.ts.map +1 -1
  44. package/dist/device/wohumi.js +52 -83
  45. package/dist/device/wohumi.js.map +1 -1
  46. package/dist/device/woiosensorth.d.ts +12 -1
  47. package/dist/device/woiosensorth.d.ts.map +1 -1
  48. package/dist/device/woiosensorth.js +25 -29
  49. package/dist/device/woiosensorth.js.map +1 -1
  50. package/dist/device/woplugmini.d.ts +45 -12
  51. package/dist/device/woplugmini.d.ts.map +1 -1
  52. package/dist/device/woplugmini.js +71 -77
  53. package/dist/device/woplugmini.js.map +1 -1
  54. package/dist/device/wopresence.d.ts +11 -1
  55. package/dist/device/wopresence.d.ts.map +1 -1
  56. package/dist/device/wopresence.js +21 -27
  57. package/dist/device/wopresence.js.map +1 -1
  58. package/dist/device/wosensorth.d.ts +18 -2
  59. package/dist/device/wosensorth.d.ts.map +1 -1
  60. package/dist/device/wosensorth.js +34 -50
  61. package/dist/device/wosensorth.js.map +1 -1
  62. package/dist/device/wosmartlock.d.ts +63 -13
  63. package/dist/device/wosmartlock.d.ts.map +1 -1
  64. package/dist/device/wosmartlock.js +114 -195
  65. package/dist/device/wosmartlock.js.map +1 -1
  66. package/dist/device/wosmartlockpro.d.ts +16 -12
  67. package/dist/device/wosmartlockpro.d.ts.map +1 -1
  68. package/dist/device/wosmartlockpro.js +34 -29
  69. package/dist/device/wosmartlockpro.js.map +1 -1
  70. package/dist/device/wostrip.d.ts +4 -3
  71. package/dist/device/wostrip.d.ts.map +1 -1
  72. package/dist/device/wostrip.js +5 -4
  73. package/dist/device/wostrip.js.map +1 -1
  74. package/dist/device.d.ts +13 -5
  75. package/dist/device.d.ts.map +1 -1
  76. package/dist/device.js +13 -2
  77. package/dist/device.js.map +1 -1
  78. package/dist/index.d.ts +9 -1
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/index.js +9 -1
  81. package/dist/index.js.map +1 -1
  82. package/dist/parameter-checker.d.ts +10 -13
  83. package/dist/parameter-checker.d.ts.map +1 -1
  84. package/dist/parameter-checker.js +16 -1
  85. package/dist/parameter-checker.js.map +1 -1
  86. package/dist/settings.d.ts +41 -0
  87. package/dist/settings.d.ts.map +1 -1
  88. package/dist/settings.js +43 -0
  89. package/dist/settings.js.map +1 -1
  90. package/dist/{switchbot.d.ts → switchbot-ble.d.ts} +13 -8
  91. package/dist/switchbot-ble.d.ts.map +1 -0
  92. package/dist/switchbot-ble.js +427 -0
  93. package/dist/switchbot-ble.js.map +1 -0
  94. package/dist/switchbot-openapi.d.ts +131 -0
  95. package/dist/switchbot-openapi.d.ts.map +1 -0
  96. package/dist/switchbot-openapi.js +311 -0
  97. package/dist/switchbot-openapi.js.map +1 -0
  98. package/dist/test/advertising.test.d.ts +2 -0
  99. package/dist/test/advertising.test.d.ts.map +1 -0
  100. package/dist/test/advertising.test.js +99 -0
  101. package/dist/test/advertising.test.js.map +1 -0
  102. package/dist/test/device.test.d.ts +2 -0
  103. package/dist/test/device.test.d.ts.map +1 -0
  104. package/dist/test/device.test.js +38 -0
  105. package/dist/test/device.test.js.map +1 -0
  106. package/dist/test/index.test.d.ts +2 -0
  107. package/dist/test/index.test.d.ts.map +1 -0
  108. package/dist/test/index.test.js +35 -0
  109. package/dist/test/index.test.js.map +1 -0
  110. package/dist/test/parameter-checker.test.d.ts +2 -0
  111. package/dist/test/parameter-checker.test.d.ts.map +1 -0
  112. package/dist/test/parameter-checker.test.js +108 -0
  113. package/dist/test/parameter-checker.test.js.map +1 -0
  114. package/dist/test/settings.test.d.ts +2 -0
  115. package/dist/test/settings.test.d.ts.map +1 -0
  116. package/dist/test/settings.test.js +49 -0
  117. package/dist/test/settings.test.js.map +1 -0
  118. package/dist/test/switchbot-openapi.test.d.ts +2 -0
  119. package/dist/test/switchbot-openapi.test.d.ts.map +1 -0
  120. package/dist/test/switchbot-openapi.test.js +96 -0
  121. package/dist/test/switchbot-openapi.test.js.map +1 -0
  122. package/dist/test/switchbot.test.d.ts +2 -0
  123. package/dist/test/switchbot.test.d.ts.map +1 -0
  124. package/dist/test/switchbot.test.js +106 -0
  125. package/dist/test/switchbot.test.js.map +1 -0
  126. package/dist/test/woblindtilt.test.js +70 -20
  127. package/dist/test/woblindtilt.test.js.map +1 -1
  128. package/dist/test/wobulb.test.js +87 -44
  129. package/dist/test/wobulb.test.js.map +1 -1
  130. package/dist/test/woceilinglight.test.js +72 -54
  131. package/dist/test/woceilinglight.test.js.map +1 -1
  132. package/dist/test/wocontact.test.js +51 -20
  133. package/dist/test/wocontact.test.js.map +1 -1
  134. package/dist/test/wocurtain.test.js +65 -23
  135. package/dist/test/wocurtain.test.js.map +1 -1
  136. package/dist/test/wohand.test.js +34 -40
  137. package/dist/test/wohand.test.js.map +1 -1
  138. package/dist/test/wohub2.test.d.ts +2 -0
  139. package/dist/test/wohub2.test.d.ts.map +1 -0
  140. package/dist/test/wohub2.test.js +80 -0
  141. package/dist/test/wohub2.test.js.map +1 -0
  142. package/dist/test/wohumi.test.js +70 -49
  143. package/dist/test/wohumi.test.js.map +1 -1
  144. package/dist/test/woiosensorth.test.js +33 -32
  145. package/dist/test/woiosensorth.test.js.map +1 -1
  146. package/dist/test/woplugmini.test.js +80 -57
  147. package/dist/test/woplugmini.test.js.map +1 -1
  148. package/dist/test/wopresence.test.js +44 -18
  149. package/dist/test/wopresence.test.js.map +1 -1
  150. package/dist/test/wosensorth.test.js +44 -52
  151. package/dist/test/wosensorth.test.js.map +1 -1
  152. package/dist/test/wosmartlock.test.js +126 -59
  153. package/dist/test/wosmartlock.test.js.map +1 -1
  154. package/dist/test/wosmartlockpro.test.js +96 -69
  155. package/dist/test/wosmartlockpro.test.js.map +1 -1
  156. package/dist/test/wostrip.test.js +70 -83
  157. package/dist/test/wostrip.test.js.map +1 -1
  158. package/dist/types/bledevicestatus.d.ts +4 -12
  159. package/dist/types/bledevicestatus.d.ts.map +1 -1
  160. package/dist/types/devicelist.d.ts.map +1 -1
  161. package/dist/types/devicelist.js +0 -4
  162. package/dist/types/devicelist.js.map +1 -1
  163. package/dist/types/devicepush.d.ts +13 -0
  164. package/dist/types/devicepush.d.ts.map +1 -0
  165. package/dist/types/devicepush.js +2 -0
  166. package/dist/types/devicepush.js.map +1 -0
  167. package/dist/types/deviceresponse.d.ts +2 -3
  168. package/dist/types/deviceresponse.d.ts.map +1 -1
  169. package/dist/types/devicestatus.d.ts.map +1 -1
  170. package/dist/types/devicewebhookstatus.d.ts +32 -0
  171. package/dist/types/devicewebhookstatus.d.ts.map +1 -1
  172. package/dist/types/irdevicelist.d.ts.map +1 -1
  173. package/dist/types/types.d.ts +23 -0
  174. package/dist/types/types.d.ts.map +1 -1
  175. package/dist/types/types.js +14 -0
  176. package/dist/types/types.js.map +1 -1
  177. package/docs/assets/highlight.css +12 -47
  178. package/docs/assets/main.js +1 -1
  179. package/docs/assets/navigation.js +1 -1
  180. package/docs/assets/search.js +1 -1
  181. package/docs/classes/SwitchBotBLE.html +64 -0
  182. package/docs/classes/SwitchBotOpenAPI.html +47 -0
  183. package/docs/classes/SwitchbotDevice.html +32 -33
  184. package/docs/enums/LogLevel.html +10 -0
  185. package/docs/enums/SwitchBotBLEModel.html +2 -2
  186. package/docs/enums/SwitchBotBLEModelFriendlyName.html +2 -2
  187. package/docs/enums/SwitchBotBLEModelName.html +2 -2
  188. package/docs/enums/SwitchBotModel.html +2 -2
  189. package/docs/hierarchy.html +1 -0
  190. package/docs/index.html +16 -993
  191. package/docs/interfaces/Ad-1.html +5 -0
  192. package/docs/interfaces/AdvertisementData.html +3 -0
  193. package/docs/interfaces/Chars.html +4 -0
  194. package/docs/interfaces/ErrorObject.html +3 -0
  195. package/docs/interfaces/Params.html +6 -0
  196. package/docs/interfaces/ServiceData.html +2 -0
  197. package/docs/interfaces/SwitchBotBLEDevice.html +21 -0
  198. package/docs/interfaces/WebhookDetail.html +6 -0
  199. package/docs/interfaces/ad.html +5 -0
  200. package/docs/interfaces/body.html +3 -0
  201. package/docs/interfaces/bodyChange.html +4 -0
  202. package/docs/interfaces/deleteWebhookResponse.html +4 -0
  203. package/docs/interfaces/device.html +7 -0
  204. package/docs/interfaces/deviceList.html +2 -0
  205. package/docs/interfaces/deviceStatus.html +7 -0
  206. package/docs/interfaces/deviceStatusRequest.html +4 -0
  207. package/docs/interfaces/deviceWebhook.html +4 -0
  208. package/docs/interfaces/deviceWebhookContext.html +4 -0
  209. package/docs/interfaces/devices.html +4 -0
  210. package/docs/interfaces/infraredRemoteList.html +2 -0
  211. package/docs/interfaces/irdevice.html +5 -0
  212. package/docs/interfaces/pushResponse.html +4 -0
  213. package/docs/interfaces/queryWebhookResponse.html +4 -0
  214. package/docs/interfaces/setupWebhookResponse.html +4 -0
  215. package/docs/interfaces/switchbot.html +3 -0
  216. package/docs/interfaces/updateWebhookResponse.html +4 -0
  217. package/docs/interfaces/webhookRequest.html +4 -0
  218. package/docs/media/BLE.md +1109 -0
  219. package/docs/media/OpenAPI.md +185 -0
  220. package/docs/modules.html +136 -3
  221. package/docs/types/MacAddress.html +1 -0
  222. package/docs/types/batteryCirculatorFan.html +1 -0
  223. package/docs/types/batteryCirculatorFanServiceData.html +1 -0
  224. package/docs/types/batteryCirculatorFanStatus.html +1 -0
  225. package/docs/types/batteryCirculatorFanWebhookContext.html +1 -0
  226. package/docs/types/blindTilt.html +1 -0
  227. package/docs/types/blindTiltServiceData.html +1 -0
  228. package/docs/types/blindTiltStatus.html +1 -0
  229. package/docs/types/blindTiltWebhookContext.html +1 -0
  230. package/docs/types/bot.html +1 -0
  231. package/docs/types/botServiceData.html +1 -0
  232. package/docs/types/botStatus.html +1 -0
  233. package/docs/types/botWebhookContext.html +1 -0
  234. package/docs/types/ceilingLight.html +1 -0
  235. package/docs/types/ceilingLightPro.html +1 -0
  236. package/docs/types/ceilingLightProServiceData.html +1 -0
  237. package/docs/types/ceilingLightProStatus.html +1 -0
  238. package/docs/types/ceilingLightProWebhookContext.html +1 -0
  239. package/docs/types/ceilingLightServiceData.html +1 -0
  240. package/docs/types/ceilingLightStatus.html +1 -0
  241. package/docs/types/ceilingLightWebhookContext.html +1 -0
  242. package/docs/types/colorBulb.html +1 -0
  243. package/docs/types/colorBulbServiceData.html +1 -0
  244. package/docs/types/colorBulbStatus.html +1 -0
  245. package/docs/types/colorBulbWebhookContext.html +1 -0
  246. package/docs/types/contactSensor.html +1 -0
  247. package/docs/types/contactSensorServiceData.html +1 -0
  248. package/docs/types/contactSensorStatus.html +1 -0
  249. package/docs/types/contactSensorWebhookContext.html +1 -0
  250. package/docs/types/curtain.html +1 -0
  251. package/docs/types/curtain3.html +1 -0
  252. package/docs/types/curtain3ServiceData.html +1 -0
  253. package/docs/types/curtain3WebhookContext.html +1 -0
  254. package/docs/types/curtainServiceData.html +1 -0
  255. package/docs/types/curtainStatus.html +1 -0
  256. package/docs/types/curtainWebhookContext.html +1 -0
  257. package/docs/types/floorCleaningRobotS10.html +1 -0
  258. package/docs/types/floorCleaningRobotS10Status.html +1 -0
  259. package/docs/types/floorCleaningRobotS10WebhookContext.html +1 -0
  260. package/docs/types/hub2.html +1 -0
  261. package/docs/types/hub2ServiceData.html +1 -0
  262. package/docs/types/hub2Status.html +1 -0
  263. package/docs/types/hub2WebhookContext.html +1 -0
  264. package/docs/types/humidifier.html +1 -0
  265. package/docs/types/humidifierServiceData.html +1 -0
  266. package/docs/types/humidifierStatus.html +1 -0
  267. package/docs/types/humidifierWebhookContext.html +1 -0
  268. package/docs/types/indoorCam.html +1 -0
  269. package/docs/types/indoorCameraWebhookContext.html +1 -0
  270. package/docs/types/keypad.html +1 -0
  271. package/docs/types/keypadTouch.html +1 -0
  272. package/docs/types/keypadTouchWebhookContext.html +1 -0
  273. package/docs/types/keypadWebhookContext.html +1 -0
  274. package/docs/types/lock.html +1 -0
  275. package/docs/types/lockPro.html +1 -0
  276. package/docs/types/lockProServiceData.html +1 -0
  277. package/docs/types/lockProStatus.html +1 -0
  278. package/docs/types/lockProWebhookContext.html +1 -0
  279. package/docs/types/lockServiceData.html +1 -0
  280. package/docs/types/lockStatus.html +1 -0
  281. package/docs/types/lockWebhookContext.html +1 -0
  282. package/docs/types/meter.html +1 -0
  283. package/docs/types/meterPlus.html +1 -0
  284. package/docs/types/meterPlusServiceData.html +1 -0
  285. package/docs/types/meterPlusStatus.html +1 -0
  286. package/docs/types/meterPlusWebhookContext.html +1 -0
  287. package/docs/types/meterServiceData.html +1 -0
  288. package/docs/types/meterStatus.html +1 -0
  289. package/docs/types/meterWebhookContext.html +1 -0
  290. package/docs/types/motionSensor.html +1 -0
  291. package/docs/types/motionSensorServiceData.html +1 -0
  292. package/docs/types/motionSensorStatus.html +1 -0
  293. package/docs/types/motionSensorWebhookContext.html +1 -0
  294. package/docs/types/outdoorMeter.html +1 -0
  295. package/docs/types/outdoorMeterServiceData.html +1 -0
  296. package/docs/types/outdoorMeterStatus.html +1 -0
  297. package/docs/types/outdoorMeterWebhookContext.html +1 -0
  298. package/docs/types/panTiltCamWebhookContext.html +1 -0
  299. package/docs/types/pantiltCam.html +1 -0
  300. package/docs/types/pantiltCam2k.html +1 -0
  301. package/docs/types/plug.html +1 -0
  302. package/docs/types/plugMini.html +1 -0
  303. package/docs/types/plugMiniJPServiceData.html +1 -0
  304. package/docs/types/plugMiniJPWebhookContext.html +1 -0
  305. package/docs/types/plugMiniStatus.html +1 -0
  306. package/docs/types/plugMiniUSServiceData.html +1 -0
  307. package/docs/types/plugMiniUSWebhookContext.html +1 -0
  308. package/docs/types/plugStatus.html +1 -0
  309. package/docs/types/plugWebhookContext.html +1 -0
  310. package/docs/types/remote.html +1 -0
  311. package/docs/types/robotVacuumCleanerS1.html +1 -0
  312. package/docs/types/robotVacuumCleanerS1Plus.html +1 -0
  313. package/docs/types/robotVacuumCleanerS1PlusStatus.html +1 -0
  314. package/docs/types/robotVacuumCleanerS1PlusWebhookContext.html +1 -0
  315. package/docs/types/robotVacuumCleanerS1Status.html +1 -0
  316. package/docs/types/robotVacuumCleanerS1WebhookContext.html +1 -0
  317. package/docs/types/robotVacuumCleanerServiceData.html +1 -0
  318. package/docs/types/stripLight.html +1 -0
  319. package/docs/types/stripLightServiceData.html +1 -0
  320. package/docs/types/stripLightStatus.html +1 -0
  321. package/docs/types/stripLightWebhookContext.html +1 -0
  322. package/docs/types/waterLeakDetector.html +1 -0
  323. package/docs/types/waterLeakDetectorServiceData.html +1 -0
  324. package/docs/types/waterLeakDetectorStatus.html +1 -0
  325. package/docs/types/waterLeakDetectorWebhookContext.html +1 -0
  326. package/package.json +13 -11
  327. package/.github/npm-version-script.cjs +0 -81
  328. package/dist/switchbot.d.ts.map +0 -1
  329. package/dist/switchbot.js +0 -259
  330. package/dist/switchbot.js.map +0 -1
  331. package/dist/test/wohand2.test.d.ts +0 -2
  332. package/dist/test/wohand2.test.d.ts.map +0 -1
  333. package/dist/test/wohand2.test.js +0 -50
  334. package/dist/test/wohand2.test.js.map +0 -1
  335. package/dist/types/pushbody.d.ts +0 -6
  336. package/dist/types/pushbody.d.ts.map +0 -1
  337. package/dist/types/pushbody.js +0 -2
  338. package/dist/types/pushbody.js.map +0 -1
  339. package/docs/classes/SwitchBot.html +0 -16
  340. package/docs/types/SwitchBotBLEDevice.html +0 -1
@@ -0,0 +1,427 @@
1
+ import { EventEmitter } from 'node:events';
2
+ import { Advertising } from './advertising.js';
3
+ import { SwitchbotDevice } from './device.js';
4
+ import { WoBlindTilt } from './device/woblindtilt.js';
5
+ import { WoBulb } from './device/wobulb.js';
6
+ import { WoCeilingLight } from './device/woceilinglight.js';
7
+ import { WoContact } from './device/wocontact.js';
8
+ import { WoCurtain } from './device/wocurtain.js';
9
+ import { WoHand } from './device/wohand.js';
10
+ import { WoHub2 } from './device/wohub2.js';
11
+ import { WoHumi } from './device/wohumi.js';
12
+ import { WoIOSensorTH } from './device/woiosensorth.js';
13
+ import { WoPlugMini } from './device/woplugmini.js';
14
+ import { WoPresence } from './device/wopresence.js';
15
+ import { WoSensorTH } from './device/wosensorth.js';
16
+ import { WoSmartLock } from './device/wosmartlock.js';
17
+ import { WoSmartLockPro } from './device/wosmartlockpro.js';
18
+ import { WoStrip } from './device/wostrip.js';
19
+ import { parameterChecker } from './parameter-checker.js';
20
+ import { SwitchBotBLEModel } from './types/types.js';
21
+ /**
22
+ * SwitchBot class to interact with SwitchBot devices.
23
+ */
24
+ export class SwitchBotBLE extends EventEmitter {
25
+ ready;
26
+ noble;
27
+ ondiscover;
28
+ onadvertisement;
29
+ DEFAULT_DISCOVERY_DURATION = 5000;
30
+ PRIMARY_SERVICE_UUID_LIST = [];
31
+ /**
32
+ * Constructor
33
+ *
34
+ * @param {Params} [params] - Optional parameters
35
+ */
36
+ constructor(params) {
37
+ super();
38
+ this.ready = this.init(params);
39
+ }
40
+ /**
41
+ * Emits a log event with the specified log level and message.
42
+ *
43
+ * @param level - The severity level of the log (e.g., 'info', 'warn', 'error').
44
+ * @param message - The log message to be emitted.
45
+ */
46
+ async emitLog(level, message) {
47
+ this.emit('log', { level, message });
48
+ }
49
+ /**
50
+ * Initializes the noble object.
51
+ *
52
+ * @param {Params} [params] - Optional parameters
53
+ * @returns {Promise<void>} - Resolves when initialization is complete
54
+ */
55
+ async init(params) {
56
+ let noble;
57
+ if (params && params.noble) {
58
+ noble = params.noble;
59
+ }
60
+ else {
61
+ noble = (await import('@stoprocent/noble')).default;
62
+ }
63
+ // Public properties
64
+ this.noble = noble;
65
+ }
66
+ /**
67
+ * Discover SwitchBot devices based on the provided parameters.
68
+ *
69
+ * @param {Params} params - The parameters for discovery.
70
+ * @returns {Promise<SwitchbotDevice[]>} - A promise that resolves with a list of discovered devices.
71
+ */
72
+ async discover(params = {}) {
73
+ const promise = new Promise((resolve, reject) => {
74
+ // Check the parameters
75
+ const valid = parameterChecker.check(params, {
76
+ duration: { required: false, type: 'integer', min: 1, max: 60000 },
77
+ model: {
78
+ required: false,
79
+ type: 'string',
80
+ enum: [
81
+ SwitchBotBLEModel.Bot,
82
+ SwitchBotBLEModel.Curtain,
83
+ SwitchBotBLEModel.Curtain3,
84
+ SwitchBotBLEModel.Humidifier,
85
+ SwitchBotBLEModel.Meter,
86
+ SwitchBotBLEModel.MeterPlus,
87
+ SwitchBotBLEModel.Hub2,
88
+ SwitchBotBLEModel.OutdoorMeter,
89
+ SwitchBotBLEModel.MotionSensor,
90
+ SwitchBotBLEModel.ContactSensor,
91
+ SwitchBotBLEModel.ColorBulb,
92
+ SwitchBotBLEModel.CeilingLight,
93
+ SwitchBotBLEModel.CeilingLightPro,
94
+ SwitchBotBLEModel.StripLight,
95
+ SwitchBotBLEModel.PlugMiniUS,
96
+ SwitchBotBLEModel.PlugMiniJP,
97
+ SwitchBotBLEModel.Lock,
98
+ SwitchBotBLEModel.LockPro,
99
+ SwitchBotBLEModel.BlindTilt,
100
+ ],
101
+ },
102
+ id: { required: false, type: 'string', min: 12, max: 17 },
103
+ quick: { required: false, type: 'boolean' },
104
+ }, false);
105
+ if (!valid) {
106
+ this.emitLog('error', `parameterChecker: ${JSON.stringify(parameterChecker.error.message)}`);
107
+ reject(new Error(parameterChecker.error.message));
108
+ return;
109
+ }
110
+ if (!params) {
111
+ params = {};
112
+ }
113
+ // Determine the values of the parameters
114
+ const p = {
115
+ duration: params.duration || this.DEFAULT_DISCOVERY_DURATION,
116
+ model: params.model || '',
117
+ id: params.id || '',
118
+ quick: !!params.quick,
119
+ };
120
+ // Initialize the noble object
121
+ this._init()
122
+ .then(() => {
123
+ if (this.noble === null) {
124
+ return reject(new Error('noble failed to initialize'));
125
+ }
126
+ const peripherals = {};
127
+ let timer = setTimeout(() => { }, 0);
128
+ const finishDiscovery = () => {
129
+ if (timer) {
130
+ clearTimeout(timer);
131
+ }
132
+ this.noble.removeAllListeners('discover');
133
+ this.noble.stopScanningAsync();
134
+ const device_list = [];
135
+ for (const addr in peripherals) {
136
+ device_list.push(peripherals[addr]);
137
+ }
138
+ resolve(device_list);
139
+ };
140
+ // Set a handler for the 'discover' event
141
+ this.noble.on('discover', async (peripheral) => {
142
+ const device = await this.getDeviceObject(peripheral, p.id, p.model);
143
+ if (!device) {
144
+ return;
145
+ }
146
+ const id = device.id;
147
+ peripherals[id] = device;
148
+ if (this.ondiscover && typeof this.ondiscover === 'function') {
149
+ this.ondiscover(device);
150
+ }
151
+ if (p.quick) {
152
+ finishDiscovery();
153
+ }
154
+ });
155
+ // Start scanning
156
+ this.noble.startScanningAsync(this.PRIMARY_SERVICE_UUID_LIST, false).then(() => {
157
+ timer = setTimeout(() => {
158
+ finishDiscovery();
159
+ }, p.duration);
160
+ }).catch((error) => {
161
+ reject(error);
162
+ });
163
+ })
164
+ .catch((error) => {
165
+ reject(error);
166
+ });
167
+ });
168
+ return promise;
169
+ }
170
+ /**
171
+ * Initializes the noble object and waits for it to be powered on.
172
+ *
173
+ * @returns {Promise<void>} - Resolves when the noble object is powered on.
174
+ */
175
+ async _init() {
176
+ await this.ready;
177
+ const promise = new Promise((resolve, reject) => {
178
+ let err;
179
+ if (this.noble._state === 'poweredOn') {
180
+ resolve();
181
+ return;
182
+ }
183
+ this.noble.once('stateChange', (state) => {
184
+ switch (state) {
185
+ case 'unsupported':
186
+ case 'unauthorized':
187
+ case 'poweredOff':
188
+ err = new Error(`Failed to initialize the Noble object: ${this.noble._state}`);
189
+ reject(err);
190
+ return;
191
+ case 'resetting':
192
+ case 'unknown':
193
+ err = new Error(`Adapter is not ready: ${this.noble._state}`);
194
+ reject(err);
195
+ return;
196
+ case 'poweredOn':
197
+ resolve();
198
+ return;
199
+ default:
200
+ err = new Error(`Unknown state: ${this.noble._state}`);
201
+ reject(err);
202
+ }
203
+ });
204
+ });
205
+ return promise;
206
+ }
207
+ /**
208
+ * Gets the device object based on the peripheral, id, and model.
209
+ *
210
+ * @param {Noble.Peripheral} peripheral - The peripheral object.
211
+ * @param {string} id - The device id.
212
+ * @param {string} model - The device model.
213
+ * @returns {Promise<SwitchbotDevice | null>} - The device object or null.
214
+ */
215
+ async getDeviceObject(peripheral, id, model) {
216
+ const ad = await Advertising.parse(peripheral, this.emitLog.bind(this));
217
+ if (ad && await this.filterAdvertising(ad, id, model)) {
218
+ let device;
219
+ if (ad && ad.serviceData && ad.serviceData.model) {
220
+ switch (ad.serviceData.model) {
221
+ case SwitchBotBLEModel.Bot:
222
+ device = new WoHand(peripheral, this.noble);
223
+ break;
224
+ case SwitchBotBLEModel.Curtain:
225
+ case SwitchBotBLEModel.Curtain3:
226
+ device = new WoCurtain(peripheral, this.noble);
227
+ break;
228
+ case SwitchBotBLEModel.Humidifier:
229
+ device = new WoHumi(peripheral, this.noble);
230
+ break;
231
+ case SwitchBotBLEModel.Meter:
232
+ device = new WoSensorTH(peripheral, this.noble);
233
+ break;
234
+ case SwitchBotBLEModel.MeterPlus:
235
+ device = new WoSensorTH(peripheral, this.noble);
236
+ break;
237
+ case SwitchBotBLEModel.Hub2:
238
+ device = new WoHub2(peripheral, this.noble);
239
+ break;
240
+ case SwitchBotBLEModel.OutdoorMeter:
241
+ device = new WoIOSensorTH(peripheral, this.noble);
242
+ break;
243
+ case SwitchBotBLEModel.MotionSensor:
244
+ device = new WoPresence(peripheral, this.noble);
245
+ break;
246
+ case SwitchBotBLEModel.ContactSensor:
247
+ device = new WoContact(peripheral, this.noble);
248
+ break;
249
+ case SwitchBotBLEModel.ColorBulb:
250
+ device = new WoBulb(peripheral, this.noble);
251
+ break;
252
+ case SwitchBotBLEModel.CeilingLight:
253
+ device = new WoCeilingLight(peripheral, this.noble);
254
+ break;
255
+ case SwitchBotBLEModel.CeilingLightPro:
256
+ device = new WoCeilingLight(peripheral, this.noble);
257
+ break;
258
+ case SwitchBotBLEModel.StripLight:
259
+ device = new WoStrip(peripheral, this.noble);
260
+ break;
261
+ case SwitchBotBLEModel.PlugMiniUS:
262
+ case SwitchBotBLEModel.PlugMiniJP:
263
+ device = new WoPlugMini(peripheral, this.noble);
264
+ break;
265
+ case SwitchBotBLEModel.Lock:
266
+ device = new WoSmartLock(peripheral, this.noble);
267
+ break;
268
+ case SwitchBotBLEModel.LockPro:
269
+ device = new WoSmartLockPro(peripheral, this.noble);
270
+ break;
271
+ case SwitchBotBLEModel.BlindTilt:
272
+ device = new WoBlindTilt(peripheral, this.noble);
273
+ break;
274
+ default: // 'resetting', 'unknown'
275
+ device = new SwitchbotDevice(peripheral, this.noble);
276
+ }
277
+ }
278
+ return device || null;
279
+ }
280
+ else {
281
+ return null;
282
+ }
283
+ }
284
+ /**
285
+ * Filters advertising data based on id and model.
286
+ *
287
+ * @param {Ad} ad - The advertising data.
288
+ * @param {string} id - The device id.
289
+ * @param {string} model - The device model.
290
+ * @returns {boolean} - True if the advertising data matches the id and model, false otherwise.
291
+ */
292
+ async filterAdvertising(ad, id, model) {
293
+ if (!ad) {
294
+ return false;
295
+ }
296
+ if (id) {
297
+ id = id.toLowerCase().replace(/:/g, '');
298
+ const ad_id = ad.address.toLowerCase().replace(/[^a-z0-9]/g, '');
299
+ if (ad_id !== id) {
300
+ return false;
301
+ }
302
+ }
303
+ if (model) {
304
+ if (ad.serviceData.model !== model) {
305
+ return false;
306
+ }
307
+ }
308
+ return true;
309
+ }
310
+ /**
311
+ * Starts scanning for SwitchBot devices.
312
+ *
313
+ * @param {Params} [params] - Optional parameters.
314
+ * @returns {Promise<void>} - Resolves when scanning starts successfully.
315
+ */
316
+ async startScan(params = {}) {
317
+ const promise = new Promise((resolve, reject) => {
318
+ // Check the parameters
319
+ const valid = parameterChecker.check(params, {
320
+ model: {
321
+ required: false,
322
+ type: 'string',
323
+ enum: [
324
+ SwitchBotBLEModel.Bot,
325
+ SwitchBotBLEModel.Curtain,
326
+ SwitchBotBLEModel.Curtain3,
327
+ SwitchBotBLEModel.Humidifier,
328
+ SwitchBotBLEModel.Meter,
329
+ SwitchBotBLEModel.MeterPlus,
330
+ SwitchBotBLEModel.Hub2,
331
+ SwitchBotBLEModel.OutdoorMeter,
332
+ SwitchBotBLEModel.MotionSensor,
333
+ SwitchBotBLEModel.ContactSensor,
334
+ SwitchBotBLEModel.ColorBulb,
335
+ SwitchBotBLEModel.CeilingLight,
336
+ SwitchBotBLEModel.CeilingLightPro,
337
+ SwitchBotBLEModel.StripLight,
338
+ SwitchBotBLEModel.PlugMiniUS,
339
+ SwitchBotBLEModel.PlugMiniJP,
340
+ SwitchBotBLEModel.Lock,
341
+ SwitchBotBLEModel.LockPro,
342
+ SwitchBotBLEModel.BlindTilt,
343
+ ],
344
+ },
345
+ id: { required: false, type: 'string', min: 12, max: 17 },
346
+ }, false);
347
+ if (!valid) {
348
+ this.emitLog('error', `parameterChecker: ${JSON.stringify(parameterChecker.error.message)}`);
349
+ reject(new Error(parameterChecker.error.message));
350
+ return;
351
+ }
352
+ // Initialize the noble object
353
+ this._init()
354
+ .then(() => {
355
+ if (this.noble === null) {
356
+ return reject(new Error('noble object failed to initialize'));
357
+ }
358
+ // Determine the values of the parameters
359
+ const p = {
360
+ model: params.model || '',
361
+ id: params.id || '',
362
+ };
363
+ // Set a handler for the 'discover' event
364
+ this.noble.on('discover', async (peripheral) => {
365
+ const ad = await Advertising.parse(peripheral, this.emitLog.bind(this));
366
+ if (ad && await this.filterAdvertising(ad, p.id, p.model)) {
367
+ if (this.onadvertisement
368
+ && typeof this.onadvertisement === 'function') {
369
+ this.onadvertisement(ad);
370
+ }
371
+ }
372
+ });
373
+ // Start scanning
374
+ this.noble.startScanningAsync(this.PRIMARY_SERVICE_UUID_LIST, true).then(() => {
375
+ this.emitLog('info', 'Started Scanning for SwitchBot BLE devices.');
376
+ resolve();
377
+ }).catch((error) => {
378
+ this.emitLog('error', `startScanning error: ${JSON.stringify(error.message)}`);
379
+ reject(error);
380
+ });
381
+ })
382
+ .catch((error) => {
383
+ this.emitLog('error', `startScanning error: ${JSON.stringify(error.message)}`);
384
+ reject(error);
385
+ });
386
+ });
387
+ return promise;
388
+ }
389
+ /**
390
+ * Stops scanning for SwitchBot devices.
391
+ *
392
+ * @returns {Promise<void>} - Resolves when scanning stops successfully.
393
+ */
394
+ async stopScan() {
395
+ if (this.noble === null) {
396
+ return;
397
+ }
398
+ this.noble.removeAllListeners('discover');
399
+ this.noble.stopScanningAsync();
400
+ this.emitLog('info', 'Stopped Scanning for SwitchBot BLE devices.');
401
+ }
402
+ /**
403
+ * Waits for the specified time.
404
+ *
405
+ * @param {number} msec - The time to wait in milliseconds.
406
+ * @returns {Promise<void>} - Resolves after the specified time.
407
+ */
408
+ async wait(msec) {
409
+ return new Promise((resolve, reject) => {
410
+ // Check the parameters
411
+ const valid = parameterChecker.check({
412
+ msec,
413
+ }, {
414
+ msec: { required: true, type: 'integer', min: 0 },
415
+ }, true);
416
+ if (!valid) {
417
+ this.emitLog('error', `parameterChecker: ${JSON.stringify(parameterChecker.error.message)}`);
418
+ reject(new Error(parameterChecker.error.message));
419
+ return;
420
+ }
421
+ // Set a timer
422
+ setTimeout(resolve, msec);
423
+ });
424
+ }
425
+ }
426
+ export { SwitchbotDevice };
427
+ //# sourceMappingURL=switchbot-ble.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switchbot-ble.js","sourceRoot":"","sources":["../src/switchbot-ble.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,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B,CAAC,KAAM,CAAC,OAAO,CAAC,CAAC,CAAA;gBAClD,OAAM;YACR,CAAC;YACD,cAAc;YACd,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QAC3B,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AAED,OAAO,EAAE,eAAe,EAAE,CAAA"}
@@ -0,0 +1,131 @@
1
+ import type { Server } from 'node:http';
2
+ import type { pushResponse } from './types/devicepush.js';
3
+ import type { devices } from './types/deviceresponse.js';
4
+ import type { deviceStatus } from './types/devicestatus.js';
5
+ import { EventEmitter } from 'node:events';
6
+ /**
7
+ * The `SwitchBotOpenAPI` class provides methods to interact with the SwitchBot OpenAPI.
8
+ * It allows you to retrieve device information, control devices, and manage webhooks.
9
+ *
10
+ * @extends EventEmitter
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const switchBotAPI = new SwitchBotOpenAPI('your-token', 'your-secret');
15
+ *
16
+ * // Get devices
17
+ * switchBotAPI.getDevices().then(response => {
18
+ * console.log(response);
19
+ * }).catch(error => {
20
+ * console.error(error);
21
+ * });
22
+ *
23
+ * // Control a device
24
+ * switchBotAPI.controlDevice('device-id', 'turnOn', 'default').then(response => {
25
+ * console.log(response);
26
+ * }).catch(error => {
27
+ * console.error(error);
28
+ * });
29
+ *
30
+ * // Setup webhook
31
+ * switchBotAPI.setupWebhook('http://your-webhook-url').then(() => {
32
+ * console.log('Webhook setup successfully');
33
+ * }).catch(error => {
34
+ * console.error(error);
35
+ * });
36
+ * ```
37
+ *
38
+ * @param {string} token - The API token used for authentication.
39
+ * @param {string} secret - The secret key used for signing requests.
40
+ */
41
+ export declare class SwitchBotOpenAPI extends EventEmitter {
42
+ private token;
43
+ private secret;
44
+ private baseURL;
45
+ webhookEventListener?: Server | null;
46
+ /**
47
+ * Creates an instance of the SwitchBot OpenAPI client.
48
+ *
49
+ * @param token - The API token used for authentication.
50
+ * @param secret - The secret key used for signing requests.
51
+ */
52
+ constructor(token: string, secret: string);
53
+ /**
54
+ * Emits a log event with the specified log level and message.
55
+ *
56
+ * @param level - The severity level of the log (e.g., 'info', 'warn', 'error').
57
+ * @param message - The log message to be emitted.
58
+ */
59
+ private emitLog;
60
+ /**
61
+ * Retrieves the list of devices from the SwitchBot OpenAPI.
62
+ *
63
+ * @returns {Promise<{ response: body, statusCode: number }>} A promise that resolves to an object containing the API response.
64
+ * @throws {Error} Throws an error if the request to get devices fails.
65
+ */
66
+ getDevices(): Promise<{
67
+ response: devices;
68
+ statusCode: number;
69
+ }>;
70
+ /**
71
+ * Controls a device by sending a command to the SwitchBot API.
72
+ *
73
+ * @param deviceId - The unique identifier of the device to control.
74
+ * @param command - The command to send to the device.
75
+ * @param parameter - The parameter for the command.
76
+ * @param commandType - The type of the command, defaults to 'command'.
77
+ * @returns {Promise<{ response: pushResponse['body'], statusCode: number }>} A promise that resolves to an object containing the API response.
78
+ * @throws An error if the device control fails.
79
+ */
80
+ controlDevice(deviceId: string, command: string, parameter: string, commandType?: string): Promise<{
81
+ response: pushResponse['body'];
82
+ statusCode: number;
83
+ }>;
84
+ /**
85
+ * Retrieves the status of a specific device.
86
+ *
87
+ * @param deviceId - The unique identifier of the device.
88
+ * @returns {Promise<{ response: deviceStatus, statusCode: number }>} A promise that resolves to the device status.
89
+ * @throws An error if the request fails.
90
+ */
91
+ getDeviceStatus(deviceId: string): Promise<{
92
+ response: deviceStatus;
93
+ statusCode: number;
94
+ }>;
95
+ /**
96
+ * Generates the headers required for authentication with the SwitchBot OpenAPI.
97
+ *
98
+ * @returns An object containing the following headers:
99
+ * - `Authorization`: The token used for authorization.
100
+ * - `sign`: The HMAC-SHA256 signature of the concatenated token, timestamp, and nonce.
101
+ * - `nonce`: A unique identifier for the request, formatted as a UUID.
102
+ * - `t`: The current timestamp in milliseconds since the Unix epoch.
103
+ * - `Content-Type`: The content type of the request, set to `application/json`.
104
+ */
105
+ private generateHeaders;
106
+ /**
107
+ * Sets up a webhook listener and configures the webhook on the server.
108
+ *
109
+ * This method performs the following steps:
110
+ * 1. Creates a local server to listen for incoming webhook events.
111
+ * 2. Sends a request to set up the webhook with the provided URL.
112
+ * 3. Sends a request to update the webhook configuration.
113
+ * 4. Sends a request to query the current webhook URL.
114
+ *
115
+ * @param url - The URL to which the webhook events will be sent.
116
+ * @returns A promise that resolves when the webhook setup is complete.
117
+ *
118
+ * @throws Will log an error if any step in the webhook setup process fails.
119
+ */
120
+ setupWebhook(url: string): Promise<void>;
121
+ /**
122
+ * Deletes a webhook by sending a request to the specified URL.
123
+ *
124
+ * @param url - The URL of the webhook to be deleted.
125
+ * @returns A promise that resolves when the webhook is successfully deleted.
126
+ *
127
+ * @throws Will log an error if the deletion fails.
128
+ */
129
+ deleteWebhook(url: string): Promise<void>;
130
+ }
131
+ //# sourceMappingURL=switchbot-openapi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switchbot-openapi.d.ts","sourceRoot":"","sources":["../src/switchbot-openapi.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAmB,MAAM,EAAkB,MAAM,WAAW,CAAA;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAK3D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAO1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,qBAAa,gBAAiB,SAAQ,YAAY;IAChD,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,OAAO,CAAQ;IAEvB,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAO;IAE3C;;;;;OAKG;gBACS,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAOzC;;;;;OAKG;YACW,OAAO;IAIrB;;;;;OAKG;IACG,UAAU,IAA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