node-switchbot 1.7.0-beta.0 → 1.7.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.
- package/lib/switchbot-advertising.js +36 -36
- package/package.json +1 -1
|
@@ -101,7 +101,7 @@ class SwitchbotAdvertising {
|
|
|
101
101
|
} else if (model === "j") {
|
|
102
102
|
sd = this._parseServiceDataForWoPlugMiniJP(manufacturerData, onlog);// WoPlugMini (JP)
|
|
103
103
|
} else if (model === "o") {
|
|
104
|
-
sd = this._parseServiceDataForWoSmartLock(
|
|
104
|
+
sd = this._parseServiceDataForWoSmartLock(manufacturerData, onlog);// WoSmartLock
|
|
105
105
|
} else if (model === "i") {
|
|
106
106
|
sd = this._parseServiceDataForWoSensorTHPlus(buf, onlog);// WoMeterPlus
|
|
107
107
|
} else if (model === "r") {
|
|
@@ -365,25 +365,25 @@ class SwitchbotAdvertising {
|
|
|
365
365
|
return data;
|
|
366
366
|
}
|
|
367
367
|
|
|
368
|
-
_parseServiceDataForWoBulb(
|
|
369
|
-
if (
|
|
368
|
+
_parseServiceDataForWoBulb(manufacturerData, onlog) {
|
|
369
|
+
if (manufacturerData.length !== 13) {
|
|
370
370
|
if (onlog && typeof onlog === "function") {
|
|
371
371
|
onlog(
|
|
372
|
-
`[_parseServiceDataForWoBulb] Buffer length ${
|
|
372
|
+
`[_parseServiceDataForWoBulb] Buffer length ${manufacturerData.length} !== 13!`
|
|
373
373
|
);
|
|
374
374
|
}
|
|
375
375
|
return null;
|
|
376
376
|
}
|
|
377
|
-
let byte1 =
|
|
378
|
-
let byte2 =
|
|
379
|
-
let byte3 =
|
|
380
|
-
let byte4 =
|
|
381
|
-
let byte5 =
|
|
382
|
-
let byte6 =
|
|
383
|
-
let byte7 =
|
|
384
|
-
let byte8 =
|
|
385
|
-
let byte9 =
|
|
386
|
-
let byte10 =
|
|
377
|
+
let byte1 = manufacturerData.readUInt8(1);//power and light status
|
|
378
|
+
let byte2 = manufacturerData.readUInt8(2);//bulb brightness
|
|
379
|
+
let byte3 = manufacturerData.readUInt8(3);//bulb R
|
|
380
|
+
let byte4 = manufacturerData.readUInt8(4);//bulb G
|
|
381
|
+
let byte5 = manufacturerData.readUInt8(5);//bulb B
|
|
382
|
+
let byte6 = manufacturerData.readUInt8(6);//bulb temperature
|
|
383
|
+
let byte7 = manufacturerData.readUInt8(7);
|
|
384
|
+
let byte8 = manufacturerData.readUInt8(8);
|
|
385
|
+
let byte9 = manufacturerData.readUInt8(9);
|
|
386
|
+
let byte10 = manufacturerData.readUInt8(10);//bulb mode
|
|
387
387
|
|
|
388
388
|
let power = byte1;
|
|
389
389
|
let red = byte3;
|
|
@@ -418,20 +418,20 @@ class SwitchbotAdvertising {
|
|
|
418
418
|
return data;
|
|
419
419
|
}
|
|
420
420
|
|
|
421
|
-
_parseServiceDataForWoPlugMiniUS(
|
|
422
|
-
if (
|
|
421
|
+
_parseServiceDataForWoPlugMiniUS(manufacturerData, onlog) {
|
|
422
|
+
if (manufacturerData.length !== 14) {
|
|
423
423
|
if (onlog && typeof onlog === "function") {
|
|
424
424
|
onlog(
|
|
425
|
-
`[_parseServiceDataForWoPlugMiniUS] Buffer length ${
|
|
425
|
+
`[_parseServiceDataForWoPlugMiniUS] Buffer length ${manufacturerData.length} should be 14`
|
|
426
426
|
);
|
|
427
427
|
}
|
|
428
428
|
return null;
|
|
429
429
|
}
|
|
430
|
-
let byte9 =
|
|
431
|
-
let byte10 =
|
|
432
|
-
let byte11 =
|
|
433
|
-
let byte12 =
|
|
434
|
-
let byte13 =
|
|
430
|
+
let byte9 = manufacturerData.readUInt8(9); // byte9: plug mini state; 0x00=off, 0x80=on
|
|
431
|
+
let byte10 = manufacturerData.readUInt8(10); // byte10: bit0: 0=no delay,1=delay, bit1:0=no timer, 1=timer; bit2:0=no sync time, 1=sync'ed time
|
|
432
|
+
let byte11 = manufacturerData.readUInt8(11); // byte11: wifi rssi
|
|
433
|
+
let byte12 = manufacturerData.readUInt8(12); // byte12: bit7: overload?
|
|
434
|
+
let byte13 = manufacturerData.readUInt8(13); // byte12[bit0~6] + byte13: current power value
|
|
435
435
|
|
|
436
436
|
let state = byte9 === 0x00 ? "off" : byte9 === 0x80 ? "on" : null;
|
|
437
437
|
let delay = !!(byte10 & 0b00000001);
|
|
@@ -457,20 +457,20 @@ class SwitchbotAdvertising {
|
|
|
457
457
|
return data;
|
|
458
458
|
}
|
|
459
459
|
|
|
460
|
-
_parseServiceDataForWoPlugMiniJP(
|
|
461
|
-
if (
|
|
460
|
+
_parseServiceDataForWoPlugMiniJP(manufacturerData, onlog) {
|
|
461
|
+
if (manufacturerData.length !== 14) {
|
|
462
462
|
if (onlog && typeof onlog === "function") {
|
|
463
463
|
onlog(
|
|
464
|
-
`[_parseServiceDataForWoPlugMiniJP] Buffer length ${
|
|
464
|
+
`[_parseServiceDataForWoPlugMiniJP] Buffer length ${manufacturerData.length} should be 14`
|
|
465
465
|
);
|
|
466
466
|
}
|
|
467
467
|
return null;
|
|
468
468
|
}
|
|
469
|
-
let byte9 =
|
|
470
|
-
let byte10 =
|
|
471
|
-
let byte11 =
|
|
472
|
-
let byte12 =
|
|
473
|
-
let byte13 =
|
|
469
|
+
let byte9 = manufacturerData.readUInt8(9); // byte9: plug mini state; 0x00=off, 0x80=on
|
|
470
|
+
let byte10 = manufacturerData.readUInt8(10); // byte10: bit0: 0=no delay,1=delay, bit1:0=no timer, 1=timer; bit2:0=no sync time, 1=sync'ed time
|
|
471
|
+
let byte11 = manufacturerData.readUInt8(11); // byte11: wifi rssi
|
|
472
|
+
let byte12 = manufacturerData.readUInt8(12); // byte12: bit7: overload?
|
|
473
|
+
let byte13 = manufacturerData.readUInt8(13); // byte12[bit0~6] + byte13: current power value
|
|
474
474
|
|
|
475
475
|
let state = byte9 === 0x00 ? "off" : byte9 === 0x80 ? "on" : null;
|
|
476
476
|
let delay = !!(byte10 & 0b00000001);
|
|
@@ -496,18 +496,18 @@ class SwitchbotAdvertising {
|
|
|
496
496
|
return data;
|
|
497
497
|
}
|
|
498
498
|
|
|
499
|
-
_parseServiceDataForWoSmartLock(
|
|
500
|
-
if (
|
|
499
|
+
_parseServiceDataForWoSmartLock(manufacturerData, onlog) {
|
|
500
|
+
if (manufacturerData.length !== 6) {
|
|
501
501
|
if (onlog && typeof onlog === "function") {
|
|
502
502
|
onlog(
|
|
503
|
-
`[_parseServiceDataForWoSmartLock] Buffer length ${
|
|
503
|
+
`[_parseServiceDataForWoSmartLock] Buffer length ${manufacturerData.length} !== 6!`
|
|
504
504
|
);
|
|
505
505
|
}
|
|
506
506
|
return null;
|
|
507
507
|
}
|
|
508
|
-
let byte2 =
|
|
509
|
-
let byte7 =
|
|
510
|
-
let byte8 =
|
|
508
|
+
let byte2 = manufacturerData.readUInt8(2);
|
|
509
|
+
let byte7 = manufacturerData.readUInt8(7);
|
|
510
|
+
let byte8 = manufacturerData.readUInt8(8);
|
|
511
511
|
|
|
512
512
|
|
|
513
513
|
let LockStatus = {
|
package/package.json
CHANGED