node-switchbot 1.8.0-beta.2 → 1.8.0-beta.4
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.
|
@@ -94,7 +94,7 @@ class SwitchbotAdvertising {
|
|
|
94
94
|
sd = this._parseServiceDataForWoContact(buf, onlog);//WoContact
|
|
95
95
|
} else if (model === "c") {
|
|
96
96
|
sd = this._parseServiceDataForWoCurtain(buf, onlog);// WoCurtain
|
|
97
|
-
} else if (model === "x") {
|
|
97
|
+
} else if (model === "x" || 'X') {
|
|
98
98
|
sd = this._parseServiceDataForWoBlindTilt(buf, onlog);// WoBlindTilt
|
|
99
99
|
} else if (model === "u") {
|
|
100
100
|
sd = this._parseServiceDataForWoBulb(manufacturerData, onlog);// WoBulb
|
|
@@ -378,15 +378,12 @@ class SwitchbotAdvertising {
|
|
|
378
378
|
}
|
|
379
379
|
let byte1 = buf.readUInt8(1);
|
|
380
380
|
let byte2 = buf.readUInt8(2);
|
|
381
|
-
let byte3 = buf.readUInt8(3);
|
|
382
|
-
let byte4 = buf.readUInt8(4);
|
|
383
381
|
|
|
384
|
-
let calibration = byte1 &
|
|
382
|
+
let calibration = byte1 & 0b00000001 ? true : false; // Whether the calibration is completed
|
|
385
383
|
let battery = byte2 & 0b01111111; // %
|
|
386
|
-
let inMotion =
|
|
387
|
-
let
|
|
388
|
-
let lightLevel = (
|
|
389
|
-
let deviceChain = byte4 & 0b00000111;
|
|
384
|
+
let inMotion = byte2 & 0b10000000 ? true : false;
|
|
385
|
+
let tilt = byte2 & 0b01111111; // current tilt % (100 - _tilt) if reverse else _tilt,
|
|
386
|
+
let lightLevel = (byte1 >> 4) & 0b00001111; // light sensor level (1-10)
|
|
390
387
|
|
|
391
388
|
let data = {
|
|
392
389
|
model: "x",
|
|
@@ -394,9 +391,8 @@ class SwitchbotAdvertising {
|
|
|
394
391
|
calibration: calibration,
|
|
395
392
|
battery: battery,
|
|
396
393
|
inMotion: inMotion,
|
|
397
|
-
|
|
394
|
+
tilt: tilt,
|
|
398
395
|
lightLevel: lightLevel,
|
|
399
|
-
deviceChain: deviceChain,
|
|
400
396
|
};
|
|
401
397
|
|
|
402
398
|
return data;
|
|
@@ -49,7 +49,7 @@ class SwitchbotDeviceWoCurtain extends SwitchbotDevice {
|
|
|
49
49
|
|
|
50
50
|
/* ------------------------------------------------------------------
|
|
51
51
|
* runToPos()
|
|
52
|
-
* - run to the
|
|
52
|
+
* - run to the target position
|
|
53
53
|
*
|
|
54
54
|
* [Arguments]
|
|
55
55
|
* - percent | number | Required | the percentage of target position
|
|
@@ -63,7 +63,7 @@ class SwitchbotDeviceWoCurtain extends SwitchbotDevice {
|
|
|
63
63
|
return new Promise((resolve, reject) => {
|
|
64
64
|
reject(
|
|
65
65
|
new Error(
|
|
66
|
-
"The type of target position percentage is
|
|
66
|
+
"The type of target position percentage is incorrect: " +
|
|
67
67
|
typeof percent
|
|
68
68
|
)
|
|
69
69
|
);
|
|
@@ -75,7 +75,7 @@ class SwitchbotDeviceWoCurtain extends SwitchbotDevice {
|
|
|
75
75
|
if (typeof mode != "number") {
|
|
76
76
|
return new Promise((resolve, reject) => {
|
|
77
77
|
reject(
|
|
78
|
-
new Error("The type of running mode is
|
|
78
|
+
new Error("The type of running mode is incorrect: " + typeof mode)
|
|
79
79
|
);
|
|
80
80
|
});
|
|
81
81
|
}
|
package/lib/switchbot-device.js
CHANGED
|
@@ -444,7 +444,7 @@ class SwitchbotDevice {
|
|
|
444
444
|
this._connect()
|
|
445
445
|
.then(() => {
|
|
446
446
|
if (!this._chars) {
|
|
447
|
-
return reject("No characteristics available.");
|
|
447
|
+
return reject(new Error("No characteristics available."));
|
|
448
448
|
}
|
|
449
449
|
return this._write(this._chars.write, req_buf);
|
|
450
450
|
})
|
package/lib/switchbot.js
CHANGED
|
@@ -107,6 +107,7 @@ class Switchbot {
|
|
|
107
107
|
"i",
|
|
108
108
|
"r",
|
|
109
109
|
"x",
|
|
110
|
+
"X",
|
|
110
111
|
],
|
|
111
112
|
},
|
|
112
113
|
id: { required: false, type: "string", min: 12, max: 17 },
|
|
@@ -245,6 +246,7 @@ class Switchbot {
|
|
|
245
246
|
device = new SwitchbotDeviceWoCurtain(peripheral, this.noble);
|
|
246
247
|
break;
|
|
247
248
|
case "x":
|
|
249
|
+
case "X":
|
|
248
250
|
device = new SwitchbotDeviceWoBlindTilt(peripheral, this.noble);
|
|
249
251
|
break;
|
|
250
252
|
case "u":
|
|
@@ -355,7 +357,22 @@ class Switchbot {
|
|
|
355
357
|
model: {
|
|
356
358
|
required: false,
|
|
357
359
|
type: "string",
|
|
358
|
-
enum: [
|
|
360
|
+
enum: [
|
|
361
|
+
"H",
|
|
362
|
+
"T",
|
|
363
|
+
"e",
|
|
364
|
+
"s",
|
|
365
|
+
"d",
|
|
366
|
+
"c",
|
|
367
|
+
"u",
|
|
368
|
+
"g",
|
|
369
|
+
"j",
|
|
370
|
+
"o",
|
|
371
|
+
"i",
|
|
372
|
+
"r",
|
|
373
|
+
"x",
|
|
374
|
+
"X",
|
|
375
|
+
],
|
|
359
376
|
},
|
|
360
377
|
id: { required: false, type: "string", min: 12, max: 17 },
|
|
361
378
|
},
|
package/package.json
CHANGED