node-switchbot 1.8.0-beta.1 → 1.8.0-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.
@@ -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 & 0b01000000 ? true : false; // Whether the calibration is completed
382
+ let calibration = byte1 & 0b00000001 ? true : false; // Whether the calibration is completed
385
383
  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)
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
- position: currPosition,
394
+ tilt: tilt,
398
395
  lightLevel: lightLevel,
399
- deviceChain: deviceChain,
400
396
  };
401
397
 
402
398
  return data;
package/lib/switchbot.js CHANGED
@@ -93,7 +93,22 @@ class Switchbot {
93
93
  model: {
94
94
  required: false,
95
95
  type: "string",
96
- enum: ["H", "T", "e", "s", "d", "c", "u", "g", "j", "o", "i", "r", "x"],
96
+ enum: [
97
+ "H",
98
+ "T",
99
+ "e",
100
+ "s",
101
+ "d",
102
+ "c",
103
+ "u",
104
+ "g",
105
+ "j",
106
+ "o",
107
+ "i",
108
+ "r",
109
+ "x",
110
+ "X",
111
+ ],
97
112
  },
98
113
  id: { required: false, type: "string", min: 12, max: 17 },
99
114
  quick: { required: false, type: "boolean" },
@@ -230,6 +245,10 @@ class Switchbot {
230
245
  case "c":
231
246
  device = new SwitchbotDeviceWoCurtain(peripheral, this.noble);
232
247
  break;
248
+ case "x":
249
+ case "X":
250
+ device = new SwitchbotDeviceWoBlindTilt(peripheral, this.noble);
251
+ break;
233
252
  case "u":
234
253
  device = new SwitchbotDeviceWoBulb(peripheral, this.noble);
235
254
  break;
@@ -241,7 +260,7 @@ class Switchbot {
241
260
  device = new SwitchbotDeviceWoSmartLock(peripheral, this.noble);
242
261
  break;
243
262
  case "i":
244
- device = new SwitchbotDeviceWoSensorTHPlus(peripheral, this.noble);
263
+ device = new SwitchbotDeviceWoSensorTH(peripheral, this.noble);
245
264
  break;
246
265
  case "r":
247
266
  device = new SwitchbotDeviceWoStrip(peripheral, this.noble);
@@ -280,7 +299,7 @@ class Switchbot {
280
299
  *
281
300
  * [Arguments]
282
301
  * - params | Object | Optional |
283
- * - model | String | Optional | "H", "T", "e", "s", "d", "c", "u", "g", "o", "i", or "r".
302
+ * - model | String | Optional | "H", "T", "e", "s", "d", "c", "u", "g", "o", "i", "x", or "r".
284
303
  * | | | If "H" is specified, the `onadvertisement`
285
304
  * | | | event handler will be called only when advertising
286
305
  * | | | packets comes from Bots.
@@ -299,6 +318,9 @@ class Switchbot {
299
318
  * | | | If "c" is specified, the `onadvertisement`
300
319
  * | | | event handler will be called only when advertising
301
320
  * | | | packets comes from Curtains.
321
+ * | | | If "x" is specified, the `onadvertisement`
322
+ * | | | event handler will be called only when advertising
323
+ * | | | packets comes from BlindTilt.
302
324
  * | | | If "u" is specified, the `onadvertisement`
303
325
  * | | | event handler will be called only when advertising
304
326
  * | | | packets comes from Color Bulb.
@@ -335,7 +357,22 @@ class Switchbot {
335
357
  model: {
336
358
  required: false,
337
359
  type: "string",
338
- enum: ["H", "T", "e", "s", "d", "c", "u", "g", "j", "o", "i", "r"],
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
+ ],
339
376
  },
340
377
  id: { required: false, type: "string", min: 12, max: 17 },
341
378
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-switchbot",
3
- "version": "1.8.0-beta.1",
3
+ "version": "1.8.0-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": [