Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/parameter-checker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use strict";

const { Buffer } = require('buffer');

class ParameterChecker {
constructor() {
this._error = null;
Expand Down
5 changes: 3 additions & 2 deletions lib/switchbot-advertising.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use strict";

const { Buffer } = require('buffer');

class SwitchbotAdvertising {
constructor() {}

Expand Down Expand Up @@ -595,8 +597,7 @@ class SwitchbotAdvertising {

const temp_sign = byte4 & 0b10000000 ? 1 : -1;
const temp_c = temp_sign * ((byte4 & 0b01111111) + (byte3 & 0b00001111) / 10);
const temp_f = (temp_c * 9 / 5) + 32;
temp_f = Math.round(temp_f * 10) / 10;
const temp_f = Math.round(((temp_c * 9 / 5) + 32) * 10) / 10;

const data = {
model: "i",
Expand Down
3 changes: 3 additions & 0 deletions lib/switchbot-device-woblindtilt.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
"use strict";

const { Buffer } = require('buffer');

let SwitchbotDevice = require("./switchbot-device.js");

class SwitchbotDeviceWoBlindTilt extends SwitchbotDevice {
Expand Down
3 changes: 3 additions & 0 deletions lib/switchbot-device-wobulb.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
"use strict";

const { Buffer } = require('buffer');

const SwitchbotDevice = require("./switchbot-device.js");

/**
Expand Down
3 changes: 3 additions & 0 deletions lib/switchbot-device-wocurtain.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
"use strict";

const { Buffer } = require('buffer');

const SwitchbotDevice = require("./switchbot-device.js");

class SwitchbotDeviceWoCurtain extends SwitchbotDevice {
Expand Down
3 changes: 3 additions & 0 deletions lib/switchbot-device-wohand.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
"use strict";

const { Buffer } = require('buffer');

const SwitchbotDevice = require("./switchbot-device.js");

class SwitchbotDeviceWoHand extends SwitchbotDevice {
Expand Down
3 changes: 3 additions & 0 deletions lib/switchbot-device-wohumi.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
"use strict";

const { Buffer } = require('buffer');

const SwitchbotDevice = require("./switchbot-device.js");

class SwitchbotDeviceWoHumi extends SwitchbotDevice {
Expand Down
3 changes: 3 additions & 0 deletions lib/switchbot-device-woplugmini.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
"use strict";

const { Buffer } = require('buffer');

const SwitchbotDevice = require("./switchbot-device.js");

/**
Expand Down
3 changes: 3 additions & 0 deletions lib/switchbot-device-wostrip.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
"use strict";

const { Buffer } = require('buffer');

const SwitchbotDevice = require("./switchbot-device.js");

/**
Expand Down
7 changes: 5 additions & 2 deletions lib/switchbot-device.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
"use strict";

const { Buffer } = require('buffer');

const parameterChecker = require("./parameter-checker.js");
const switchbotAdvertising = require("./switchbot-advertising.js");

Expand Down Expand Up @@ -330,7 +333,7 @@ class SwitchbotDevice {

_disconnect() {
if (this._was_connected_explicitly) {
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
resolve();
});
} else {
Expand All @@ -351,7 +354,7 @@ class SwitchbotDevice {
* ---------------------------------------------------------------- */
getDeviceName() {
return new Promise((resolve, reject) => {
const name = "";
let name = "";
this._connect()
.then(() => {
if (!this._chars.device) {
Expand Down
2 changes: 1 addition & 1 deletion lib/switchbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ class Switchbot {
return false;
}
if (id) {
id = id.toLowerCase().replace(/\:/g, "");
id = id.toLowerCase().replace(/:/g, "");
const ad_id = ad.address.toLowerCase().replace(/[^a-z0-9]/g, "");
if (ad_id !== id) {
return false;
Expand Down