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
@@ -1,7 +1,17 @@
1
1
  import type { Buffer } from 'node:buffer';
2
2
  import type { motionSensorServiceData } from '../types/bledevicestatus.js';
3
3
  import { SwitchbotDevice } from '../device.js';
4
+ /**
5
+ * Class representing a WoPresence device.
6
+ * @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/meter.md
7
+ */
4
8
  export declare class WoPresence extends SwitchbotDevice {
5
- static parseServiceData(serviceData: Buffer, onlog: ((message: string) => void) | undefined): Promise<motionSensorServiceData | null>;
9
+ /**
10
+ * Parses the service data for WoPresence.
11
+ * @param {Buffer} serviceData - The service data buffer.
12
+ * @param {Function} emitLog - The function to emit log messages.
13
+ * @returns {Promise<motionSensorServiceData | null>} - Parsed service data or null if invalid.
14
+ */
15
+ static parseServiceData(serviceData: Buffer, emitLog: (level: string, message: string) => void): Promise<motionSensorServiceData | null>;
6
16
  }
7
17
  //# sourceMappingURL=wopresence.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wopresence.d.ts","sourceRoot":"","sources":["../../src/device/wopresence.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AAM1E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG9C,qBAAa,UAAW,SAAQ,eAAe;WAChC,gBAAgB,CAC3B,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,GAC7C,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC;CAqC3C"}
