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

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.
@@ -198,8 +198,8 @@ class SwitchbotAdvertising {
198
198
  let byte5 = buf.readUInt8(5);
199
199
 
200
200
  let temp_sign = byte4 & 0b10000000 ? 1 : -1;
201
- let temp_c = temp_sign * ((byte4 & 0b01111111) + byte3 / 10);
202
- let temp_f = (temp_c * 9) / 5 + 32;
201
+ let temp_c = temp_sign * ((byte4 & 0b01111111) + (byte3 & 0b00001111) / 10);
202
+ let temp_f = (temp_c * 9 / 5) + 32;
203
203
  temp_f = Math.round(temp_f * 10) / 10;
204
204
 
205
205
  let data = {
@@ -227,10 +227,8 @@ class SwitchbotAdvertising {
227
227
  return null;
228
228
  }
229
229
  let byte1 = buf.readUInt8(1);
230
- // let byte2 = buf.readUInt8(2);
231
- let byte3 = buf.readUInt8(3);
232
230
  let byte4 = buf.readUInt8(4);
233
- let byte5 = buf.readUInt8(5);
231
+
234
232
 
235
233
  let onState = byte1 & 0b10000000 ? true : false; // 1 - on
236
234
  let autoMode = byte4 & 0b10000000 ? true : false; // 1 - auto
@@ -256,23 +254,34 @@ class SwitchbotAdvertising {
256
254
  }
257
255
  return null;
258
256
  }
257
+
258
+
259
259
  let byte1 = buf.readUInt8(1);
260
260
  let byte2 = buf.readUInt8(2);
261
- // let byte3 = buf.readUInt8(3);
262
- // let byte4 = buf.readUInt8(4);
263
261
  let byte5 = buf.readUInt8(5);
264
262
 
265
- let pirState = byte1 & 0b01000000 ? true : false; // 1 - Movement detected
266
- let battery = byte2 & 0b01111111; // %
263
+
264
+ let tested = byte1 & 0b10000000 ? true : false;
265
+ let movement = byte1 & 0b01000000 ? true : false;
266
+ let battery = byte2 & 0b01111111;
267
+ let led = (byte5 & 0b00100000) >> 5;
268
+ let iot = (byte5 & 0b00010000) >> 4;
269
+ let sense_distance = (byte5 & 0b00001100) >> 2;
267
270
  let lightLevel = byte5 & 0b00000011;
271
+ let is_light = byte5 & 0b00000010 ? true : false;
268
272
 
269
273
  let data = {
270
274
  model: "s",
271
275
  modelName: "WoMotion",
272
- movement: pirState,
276
+ tested: tested,
277
+ movement: movement,
273
278
  battery: battery,
279
+ led: led,
280
+ iot: iot,
281
+ sense_distance: sense_distance,
274
282
  lightLevel:
275
283
  lightLevel == 1 ? "dark" : lightLevel == 2 ? "bright" : "unknown",
284
+ is_light: is_light,
276
285
  };
277
286
 
278
287
  return data;
@@ -291,29 +300,33 @@ class SwitchbotAdvertising {
291
300
  let byte1 = buf.readUInt8(1);
292
301
  let byte2 = buf.readUInt8(2);
293
302
  let byte3 = buf.readUInt8(3);
294
- // let byte4 = buf.readUInt8(4);
295
- // let byte5 = buf.readUInt8(5);
296
- // let byte6 = buf.readUInt8(6);
297
- // let byte7 = buf.readUInt8(7);
298
- // let byte8 = buf.readUInt8(8);
303
+ let byte8 = buf.readUInt8(8);
299
304
 
300
- let pirState = byte1 & 0b01000000 ? true : false; // 1 - Movement detected
301
- let battery = byte2 & 0b01111111; // %
302
305
  let hallState = (byte3 >> 1) & 0b00000011;
306
+ let tested = byte1 & 0b10000000;
307
+ let movement = byte1 & 0b01000000 ? true : false; // 1 - Movement detected
308
+ let battery = byte2 & 0b01111111; // %
309
+ let contact_open = byte3 & 0b00000010 == 0b00000010;
310
+ let contact_timeout = byte3 & 0b00000100 == 0b00000100;
303
311
  let lightLevel = byte3 & 0b00000001;
312
+ let button_count = byte8 & 0b00001111;
304
313
 
305
314
  let data = {
306
315
  model: "d",
307
316
  modelName: "WoContact",
308
- movement: pirState,
317
+ movement: movement,
318
+ tested: tested,
309
319
  battery: battery,
320
+ contact_open: contact_open,
321
+ contact_timeout: contact_timeout,
322
+ lightLevel: lightLevel == 0 ? "dark" : "bright",
323
+ button_count: button_count,
310
324
  doorState:
311
325
  hallState == 0
312
326
  ? "close"
313
327
  : hallState == 1
314
328
  ? "open"
315
329
  : "timeout no closed",
316
- lightLevel: lightLevel == 0 ? "dark" : "bright",
317
330
  };
318
331
 
319
332
  return data;
@@ -332,20 +345,24 @@ class SwitchbotAdvertising {
332
345
  let byte2 = buf.readUInt8(2);
333
346
  let byte3 = buf.readUInt8(3);
334
347
  let byte4 = buf.readUInt8(4);
335
- // let byte5 = buf.readUInt8(5);
336
348
 
337
349
  let calibration = byte1 & 0b01000000 ? true : false; // Whether the calibration is completed
338
350
  let battery = byte2 & 0b01111111; // %
351
+ let inMotion = byte3 & 0b10000000 ? true : false;
339
352
  let currPosition = byte3 & 0b01111111; // current positon %
353
+ //let currPosition = max(min(byte3 & 0b01111111, 100), 0) //byte3 & 0b01111111; // current positon %
340
354
  let lightLevel = (byte4 >> 4) & 0b00001111; // light sensor level (1-10)
355
+ let deviceChain = byte4 & 0b00000111;
341
356
 
342
357
  let data = {
343
358
  model: "c",
344
359
  modelName: "WoCurtain",
345
360
  calibration: calibration,
346
361
  battery: battery,
362
+ inMotion: inMotion,
347
363
  position: currPosition,
348
364
  lightLevel: lightLevel,
365
+ deviceChain: deviceChain,
349
366
  };
350
367
 
351
368
  return data;
@@ -360,40 +377,44 @@ class SwitchbotAdvertising {
360
377
  }
361
378
  return null;
362
379
  }
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
378
-
379
- const data = {
380
- model: "u",
381
- modelName: "WoBulb",
382
- state: state,
383
- };
384
- /* const data = {
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
386
+ let byte7 = buf.readUInt8(7);
387
+ let byte8 = buf.readUInt8(8);
388
+ let byte9 = buf.readUInt8(9);
389
+ let byte10 = buf.readUInt8(10);//bulb mode
390
+
391
+ let red = byte3;
392
+ let green = byte4;
393
+ let blue = byte5;
394
+ let color_temperature = byte6;
395
+ let state = byte7 & 0b01111111 ? true : false;
396
+ let brightness = byte7 & 0b01111111;
397
+ let delay = byte8 & 0b10000000;
398
+ let preset = byte8 & 0b00001000;
399
+ let color_mode = byte8 & 0b00000111;
400
+ let speed = byte9 & 0b01111111;
401
+ let loop_index = byte10 & 0b11111110;
402
+
403
+ let data = {
385
404
  model: "u",
386
405
  modelName: "WoBulb",
406
+ color_temperature: color_temperature,
387
407
  state: state,
388
- lightLevel: lightLevel,
408
+ red: red,
409
+ green: green,
410
+ blue: blue,
411
+ brightness: brightness,
389
412
  delay: delay,
390
- networkStatus: networkStatus,
391
- statePreset: statePreset,
392
- lightState: lightState,
393
- wifiRssi: wifiRssi,
394
- dynamicRate: dynamicRate,
395
- loopIndex: loopIndex,
396
- };*/
413
+ preset: preset,
414
+ color_mode: color_mode,
415
+ speed: speed,
416
+ loop_index: loop_index,
417
+ };
397
418
 
398
419
  return data;
399
420
  }
