node-switchbot 1.5.0 → 1.6.0-beta.0

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.
@@ -549,40 +549,31 @@ class SwitchbotAdvertising {
549
549
  }
550
550
  return null;
551
551
  }
552
- const byte9 = buf.readUInt8(9); // byte9: color bulb state; 0x00=off, 0x80=on & lightLevel: 1~100%
553
- //const byte10 = buf.readUInt8(10); // byte10: bit0: 0=no delay,1=delay, bit1:0=no timer, 1=timer; bit2:0=no sync time, 1=sync'ed time
554
- //const byte11 = buf.readUInt8(11); // byte11: wifi rssi
555
- //const byte12 = buf.readUInt8(12); // byte12: bit7: overload?
556
- //const byte13 = buf.readUInt8(13); // byte12[bit0~6] + byte13: current power value
557
552
 
558
- const state = byte9 === 0x01 ? "off" : byte9 === 0x80 ? "on" : null;
559
- //const lightLevel = byte9 & 0b00000011;
560
- //const delay = !!(byte10 & 0b00000001);
561
- //const networkStatus = !!(byte10 & 0b00000001);
562
- //const statePreset = !!(byte10 & 0b00000010);
563
- //const lightState = !!(byte10 & 0b00000100);
564
- //const wifiRssi = byte11;
565
- //const dynamicRate = !!(byte12 & 0b10000000);
566
- //const loopIndex = (((byte12 & 0b01111111) << 8) + byte13) / 10; // in watt
553
+ const byte7 = buf.readUInt8(7);
554
+ const byte8 = buf.readUInt8(8);
555
+ const byte9 = buf.readUInt8(9);
556
+ const byte10 = buf.readUInt8(10);
557
+
558
+ const isOn = byte7 & 0b10000000;
559
+ const brightness = byte7 & 0b01111111;
560
+ const delay = byte8 & 0b10000000;
561
+ const preset = byte8 & 0b00001000;
562
+ const color_mode = byte8 & 0b00000111;
563
+ const speed = byte9 & 0b01111111;
564
+ const loop_index = byte10 & 0b11111110;
567
565
 
568
566
  const data = {
569
567
  model: "r",
570
568
  modelName: "WoStrip",
571
- state: state,
572
- };
573
- /* const data = {
574
- model: "u",
575
- modelName: "WoBulb",
576
- state: state,
577
- lightLevel: lightLevel,
569
+ isOn: isOn,
570
+ brightness: brightness,
578
571
  delay: delay,
579
- networkStatus: networkStatus,
580
- statePreset: statePreset,
581
- lightState: lightState,
582
- wifiRssi: wifiRssi,
583
- dynamicRate: dynamicRate,
584
- loopIndex: loopIndex,
585
- };*/
572
+ preset: preset,
573
+ color_mode: color_mode,
574
+ speed: speed,
575
+ loop_index: loop_index,
576
+ };
586
577
 
587
578
  return data;
588
579
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-switchbot",
3
- "version": "1.5.0",
3
+ "version": "1.6.0-beta.0",
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": [
@@ -39,4 +39,4 @@
39
39
  "devDependencies": {
40
40
  "npm-check-updates": "^16.3.8"
41
41
  }
42
- }
42
+ }