node-switchbot 2.5.0-beta.25 → 2.5.0-beta.26

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.
@@ -1,55 +1,121 @@
1
+ import type { Server } from 'node:http';
2
+ import type { ApiResponse } from './types/types.js';
1
3
  import { EventEmitter } from 'node:events';
2
- import { createServer } from 'node:http';
3
4
  /**
4
- * SwitchBotOpenAPI class to interact with SwitchBot devices via OpenAPI.
5
+ * The `SwitchBotOpenAPI` class provides methods to interact with the SwitchBot OpenAPI.
6
+ * It allows you to retrieve device information, control devices, and manage webhooks.
7
+ *
8
+ * @extends EventEmitter
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const switchBotAPI = new SwitchBotOpenAPI('your-token', 'your-secret');
13
+ *
14
+ * // Get devices
15
+ * switchBotAPI.getDevices().then(response => {
16
+ * console.log(response);
17
+ * }).catch(error => {
18
+ * console.error(error);
19
+ * });
20
+ *
21
+ * // Control a device
22
+ * switchBotAPI.controlDevice('device-id', 'turnOn', 'default').then(response => {
23
+ * console.log(response);
24
+ * }).catch(error => {
25
+ * console.error(error);
26
+ * });
27
+ *
28
+ * // Setup webhook
29
+ * switchBotAPI.setupWebhook('http://your-webhook-url').then(() => {
30
+ * console.log('Webhook setup successfully');
31
+ * }).catch(error => {
32
+ * console.error(error);
33
+ * });
34
+ * ```
35
+ *
36
+ * @param {string} token - The API token used for authentication.
37
+ * @param {string} secret - The secret key used for signing requests.
5
38
  */
6
39
  export declare class SwitchBotOpenAPI extends EventEmitter {
7
40
  private token;
8
41
  private secret;
9
42
  private baseURL;
10
- webhookEventListener?: ReturnType<typeof createServer>;
43
+ webhookEventListener?: Server | null;
44
+ /**
45
+ * Creates an instance of the SwitchBot OpenAPI client.
46
+ *
47
+ * @param token - The API token used for authentication.
48
+ * @param secret - The secret key used for signing requests.
49
+ */
11
50
  constructor(token: string, secret: string);
12
51
  /**
13
- * Emit a log event.
14
- * @param level The log level.
15
- * @param message The log message.
52
+ * Emits a log event with the specified log level and message.
53
+ *
54
+ * @param level - The severity level of the log (e.g., 'info', 'warn', 'error').
55
+ * @param message - The log message to be emitted.
16
56
  */
17
57
  private emitLog;
18
58
  /**
19
- * Get a list of devices.
59
+ * Retrieves the list of devices from the SwitchBot OpenAPI.
60
+ *
61
+ * @returns {Promise<{ response: ApiResponse }>} A promise that resolves to an object containing the API response.
62
+ * @throws {Error} Throws an error if the request to get devices fails.
63
+ */
64
+ getDevices(): Promise<{
65
+ response: ApiResponse;
66
+ }>;
67
+ /**
68
+ * Generates the headers required for authentication with the SwitchBot OpenAPI.
69
+ *
70
+ * @returns An object containing the following headers:
71
+ * - `Authorization`: The token used for authorization.
72
+ * - `sign`: The HMAC-SHA256 signature of the concatenated token, timestamp, and nonce.
73
+ * - `nonce`: A unique identifier for the request, formatted as a UUID.
74
+ * - `t`: The current timestamp in milliseconds since the Unix epoch.
75
+ * - `Content-Type`: The content type of the request, set to `application/json`.
20
76
  */
21
- getDevices(): Promise<any>;
22
77
  private generateHeaders;
23
78
  /**
24
- * Control a device.
25
- * @param deviceId The ID of the device to control.
26
- * @param command The command to send to the device.
27
- * @param parameter The parameter for the command.
28
- * @param commandType The type of command (e.g., "command", "customize").
79
+ * Controls a device by sending a command to the SwitchBot API.
80
+ *
81
+ * @param deviceId - The unique identifier of the device to control.
82
+ * @param command - The command to send to the device.
83
+ * @param parameter - The parameter for the command.
84
+ * @param commandType - The type of the command, defaults to 'command'.
85
+ * @returns A promise that resolves to the API response.
86
+ * @throws An error if the device control fails.
29
87
  */
30
88
  controlDevice(deviceId: string, command: string, parameter: string, commandType?: string): Promise<any>;
31
89
  /**
32
- * Get the status of a device.
33
- * @param deviceId The ID of the device.
90
+ * Retrieves the status of a specific device.
91
+ *
92
+ * @param deviceId - The unique identifier of the device.
93
+ * @returns A promise that resolves to the device status.
94
+ * @throws An error if the request fails.
34
95
  */
35
96
  getDeviceStatus(deviceId: string): Promise<any>;
36
97
  /**
37
- * Setup webhook for receiving events.
38
- * @param url The webhook URL.
98
+ * Sets up a webhook listener and configures the webhook on the server.
99
+ *
100
+ * This method performs the following steps:
101
+ * 1. Creates a local server to listen for incoming webhook events.
102
+ * 2. Sends a request to set up the webhook with the provided URL.
103
+ * 3. Sends a request to update the webhook configuration.
104
+ * 4. Sends a request to query the current webhook URL.
105
+ *
106
+ * @param url - The URL to which the webhook events will be sent.
107
+ * @returns A promise that resolves when the webhook setup is complete.
108
+ *
109
+ * @throws Will log an error if any step in the webhook setup process fails.
39
110
  */
40
111
  setupWebhook(url: string): Promise<void>;
41
112
  /**
42
- * Update webhook configuration.
43
- * @param url The webhook URL.
44
- */
45
- updateWebhook(url: string): Promise<void>;
46
- /**
47
- * Query webhook configuration.
48
- */
49
- queryWebhook(): Promise<void>;
50
- /**
51
- * Delete webhook configuration.
52
- * @param url The webhook URL.
113
+ * Deletes a webhook by sending a request to the specified URL.
114
+ *
115
+ * @param url - The URL of the webhook to be deleted.
116
+ * @returns A promise that resolves when the webhook is successfully deleted.
117
+ *
118
+ * @throws Will log an error if the deletion fails.
53
119
  */
54
120
  deleteWebhook(url: string): Promise<void>;
55
121
  }
