node-switchbot 1.6.0-beta.2 → 1.6.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.
- package/lib/switchbot-advertising.js +5 -18
- package/package.json +1 -1
|
@@ -227,10 +227,8 @@ class SwitchbotAdvertising {
|
|
|
227
227
|
return null;
|
|
228
228
|
}
|
|
229
229
|
let byte1 = buf.readUInt8(1);
|
|
230
|
-
// let byte2 = buf.readUInt8(2);
|
|
231
|
-
let byte3 = buf.readUInt8(3);
|
|
232
230
|
let byte4 = buf.readUInt8(4);
|
|
233
|
-
|
|
231
|
+
|
|
234
232
|
|
|
235
233
|
let onState = byte1 & 0b10000000 ? true : false; // 1 - on
|
|
236
234
|
let autoMode = byte4 & 0b10000000 ? true : false; // 1 - auto
|
|
@@ -260,8 +258,6 @@ class SwitchbotAdvertising {
|
|
|
260
258
|
|
|
261
259
|
let byte1 = buf.readUInt8(1);
|
|
262
260
|
let byte2 = buf.readUInt8(2);
|
|
263
|
-
//let byte3 = buf.readUInt8(3);
|
|
264
|
-
//let byte4 = buf.readUInt8(4);
|
|
265
261
|
let byte5 = buf.readUInt8(5);
|
|
266
262
|
|
|
267
263
|
|
|
@@ -303,10 +299,6 @@ class SwitchbotAdvertising {
|
|
|
303
299
|
let byte1 = buf.readUInt8(1);
|
|
304
300
|
let byte2 = buf.readUInt8(2);
|
|
305
301
|
let byte3 = buf.readUInt8(3);
|
|
306
|
-
// let byte4 = buf.readUInt8(4);
|
|
307
|
-
// let byte5 = buf.readUInt8(5);
|
|
308
|
-
// let byte6 = buf.readUInt8(6);
|
|
309
|
-
// let byte7 = buf.readUInt8(7);
|
|
310
302
|
let byte8 = buf.readUInt8(8);
|
|
311
303
|
|
|
312
304
|
let hallState = (byte3 >> 1) & 0b00000011;
|
|
@@ -316,7 +308,7 @@ class SwitchbotAdvertising {
|
|
|
316
308
|
let contact_open = byte3 & 0b00000010 == 0b00000010;
|
|
317
309
|
let contact_timeout = byte3 & 0b00000100 == 0b00000100;
|
|
318
310
|
let is_light = byte3 & 0b00000001 ? true : false;
|
|
319
|
-
let button_count =
|
|
311
|
+
let button_count = byte8 & 0b00001111;
|
|
320
312
|
|
|
321
313
|
let data = {
|
|
322
314
|
model: "d",
|
|
@@ -351,7 +343,7 @@ class SwitchbotAdvertising {
|
|
|
351
343
|
let calibration = byte1 & 0b01000000 ? true : false; // Whether the calibration is completed
|
|
352
344
|
let battery = byte2 & 0b01111111; // %
|
|
353
345
|
let inMotion = byte3 & 0b10000000 ? true : false;
|
|
354
|
-
let currPosition = max(min(
|
|
346
|
+
let currPosition = max(min(byte3 & 0b01111111, 100), 0) //byte3 & 0b01111111; // current positon %
|
|
355
347
|
let lightLevel = (byte4 >> 4) & 0b00001111; // light sensor level (1-10)
|
|
356
348
|
let deviceChain = byte4 & 0b00000111;
|
|
357
349
|
|
|
@@ -500,20 +492,15 @@ class SwitchbotAdvertising {
|
|
|
500
492
|
}
|
|
501
493
|
let byte1 = buf.readUInt8(1);
|
|
502
494
|
let byte2 = buf.readUInt8(2);
|
|
503
|
-
// let byte3 = buf.readUInt8(3);
|
|
504
|
-
// let byte4 = buf.readUInt8(4);
|
|
505
|
-
let byte5 = buf.readUInt8(5);
|
|
506
495
|
|
|
507
|
-
|
|
496
|
+
let movement = (byte1 & 0b01000000) ? true : false; // 1 - Movement detected
|
|
508
497
|
let battery = byte2 & 0b01111111; // %
|
|
509
|
-
//let lightLevel = byte5 & 0b00000011;
|
|
510
498
|
|
|
511
499
|
let data = {
|
|
512
500
|
model: "o",
|
|
513
501
|
modelName: "WoSmartLock",
|
|
514
|
-
//movement: movement,
|
|
515
502
|
battery: battery,
|
|
516
|
-
|
|
503
|
+
movement: movement,
|
|
517
504
|
};
|
|
518
505
|
|
|
519
506
|
return data;
|
package/package.json
CHANGED