Skip to content

Commit c9eb43e

Browse files
committed
blindtilt
1 parent 5ec1b8b commit c9eb43e

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

lib/switchbot-advertising.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class SwitchbotAdvertising {
9494
sd = this._parseServiceDataForWoContact(buf, onlog);//WoContact
9595
} else if (model === "c") {
9696
sd = this._parseServiceDataForWoCurtain(buf, onlog);// WoCurtain
97-
} else if (model === "x") {
97+
} else if (model === "x" || 'X') {
9898
sd = this._parseServiceDataForWoBlindTilt(buf, onlog);// WoBlindTilt
9999
} else if (model === "u") {
100100
sd = this._parseServiceDataForWoBulb(manufacturerData, onlog);// WoBulb
@@ -378,25 +378,21 @@ class SwitchbotAdvertising {
378378
}
379379
let byte1 = buf.readUInt8(1);
380380
let byte2 = buf.readUInt8(2);
381-
let byte3 = buf.readUInt8(3);
382-
let byte4 = buf.readUInt8(4);
383381

384-
let calibration = byte1 & 0b01000000 ? true : false; // Whether the calibration is completed
382+
let calibration = byte1 & 0b00000001 ? true : false; // Whether the calibration is completed
385383
let battery = byte2 & 0b01111111; // %
386-
let inMotion = byte3 & 0b10000000 ? true : false;
387-
let currPosition = byte3 & 0b01111111; // current positon %
388-
let lightLevel = (byte4 >> 4) & 0b00001111; // light sensor level (1-10)
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)
390387

391388
let data = {
392389
model: "x",
393390
modelName: "WoBlindTilt",
394391
calibration: calibration,
395392
battery: battery,
396393
inMotion: inMotion,
397-
position: currPosition,
394+
tilt: tilt,
398395
lightLevel: lightLevel,
399-
deviceChain: deviceChain,
400396
};
401397

402398
return data;

lib/switchbot.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class Switchbot {
107107
"i",
108108
"r",
109109
"x",
110+
"X",
110111
],
111112
},
112113
id: { required: false, type: "string", min: 12, max: 17 },
@@ -245,6 +246,7 @@ class Switchbot {
245246
device = new SwitchbotDeviceWoCurtain(peripheral, this.noble);
246247
break;
247248
case "x":
249+
case "X":
248250
device = new SwitchbotDeviceWoBlindTilt(peripheral, this.noble);
249251
break;
250252
case "u":
@@ -355,7 +357,22 @@ class Switchbot {
355357
model: {
356358
required: false,
357359
type: "string",
358-
enum: ["H", "T", "e", "s", "d", "c", "u", "g", "j", "o", "i", "r", "x"],
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+
],
359376
},
360377
id: { required: false, type: "string", min: 12, max: 17 },
361378
},

0 commit comments

Comments
 (0)