@@ -1 +1 @@
1
- {"version":3,"file":"switchbot-openapi.d.ts","sourceRoot":"","sources":["../src/switchbot-openapi.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAMxC;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,YAAY;IAChD,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,OAAO,CAAQ;IAEvB,oBAAoB,CAAC,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAA;gBAE1C,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAOzC;;;;OAIG;IACH,OAAO,CAAC,OAAO;IAIf;;OAEG;IACG,UAAU,IAAI,OAA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AQ,EAAE,WAAW,CAAA;KAAE,CAAC;IAatD;;;;;;;;;OASG;IACH,OAAO,CAAC,eAAe,CAiBtB;IAED;;;;;;;;;OASG;IACG,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,GAAE,MAAkB,GAAG,OAAO,CAAC,GAAG,CAAC;IAqBxH;;;;;;OAMG;IACG,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAgBrD;;;;;;;;;;;;;OAaG;IACG,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA6F9C;;;;;;;OAOG;IACG,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAqBhD"}
@@ -5,13 +5,51 @@ import { createServer } from 'node:http';
5
5
  import { request } from 'undici';
6
6
  import { deleteWebhook, Devices, queryWebhook, setupWebhook, updateWebhook } from './settings.js';
7
7
  /**
8
- * SwitchBotOpenAPI class to interact with SwitchBot devices via OpenAPI.
8
+ * The `SwitchBotOpenAPI` class provides methods to interact with the SwitchBot OpenAPI.
9
+ * It allows you to retrieve device information, control devices, and manage webhooks.
10
+ *
11
+ * @extends EventEmitter
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const switchBotAPI = new SwitchBotOpenAPI('your-token', 'your-secret');
16
+ *
17
+ * // Get devices
18
+ * switchBotAPI.getDevices().then(response => {
19
+ * console.log(response);
20
+ * }).catch(error => {
21
+ * console.error(error);
22
+ * });
23
+ *
24
+ * // Control a device
25
+ * switchBotAPI.controlDevice('device-id', 'turnOn', 'default').then(response => {
26
+ * console.log(response);
27
+ * }).catch(error => {
28
+ * console.error(error);
29
+ * });
30
+ *
31
+ * // Setup webhook
32
+ * switchBotAPI.setupWebhook('http://your-webhook-url').then(() => {
33
+ * console.log('Webhook setup successfully');
34
+ * }).catch(error => {
35
+ * console.error(error);
36
+ * });
37
+ * ```
38
+ *
39
+ * @param {string} token - The API token used for authentication.
40
+ * @param {string} secret - The secret key used for signing requests.
9
41
  */
10
42
  export class SwitchBotOpenAPI extends EventEmitter {
11
43
  token;
12
44
  secret;
13
45
  baseURL;
14
- webhookEventListener;
46
+ webhookEventListener = null;
47
+ /**
48
+ * Creates an instance of the SwitchBot OpenAPI client.
49
+ *
50
+ * @param token - The API token used for authentication.
51
+ * @param secret - The secret key used for signing requests.
52
+ */
15
53
  constructor(token, secret) {
16
54
  super();
17
55
  this.token = token;
@@ -19,15 +57,19 @@ export class SwitchBotOpenAPI extends EventEmitter {
19
57
  this.baseURL = 'https://api.switch-bot.com/v1.0';
20
58
  }
21
59
  /**
22
- * Emit a log event.
23
- * @param level The log level.
24
- * @param message The log message.
60
+ * Emits a log event with the specified log level and message.
61
+ *
62
+ * @param level - The severity level of the log (e.g., 'info', 'warn', 'error').
63
+ * @param message - The log message to be emitted.
25
64
  */
26
- emitLog(level, message) {
65
+ async emitLog(level, message) {
27
66
  this.emit('log', { level, message });
28
67
  }
29
68
  /**
30
- * Get a list of devices.
69
+ * Retrieves the list of devices from the SwitchBot OpenAPI.
70
+ *
71
+ * @returns {Promise<{ response: ApiResponse }>} A promise that resolves to an object containing the API response.
72
+ * @throws {Error} Throws an error if the request to get devices fails.
31
73
  */
32
74
  async getDevices() {
33
75
  try {
@@ -42,6 +84,16 @@ export class SwitchBotOpenAPI extends EventEmitter {
42
84
  throw new Error(`Failed to get devices: ${error.message}`);
43
85
  }
44
86
  }
87
+ /**
88
+ * Generates the headers required for authentication with the SwitchBot OpenAPI.
89
+ *
90
+ * @returns An object containing the following headers:
91
+ * - `Authorization`: The token used for authorization.
92
+ * - `sign`: The HMAC-SHA256 signature of the concatenated token, timestamp, and nonce.
93
+ * - `nonce`: A unique identifier for the request, formatted as a UUID.
94
+ * - `t`: The current timestamp in milliseconds since the Unix epoch.
95
+ * - `Content-Type`: The content type of the request, set to `application/json`.
96
+ */
45
97
  generateHeaders = () => {
46
98
  const t = `${Date.now()}`;
47
99
  const nonce = randomUUID();
@@ -60,11 +112,14 @@ export class SwitchBotOpenAPI extends EventEmitter {
60
112
  };
61
113
  };
62
114
  /**
63
- * Control a device.
64
- * @param deviceId The ID of the device to control.
65
- * @param command The command to send to the device.
66
- * @param parameter The parameter for the command.
67
- * @param commandType The type of command (e.g., "command", "customize").
115
+ * Controls a device by sending a command to the SwitchBot API.
116
+ *
117
+ * @param deviceId - The unique identifier of the device to control.
118
+ * @param command - The command to send to the device.
119
+ * @param parameter - The parameter for the command.
120
+ * @param commandType - The type of the command, defaults to 'command'.
121
+ * @returns A promise that resolves to the API response.
122
+ * @throws An error if the device control fails.
68
123
  */
69
124
  async controlDevice(deviceId, command, parameter, commandType = 'command') {
70
125
  try {
@@ -88,8 +143,11 @@ export class SwitchBotOpenAPI extends EventEmitter {
88
143
  }
89
144
  }
90
145
  /**
91
- * Get the status of a device.
92
- * @param deviceId The ID of the device.
146
+ * Retrieves the status of a specific device.
147
+ *
148
+ * @param deviceId - The unique identifier of the device.
149
+ * @returns A promise that resolves to the device status.
150
+ * @throws An error if the request fails.
93
151
  */
94
152
  async getDeviceStatus(deviceId) {
95
153
  try {
@@ -108,41 +166,56 @@ export class SwitchBotOpenAPI extends EventEmitter {
108
166
  }
109
167
  }
110
168
  /**
111
- * Setup webhook for receiving events.
112
- * @param url The webhook URL.
169
+ * Sets up a webhook listener and configures the webhook on the server.
170
+ *
171
+ * This method performs the following steps:
172
+ * 1. Creates a local server to listen for incoming webhook events.
173
+ * 2. Sends a request to set up the webhook with the provided URL.
174
+ * 3. Sends a request to update the webhook configuration.
175
+ * 4. Sends a request to query the current webhook URL.
176
+ *
177
+ * @param url - The URL to which the webhook events will be sent.
178
+ * @returns A promise that resolves when the webhook setup is complete.
179
+ *
180
+ * @throws Will log an error if any step in the webhook setup process fails.
113
181
  */
114
182
  async setupWebhook(url) {
115
183
  try {
116
184
  const xurl = new URL(url);
117
- const port = Number(xurl.port) || 80;
185
+ const port = Number(xurl.port);
118
186
  const path = xurl.pathname;
119
- this.webhookEventListener = createServer((request, response) => {
120
- if (request.url === path && request.method === 'POST') {
121
- let data = '';
122
- request.on('data', (chunk) => {
123
- data += chunk;
124
- });
125
- request.on('end', async () => {
126
- try {
127
- const body = JSON.parse(data);
128
- this.emitLog('debug', `Received Webhook: ${JSON.stringify(body)}`);
129
- // Emit the webhook event
130
- this.emit('webhookEvent', body);
131
- response.writeHead(200, { 'Content-Type': 'text/plain' });
132
- response.end('OK');
133
- }
134
- catch (e) {
135
- this.emitLog('error', `Failed to handle webhook event. Error: ${e.message}`);
136
- response.writeHead(500, { 'Content-Type': 'text/plain' });
137
- response.end('Internal Server Error');
138
- }
139
- });
187
+ this.webhookEventListener = createServer(async (request, response) => {
188
+ try {
189
+ if (request.url === path && request.method === 'POST') {
190
+ request.on('data', async (data) => {
191
+ try {
192
+ const body = JSON.parse(data);
193
+ await this.emitLog('debug', `Received Webhook: ${JSON.stringify(body)}`);
194
+ this.emit('webhookEvent', body);
195
+ }
196
+ catch (e) {
197
+ await this.emitLog('error', `Failed to handle webhook event data. Error:${e}`);
198
+ }
199
+ });
200
+ response.writeHead(200, { 'Content-Type': 'text/plain' });
201
+ response.end('OK');
202
+ }
203
+ else {
204
+ await this.emitLog('error', `Invalid request received. URL:${request.url}, Method:${request.method}`);
205
+ response.writeHead(403, { 'Content-Type': 'text/plain' });
206
+ response.end(`NG`);
207
+ }
140
208
  }
141
- else {
142
- response.writeHead(403, { 'Content-Type': 'text/plain' });
143
- response.end('NG');
209
+ catch (e) {
210
+ await this.emitLog('error', `Failed to handle webhook event. Error:${e}`);
144
211
  }
145
- }).listen(port);
212
+ }).listen(port || 80);
213
+ }
214
+ catch (e) {
215
+ await this.emitLog('error', `Failed to create webhook listener. Error:${e.message}`);
216
+ return;
217
+ }
218
+ try {
146
219
  const { body, statusCode } = await request(setupWebhook, {
147
220
  method: 'POST',
148
221
  headers: this.generateHeaders(),
@@ -153,20 +226,14 @@ export class SwitchBotOpenAPI extends EventEmitter {
153
226
  }),
154
227
  });
155
228
  const response = await body.json();
156
- this.emitLog('debug', `setupWebhook: url:${url}, body:${JSON.stringify(response)}, statusCode:${statusCode}`);
229
+ await this.emitLog('debug', `setupWebhook: url:${url}, body:${JSON.stringify(response)}, statusCode:${statusCode}`);
157
230
  if (statusCode !== 200 || response?.statusCode !== 100) {
158
- this.emitLog('error', `Failed to configure webhook. HTTP:${statusCode} API:${response?.statusCode} message:${response?.message}`);
231
+ await this.emitLog('error', `Failed to configure webhook. Existing webhook well be overridden. HTTP:${statusCode} API:${response?.statusCode} message:${response?.message}`);
159
232
  }
160
233
  }
161
234
  catch (e) {
162
- this.emitLog('error', `Failed to configure webhook. Error: ${e.message}`);
235
+ await this.emitLog('error', `Failed to configure webhook. Error: ${e.message}`);
163
236
  }
164
- }
165
- /**
166
- * Update webhook configuration.
167
- * @param url The webhook URL.
168
- */
169
- async updateWebhook(url) {
170
237
  try {
171
238
  const { body, statusCode } = await request(updateWebhook, {
172
239
  method: 'POST',
@@ -180,19 +247,14 @@ export class SwitchBotOpenAPI extends EventEmitter {
180
247
  }),
181
248
  });
182
249
  const response = await body.json();
183
- this.emitLog('debug', `updateWebhook: url:${url}, body:${JSON.stringify(response)}, statusCode:${statusCode}`);
250
+ await this.emitLog('debug', `updateWebhook: url:${url}, body:${JSON.stringify(response)}, statusCode:${statusCode}`);
184
251
  if (statusCode !== 200 || response?.statusCode !== 100) {
185
- this.emitLog('error', `Failed to update webhook. HTTP:${statusCode} API:${response?.statusCode} message:${response?.message}`);
252
+ await this.emitLog('error', `Failed to update webhook. HTTP:${statusCode} API:${response?.statusCode} message:${response?.message}`);
186
253
  }
187
254
  }
188
255
  catch (e) {
189
- this.emitLog('error', `Failed to update webhook. Error: ${e.message}`);
256
+ await this.emitLog('error', `Failed to update webhook. Error:${e.message}`);
190
257
  }
191
- }
192
- /**
193
- * Query webhook configuration.
194
- */
195
- async queryWebhook() {
196
258
  try {
197
259
  const { body, statusCode } = await request(queryWebhook, {
198
260
  method: 'POST',
@@ -202,22 +264,25 @@ export class SwitchBotOpenAPI extends EventEmitter {
202
264
  }),
203
265
  });
204
266
  const response = await body.json();
205
- this.emitLog('debug', `queryWebhook: body:${JSON.stringify(response)}`);
206
- this.emitLog('debug', `queryWebhook: statusCode:${statusCode}`);
267
+ await this.emitLog('debug', `queryWebhook: body:${JSON.stringify(response)}, statusCode:${statusCode}`);
207
268
  if (statusCode !== 200 || response?.statusCode !== 100) {
208
- this.emitLog('error', `Failed to query webhook. HTTP:${statusCode} API:${response?.statusCode} message:${response?.message}`);
269
+ await this.emitLog('error', `Failed to query webhook. HTTP:${statusCode} API:${response?.statusCode} message:${response?.message}`);
209
270
  }
210
271
  else {
211
- this.emitLog('info', `Listening webhook on ${response?.body?.urls?.[0]}`);
272
+ await this.emitLog('info', `Listening webhook on ${response?.body?.urls[0]}`);
212
273
  }
213
274
  }
214
275
  catch (e) {
215
- this.emitLog('error', `Failed to query webhook. Error: ${e.message}`);
276
+ await this.emitLog('error', `Failed to query webhook. Error:${e}`);
216
277
  }
217
278
  }
218
279
  /**
219
- * Delete webhook configuration.
220
- * @param url The webhook URL.
280
+ * Deletes a webhook by sending a request to the specified URL.
281
+ *
282
+ * @param url - The URL of the webhook to be deleted.
283
+ * @returns A promise that resolves when the webhook is successfully deleted.
284
+ *
285
+ * @throws Will log an error if the deletion fails.
221
286
  */
222
287
  async deleteWebhook(url) {
223
288
  try {
@@ -230,17 +295,16 @@ export class SwitchBotOpenAPI extends EventEmitter {
230
295
  }),
231
296
  });
232
297
  const response = await body.json();
233
- this.emitLog('debug', `deleteWebhook: url:${url}, body:${JSON.stringify(response)}`);
234
- this.emitLog('debug', `statusCode: ${statusCode}`);
298
+ await this.emitLog('debug', `deleteWebhook: url:${url}, body:${JSON.stringify(response)}, statusCode:${statusCode}`);
235
299
  if (statusCode !== 200 || response?.statusCode !== 100) {
236
- this.emitLog('error', `Failed to delete webhook. HTTP:${statusCode} API:${response?.statusCode} message:${response?.message}`);
300
+ await this.emitLog('error', `Failed to delete webhook. HTTP:${statusCode} API:${response?.statusCode} message:${response?.message}`);
237
301
  }
238
302
  else {
239
- this.emitLog('info', 'Unregistered webhook to close listening.');
303
+ await this.emitLog('info', 'Unregistered webhook to close listening.');
240
304
  }
241
305
  }
242
306
  catch (e) {
243
- this.emitLog('error', `Failed to delete webhook. Error: ${e.message}`);
307
+ await this.emitLog('error', `Failed to delete webhook. Error:${e.message}`);
244
308
  }
245
309
  }
246
310
  }
@@ -1 +1 @@
1
- {"version":3,"file":"switchbot-openapi.js","sourceRoot":"","sources":["../src/switchbot-openapi.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAEhC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAEjG;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,YAAY;IACxC,KAAK,CAAQ;IACb,MAAM,CAAQ;IACd,OAAO,CAAQ;IAEvB,oBAAoB,CAAkC;IAEtD,YAAY,KAAa,EAAE,MAAc;QACvC,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,OAAO,GAAG,iCAAiC,CAAA;IAClD,CAAC;IAED;;;;OAIG;IACK,OAAO,CAAC,KAAa,EAAE,OAAe;QAC5C,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAA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;oBACvB,GAAG;iBACJ,CAAC;aACH,CAAC,CAAA;YACF,MAAM,QAAQ,GAAQ,MAAM,IAAI,CAAC,IAAI,EAAiB,CAAA;YACtD,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,sBAAsB,GAAG,UAAU,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,gBAAgB,UAAU,EAAE,CAAC,CAAA;YACpH,IAAI,UAAU,KAAK,GAAG,IAAI,QAAQ,EAAE,UAAU,KAAK,GAAG,EAAE,CAAC;gBACvD,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,kCAAkC,UAAU,QAAQ,QAAQ,EAAE,UAAU,YAAY,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAA;YACtI,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,0CAA0C,CAAC,CAAA;YACxE,CAAC;QACH,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,mCAAmC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;QAC7E,CAAC;IACH,CAAC;CACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "node-switchbot",
3
3
  "type": "module",
4
- "version": "2.5.0-beta.25",
4
+ "version": "2.5.0-beta.26",
5
5
  "description": "The node-switchbot is a Node.js module which allows you to control your Switchbot Devices through Bluetooth (BLE).",
6
6
  "author": "OpenWonderLabs (https://github.com/OpenWonderLabs)",
7
7
  "license": "MIT",