node-switchbot 1.6.0-beta.4 → 1.6.0-beta.6

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.
@@ -267,7 +267,7 @@ class SwitchbotAdvertising {
267
267
  let led = (byte5 & 0b00100000) >> 5;
268
268
  let iot = (byte5 & 0b00010000) >> 4;
269
269
  let sense_distance = (byte5 & 0b00001100) >> 2;
270
- let light_intensity = byte5 & 0b00000011;
270
+ let lightLevel = byte5 & 0b00000011;
271
271
  let is_light = byte5 & 0b00000010 ? true : false;
272
272
 
273
273
  let data = {
@@ -279,7 +279,8 @@ class SwitchbotAdvertising {
279
279
  led: led,
280
280
  iot: iot,
281
281
  sense_distance: sense_distance,
282
- light_intensity: light_intensity,
282
+ lightLevel:
283
+ lightLevel == 1 ? "dark" : lightLevel == 2 ? "bright" : "unknown",
283
284
  is_light: is_light,
284
285
  };
285
286
 
@@ -307,7 +308,7 @@ class SwitchbotAdvertising {
307
308
  let battery = byte2 & 0b01111111; // %
308
309
  let contact_open = byte3 & 0b00000010 == 0b00000010;
309
310
  let contact_timeout = byte3 & 0b00000100 == 0b00000100;
310
- let is_light = byte3 & 0b00000001 ? true : false;
311
+ let lightLevel = byte3 & 0b00000001;
311
312
  let button_count = byte8 & 0b00001111;
312
313
 
313
314
  let data = {
@@ -318,9 +319,14 @@ class SwitchbotAdvertising {
318
319
  battery: battery,
319
320
  contact_open: contact_open,
320
321
  contact_timeout: contact_timeout,
321
- is_light: is_light,
322
+ lightLevel: lightLevel == 0 ? "dark" : "bright",
322
323
  button_count: button_count,
323
- hallState: hallState,
324
+ doorState:
325
+ hallState == 0
326
+ ? "close"
327
+ : hallState == 1
328
+ ? "open"
329
+ : "timeout no closed",
324
330
  };
325
331
 
326
332
  return data;
@@ -343,7 +349,8 @@ class SwitchbotAdvertising {
343
349
  let calibration = byte1 & 0b01000000 ? true : false; // Whether the calibration is completed
344
350
  let battery = byte2 & 0b01111111; // %
345
351
  let inMotion = byte3 & 0b10000000 ? true : false;
346
- let currPosition = max(min(byte3 & 0b01111111, 100), 0) //byte3 & 0b01111111; // current positon %
352
+ let currPosition = byte3 & 0b01111111; // current positon %
353
+ //let currPosition = max(min(byte3 & 0b01111111, 100), 0) //byte3 & 0b01111111; // current positon %
347
354
  let lightLevel = (byte4 >> 4) & 0b00001111; // light sensor level (1-10)
348
355
  let deviceChain = byte4 & 0b00000111;
349
356
 
@@ -370,14 +377,20 @@ class SwitchbotAdvertising {
370
377
  }
371
378
  return null;
372
379
  }
373
-
374
- let byte6 = buf.readUInt8(6);
380
+ let byte1 = buf.readUInt8(1);//power and light status
381
+ let byte2 = buf.readUInt8(2);//bulb brightness
382
+ let byte3 = buf.readUInt8(3);//bulb R
383
+ let byte4 = buf.readUInt8(4);//bulb G
384
+ let byte5 = buf.readUInt8(5);//bulb B
385
+ let byte6 = buf.readUInt8(6);//bulb temperature
375
386
  let byte7 = buf.readUInt8(7);
376
387
  let byte8 = buf.readUInt8(8);
377
388
  let byte9 = buf.readUInt8(9);
378
- let byte10 = buf.readUInt8(10);
379
-
389
+ let byte10 = buf.readUInt8(10);//bulb mode
380
390
 
391
+ let r = byte3;
392
+ let g = byte4;
393
+ let b = byte5;
381
394
  let sequence_number = byte6;
382
395
  let state = byte7 & 0b01111111 ? true : false;
383
396
  let brightness = byte7 & 0b01111111;
@@ -392,6 +405,9 @@ class SwitchbotAdvertising {
392
405
  modelName: "WoBulb",
393
406
  sequence_number: sequence_number,
394
407
  state: state,
408
+ r: r,
409
+ g: g,
410
+ b: b,
395
411
  brightness: brightness,
396
412
  delay: delay,
397
413
  preset: preset,
@@ -556,7 +572,7 @@ class SwitchbotAdvertising {
556
572
  let byte10 = buf.readUInt8(10);
557
573
 
558
574
  let state = byte7 & 0b10000000 ? true : false;
559
- let lightLevel = byte7 & 0b01111111;
575
+ let brightness = byte7 & 0b01111111;
560
576
  let delay = byte8 & 0b10000000;
561
577
  let preset = byte8 & 0b00001000;
562
578
  let color_mode = byte8 & 0b00000111;
@@ -567,7 +583,7 @@ class SwitchbotAdvertising {
567
583
  model: "r",
568
584
  modelName: "WoStrip",
569
585
  state: state,
570
- lightLevel: lightLevel,
586
+ brightness: brightness,
571
587
  delay: delay,
572
588
  preset: preset,
573
589
  color_mode: color_mode,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-switchbot",
3
- "version": "1.6.0-beta.4",
3
+ "version": "1.6.0-beta.6",
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": [