@@ -407,22 +428,22 @@ class SwitchbotAdvertising {
407
428
  }
408
429
  return null;
409
430
  }
410
- const byte9 = buf.readUInt8(9); // byte9: plug mini state; 0x00=off, 0x80=on
411
- 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
412
- const byte11 = buf.readUInt8(11); // byte11: wifi rssi
413
- const byte12 = buf.readUInt8(12); // byte12: bit7: overload?
414
- const byte13 = buf.readUInt8(13); // byte12[bit0~6] + byte13: current power value
415
-
416
- const state = byte9 === 0x00 ? "off" : byte9 === 0x80 ? "on" : null;
417
- const delay = !!(byte10 & 0b00000001);
418
- const timer = !!(byte10 & 0b00000010);
419
- const syncUtcTime = !!(byte10 & 0b00000100);
420
- const wifiRssi = byte11;
421
- const overload = !!(byte12 & 0b10000000);
422
- const currentPower = (((byte12 & 0b01111111) << 8) + byte13) / 10; // in watt
431
+ let byte9 = buf.readUInt8(9); // byte9: plug mini state; 0x00=off, 0x80=on
432
+ let 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
433
+ let byte11 = buf.readUInt8(11); // byte11: wifi rssi
434
+ let byte12 = buf.readUInt8(12); // byte12: bit7: overload?
435
+ let byte13 = buf.readUInt8(13); // byte12[bit0~6] + byte13: current power value
436
+
437
+ let state = byte9 === 0x00 ? "off" : byte9 === 0x80 ? "on" : null;
438
+ let delay = !!(byte10 & 0b00000001);
439
+ let timer = !!(byte10 & 0b00000010);
440
+ let syncUtcTime = !!(byte10 & 0b00000100);
441
+ let wifiRssi = byte11;
442
+ let overload = !!(byte12 & 0b10000000);
443
+ let currentPower = (((byte12 & 0b01111111) << 8) + byte13) / 10; // in watt
423
444
  // TODO: voltage ???
