node-switchbot 2.5.0-beta.2 → 2.5.0-beta.20

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 (197) hide show
  1. package/dist/advertising.d.ts +31 -20
  2. package/dist/advertising.d.ts.map +1 -1
  3. package/dist/advertising.js +72 -75
  4. package/dist/advertising.js.map +1 -1
  5. package/dist/device/woblindtilt.d.ts +19 -50
  6. package/dist/device/woblindtilt.d.ts.map +1 -1
  7. package/dist/device/woblindtilt.js +39 -98
  8. package/dist/device/woblindtilt.js.map +1 -1
  9. package/dist/device/wobulb.d.ts +41 -15
  10. package/dist/device/wobulb.d.ts.map +1 -1
  11. package/dist/device/wobulb.js +71 -127
  12. package/dist/device/wobulb.js.map +1 -1
  13. package/dist/device/woceilinglight.d.ts +47 -21
  14. package/dist/device/woceilinglight.d.ts.map +1 -1
  15. package/dist/device/woceilinglight.js +94 -169
  16. package/dist/device/woceilinglight.js.map +1 -1
  17. package/dist/device/wocontact.d.ts +11 -1
  18. package/dist/device/wocontact.d.ts.map +1 -1
  19. package/dist/device/wocontact.js +22 -21
  20. package/dist/device/wocontact.js.map +1 -1
  21. package/dist/device/wocurtain.d.ts +39 -1
  22. package/dist/device/wocurtain.d.ts.map +1 -1
  23. package/dist/device/wocurtain.js +68 -102
  24. package/dist/device/wocurtain.js.map +1 -1
  25. package/dist/device/wohand.d.ts +37 -2
  26. package/dist/device/wohand.d.ts.map +1 -1
  27. package/dist/device/wohand.js +54 -88
  28. package/dist/device/wohand.js.map +1 -1
  29. package/dist/device/wohub2.d.ts +11 -1
  30. package/dist/device/wohub2.d.ts.map +1 -1
  31. package/dist/device/wohub2.js +20 -28
  32. package/dist/device/wohub2.js.map +1 -1
  33. package/dist/device/wohumi.d.ts +37 -2
  34. package/dist/device/wohumi.d.ts.map +1 -1
  35. package/dist/device/wohumi.js +51 -82
  36. package/dist/device/wohumi.js.map +1 -1
  37. package/dist/device/woiosensorth.d.ts +12 -1
  38. package/dist/device/woiosensorth.d.ts.map +1 -1
  39. package/dist/device/woiosensorth.js +24 -28
  40. package/dist/device/woiosensorth.js.map +1 -1
  41. package/dist/device/woplugmini.d.ts +45 -12
  42. package/dist/device/woplugmini.d.ts.map +1 -1
  43. package/dist/device/woplugmini.js +69 -75
  44. package/dist/device/woplugmini.js.map +1 -1
  45. package/dist/device/wopresence.d.ts +11 -1
  46. package/dist/device/wopresence.d.ts.map +1 -1
  47. package/dist/device/wopresence.js +20 -26
  48. package/dist/device/wopresence.js.map +1 -1
  49. package/dist/device/wosensorth.d.ts +18 -2
  50. package/dist/device/wosensorth.d.ts.map +1 -1
  51. package/dist/device/wosensorth.js +32 -48
  52. package/dist/device/wosensorth.js.map +1 -1
  53. package/dist/device/wosmartlock.d.ts +56 -13
  54. package/dist/device/wosmartlock.d.ts.map +1 -1
  55. package/dist/device/wosmartlock.js +106 -194
  56. package/dist/device/wosmartlock.js.map +1 -1
  57. package/dist/device/wosmartlockpro.d.ts +61 -18
  58. package/dist/device/wosmartlockpro.d.ts.map +1 -1
  59. package/dist/device/wosmartlockpro.js +114 -203
  60. package/dist/device/wosmartlockpro.js.map +1 -1
  61. package/dist/device/wostrip.d.ts +37 -18
  62. package/dist/device/wostrip.d.ts.map +1 -1
  63. package/dist/device/wostrip.js +78 -124
  64. package/dist/device/wostrip.js.map +1 -1
  65. package/dist/device.d.ts +87 -224
  66. package/dist/device.d.ts.map +1 -1
  67. package/dist/device.js +123 -407
  68. package/dist/device.js.map +1 -1
  69. package/dist/index.d.ts +8 -0
  70. package/dist/index.d.ts.map +1 -1
  71. package/dist/index.js +8 -0
  72. package/dist/index.js.map +1 -1
  73. package/dist/parameter-checker.d.ts +78 -18
  74. package/dist/parameter-checker.d.ts.map +1 -1
  75. package/dist/parameter-checker.js +139 -334
  76. package/dist/parameter-checker.js.map +1 -1
  77. package/dist/settings.d.ts +46 -0
  78. package/dist/settings.d.ts.map +1 -1
  79. package/dist/settings.js +46 -2
  80. package/dist/settings.js.map +1 -1
  81. package/dist/switchbot-openapi.d.ts +56 -0
  82. package/dist/switchbot-openapi.d.ts.map +1 -0
  83. package/dist/switchbot-openapi.js +238 -0
  84. package/dist/switchbot-openapi.js.map +1 -0
  85. package/dist/switchbot.d.ts +41 -17
  86. package/dist/switchbot.d.ts.map +1 -1
  87. package/dist/switchbot.js +311 -176
  88. package/dist/switchbot.js.map +1 -1
  89. package/dist/test/woblindtilt.test.d.ts.map +1 -0
  90. package/dist/test/woblindtilt.test.js +97 -0
  91. package/dist/test/woblindtilt.test.js.map +1 -0
  92. package/dist/{device → test}/wobulb.test.d.ts.map +1 -1
  93. package/dist/test/wobulb.test.js +104 -0
  94. package/dist/test/wobulb.test.js.map +1 -0
  95. package/dist/test/woceilinglight.test.d.ts.map +1 -0
  96. package/dist/test/woceilinglight.test.js +95 -0
  97. package/dist/test/woceilinglight.test.js.map +1 -0
  98. package/dist/test/wocontact.test.d.ts.map +1 -0
  99. package/dist/test/wocontact.test.js +38 -0
  100. package/dist/test/wocontact.test.js.map +1 -0
  101. package/dist/test/wocurtain.test.d.ts.map +1 -0
  102. package/dist/test/wocurtain.test.js +76 -0
  103. package/dist/test/wocurtain.test.js.map +1 -0
  104. package/dist/{device → test}/wohand.test.d.ts.map +1 -1
  105. package/dist/test/wohand.test.js +76 -0
  106. package/dist/test/wohand.test.js.map +1 -0
  107. package/dist/test/wohub2.test.d.ts +2 -0
  108. package/dist/test/wohub2.test.d.ts.map +1 -0
  109. package/dist/{device/wohand2.test.js → test/wohub2.test.js} +10 -8
  110. package/dist/test/wohub2.test.js.map +1 -0
  111. package/dist/{device → test}/wohumi.test.d.ts.map +1 -1
  112. package/dist/{device → test}/wohumi.test.js +5 -2
  113. package/dist/test/wohumi.test.js.map +1 -0
  114. package/dist/test/woiosensorth.test.d.ts.map +1 -0
  115. package/dist/{device → test}/woiosensorth.test.js +11 -9
  116. package/dist/test/woiosensorth.test.js.map +1 -0
  117. package/dist/test/woplugmini.test.d.ts.map +1 -0
  118. package/dist/{device → test}/woplugmini.test.js +10 -5
  119. package/dist/test/woplugmini.test.js.map +1 -0
  120. package/dist/test/wopresence.test.d.ts.map +1 -0
  121. package/dist/{device → test}/wopresence.test.js +5 -1
  122. package/dist/test/wopresence.test.js.map +1 -0
  123. package/dist/test/wosensorth.test.d.ts.map +1 -0
  124. package/dist/{device → test}/wosensorth.test.js +5 -14
  125. package/dist/test/wosensorth.test.js.map +1 -0
  126. package/dist/test/wosmartlock.test.d.ts.map +1 -0
  127. package/dist/test/wosmartlock.test.js +147 -0
  128. package/dist/test/wosmartlock.test.js.map +1 -0
  129. package/dist/test/wosmartlockpro.test.d.ts.map +1 -0
  130. package/dist/{device → test}/wosmartlockpro.test.js +30 -26
  131. package/dist/test/wosmartlockpro.test.js.map +1 -0
  132. package/dist/{device → test}/wostrip.test.d.ts.map +1 -1
  133. package/dist/{device → test}/wostrip.test.js +18 -19
  134. package/dist/test/wostrip.test.js.map +1 -0
  135. package/dist/types/bledevicestatus.d.ts +4 -12
  136. package/dist/types/bledevicestatus.d.ts.map +1 -1
  137. package/dist/types/devicelist.d.ts.map +1 -1
  138. package/dist/types/devicelist.js +0 -4
  139. package/dist/types/devicelist.js.map +1 -1
  140. package/dist/types/deviceresponse.d.ts.map +1 -1
  141. package/dist/types/devicestatus.d.ts.map +1 -1
  142. package/dist/types/irdevicelist.d.ts.map +1 -1
  143. package/dist/types/pushbody.d.ts +1 -1
  144. package/dist/types/pushbody.d.ts.map +1 -1
  145. package/dist/types/types.d.ts +71 -120
  146. package/dist/types/types.d.ts.map +1 -1
  147. package/dist/types/types.js +10 -0
  148. package/dist/types/types.js.map +1 -1
  149. package/package.json +6 -4
  150. package/dist/device/woblindtilt.test.d.ts.map +0 -1
  151. package/dist/device/woblindtilt.test.js +0 -26
  152. package/dist/device/woblindtilt.test.js.map +0 -1
  153. package/dist/device/wobulb.test.js +0 -52
  154. package/dist/device/wobulb.test.js.map +0 -1
  155. package/dist/device/woceilinglight.test.d.ts.map +0 -1
  156. package/dist/device/woceilinglight.test.js +0 -63
  157. package/dist/device/woceilinglight.test.js.map +0 -1
  158. package/dist/device/wocontact.test.d.ts.map +0 -1
  159. package/dist/device/wocontact.test.js +0 -34
  160. package/dist/device/wocontact.test.js.map +0 -1
  161. package/dist/device/wocurtain.test.d.ts.map +0 -1
  162. package/dist/device/wocurtain.test.js +0 -33
  163. package/dist/device/wocurtain.test.js.map +0 -1
  164. package/dist/device/wohand.test.js +0 -62
  165. package/dist/device/wohand.test.js.map +0 -1
  166. package/dist/device/wohand2.test.d.ts +0 -2
  167. package/dist/device/wohand2.test.d.ts.map +0 -1
  168. package/dist/device/wohand2.test.js.map +0 -1
  169. package/dist/device/wohumi.test.js.map +0 -1
  170. package/dist/device/woiosensorth.test.d.ts.map +0 -1
  171. package/dist/device/woiosensorth.test.js.map +0 -1
  172. package/dist/device/woplugmini.test.d.ts.map +0 -1
  173. package/dist/device/woplugmini.test.js.map +0 -1
  174. package/dist/device/wopresence.test.d.ts.map +0 -1
  175. package/dist/device/wopresence.test.js.map +0 -1
  176. package/dist/device/wosensorth.test.d.ts.map +0 -1
  177. package/dist/device/wosensorth.test.js.map +0 -1
  178. package/dist/device/wosmartlock.test.d.ts.map +0 -1
  179. package/dist/device/wosmartlock.test.js +0 -84
  180. package/dist/device/wosmartlock.test.js.map +0 -1
  181. package/dist/device/wosmartlockpro.test.d.ts.map +0 -1
  182. package/dist/device/wosmartlockpro.test.js.map +0 -1
  183. package/dist/device/wostrip.test.js.map +0 -1
  184. /package/dist/{device → test}/woblindtilt.test.d.ts +0 -0
  185. /package/dist/{device → test}/wobulb.test.d.ts +0 -0
  186. /package/dist/{device → test}/woceilinglight.test.d.ts +0 -0
  187. /package/dist/{device → test}/wocontact.test.d.ts +0 -0
  188. /package/dist/{device → test}/wocurtain.test.d.ts +0 -0
  189. /package/dist/{device → test}/wohand.test.d.ts +0 -0
  190. /package/dist/{device → test}/wohumi.test.d.ts +0 -0
  191. /package/dist/{device → test}/woiosensorth.test.d.ts +0 -0
  192. /package/dist/{device → test}/woplugmini.test.d.ts +0 -0
  193. /package/dist/{device → test}/wopresence.test.d.ts +0 -0
  194. /package/dist/{device → test}/wosensorth.test.d.ts +0 -0
  195. /package/dist/{device → test}/wosmartlock.test.d.ts +0 -0
  196. /package/dist/{device → test}/wosmartlockpro.test.d.ts +0 -0
  197. /package/dist/{device → test}/wostrip.test.d.ts +0 -0
