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
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/)
4
4
 
5
+ ## [3.0.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v3.0.0) (2024-10-05)
6
+
7
+ ### What's Changed
8
+ #### ⚠️ Breaking Changes
9
+ - Have added OpenAPI Functionality into `node-switchbot`, so now it is able to handle both APIs with just one module.
10
+ - There are now two different Classes `SwitchBotBLE` and `SwitchBotOpenAPI` that can be used interact with the two different APIs
11
+ - You will need to update your current setup from`SwitchBot` to `SwitchBotBLE` to be able to interact with the BLE API
12
+ - Updated the documents to explain both the `BLE` and the `OpenAPI` Functionality within `node-switchbot`
13
+
14
+ #### Other Changes
15
+ - Housekeeping and update dependencies
16
+
17
+ **Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v2.4.0...v3.0.0
18
+
5
19
  ## [2.4.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v2.4.0) (2024-09-13)
6
20
 
7
21
  ### What's Changed
package/OpenAPI.md ADDED
@@ -0,0 +1,185 @@
1
+ # SwitchBot OpenAPI Documentation
2
+
3
+ The `SwitchBotOpenAPI` class allows you to interact with SwitchBot devices using the SwitchBot OpenAPI. This documentation provides an overview of how to install, set up, and use the various methods available in the `SwitchBotOpenAPI` class.
4
+
5
+ ## Table of Contents
6
+
7
+ - [OpenAPI](#openapi)
8
+ - [Importing and Setting Up](#importing-and-setting-up)
9
+ - [`SwitchBotOpenAPI` Object](#switchbotopenapi-object)
10
+ - [`getDevices()` Method](#getdevices-method)
11
+ - [`controlDevice()` Method](#controldevice-method)
12
+ - [`getDeviceStatus()` Method](#getdevicestatus-method)
13
+ - [`setupWebhook()` Method](#setupwebhook-method)
14
+ - [`deleteWebhook()` Method](#deletewebhook-method)
15
+ - [Logging](#logging)
16
+ - [Supported Devices](#supported-devices)
17
+
18
+ ## OpenAPI
19
+
20
+ ### Importing and Setting Up
21
+
22
+ To use the `SwitchBotOpenAPI` class, you need to import it and create an instance with your SwitchBot token and secret.
23
+
24
+ ```typescript
25
+ import { SwitchBotOpenAPI } from 'node-switchbot'
26
+
27
+ const switchBotAPI = new SwitchBotOpenAPI('your-token', 'your-secret')
28
+
29
+ // Example usage
30
+ switchBotAPI.getDevices().then((devices) => {
31
+ console.log('Devices:', devices)
32
+ }).catch((error) => {
33
+ console.error('Error getting devices:', error)
34
+ })
35
+ ```
36
+
37
+ ### SwitchBotOpenAPI Object
38
+
39
+ The `SwitchBotOpenAPI` object provides several methods to interact with SwitchBot devices. Below are examples of how to use each method.
40
+
41
+ #### `getDevices()` Method
42
+
43
+ Fetches the list of devices associated with your SwitchBot account.
44
+
45
+ ```typescript
46
+ async function getDevices() {
47
+ try {
48
+ const devices = await switchBotAPI.getDevices()
49
+ console.log('Devices:', devices)
50
+ } catch (error) {
51
+ console.error('Error getting devices:', error)
52
+ }
53
+ }
54
+
55
+ // Example usage
56
+ getDevices()
57
+ ```
58
+
59
+ #### `controlDevice()` Method
60
+
61
+ Sends a command to control a specific device.
62
+
63
+ ```typescript
64
+ async function controlDevice(deviceId, command, parameter) {
65
+ try {
66
+ const response = await switchBotAPI.controlDevice(deviceId, command, parameter)
67
+ console.log('Control Device Response:', response)
68
+ } catch (error) {
69
+ console.error('Error controlling device:', error)
70
+ }
71
+ }
72
+
73
+ // Example usage
74
+ controlDevice('your-device-id', 'turnOn', 'default')
75
+ ```
76
+
77
+ #### `getDeviceStatus()` Method
78
+
79
+ Fetches the current status of a specific device.
80
+
81
+ ```typescript
82
+ async function getDeviceStatus(deviceId) {
83
+ try {
84
+ const status = await switchBotAPI.getDeviceStatus(deviceId)
85
+ console.log('Device Status:', status)
86
+ } catch (error) {
87
+ console.error('Error getting device status:', error)
88
+ }
89
+ }
90
+
91
+ // Example usage
92
+ getDeviceStatus('your-device-id')
93
+ ```
94
+
95
+ #### `setupWebhook()` Method
96
+
97
+ Sets up a webhook to receive events from SwitchBot devices.
98
+
99
+ ```typescript
100
+ async function setupWebhook(url) {
101
+ try {
102
+ await switchBotAPI.setupWebhook(url)
103
+ console.log('Webhook setup successfully')
104
+ } catch (error) {
105
+ console.error('Error setting up webhook:', error)
106
+ }
107
+ }
108
+
109
+ // Example usage
110
+ setupWebhook('http://your-webhook-url')
111
+ ```
112
+
113
+ #### `deleteWebhook()` Method
114
+
115
+ Deletes an existing webhook.
116
+
117
+ ```typescript
118
+ async function deleteWebhook(url) {
119
+ try {
120
+ await switchBotAPI.deleteWebhook(url)
121
+ console.log('Webhook deleted successfully')
122
+ } catch (error) {
123
+ console.error('Error deleting webhook:', error)
124
+ }
125
+ }
126
+
127
+ // Example usage
128
+ deleteWebhook('http://your-webhook-url')
129
+ ```
130
+
131
+ ### Logging
132
+
133
+ To be able to receive logging that this module is pushing out you will need to subscribt to the events.
134
+
135
+ ```typescript
136
+ this.switchBotAPI.on('log', (log) => {
137
+ switch (log.level) {
138
+ case LogLevel.SUCCESS:
139
+ this.successLog(log.message)
140
+ break
141
+ case LogLevel.DEBUGSUCCESS:
142
+ this.debugSuccessLog(log.message)
143
+ break
144
+ case LogLevel.WARN:
145
+ this.warnLog(log.message)
146
+ break
147
+ case LogLevel.DEBUGWARN:
148
+ this.debugWarnLog(log.message)
149
+ break
150
+ case LogLevel.ERROR:
151
+ this.errorLog(log.message)
152
+ break
153
+ case LogLevel.DEBUGERROR:
154
+ this.debugErrorLog(log.message)
155
+ break
156
+ case LogLevel.DEBUG:
157
+ this.debugLog(log.message)
158
+ break
159
+ case LogLevel.INFO:
160
+ default:
161
+ this.infoLog(log.message)
162
+ }
163
+ })
164
+ ```
165
+
166
+ ### Supported Devices
167
+
168
+ The following devices are supported.
169
+
170
+ | Device | OpenAPI Support | Webhook Support |
171
+ | ------------------------- | --------------- | --------------- |
172
+ | SwitchBot Bot | Yes | Yes |
173
+ | SwitchBot Curtain | Yes | Yes |
174
+ | SwitchBot Meter | Yes | Yes |
175
+ | SwitchBot Motion Sensor | Yes | Yes |
176
+ | SwitchBot Contact Sensor | Yes | Yes |
177
+ | SwitchBot Plug Mini | Yes | Yes |
178
+ | SwitchBot Smart Lock | Yes | Yes |
179
+ | SwitchBot Humidifier | Yes | Yes |
180
+ | SwitchBot Color Bulb | Yes | Yes |
181
+ | SwitchBot LED Strip Light | Yes | Yes |
182
+
183
+ ### Summary
184
+
185
+ The `SwitchBotOpenAPI` class provides a powerful way to interact with your SwitchBot devices programmatically. By following the examples provided, you can easily integrate SwitchBot device control and monitoring into your applications.