424
445
 
425
- const data = {
446
+ let data = {
426
447
  model: "g",
427
448
  modelName: "WoPlugMini",
428
449
  state: state,
@@ -446,22 +467,22 @@ class SwitchbotAdvertising {
446
467
  }
447
468
  return null;
448
469
  }
449
- const byte9 = buf.readUInt8(9); // byte9: plug mini state; 0x00=off, 0x80=on
450
- 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
451
- const byte11 = buf.readUInt8(11); // byte11: wifi rssi
452
- const byte12 = buf.readUInt8(12); // byte12: bit7: overload?
453
- const byte13 = buf.readUInt8(13); // byte12[bit0~6] + byte13: current power value
454
-
455
- const state = byte9 === 0x00 ? "off" : byte9 === 0x80 ? "on" : null;
456
- const delay = !!(byte10 & 0b00000001);
457
- const timer = !!(byte10 & 0b00000010);
458
- const syncUtcTime = !!(byte10 & 0b00000100);
459
- const wifiRssi = byte11;
460
- const overload = !!(byte12 & 0b10000000);
461
- const currentPower = (((byte12 & 0b01111111) << 8) + byte13) / 10; // in watt
470
+ let byte9 = buf.readUInt8(9); // byte9: plug mini state; 0x00=off, 0x80=on
471
+ let 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
472
+ let byte11 = buf.readUInt8(11); // byte11: wifi rssi
473
+ let byte12 = buf.readUInt8(12); // byte12: bit7: overload?
474
+ let byte13 = buf.readUInt8(13); // byte12[bit0~6] + byte13: current power value
475
+
476
+ let state = byte9 === 0x00 ? "off" : byte9 === 0x80 ? "on" : null;
477
+ let delay = !!(byte10 & 0b00000001);
478
+ let timer = !!(byte10 & 0b00000010);
479
+ let syncUtcTime = !!(byte10 & 0b00000100);
480
+ let wifiRssi = byte11;
481
+ let overload = !!(byte12 & 0b10000000);
482
+ let currentPower = (((byte12 & 0b01111111) << 8) + byte13) / 10; // in watt
462
483
  // TODO: voltage ???
463
484
 
464
- const data = {
485
+ let data = {
465
486
  model: "j",
466
487
  modelName: "WoPlugMini",
467
488
  state: state,
@@ -487,20 +508,15 @@ class SwitchbotAdvertising {
487
508
  }
488
509
  let byte1 = buf.readUInt8(1);
489
510
  let byte2 = buf.readUInt8(2);
490
- // let byte3 = buf.readUInt8(3);
491
- // let byte4 = buf.readUInt8(4);
492
- let byte5 = buf.readUInt8(5);
493
511
 
494
- //let pirState = (byte1 & 0b01000000) ? true : false; // 1 - Movement detected
512
+ let movement = (byte1 & 0b01000000) ? true : false; // 1 - Movement detected
495
513
  let battery = byte2 & 0b01111111; // %
496
- //let lightLevel = byte5 & 0b00000011;
497
514
 
498
515
  let data = {
499
516
  model: "o",
500
517
  modelName: "WoSmartLock",
501
- //movement: pirState,
502
518
  battery: battery,
503
- //lightLevel: (lightLevel == 1) ? 'dark' : ((lightLevel == 2) ? 'bright' : 'unknown'),
519
+ movement: movement,
504
520
  };
505
521
 
506
522
  return data;
@@ -521,8 +537,8 @@ class SwitchbotAdvertising {
521
537
  let byte5 = buf.readUInt8(5);
522
538
 
523
539
  let temp_sign = byte4 & 0b10000000 ? 1 : -1;
524
- let temp_c = temp_sign * ((byte4 & 0b01111111) + byte3 / 10);
525
- let temp_f = (temp_c * 9) / 5 + 32;
540
+ let temp_c = temp_sign * ((byte4 & 0b01111111) + (byte3 & 0b00001111) / 10);
541
+ let temp_f = (temp_c * 9 / 5) + 32;
526
542
  temp_f = Math.round(temp_f * 10) / 10;
527
543
 
528
544
  let data = {
@@ -550,24 +566,35 @@ class SwitchbotAdvertising {
550
566
  return null;
551
567
  }
552
568
 
553
- const byte7 = buf.readUInt8(7);
554
- const byte8 = buf.readUInt8(8);
555
- const byte9 = buf.readUInt8(9);
556
- const byte10 = buf.readUInt8(10);
569
+ let byte1 = buf.readUInt8(1);//power and light status
570
+ let byte2 = buf.readUInt8(2);//bulb brightness
571
+ let byte3 = buf.readUInt8(3);//bulb R
572
+ let byte4 = buf.readUInt8(4);//bulb G
573
+ let byte5 = buf.readUInt8(5);//bulb B
574
+ let byte7 = buf.readUInt8(7);
575
+ let byte8 = buf.readUInt8(8);
576
+ let byte9 = buf.readUInt8(9);
577
+ let byte10 = buf.readUInt8(10);
578
+
579
+ let state = byte7 & 0b10000000 ? true : false;
580
+ let brightness = byte7 & 0b01111111;
581
+ let red = byte3;
582
+ let green = byte4;
583
+ let blue = byte5;
584
+ let delay = byte8 & 0b10000000;
585
+ let preset = byte8 & 0b00001000;
586
+ let color_mode = byte8 & 0b00000111;
587
+ let speed = byte9 & 0b01111111;
588
+ let loop_index = byte10 & 0b11111110;
557
589
 
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;
565
-
566
- const data = {
590
+ let data = {
567
591
  model: "r",
568
592
  modelName: "WoStrip",
569
- isOn: isOn,
593
+ state: state,
570
594
  brightness: brightness,
595
+ red: red,
596
+ green: green,
597
+ blue: blue,
571
598
  delay: delay,
572
599
  preset: preset,
573
600
  color_mode: color_mode,
@@ -35,10 +35,114 @@ class SwitchbotDeviceWoBulb extends SwitchbotDevice {
35
35
  }
36
36
 
37
37
  /**
38
- * @returns {Promise<boolean>} resolves with a boolean that tells whether the plug in ON(true) or OFF(false)
38
+ * @returns {Promise<number>} resolves with brightness percent
39
+ */
40
+ setBrightness(brightness) {
41
+ if (typeof brightness != "number") {
42
+ return new Promise((resolve, reject) => {
43
+ reject(
44
+ new Error(
45
+ "The type of target brightness percentage is incorrent: " +
46
+ typeof brightness
47
+ )
48
+ );
49
+ });
50
+ }
51
+ if (brightness > 100) {
52
+ brightness = 100;
53
+ } else if (brightness < 0) {
54
+ brightness = 0;
55
+ }
56
+ return this._setState([0x02, 0x14]);
57
+ }
58
+
59
+ /**
60
+ * @returns {Promise<number>} resolves with brightness percent
61
+ */
62
+ setColorTemperature(color_temperature) {
63
+ if (typeof color_temperature != "number") {
64
+ return new Promise((resolve, reject) => {
65
+ reject(
66
+ new Error(
67
+ "The type of target brightness percentage is incorrent: " +
68
+ typeof brightness
69
+ )
70
+ );
71
+ });
72
+ }
73
+ if (color_temperature > 100) {
74
+ color_temperature = 100;
75
+ } else if (color_temperature < 0) {
76
+ color_temperature = 0;
77
+ }
78
+ return this._setState([0x02, 0x17, color_temperature]);
79
+ }
80
+
81
+ /**
82
+ * @returns {Promise<number>} resolves with brightness percent
39
83
  */
40
- toggle() {
41
- return this._setState([0x02, 0x03]);
84
+ setRGB(brightness, red, green, blue) {
85
+ if (typeof brightness != "number") {
86
+ return new Promise((resolve, reject) => {
87
+ reject(
88
+ new Error(
89
+ "The type of target brightness percentage is incorrent: " +
90
+ typeof brightness
91
+ )
92
+ );
93
+ });
94
+ }
95
+ if (typeof red != "number") {
96
+ return new Promise((resolve, reject) => {
97
+ reject(
98
+ new Error(
99
+ "The type of target red is incorrent: " +
100
+ typeof red
101
+ )
102
+ );
103
+ });
104
+ }
105
+ if (typeof green != "number") {
106
+ return new Promise((resolve, reject) => {
107
+ reject(
108
+ new Error(
109
+ "The type of target green is incorrent: " +
110
+ typeof green
111
+ )
112
+ );
113
+ });
114
+ }
115
+ if (typeof blue != "number") {
116
+ return new Promise((resolve, reject) => {
117
+ reject(
118
+ new Error(
119
+ "The type of target blue is incorrent: " +
120
+ typeof blue
121
+ )
122
+ );
123
+ });
124
+ }
125
+ if (brightness > 100) {
126
+ brightness = 100;
127
+ } else if (brightness < 0) {
128
+ brightness = 0;
129
+ }
130
+ if (red > 255) {
131
+ red = 255;
132
+ } else if (red < 0) {
133
+ red = 0;
134
+ }
135
+ if (green > 255) {
136
+ green = 255;
137
+ } else if (green < 0) {
138
+ green = 0;
139
+ }
140
+ if (blue > 255) {
141
+ blue = 255;
142
+ } else if (blue < 0) {
143
+ blue = 0;
144
+ }
145
+ return this._setState([0x02, 0x12, brightness, red, green, blue]);
42
146
  }
43
147
 
44
148
  /**
@@ -35,10 +35,108 @@ class SwitchbotDeviceWoStrip extends SwitchbotDevice {
35
35
  }
36
36
 
37
37
  /**
38
- * @returns {Promise<boolean>} resolves with a boolean that tells whether the plug in ON(true) or OFF(false)
38
+ * @returns {Promise<number>} resolves with brightness percent
39
+ */
40
+ setBrightness(brightness) {
41
+ if (typeof brightness != "number") {
42
+ return new Promise((resolve, reject) => {
43
+ reject(
44
+ new Error(
45
+ "The type of target brightness percentage is incorrent: " +
46
+ typeof brightness
47
+ )
48
+ );
49
+ });
50
+ }
51
+ if (brightness > 100) {
52
+ brightness = 100;
53
+ } else if (brightness < 0) {
54
+ brightness = 0;
55
+ }
56
+ return this._setState([0x02, 0x14]);
57
+ }
58
+
59
+ /**
60
+ * @returns {Promise<number>} resolves with color temperature
61
+ */
62
+ setColorTemperature(color_temperature) {
63
+ if (color_temperature) {
64
+ return new Promise((resolve, reject) => {
65
+ reject(
66
+ new Error(
67
+ "Strip Light Doesn't Support Color temperature: " +
68
+ typeof color_temperature
69
+ )
70
+ );
71
+ });
72
+ }
73
+ }
74
+
75
+ /**
76
+ * @returns {Promise<number>} resolves with brightness + rgb
39
77
  */
40
- toggle() {
41
- return this._setState([0x02, 0x03]);
78
+ setRGB(brightness, red, green, blue) {
79
+ if (typeof brightness != "number") {
80
+ return new Promise((resolve, reject) => {
81
+ reject(
82
+ new Error(
83
+ "The type of target brightness percentage is incorrent: " +
84
+ typeof brightness
85
+ )
86
+ );
87
+ });
88
+ }
89
+ if (typeof red != "number") {
90
+ return new Promise((resolve, reject) => {
91
+ reject(
92
+ new Error(
93
+ "The type of target red is incorrent: " +
94
+ typeof red
95
+ )
96
+ );
97
+ });
98
+ }
99
+ if (typeof green != "number") {
100
+ return new Promise((resolve, reject) => {
101
+ reject(
102
+ new Error(
103
+ "The type of target green is incorrent: " +
104
+ typeof green
105
+ )
106
+ );
107
+ });
108
+ }
109
+ if (typeof blue != "number") {
110
+ return new Promise((resolve, reject) => {
111
+ reject(
112
+ new Error(
113
+ "The type of target blue is incorrent: " +
114
+ typeof blue
115
+ )
116
+ );
117
+ });
118
+ }
119
+ if (brightness > 100) {
120
+ brightness = 100;
121
+ } else if (brightness < 0) {
122
+ brightness = 0;
123
+ }
124
+ if (red > 255) {
125
+ red = 255;
126
+ } else if (red < 0) {
127
+ red = 0;
128
+ }
129
+ if (green > 255) {
130
+ green = 255;
131
+ } else if (green < 0) {
132
+ green = 0;
133
+ }
134
+ if (blue > 255) {
135
+ blue = 255;
136
+ } else if (blue < 0) {
137
+ blue = 0;
138
+ }
139
+ return this._setState([0x02, 0x12, brightness, red, green, blue]);
42
140
  }
43
141
 
44
142
  /**
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.10",
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
  }