1
+ {"version":3,"file":"wopresence.d.ts","sourceRoot":"","sources":["../../src/device/wopresence.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AAE1E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG9C;;;GAGG;AACH,qBAAa,UAAW,SAAQ,eAAe;IAC7C;;;;;OAKG;WACU,gBAAgB,CAC3B,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,GAChD,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC;CAwB3C"}
@@ -1,40 +1,34 @@
1
- /* Copyright(C) 2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
2
- *
3
- * wopresence.ts: Switchbot BLE API registration.
4
- */
5
1
  import { SwitchbotDevice } from '../device.js';
6
2
  import { SwitchBotBLEModel, SwitchBotBLEModelFriendlyName, SwitchBotBLEModelName } from '../types/types.js';
3
+ /**
4
+ * Class representing a WoPresence device.
5
+ * @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/meter.md
6
+ */
7
7
  export class WoPresence extends SwitchbotDevice {
8
- static async parseServiceData(serviceData, onlog) {
8
+ /**
9
+ * Parses the service data for WoPresence.
10
+ * @param {Buffer} serviceData - The service data buffer.
11
+ * @param {Function} emitLog - The function to emit log messages.
12
+ * @returns {Promise<motionSensorServiceData | null>} - Parsed service data or null if invalid.
13
+ */
14
+ static async parseServiceData(serviceData, emitLog) {
9
15
  if (serviceData.length !== 6) {
10
- if (onlog && typeof onlog === 'function') {
11
- onlog(`[parseServiceDataForWoPresence] Buffer length ${serviceData.length} !== 6!`);
12
- }
16
+ emitLog('debugerror', `[parseServiceDataForWoPresence] Buffer length ${serviceData.length} !== 6!`);
13
17
  return null;
14
18
  }
15
- const byte1 = serviceData.readUInt8(1);
16
- const byte2 = serviceData.readUInt8(2);
17
- const byte5 = serviceData.readUInt8(5);
18
- const tested = !!(byte1 & 0b10000000);
19
- const movement = !!(byte1 & 0b01000000);
20
- const battery = byte2 & 0b01111111;
21
- const led = (byte5 & 0b00100000) >> 5;
22
- const iot = (byte5 & 0b00010000) >> 4;
23
- const sense_distance = (byte5 & 0b00001100) >> 2;
24
- const lightLevel = byte5 & 0b00000011;
25
- const is_light = !!(byte5 & 0b00000010);
19
+ const [byte1, byte2, , , , byte5] = serviceData;
26
20
  const data = {
27
21
  model: SwitchBotBLEModel.MotionSensor,
28
22
  modelName: SwitchBotBLEModelName.MotionSensor,
29
23
  modelFriendlyName: SwitchBotBLEModelFriendlyName.MotionSensor,
30
- tested,
31
- movement,
32
- battery,
33
- led,
34
- iot,
35
- sense_distance,
36
- lightLevel: lightLevel === 1 ? 'dark' : lightLevel === 2 ? 'bright' : 'unknown',
37
- is_light,
24
+ tested: !!(byte1 & 0b10000000),
25
+ movement: !!(byte1 & 0b01000000),
26
+ battery: byte2 & 0b01111111,
27
+ led: (byte5 & 0b00100000) >> 5,
28
+ iot: (byte5 & 0b00010000) >> 4,
29
+ sense_distance: (byte5 & 0b00001100) >> 2,
30
+ lightLevel: (byte5 & 0b00000011) === 1 ? 'dark' : (byte5 & 0b00000011) === 2 ? 'bright' : 'unknown',
31
+ is_light: !!(byte5 & 0b00000010),
38
32
  };
39
33
  return data;
40
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"wopresence.js","sourceRoot":"","sources":["../../src/device/wopresence.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAE3G,MAAM,OAAO,UAAW,SAAQ,eAAe;IAC7C,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAC3B,WAAmB,EACnB,KAA8C;QAE9C,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7B,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;gBACzC,KAAK,CAAC,iDAAiD,WAAW,CAAC,MAAM,SAAS,CAAC,CAAA;YACrF,CAAC;YACD,OAAO,IAAI,CAAA;QACb,CAAC;QAED,MAAM,KAAK,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;QACtC,MAAM,KAAK,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;QACtC,MAAM,KAAK,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;QAEtC,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC,CAAA;QACrC,MAAM,QAAQ,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC,CAAA;QACvC,MAAM,OAAO,GAAG,KAAK,GAAG,UAAU,CAAA;QAClC,MAAM,GAAG,GAAG,CAAC,KAA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;QAED,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,AAAD,EAAG,AAAD,EAAG,AAAD,EAAG,KAAK,CAAC,GAAG,WAAW,CAAA;QAE/C,MAAM,IAAI,GAA4B;YACpC,KAAK,EAAE,iBAAiB,CAAC,YAAY;YACrC,SAAS,EAAE,qBAAqB,CAAC,YAAY;YAC7C,iBAAiB,EAAE,6BAA6B,CAAC,YAAY;YAC7D,MAAM,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC;YAC9B,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC;YAChC,OAAO,EAAE,KAAK,GAAG,UAAU;YAC3B,GAAG,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC;YAC9B,GAAG,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC;YAC9B,cAAc,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC;YACzC,UAAU,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;YACnG,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC;SACjC,CAAA;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CACF"}
@@ -1,8 +1,24 @@
1
1
  import type { Buffer } from 'node:buffer';
2
2
  import type { meterPlusServiceData, meterServiceData } from '../types/bledevicestatus.js';
3
3
  import { SwitchbotDevice } from '../device.js';
4
+ /**
5
+ * Class representing a WoSensorTH device.
6
+ * @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/meter.md
7
+ */
4
8
  export declare class WoSensorTH extends SwitchbotDevice {
5
- static parseServiceData(serviceData: Buffer, onlog: ((message: string) => void) | undefined): Promise<meterServiceData | null>;
6
- static parseServiceData_Plus(serviceData: Buffer, onlog: ((message: string) => void) | undefined): Promise<meterPlusServiceData | null>;
9
+ /**
10
+ * Parses the service data for WoSensorTH.
11
+ * @param {Buffer} serviceData - The service data buffer.
12
+ * @param {Function} emitLog - The function to emit log messages.
13
+ * @returns {Promise<meterServiceData | null>} - Parsed service data or null if invalid.
14
+ */
15
+ static parseServiceData(serviceData: Buffer, emitLog: (level: string, message: string) => void): Promise<meterServiceData | null>;
16
+ /**
17
+ * Parses the service data for WoSensorTH Plus.
18
+ * @param {Buffer} serviceData - The service data buffer.
19
+ * @param {Function} emitLog - The function to emit log messages.
20
+ * @returns {Promise<meterPlusServiceData | null>} - Parsed service data or null if invalid.
21
+ */
22
+ static parseServiceData_Plus(serviceData: Buffer, emitLog: (level: string, message: string) => void): Promise<meterPlusServiceData | null>;
7
23
  }
8
24
  //# sourceMappingURL=wosensorth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wosensorth.d.ts","sourceRoot":"","sources":["../../src/device/wosensorth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAMzF,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG9C,qBAAa,UAAW,SAAQ,eAAe;WAChC,gBAAgB,CAC3B,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,GAC7C,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;WAsCtB,qBAAqB,CAChC,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,GAC7C,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;CAqCxC"}
1
+ {"version":3,"file":"wosensorth.d.ts","sourceRoot":"","sources":["../../src/device/wosensorth.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAEzF,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG9C;;;GAGG;AACH,qBAAa,UAAW,SAAQ,eAAe;IAC7C;;;;;OAKG;WACU,gBAAgB,CAC3B,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,GAChD,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAuBnC;;;;;OAKG;WACU,qBAAqB,CAChC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,GAChD,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;CAsBxC"}
@@ -1,77 +1,61 @@
1
- /* Copyright(C) 2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
2
- *
3
- * wosensorth.ts: Switchbot BLE API registration.
4
- */
5
1
  import { SwitchbotDevice } from '../device.js';
6
2
  import { SwitchBotBLEModel, SwitchBotBLEModelFriendlyName, SwitchBotBLEModelName } from '../types/types.js';
3
+ /**
4
+ * Class representing a WoSensorTH device.
5
+ * @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/meter.md
6
+ */
7
7
  export class WoSensorTH extends SwitchbotDevice {
8
- static async parseServiceData(serviceData, onlog) {
8
+ /**
9
+ * Parses the service data for WoSensorTH.
10
+ * @param {Buffer} serviceData - The service data buffer.
11
+ * @param {Function} emitLog - The function to emit log messages.
12
+ * @returns {Promise<meterServiceData | null>} - Parsed service data or null if invalid.
13
+ */
14
+ static async parseServiceData(serviceData, emitLog) {
9
15
  if (serviceData.length !== 6) {
10
- if (onlog && typeof onlog === 'function') {
11
- onlog(`[parseServiceDataForWoSensorTH] Buffer length ${serviceData.length} !== 6!`);
12
- }
16
+ emitLog('debugerror', `[parseServiceDataForWoSensorTH] Buffer length ${serviceData.length} !== 6!`);
13
17
  return null;
14
18
  }
15
- const byte2 = serviceData.readUInt8(2);
16
- const byte3 = serviceData.readUInt8(3);
17
- const byte4 = serviceData.readUInt8(4);
18
- const byte5 = serviceData.readUInt8(5);
19
- const temp_sign = byte4 & 0b10000000 ? 1 : -1;
20
- const temp_c = temp_sign * ((byte4 & 0b01111111) + (byte3 & 0b00001111) / 10);
21
- const temp_f = Math.round(((temp_c * 9 / 5) + 32) * 10) / 10;
22
- const data = {
19
+ const [byte2, byte3, byte4, byte5] = [serviceData.readUInt8(2), serviceData.readUInt8(3), serviceData.readUInt8(4), serviceData.readUInt8(5)];
20
+ const tempSign = byte4 & 0b10000000 ? 1 : -1;
21
+ const tempC = tempSign * ((byte4 & 0b01111111) + (byte3 & 0b00001111) / 10);
22
+ const tempF = Math.round(((tempC * 9 / 5) + 32) * 10) / 10;
23
+ return {
23
24
  model: SwitchBotBLEModel.Meter,
24
25
  modelName: SwitchBotBLEModelName.Meter,
25
26
  modelFriendlyName: SwitchBotBLEModelFriendlyName.Meter,
26
- /**
27
- * @deprecated The `temperature` object is deprecated and will be removed in future versions.
28
- * Use the `celcius` and `fahrenheit` properties directly instead.
29
- */
30
- temperature: {
31
- c: temp_c,
32
- f: temp_f,
33
- },
34
- celcius: temp_c,
35
- fahrenheit: temp_f,
27
+ celsius: tempC,
28
+ fahrenheit: tempF,
36
29
  fahrenheit_mode: !!(byte5 & 0b10000000),
37
30
  humidity: byte5 & 0b01111111,
38
31
  battery: byte2 & 0b01111111,
39
32
  };
40
- return data;
41
33
  }
42
- static async parseServiceData_Plus(serviceData, onlog) {
34
+ /**
35
+ * Parses the service data for WoSensorTH Plus.
36
+ * @param {Buffer} serviceData - The service data buffer.
37
+ * @param {Function} emitLog - The function to emit log messages.
38
+ * @returns {Promise<meterPlusServiceData | null>} - Parsed service data or null if invalid.
39
+ */
40
+ static async parseServiceData_Plus(serviceData, emitLog) {
43
41
  if (serviceData.length !== 6) {
44
- if (onlog && typeof onlog === 'function') {
45
- onlog(`[parseServiceDataForWoSensorTHPlus] Buffer length ${serviceData.length} !== 6!`);
46
- }
42
+ emitLog('debugerror', `[parseServiceDataForWoSensorTHPlus] Buffer length ${serviceData.length} !== 6!`);
47
43
  return null;
48
44
  }
49
- const byte2 = serviceData.readUInt8(2);
50
- const byte3 = serviceData.readUInt8(3);
51
- const byte4 = serviceData.readUInt8(4);
52
- const byte5 = serviceData.readUInt8(5);
53
- const temp_sign = byte4 & 0b10000000 ? 1 : -1;
54
- const temp_c = temp_sign * ((byte4 & 0b01111111) + (byte3 & 0b00001111) / 10);
55
- const temp_f = Math.round(((temp_c * 9 / 5) + 32) * 10) / 10;
56
- const data = {
45
+ const [byte2, byte3, byte4, byte5] = [serviceData.readUInt8(2), serviceData.readUInt8(3), serviceData.readUInt8(4), serviceData.readUInt8(5)];
46
+ const tempSign = byte4 & 0b10000000 ? 1 : -1;
47
+ const tempC = tempSign * ((byte4 & 0b01111111) + (byte3 & 0b00001111) / 10);
48
+ const tempF = Math.round(((tempC * 9 / 5) + 32) * 10) / 10;
49
+ return {
57
50
  model: SwitchBotBLEModel.MeterPlus,
58
51
  modelName: SwitchBotBLEModelName.MeterPlus,
59
52
  modelFriendlyName: SwitchBotBLEModelFriendlyName.MeterPlus,
60
- /**
61
- * @deprecated The `temperature` object is deprecated and will be removed in future versions.
62
- * Use the `celcius` and `fahrenheit` properties directly instead.
63
- */
64
- temperature: {
65
- c: temp_c,
66
- f: temp_f,
67
- },
68
- celcius: temp_c,
69
- fahrenheit: temp_f,
53
+ celsius: tempC,
54
+ fahrenheit: tempF,
70
55
  fahrenheit_mode: !!(byte5 & 0b10000000),
71
56
  humidity: byte5 & 0b01111111,
72
57
  battery: byte2 & 0b01111111,
73
58
  };
74
- return data;
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AAG,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;QAC7I,MAAM,QAAQ,GAAG,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAC5C,MAAM,KAAK,GAAG,QAAQ,GAAG,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,CAAA;QAC3E,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAA;QAE1D,OAAO;YACL,KAAK,EAAE,iBAAiB,CAAC,SAAS;YAClC,SAAS,EAAE,qBAAqB,CAAC,SAAS;YAC1C,iBAAiB,EAAE,6BAA6B,CAAC,SAAS;YAC1D,OAAO,EAAE,KAAK;YACd,UAAU,EAAE,KAAK;YACjB,eAAe,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC;YACvC,QAAQ,EAAE,KAAK,GAAG,UAAU;YAC5B,OAAO,EAAE,KAAK,GAAG,UAAU;SAC5B,CAAA;IACH,CAAC;CACF"}
@@ -2,17 +2,14 @@ import type * as Noble from '@stoprocent/noble';
2
2
  import type { lockServiceData } from '../types/bledevicestatus.js';
3
3
  import { Buffer } from 'node:buffer';
4
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
+ */
5
9
  export declare class WoSmartLock extends SwitchbotDevice {
6
10
  iv: Buffer | null;
7
11
  key_id: string;
8
12
  encryption_key: Buffer | null;
9
- static COMMAND_GET_CKiv: string;
10
- static COMMAND_LOCK_INFO: string;
11
- static COMMAND_UNLOCK: string;
12
- static COMMAND_UNLOCK_NO_UNLATCH: string;
13
- static COMMAND_LOCK: string;
14
- static COMMAND_ENABLE_NOTIFICATIONS: string;
15
- static COMMAND_DISABLE_NOTIFICATIONS: string;
16
13
  static Result: {
17
14
  ERROR: number;
18
15
  SUCCESS: number;
@@ -20,17 +17,70 @@ export declare class WoSmartLock extends SwitchbotDevice {
20
17
  };
21
18
  static validateResponse(res: Buffer): Promise<number>;
22
19
  static getLockStatus(code: number): string;
23
- static parseServiceData(serviceData: Buffer, manufacturerData: Buffer, onlog: ((message: string) => void) | undefined): Promise<lockServiceData | null>;
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>;
24
28
  constructor(peripheral: Noble.Peripheral, noble: typeof 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
+ */
25
34
  setKey(keyId: string, encryptionKey: string): Promise<void>;
26
- unlock(): Promise<void>;
27
- unlockNoUnlatch(): Promise<void>;
28
- lock(): Promise<void>;
29
- info(): 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
+ */
30
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
+ */
31
66
  decrypt(data: Buffer): Promise<Buffer>;
67
+ /**
68
+ * Retrieves the IV from the device.
69
+ * @returns {Promise<Buffer>} - The IV buffer.
70
+ */
32
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
+ */
33
77
  encryptedCommand(key: string): Promise<Buffer>;
34
- operateLock(key: string, encrypt?: boolean): Promise<Buffer | undefined>;
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>;
35
85
  }
36
86
  //# sourceMappingURL=wosmartlock.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wosmartlock.d.ts","sourceRoot":"","sources":["../../src/device/wosmartlock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,mBAAmB,CAAA;AAE/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAElE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAOpC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAI9C,qBAAa,WAAY,SAA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