node-switchbot 1.4.2-beta.8 → 1.4.2-beta.9

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.
@@ -352,10 +352,10 @@ class SwitchbotAdvertising {
352
352
  }
353
353
 
354
354
  _parseServiceDataForWoBulb(buf, onlog) {
355
- if (buf.length !== 6) {
355
+ if (buf.length !== 13) {
356
356
  if (onlog && typeof onlog === "function") {
357
357
  onlog(
358
- `[_parseServiceDataForWoBulb] Buffer length ${buf.length} !== 6!`
358
+ `[_parseServiceDataForWoBulb] Buffer length ${buf.length} !== 13!`
359
359
  );
360
360
  }
361
361
  return null;
@@ -366,8 +366,8 @@ class SwitchbotAdvertising {
366
366
  const byte12 = buf.readUInt8(12); // byte12: bit7: overload?
367
367
  const byte13 = buf.readUInt8(13); // byte12[bit0~6] + byte13: current power value
368
368
 
369
- const state = byte9 === 0x00 ? "off" : byte9 === 0x80 ? "on" : null;
370
- const lightLevel = byte9 & 0b01111111;
369
+ const state = byte9 === 0x01 ? "off" : byte9 === 0x80 ? "on" : null;
370
+ const lightLevel = byte9 & 0b00000011;
371
371
  const delay = !!(byte10 & 0b00000001);
372
372
  const networkStatus = !!(byte10 & 0b00000001);
373
373
  const statePreset = !!(byte10 & 0b00000010);
@@ -375,12 +375,16 @@ class SwitchbotAdvertising {
375
375
  const wifiRssi = byte11;
376
376
  const dynamicRate = !!(byte12 & 0b10000000);
377
377
  const loopIndex = (((byte12 & 0b01111111) << 8) + byte13) / 10; // in watt
378
- // TODO: voltage ???
379
378
 
380
379
  const data = {
381
380
  model: "u",
382
381
  modelName: "WoBulb",
383
382
  state: state,
383
+ };
384
+ /* const data = {
385
+ model: "u",
386
+ modelName: "WoBulb",
387
+ state: state,
384
388
  lightLevel: lightLevel,
385
389
  delay: delay,
386
390
  networkStatus: networkStatus,
@@ -389,7 +393,7 @@ class SwitchbotAdvertising {
389
393
  wifiRssi: wifiRssi,
390
394
  dynamicRate: dynamicRate,
391
395
  loopIndex: loopIndex,
392
- };
396
+ };*/
393
397
 
394
398
  return data;
395
399
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-switchbot",
3
- "version": "1.4.2-beta.8",
3
+ "version": "1.4.2-beta.9",
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": [