node-switchbot 1.6.0-beta.0 → 1.6.0-beta.1

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.
@@ -360,40 +360,35 @@ class SwitchbotAdvertising {
360
360
  }
361
361
  return null;
362
362
  }
363
- const byte9 = buf.readUInt8(9); // byte9: color bulb state; 0x00=off, 0x80=on & lightLevel: 1~100%
364
- //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
365
- //const byte11 = buf.readUInt8(11); // byte11: wifi rssi
366
- //const byte12 = buf.readUInt8(12); // byte12: bit7: overload?
367
- //const byte13 = buf.readUInt8(13); // byte12[bit0~6] + byte13: current power value
368
-
369
- const state = byte9 === 0x01 ? "off" : byte9 === 0x80 ? "on" : null;
370
- const lightLevel = byte9 & 0b00000011;
371
- //const delay = !!(byte10 & 0b00000001);
372
- //const networkStatus = !!(byte10 & 0b00000001);
373
- //const statePreset = !!(byte10 & 0b00000010);
374
- //const lightState = !!(byte10 & 0b00000100);
375
- //const wifiRssi = byte11;
376
- //const dynamicRate = !!(byte12 & 0b10000000);
377
- //const loopIndex = (((byte12 & 0b01111111) << 8) + byte13) / 10; // in watt
363
+
364
+ const byte6 = buf.readUInt8(6);
365
+ const byte7 = buf.readUInt8(7);
366
+ const byte8 = buf.readUInt8(8);
367
+ const byte9 = buf.readUInt8(9);
368
+ const byte10 = buf.readUInt8(10);
369
+
370
+
371
+ const sequence_number = byte6;
372
+ const isOn = byte7 & 0b01111111 ? true : false;
373
+ const brightness = byte7 & 0b01111111;
374
+ const delay = byte8 & 0b10000000;
375
+ const preset = byte8 & 0b00001000;
376
+ const color_mode = byte8 & 0b00000111;
377
+ const speed = byte9 & 0b01111111;
378
+ const loop_index = byte10 & 0b11111110;
378
379
 
379
380
  const data = {
380
381
  model: "u",
381
382
  modelName: "WoBulb",
382
- state: state,
383
- };
384
- /* const data = {
385
- model: "u",
386
- modelName: "WoBulb",
387
- state: state,
388
- lightLevel: lightLevel,
383
+ sequence_number: sequence_number,
384
+ isOn: isOn,
385
+ brightness: brightness,
389
386
  delay: delay,
390
- networkStatus: networkStatus,
391
- statePreset: statePreset,
392
- lightState: lightState,
393
- wifiRssi: wifiRssi,
394
- dynamicRate: dynamicRate,
395
- loopIndex: loopIndex,
396
- };*/
387
+ preset: preset,
388
+ color_mode: color_mode,
389
+ speed: speed,
390
+ loop_index: loop_index,
391
+ };
397
392
 
398
393
  return data;
399
394
  }
@@ -555,7 +550,7 @@ class SwitchbotAdvertising {
555
550
  const byte9 = buf.readUInt8(9);
556
551
  const byte10 = buf.readUInt8(10);
557
552
 
558
- const isOn = byte7 & 0b10000000;
553
+ const isOn = byte7 & 0b10000000 ? true : false;
559
554
  const brightness = byte7 & 0b01111111;
560
555
  const delay = byte8 & 0b10000000;
561
556
  const preset = byte8 & 0b00001000;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-switchbot",
3
- "version": "1.6.0-beta.0",
3
+ "version": "1.6.0-beta.1",
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": [
@@ -37,6 +37,6 @@
37
37
  "@abandonware/noble": "^1.9.2-15"
38
38
  },
39
39
  "devDependencies": {
40
- "npm-check-updates": "^16.3.8"
40
+ "npm-check-updates": "^16.3.13"
41
41
  }
42
42
  }