node-switchbot 1.8.2-beta.1 → 1.8.2-beta.3

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,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ const { Buffer } = require('buffer');
4
+
3
5
  class ParameterChecker {
4
6
  constructor() {
5
7
  this._error = null;
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ const { Buffer } = require('buffer');
4
+
3
5
  class SwitchbotAdvertising {
4
6
  constructor() {}
5
7
 
@@ -201,8 +203,7 @@ class SwitchbotAdvertising {
201
203
 
202
204
  const temp_sign = byte4 & 0b10000000 ? 1 : -1;
203
205
  const temp_c = temp_sign * ((byte4 & 0b01111111) + (byte3 & 0b00001111) / 10);
204
- const temp_f = (temp_c * 9 / 5) + 32;
205
- temp_f = Math.round(temp_f * 10) / 10;
206
+ const temp_f = Math.round(((temp_c * 9 / 5) + 32) * 10) / 10;
206
207
 
207
208
  const data = {
208
209
  model: "T",
@@ -596,8 +597,7 @@ class SwitchbotAdvertising {
596
597
 
597
598
  const temp_sign = byte4 & 0b10000000 ? 1 : -1;
598
599
  const temp_c = temp_sign * ((byte4 & 0b01111111) + (byte3 & 0b00001111) / 10);
599
- const temp_f = (temp_c * 9 / 5) + 32;
600
- temp_f = Math.round(temp_f * 10) / 10;
600
+ const temp_f = Math.round(((temp_c * 9 / 5) + 32) * 10) / 10;
601
601
 
602
602
  const data = {
603
603
  model: "i",
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+
3
+ const { Buffer } = require('buffer');
4
+
2
5
  let SwitchbotDevice = require("./switchbot-device.js");
3
6
 
4
7
  class SwitchbotDeviceWoBlindTilt extends SwitchbotDevice {
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+
3
+ const { Buffer } = require('buffer');
4
+
2
5
  const SwitchbotDevice = require("./switchbot-device.js");
3
6
 
4
7
  /**
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+
3
+ const { Buffer } = require('buffer');
4
+
2
5
  const SwitchbotDevice = require("./switchbot-device.js");
3
6
 
4
7
  class SwitchbotDeviceWoCurtain extends SwitchbotDevice {
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+
3
+ const { Buffer } = require('buffer');
4
+
2
5
  const SwitchbotDevice = require("./switchbot-device.js");
3
6
 
4
7
  class SwitchbotDeviceWoHand extends SwitchbotDevice {
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+
3
+ const { Buffer } = require('buffer');
4
+
2
5
  const SwitchbotDevice = require("./switchbot-device.js");
3
6
 
4
7
  class SwitchbotDeviceWoHumi extends SwitchbotDevice {
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+
3
+ const { Buffer } = require('buffer');
4
+
2
5
  const SwitchbotDevice = require("./switchbot-device.js");
3
6
 
4
7
  /**
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+
3
+ const { Buffer } = require('buffer');
4
+
2
5
  const SwitchbotDevice = require("./switchbot-device.js");
3
6
 
4
7
  /**
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+
3
+ const { Buffer } = require('buffer');
4
+
2
5
  const parameterChecker = require("./parameter-checker.js");
3
6
  const switchbotAdvertising = require("./switchbot-advertising.js");
4
7
 
@@ -330,7 +333,7 @@ class SwitchbotDevice {
330
333
 
331
334
  _disconnect() {
332
335
  if (this._was_connected_explicitly) {
333
- return new Promise((resolve, reject) => {
336
+ return new Promise((resolve) => {
334
337
  resolve();
335
338
  });
336
339
  } else {
@@ -351,7 +354,7 @@ class SwitchbotDevice {
351
354
  * ---------------------------------------------------------------- */
352
355
  getDeviceName() {
353
356
  return new Promise((resolve, reject) => {
354
- const name = "";
357
+ let name = "";
355
358
  this._connect()
356
359
  .then(() => {
357
360
  if (!this._chars.device) {
package/lib/switchbot.js CHANGED
@@ -279,7 +279,7 @@ class Switchbot {
279
279
  return false;
280
280
  }
281
281
  if (id) {
282
- id = id.toLowerCase().replace(/\:/g, "");
282
+ id = id.toLowerCase().replace(/:/g, "");
283
283
  const ad_id = ad.address.toLowerCase().replace(/[^a-z0-9]/g, "");
284
284
  if (ad_id !== id) {
285
285
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-switchbot",
3
- "version": "1.8.2-beta.1",
3
+ "version": "1.8.2-beta.3",
4
4
  "description": "The node-switchbot is a Node.js module which allows you to control your Switchbot Devices through Bluetooth (BLE).",
5
5
  "main": "./lib/switchbot.js",
6
6
  "files": [