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

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
 
@@ -556,7 +563,7 @@ class SwitchbotAdvertising {
556
563
  let byte10 = buf.readUInt8(10);
557
564
 
558
565
  let state = byte7 & 0b10000000 ? true : false;
559
- let lightLevel = byte7 & 0b01111111;
566
+ let brightness = byte7 & 0b01111111;
560
567
  let delay = byte8 & 0b10000000;
561
568
  let preset = byte8 & 0b00001000;
562
569
  let color_mode = byte8 & 0b00000111;
@@ -567,7 +574,7 @@ class SwitchbotAdvertising {
567
574
  model: "r",
568
575
  modelName: "WoStrip",
569
576
  state: state,
570
- lightLevel: lightLevel,
577
+ brightness: brightness,
571
578
  delay: delay,
572
579
  preset: preset,
573
580
  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.5",
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": [