@@ -1,130 +1,106 @@
1
- import { Buffer } from 'node:buffer';
2
1
  /* Copyright(C) 2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
3
2
  *
4
3
  * woblindtilt.ts: Switchbot BLE API registration.
5
4
  */
5
+ import { Buffer } from 'node:buffer';
6
6
  import { SwitchbotDevice } from '../device.js';
7
7
  import { SwitchBotBLEModel, SwitchBotBLEModelFriendlyName, SwitchBotBLEModelName } from '../types/types.js';
8
+ /**
9
+ * Class representing a WoBlindTilt device.
10
+ * @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/curtain.md
11
+ */
8
12
  export class WoBlindTilt extends SwitchbotDevice {
9
13
  _reverse = false;
10
14
  /**
11
15
  * Parses the service data and manufacturer data for the WoBlindTilt device.
12
- *
13
16
  * @param {Buffer} serviceData - The service data buffer.
14
17
  * @param {Buffer} manufacturerData - The manufacturer data buffer.
15
18
  * @param {(message: string) => void} [onlog] - Optional logging function.
16
19
  * @param {boolean} [reverse] - Whether to reverse the tilt percentage.
17
- * @returns {object | null} The parsed data object or null if the data is invalid.
20
+ * @returns {Promise<object | null>} - The parsed data object or null if the data is invalid.
18
21
  */
19
22
  static async parseServiceData(serviceData, manufacturerData, onlog, reverse = false) {
20
- if (manufacturerData.length !== 5 && manufacturerData.length !== 6) {
21
- if (onlog && typeof onlog === 'function') {
22
- onlog(`[parseServiceDataForWoBlindTilt] Buffer length ${manufacturerData.length} !== 5 or 6!`);
23
- }
23
+ if (![5, 6].includes(manufacturerData.length)) {
24
+ onlog?.(`[parseServiceDataForWoBlindTilt] Buffer length ${manufacturerData.length} !== 5 or 6!`);
24
25
  return null;
25
26
  }
26
- // const byte1 = serviceData.readUInt8(1)
27
27
  const byte2 = serviceData.readUInt8(2);
28
28
  const byte6 = manufacturerData.subarray(6);
29
- const tilt = Math.max(Math.min(byte6.readUInt8(2) & 0b01111111, 100), 0); // current tilt % (100 - _tilt) if reverse else _tilt,
29
+ const tilt = Math.max(Math.min(byte6.readUInt8(2) & 0b01111111, 100), 0);
30
30
  const inMotion = !!(byte2 & 0b10000000);
31
- const lightLevel = (byte6.readUInt8(1) >> 4) & 0b00001111; // light sensor level (1-10)
32
- const calibration = !!(byte6.readUInt8(1) & 0b00000001); // Whether the calibration is completed
31
+ const lightLevel = (byte6.readUInt8(1) >> 4) & 0b00001111;
32
+ const calibration = !!(byte6.readUInt8(1) & 0b00000001);
33
33
  const sequenceNumber = byte6.readUInt8(0);
34
34
  const battery = serviceData.length > 2 ? byte2 & 0b01111111 : null;
35
- const data = {
35
+ return {
36
36
  model: SwitchBotBLEModel.BlindTilt,
37
37
  modelName: SwitchBotBLEModelName.BlindTilt,
38
38
  modelFriendlyName: SwitchBotBLEModelFriendlyName.BlindTilt,
39
39
  calibration,
40
40
  battery,
41
41
  inMotion,
42
- tilt: reverse ? (100 - tilt) : tilt,
42
+ tilt: reverse ? 100 - tilt : tilt,
43
43
  lightLevel,
44
44
  sequenceNumber,
45
45
  };
46
- return data;
47
46
  }
48
47
  /**
49
- * open
50
- *
51
48
  * Opens the blind tilt to the fully open position.
52
- *
53
- * @returns {Promise<void>} - A promise that resolves when the operation is complete. Nothing will be passed to the `resolve()`.
49
+ * @returns {Promise<void>}
54
50
  */
55
51
  async open() {
56
- return await this.operateBlindTilt([0x57, 0x0F, 0x45, 0x01, 0x05, 0xFF, 0x32]);
52
+ await this.operateBlindTilt([0x57, 0x0F, 0x45, 0x01, 0x05, 0xFF, 0x32]);
57
53
  }
58
54
  /**
59
- * closeUp
60
- *
61
55
  * Closes the blind tilt up to the nearest endpoint.
62
- *
63
- * @returns {Promise<void>} - A promise that resolves when the operation is complete. Nothing will be passed to the `resolve()`.
56
+ * @returns {Promise<void>}
64
57
  */
65
58
  async closeUp() {
66
- return await this.operateBlindTilt([0x57, 0x0F, 0x45, 0x01, 0x05, 0xFF, 0x64]);
59
+ await this.operateBlindTilt([0x57, 0x0F, 0x45, 0x01, 0x05, 0xFF, 0x64]);
67
60
  }
68
61
  /**
69
- * closeDown
70
- *
71
62
  * Closes the blind tilt down to the nearest endpoint.
72
- *
73
- * @returns {Promise<void>} - A promise that resolves when the operation is complete. Nothing will be passed to the `resolve()`.
63
+ * @returns {Promise<void>}
74
64
  */
75
65
  async closeDown() {
76
- return await this.operateBlindTilt([0x57, 0x0F, 0x45, 0x01, 0x05, 0xFF, 0x00]);
66
+ await this.operateBlindTilt([0x57, 0x0F, 0x45, 0x01, 0x05, 0xFF, 0x00]);
77
67
  }
78
68
  /**
79
- * close
80
- *
81
69
  * Closes the blind tilt to the nearest endpoint.
82
- *
83
- * @returns {Promise<void>} - A promise that resolves when the operation is complete. Nothing will be passed to the `resolve()`.
70
+ * @returns {Promise<void>}
84
71
  */
85
72
  async close() {
86
73
  const position = await this.getPosition();
87
74
  if (position > 50) {
88
- return await this.closeUp();
75
+ await this.closeUp();
89
76
  }
90
77
  else {
91
- return await this.closeDown();
78
+ await this.closeDown();
92
79
  }
93
80
  }
94
81
  /**
95
- * getPosition
96
- *
97
82
  * Retrieves the current position of the blind tilt.
98
- *
99
- * @returns {number} - The current position of the blind tilt (0-100).
83
+ * @returns {Promise<number>} - The current position of the blind tilt (0-100).
100
84
  */
101
85
  async getPosition() {
102
- // Retrieve the current tilt position using the _getAdvValue method
103
86
  const tiltPosition = await this._getAdvValue('tilt');
104
- // Ensure the tilt position is within the valid range (0-100)
105
87
  return Math.max(0, Math.min(tiltPosition, 100));
106
88
  }
107
89
  /**
108
- * _getAdvValue
109
- *
110
90
  * Retrieves the advertised value for a given key.
111
- *
112
91
  * @param {string} key - The key for the advertised value.
113
92
  * @returns {Promise<number>} - The advertised value.
93
+ * @private
114
94
  */
115
95
  async _getAdvValue(key) {
116
- // Mock implementation, replace with actual logic to retrieve the advertised value
117
96
  if (key === 'tilt') {
118
97
  return 50; // Example value
119
98
  }
120
99
  throw new Error(`Unknown key: ${key}`);
121
100
  }
122
101
  /**
123
- * getBasicInfo
124
- *
125
102
  * Retrieves the basic information of the blind tilt.
126
- *
127
- * @returns {Promise<object>} - A promise that resolves to an object containing the basic information of the blind tilt.
103
+ * @returns {Promise<object | null>} - A promise that resolves to an object containing the basic information of the blind tilt.
128
104
  */
129
105
  async getBasicInfo() {
130
106
  const data = await this.getBasicInfo();
@@ -168,73 +144,38 @@ export class WoBlindTilt extends SwitchbotDevice {
168
144
  }
169
145
  /**
170
146
  * Pauses the blind tilt operation.
171
- *
172
- * This method sends a command to pause the current operation of the blind tilt.
173
- *
174
- * @returns {Promise<void>} A promise that resolves when the operation is complete.
175
- * No value is passed to the `resolve()` function.
147
+ * @returns {Promise<void>}
176
148
  */
177
149
  async pause() {
178
150
  await this.operateBlindTilt([0x57, 0x0F, 0x45, 0x01, 0x00, 0xFF]);
179
151
  }
180
152
  /**
181
- * runToPos the blind tilt operation.
182
- *
183
- * This method sends a command to run the blind tilt to the specified position.
184
- *
153
+ * Runs the blind tilt to the specified position.
185
154
  * @param {number} percent - The target position percentage (0-100).
186
155
  * @param {number} mode - The running mode (0 or 1).
187
- * @returns {Promise<void>} - A promise that resolves when the operation is complete.
156
+ * @returns {Promise<void>}
188
157
  */
189
158
  async runToPos(percent, mode) {
190
- if (typeof percent !== 'number') {
191
- throw new TypeError(`The type of target position percentage is incorrect: ${typeof percent}`);
159
+ if (typeof percent !== 'number' || percent < 0 || percent > 100) {
160
+ throw new RangeError('Percent must be a number between 0 and 100');
192
161
  }
193
- if (mode === null) {
194
- mode = 0xFF;
195
- }
196
- else {
197
- if (typeof mode !== 'number') {
198
- throw new TypeError(`The type of running mode is incorrect: ${typeof mode}`);
199
- }
200
- if (mode > 1) {
201
- mode = 0xFF;
202
- }
203
- }
204
- if (percent > 100) {
205
- percent = 100;
206
- }
207
- else if (percent < 0) {
208
- percent = 0;
162
+ if (typeof mode !== 'number' || mode < 0 || mode > 1) {
163
+ throw new RangeError('Mode must be a number between 0 and 1');
209
164
  }
210
165
  await this.operateBlindTilt([0x57, 0x0F, 0x45, 0x01, 0x05, mode, percent]);
211
166
  }
212
167
  /**
213
168
  * Sends a command to operate the blind tilt and handles the response.
214
- *
215
- * This method constructs a buffer from the provided byte array and sends it as a command to the device.
216
- * It returns a promise that resolves if the device responds with a success code (0x01) and rejects if the device
217
- * returns an error or if the command fails.
218
- *
219
169
  * @param {number[]} bytes - The byte array representing the command to be sent to the device.
220
- * @returns {Promise<void>} A promise that resolves when the command is successfully executed or rejects with an
221
- * error if the command fails.
222
- *
223
- * @throws {Error} Throws an error if the device returns an error code or if the command fails.
170
+ * @returns {Promise<void>}
171
+ * @private
224
172
  */
225
173
  async operateBlindTilt(bytes) {
226
- const req_buf = Buffer.from(bytes);
227
- this.command(req_buf).then((res_buf) => {
228
- const code = res_buf.readUInt8(0);
229
- if (res_buf.length === 3 && code === 0x01) {
230
- // Success: No action needed
231
- }
232
- else {
233
- throw new Error(`The device returned an error: 0x${res_buf.toString('hex')}`);
234
- }
235
- }).catch((error) => {
236
- throw error;
237
- });
174
+ const reqBuf = Buffer.from(bytes);
175
+ const resBuf = await this.command(reqBuf);
176
+ if (resBuf.length !== 3 || resBuf.readUInt8(0) !== 0x01) {
177
+ throw new Error(`The device returned an error: 0x${resBuf.toString('hex')}`);
178
+ }
238
179
  }
239
180
  }
240
181
  //# sourceMappingURL=woblindtilt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"woblindtilt.js","sourceRoot":"","sources":["../../src/device/woblindtilt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC;;;GAGG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,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AKG;IACK,KAAK,CAAC,gBAAgB,CAAC,KAAe;QAC5C,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACjC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QACzC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YACxD,MAAM,IAAI,KAAK,CAAC,mCAAmC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAC9E,CAAC;IACH,CAAC;CACF"}
@@ -1,41 +1,67 @@
1
1
  import { Buffer } from 'node:buffer';
2
2
  import { SwitchbotDevice } from '../device.js';
3
3
  /**
4
+ * Class representing a WoBulb device.
4
5
  * @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/colorbulb.md
5
6
  */
6
7
  export declare class WoBulb extends SwitchbotDevice {
7
- static parseServiceData(serviceData: Buffer, manufacturerData: Buffer, onlog: ((message: string) => void) | undefined): Promise<object | null>;
8
8
  /**
9
- * @returns resolves with a boolean that tells whether the plug in ON(true) or OFF(false)
9
+ * Parses the service data for WoBulb.
10
+ * @param {Buffer} serviceData - The service data buffer.
11
+ * @param {Buffer} manufacturerData - The manufacturer data buffer.
12
+ * @param {Function} [onlog] - Optional logging function.
13
+ * @returns {Promise<object | null>} - Parsed service data or null if invalid.
10
14
  */
11
- readState(): Promise<void>;
15
+ static parseServiceData(serviceData: Buffer, manufacturerData: Buffer, onlog?: (message: string) => void): Promise<object | null>;
12
16
  /**
17
+ * Reads the state of the bulb.
18
+ * @returns {Promise<boolean>} - Resolves with a boolean indicating whether the bulb is ON (true) or OFF (false).
19
+ */
20
+ readState(): Promise<boolean>;
21
+ /**
22
+ * Sets the state of the bulb.
23
+ * @param {number[]} reqByteArray - The request byte array.
24
+ * @returns {Promise<boolean>} - Resolves with a boolean indicating whether the operation was successful.
13
25
  * @private
14
26
  */
15
- setState(reqByteArray: number[]): Promise<void>;
27
+ setState(reqByteArray: number[]): Promise<boolean>;
16
28
  /**
17
- * @returns resolves with a boolean that tells whether the plug in ON(true) or OFF(false)
29
+ * Turns on the bulb.
30
+ * @returns {Promise<boolean>} - Resolves with a boolean indicating whether the bulb is ON (true).
18
31
  */
19
- turnOn(): Promise<void>;
32
+ turnOn(): Promise<boolean>;
20
33
  /**
21
- * @returns resolves with a boolean that tells whether the plug in ON(true) or OFF(false)
34
+ * Turns off the bulb.
35
+ * @returns {Promise<boolean>} - Resolves with a boolean indicating whether the bulb is OFF (false).
22
36
  */
23
- turnOff(): Promise<void>;
37
+ turnOff(): Promise<boolean>;
24
38
  /**
25
- * @returns resolves with brightness percent
39
+ * Sets the brightness of the bulb.
40
+ * @param {number} brightness - The brightness percentage (0-100).
41
+ * @returns {Promise<boolean>} - Resolves with a boolean indicating whether the operation was successful.
26
42
  */
27
- setBrightness(brightness: number): Promise<void>;
43
+ setBrightness(brightness: number): Promise<boolean>;
28
44
  /**
29
- * @returns resolves with color_temperature percent
45
+ * Sets the color temperature of the bulb.
46
+ * @param {number} color_temperature - The color temperature percentage (0-100).
47
+ * @returns {Promise<boolean>} - Resolves with a boolean indicating whether the operation was successful.
30
48
  */
31
- setColorTemperature(color_temperature: number): Promise<void>;
49
+ setColorTemperature(color_temperature: number): Promise<boolean>;
32
50
  /**
33
- * @returns resolves with brightness percent
51
+ * Sets the RGB color of the bulb.
52
+ * @param {number} brightness - The brightness percentage (0-100).
53
+ * @param {number} red - The red color value (0-255).
54
+ * @param {number} green - The green color value (0-255).
55
+ * @param {number} blue - The blue color value (0-255).
56
+ * @returns {Promise<boolean>} - Resolves with a boolean indicating whether the operation was successful.
34
57
  */
35
- setRGB(brightness: number, red: number, green: number, blue: number): Promise<void>;
58
+ setRGB(brightness: number, red: number, green: number, blue: number): Promise<boolean>;
36
59
  /**
60
+ * Sends a command to the bulb.
61
+ * @param {number[]} bytes - The command bytes.
62
+ * @returns {Promise<boolean>} - Resolves with a boolean indicating whether the operation was successful.
37
63
  * @private
38
64
  */
39
- operateBulb(bytes: number[]): Promise<void>;
65
+ private operateBulb;
40
66
  }
41
67
  //# sourceMappingURL=wobulb.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wobulb.d.ts","sourceRoot":"","sources":["../../src/device/wobulb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAMpC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG9C;;GAEG;AACH,qBAAa,MAAO,SAAQ,eAAe;WAC5B,gBAAgB,CAC3B,WAAW,EAAE,MAAM,EACnB,gBAAgB,EAAE,MAAM,EACxB,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,GAC7C,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IA0DzB;;OAEG;IACG,SAAS;IAIf;;OAEG;IACG,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE;IAKrC;;OAEG;IACG,MAAM;IAIZ;;OAEG;IACG,OAAO;IAIb;;OAEG;IACG,aAAa,CAAC,UAAU,EAAE,MAAM;IAYtC;;OAEG;IACG,mBAAmB,CAAC,iBAAiB,EAAE,MAAM;IAWnD;;OAEG;IACG,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAoCzE;;OAEG;IACG,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE;CAqBlC"}
1
+ {"version":3,"file":"wobulb.d.ts","sourceRoot":"","sources":["../../src/device/wobulb.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG9C;;;GAGG;AACH,qBAAa,MAAO,SAAQ,eAAe;IACzC;;;;;;OAMG;WACU,gBAAgB,CAC3B,WAAW,EAAE,MAAM,EACnB,gBAAgB,EAAE,MAAM,EACxB,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GAChC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAyCzB;;;OAGG;IACG,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAInC;;;;;OAKG;IACU,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAK/D;;;OAGG;IACG,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;IAIhC;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IAIjC;;;;OAIG;IACG,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAOzD;;;;OAIG;IACG,mBAAmB,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAOtE;;;;;;;OAOG;IACG,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAO5F;;;;;OAKG;YACW,WAAW;CAY1B"}
@@ -1,190 +1,134 @@
1
- import { Buffer } from 'node:buffer';
2
1
  /* Copyright(C) 2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
3
2
  *
4
3
  * wobulb.ts: Switchbot BLE API registration.
5
4
  */
5
+ import { Buffer } from 'node:buffer';
6
6
  import { SwitchbotDevice } from '../device.js';
7
7
  import { SwitchBotBLEModel, SwitchBotBLEModelFriendlyName, SwitchBotBLEModelName } from '../types/types.js';
8
8
  /**
9
+ * Class representing a WoBulb device.
9
10
  * @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/colorbulb.md
10
11
  */
11
12
  export class WoBulb extends SwitchbotDevice {
13
+ /**
14
+ * Parses the service data for WoBulb.
15
+ * @param {Buffer} serviceData - The service data buffer.
16
+ * @param {Buffer} manufacturerData - The manufacturer data buffer.
17
+ * @param {Function} [onlog] - Optional logging function.
18
+ * @returns {Promise<object | null>} - Parsed service data or null if invalid.
19
+ */
12
20
  static async parseServiceData(serviceData, manufacturerData, onlog) {
13
21
  if (serviceData.length !== 18) {
14
- if (onlog && typeof onlog === 'function') {
15
- onlog(`[parseServiceDataForWoBulb] Buffer length ${serviceData.length} !== 18!`);
16
- }
22
+ onlog?.(`[parseServiceDataForWoBulb] Buffer length ${serviceData.length} !== 18!`);
17
23
  return null;
18
24
  }
19
25
  if (manufacturerData.length !== 13) {
20
- if (onlog && typeof onlog === 'function') {
21
- onlog(`[parseServiceDataForWoBulb] Buffer length ${manufacturerData.length} !== 13!`);
22
- }
26
+ onlog?.(`[parseServiceDataForWoBulb] Buffer length ${manufacturerData.length} !== 13!`);
23
27
  return null;
24
28
  }
25
- const byte1 = manufacturerData.readUInt8(1); // power and light status
26
- // const byte2 = manufacturerData.readUInt8(2);//bulb brightness
27
- const byte3 = manufacturerData.readUInt8(3); // bulb R
28
- const byte4 = manufacturerData.readUInt8(4); // bulb G
29
- const byte5 = manufacturerData.readUInt8(5); // bulb B
30
- const byte6 = manufacturerData.readUInt8(6); // bulb temperature
31
- const byte7 = manufacturerData.readUInt8(7);
32
- const byte8 = manufacturerData.readUInt8(8);
33
- const byte9 = manufacturerData.readUInt8(9);
34
- const byte10 = manufacturerData.readUInt8(10); // bulb mode
35
- const power = byte1;
36
- const red = byte3;
37
- const green = byte4;
38
- const blue = byte5;
39
- const color_temperature = byte6;
40
- const state = !!(byte7 & 0b01111111);
41
- const brightness = byte7 & 0b01111111;
42
- const delay = byte8 & 0b10000000;
43
- const preset = byte8 & 0b00001000;
44
- const color_mode = byte8 & 0b00000111;
45
- const speed = byte9 & 0b01111111;
46
- const loop_index = byte10 & 0b11111110;
47
- const data = {
29
+ const [, byte1, , byte3, byte4, byte5, byte6, byte7, byte8, byte9, byte10,] = manufacturerData;
30
+ return {
48
31
  model: SwitchBotBLEModel.ColorBulb,
49
32
  modelName: SwitchBotBLEModelName.ColorBulb,
50
33
  modelFriendlyName: SwitchBotBLEModelFriendlyName.ColorBulb,
51
- color_temperature,
52
- power,
53
- state,
54
- red,
55
- green,
56
- blue,
57
- brightness,
58
- delay,
59
- preset,
60
- color_mode,
61
- speed,
62
- loop_index,
34
+ power: byte1,
35
+ red: byte3,
36
+ green: byte4,
37
+ blue: byte5,
38
+ color_temperature: byte6,
39
+ state: !!(byte7 & 0b01111111),
40
+ brightness: byte7 & 0b01111111,
41
+ delay: !!(byte8 & 0b10000000),
42
+ preset: !!(byte8 & 0b00001000),
43
+ color_mode: byte8 & 0b00000111,
44
+ speed: byte9 & 0b01111111,
45
+ loop_index: byte10 & 0b11111110,
63
46
  };
64
- return data;
65
47
  }
66
48
  /**
67
- * @returns resolves with a boolean that tells whether the plug in ON(true) or OFF(false)
49
+ * Reads the state of the bulb.
50
+ * @returns {Promise<boolean>} - Resolves with a boolean indicating whether the bulb is ON (true) or OFF (false).
68
51
  */
69
52
  async readState() {
70
- return await this.operateBulb([0x57, 0x0F, 0x48, 0x01]);
53
+ return this.operateBulb([0x57, 0x0F, 0x48, 0x01]);
71
54
  }
72
55
  /**
56
+ * Sets the state of the bulb.
57
+ * @param {number[]} reqByteArray - The request byte array.
58
+ * @returns {Promise<boolean>} - Resolves with a boolean indicating whether the operation was successful.
73
59
  * @private
74
60
  */
75
61
  async setState(reqByteArray) {
76
62
  const base = [0x57, 0x0F, 0x47, 0x01];
77
- return await this.operateBulb(base.concat(reqByteArray));
63
+ return this.operateBulb(base.concat(reqByteArray));
78
64
  }
79
65
  /**
80
- * @returns resolves with a boolean that tells whether the plug in ON(true) or OFF(false)
66
+ * Turns on the bulb.
67
+ * @returns {Promise<boolean>} - Resolves with a boolean indicating whether the bulb is ON (true).
81
68
  */
82
69
  async turnOn() {
83
- return await this.setState([0x01, 0x01]);
70
+ return this.setState([0x01, 0x01]);
84
71
  }
85
72
  /**
86
- * @returns resolves with a boolean that tells whether the plug in ON(true) or OFF(false)
73
+ * Turns off the bulb.
74
+ * @returns {Promise<boolean>} - Resolves with a boolean indicating whether the bulb is OFF (false).
87
75
  */
88
76
  async turnOff() {
89
- return await this.setState([0x01, 0x02]);
77
+ return this.setState([0x01, 0x02]);
90
78
  }
91
79
  /**
92
- * @returns resolves with brightness percent
80
+ * Sets the brightness of the bulb.
81
+ * @param {number} brightness - The brightness percentage (0-100).
82
+ * @returns {Promise<boolean>} - Resolves with a boolean indicating whether the operation was successful.
93
83
  */
94
84
  async setBrightness(brightness) {
95
- if (typeof brightness !== 'number') {
96
- throw new TypeError(`The type of target brightness percentage is incorrect: ${typeof brightness}`);
85
+ if (brightness < 0 || brightness > 100) {
86
+ throw new RangeError('Brightness must be between 0 and 100');
97
87
  }
98
- if (brightness > 100) {
99
- brightness = 100;
100
- }
101
- else if (brightness < 0) {
102
- brightness = 0;
103
- }
104
- return await this.setState([0x02, 0x14, brightness]);
88
+ return this.setState([0x02, 0x14, brightness]);
105
89
  }
106
90
  /**
107
- * @returns resolves with color_temperature percent
91
+ * Sets the color temperature of the bulb.
92
+ * @param {number} color_temperature - The color temperature percentage (0-100).
93
+ * @returns {Promise<boolean>} - Resolves with a boolean indicating whether the operation was successful.
108
94
  */
109
95
  async setColorTemperature(color_temperature) {
110
- if (typeof color_temperature !== 'number') {
111
- throw new TypeError(`The type of target color_temperature percentage is incorrect: ${typeof color_temperature}`);
112
- }
113
- else if (color_temperature > 100) {
114
- color_temperature = 100;
96
+ if (color_temperature < 0 || color_temperature > 100) {
97
+ throw new RangeError('Color temperature must be between 0 and 100');
115
98
  }
116
- else if (color_temperature < 0) {
117
- color_temperature = 0;
118
- }
119
- return await this.setState([0x02, 0x17, color_temperature]);
99
+ return this.setState([0x02, 0x17, color_temperature]);
120
100
  }
121
101
  /**
122
- * @returns resolves with brightness percent
102
+ * Sets the RGB color of the bulb.
103
+ * @param {number} brightness - The brightness percentage (0-100).
104
+ * @param {number} red - The red color value (0-255).
105
+ * @param {number} green - The green color value (0-255).
106
+ * @param {number} blue - The blue color value (0-255).
107
+ * @returns {Promise<boolean>} - Resolves with a boolean indicating whether the operation was successful.
123
108
  */
124
109
  async setRGB(brightness, red, green, blue) {
125
- if (typeof brightness !== 'number') {
126
- throw new TypeError(`The type of target brightness percentage is incorrect: ${typeof brightness}`);
127
- }
128
- if (typeof red !== 'number') {
129
- throw new TypeError(`The type of target red is incorrect: ${typeof red}`);
130
- }
131
- if (typeof green !== 'number') {
132
- throw new TypeError(`The type of target green is incorrect: ${typeof green}`);
110
+ if (brightness < 0 || brightness > 100 || red < 0 || red > 255 || green < 0 || green > 255 || blue < 0 || blue > 255) {
111
+ throw new RangeError('Invalid RGB or brightness values');
133
112
  }
134
- if (typeof blue !== 'number') {
135
- throw new TypeError(`The type of target blue is incorrect: ${typeof blue}`);
136
- }
137
- if (brightness > 100) {
138
- brightness = 100;
139
- }
140
- else if (brightness < 0) {
141
- brightness = 0;
142
- }
143
- if (red > 255) {
144
- red = 255;
145
- }
146
- else if (red < 0) {
147
- red = 0;
148
- }
149
- if (green > 255) {
150
- green = 255;
151
- }
152
- else if (green < 0) {
153
- green = 0;
154
- }
155
- if (blue > 255) {
156
- blue = 255;
157
- }
158
- else if (blue < 0) {
159
- blue = 0;
160
- }
161
- return await this.setState([0x02, 0x12, brightness, red, green, blue]);
113
+ return this.setState([0x02, 0x12, brightness, red, green, blue]);
162
114
  }
163
115
  /**
116
+ * Sends a command to the bulb.
117
+ * @param {number[]} bytes - The command bytes.
118
+ * @returns {Promise<boolean>} - Resolves with a boolean indicating whether the operation was successful.
164
119
  * @private
165
120
  */
166
121
  async operateBulb(bytes) {
167
- const req_buf = Buffer.from(bytes);
168
- await this.command(req_buf)
169
- .then((res_bytes) => {
170
- const res_buf = Buffer.from(res_bytes);
171
- if (res_buf.length === 2) {
172
- const code = res_buf.readUInt8(1);
173
- if (code === 0x00 || code === 0x80) {
174
- const is_on = code === 0x80;
175
- return is_on;
176
- }
177
- else {
178
- throw new Error(`The device returned an error: 0x${res_buf.toString('hex')}`);
179
- }
122
+ const reqBuf = Buffer.from(bytes);
123
+ const resBuf = await this.command(reqBuf);
124
+ if (resBuf.length === 2) {
125
+ const code = resBuf.readUInt8(1);
126
+ if (code === 0x00 || code === 0x80) {
127
+ return code === 0x80;
180
128
  }
181
- else {
182
- throw new Error(`Expecting a 2-byte response, got instead: 0x${res_buf.toString('hex')}`);
183
- }
184
- })
185
- .catch((error) => {
186
- throw error;
187
- });
129
+ throw new Error(`The device returned an error: 0x${resBuf.toString('hex')}`);
130
+ }
131
+ throw new Error(`Expecting a 2-byte response, got instead: 0x${resBuf.toString('hex')}`);
188
132
  }
189
133
  }
190
134
  //# sourceMappingURL=wobulb.js.map