node-switchbot 1.4.0 → 1.4.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/CHANGELOG.md +9 -0
- package/lib/switchbot-advertising.js +47 -6
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/)
|
|
4
4
|
|
|
5
|
+
## [Version 1.4.1](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.4.1) (2022-08-27)
|
|
6
|
+
|
|
7
|
+
## What's Changed
|
|
8
|
+
|
|
9
|
+
- Fix Plug Mini (US) implimentation
|
|
10
|
+
- Housekeeping and update dependencies
|
|
11
|
+
|
|
12
|
+
**Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v1.4.0...v1.4.1
|
|
13
|
+
|
|
5
14
|
## [Version 1.4.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.4.0) (2022-08-19)
|
|
6
15
|
|
|
7
16
|
## What's Changed
|
|
@@ -104,11 +104,11 @@ class SwitchbotAdvertising {
|
|
|
104
104
|
// WoColorBulb
|
|
105
105
|
sd = this._parseServiceDataForWoColorBulb(buf, onlog);
|
|
106
106
|
} else if (model === "g") {
|
|
107
|
-
// WoPlugMini
|
|
108
|
-
sd = this.
|
|
107
|
+
// WoPlugMini (US)
|
|
108
|
+
sd = this._parseServiceDataForWoPlugMiniUS(manufacturerData, onlog);
|
|
109
109
|
} else if (model === "j") {
|
|
110
|
-
// WoPlugMini (JP)
|
|
111
|
-
sd = this.
|
|
110
|
+
// WoPlugMini (JP)
|
|
111
|
+
sd = this._parseServiceDataForWoPlugMiniJP(manufacturerData, onlog);
|
|
112
112
|
} else if (model === "o") {
|
|
113
113
|
// WoSmartLock
|
|
114
114
|
sd = this._parseServiceDataForWoSmartLock(buf, onlog);
|
|
@@ -386,11 +386,52 @@ class SwitchbotAdvertising {
|
|
|
386
386
|
return data;
|
|
387
387
|
}
|
|
388
388
|
|
|
389
|
-
|
|
389
|
+
_parseServiceDataForWoPlugMiniUS(buf, onlog) {
|
|
390
390
|
if (buf.length !== 14) {
|
|
391
391
|
if (onlog && typeof onlog === "function") {
|
|
392
392
|
onlog(
|
|
393
|
-
`[
|
|
393
|
+
`[_parseServiceDataForWoPlugMiniUS] Buffer length ${buf.length} should be 14`
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
return null;
|
|
397
|
+
}
|
|
398
|
+
const byte9 = buf.readUInt8(9); // byte9: plug mini state; 0x00=off, 0x80=on
|
|
399
|
+
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
|
|
400
|
+
const byte11 = buf.readUInt8(11); // byte11: wifi rssi
|
|
401
|
+
const byte12 = buf.readUInt8(12); // byte12: bit7: overload?
|
|
402
|
+
const byte13 = buf.readUInt8(13); // byte12[bit0~6] + byte13: current power value
|
|
403
|
+
|
|
404
|
+
const state = byte9 === 0x00 ? "off" : byte9 === 0x80 ? "on" : null;
|
|
405
|
+
const delay = !!(byte10 & 0b00000001);
|
|
406
|
+
const timer = !!(byte10 & 0b00000010);
|
|
407
|
+
const syncUtcTime = !!(byte10 & 0b00000100);
|
|
408
|
+
const wifiRssi = byte11;
|
|
409
|
+
const overload = !!(byte12 & 0b10000000);
|
|
410
|
+
const currentPower = (((byte12 & 0b01111111) << 8) + byte13) / 10; // in watt
|
|
411
|
+
// TODO: voltage ???
|
|
412
|
+
|
|
413
|
+
const data = {
|
|
414
|
+
model: "g",
|
|
415
|
+
modelName: "WoPlugMini",
|
|
416
|
+
state: state,
|
|
417
|
+
delay: delay,
|
|
418
|
+
timer: timer,
|
|
419
|
+
syncUtcTime: syncUtcTime,
|
|
420
|
+
wifiRssi: wifiRssi,
|
|
421
|
+
overload: overload,
|
|
422
|
+
currentPower: currentPower,
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
return data;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
_parseServiceDataForWoPlugMiniJP(buf, onlog) {
|
|
431
|
+
if (buf.length !== 14) {
|
|
432
|
+
if (onlog && typeof onlog === "function") {
|
|
433
|
+
onlog(
|
|
434
|
+
`[_parseServiceDataForWoPlugMiniJP] Buffer length ${buf.length} should be 14`
|
|
394
435
|
);
|
|
395
436
|
}
|
|
396
437
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-switchbot",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "The node-switchbot is a Node.js module which allows you to move your Switchbot (Bot)'s arm and Switchbot Curtain(Curtain), also monitor the temperature/humidity from SwitchBot Thermometer & Hygrometer (Meter).",
|
|
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.0.
|
|
40
|
+
"npm-check-updates": "^16.0.6"
|
|
41
41
|
}
|
|
42
42
|
}
|