node-switchbot 2.1.2-beta.0 → 2.1.2-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.
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { SwitchbotDevice } from '../device.js';
|
|
3
|
+
export declare class WoHub2 extends SwitchbotDevice {
|
|
4
|
+
static parseServiceData(buf: Buffer, onlog: ((message: string) => void) | undefined): {
|
|
5
|
+
model: string;
|
|
6
|
+
modelName: string;
|
|
7
|
+
temperature: {
|
|
8
|
+
c: number;
|
|
9
|
+
f: number;
|
|
10
|
+
};
|
|
11
|
+
fahrenheit: boolean;
|
|
12
|
+
humidity: number;
|
|
13
|
+
battery: number;
|
|
14
|
+
} | null;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=wohub2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wohub2.d.ts","sourceRoot":"","sources":["../../src/device/wohub2.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,qBAAa,MAAO,SAAQ,eAAe;IACzC,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS;;;;;;;;;;;CAgCpF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/* Copyright(C) 2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* wohub2.ts: Switchbot BLE API registration.
|
|
4
|
+
*/
|
|
5
|
+
import { SwitchbotDevice } from '../device.js';
|
|
6
|
+
export class WoHub2 extends SwitchbotDevice {
|
|
7
|
+
static parseServiceData(buf, onlog) {
|
|
8
|
+
if (buf.length !== 6) {
|
|
9
|
+
if (onlog && typeof onlog === 'function') {
|
|
10
|
+
onlog(`[parseServiceDataForWoSensorTH] Buffer length ${buf.length} !== 6!`);
|
|
11
|
+
}
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const byte2 = buf.readUInt8(2);
|
|
15
|
+
const byte3 = buf.readUInt8(3);
|
|
16
|
+
const byte4 = buf.readUInt8(4);
|
|
17
|
+
const byte5 = buf.readUInt8(5);
|
|
18
|
+
const temp_sign = byte4 & 0b10000000 ? 1 : -1;
|
|
19
|
+
const temp_c = temp_sign * ((byte4 & 0b01111111) + (byte3 & 0b00001111) / 10);
|
|
20
|
+
const temp_f = Math.round(((temp_c * 9 / 5) + 32) * 10) / 10;
|
|
21
|
+
const data = {
|
|
22
|
+
model: 'v',
|
|
23
|
+
modelName: 'WoHub2',
|
|
24
|
+
temperature: {
|
|
25
|
+
c: temp_c,
|
|
26
|
+
f: temp_f,
|
|
27
|
+
},
|
|
28
|
+
fahrenheit: byte5 & 0b10000000 ? true : false,
|
|
29
|
+
humidity: byte5 & 0b01111111,
|
|
30
|
+
battery: byte2 & 0b01111111,
|
|
31
|
+
};
|
|
32
|
+
return data;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=wohub2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wohub2.js","sourceRoot":"","sources":["../../src/device/wohub2.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,OAAO,MAAO,SAAQ,eAAe;IACzC,MAAM,CAAC,gBAAgB,CAAC,GAAW,EAAE,KAA8C;QACjF,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrB,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;gBACzC,KAAK,CACH,iDAAiD,GAAG,CAAC,MAAM,SAAS,CACrE,CAAC;YACJ,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAE/B,MAAM,SAAS,GAAG,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9C,MAAM,MAAM,GAAG,SAAS,GAAG,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC;QAC9E,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC;QAE7D,MAAM,IAAI,GAAG;YACX,KAAK,EAAE,GAAG;YACV,SAAS,EAAE,QAAQ;YACnB,WAAW,EAAE;gBACX,CAAC,EAAE,MAAM;gBACT,CAAC,EAAE,MAAM;aACV;YACD,UAAU,EAAE,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;YAC7C,QAAQ,EAAE,KAAK,GAAG,UAAU;YAC5B,OAAO,EAAE,KAAK,GAAG,UAAU;SAC5B,CAAC;QAEF,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-switchbot",
|
|
3
|
-
"version": "2.1.2-beta.
|
|
3
|
+
"version": "2.1.2-beta.1",
|
|
4
4
|
"description": "The node-switchbot is a Node.js module which allows you to control your Switchbot Devices through Bluetooth (BLE).",
|
|
5
5
|
"homepage": "https://github.com/OpenWonderLabs/node-switchbot",
|
|
6
6
|
"author": "OpenWonderLabs (https://github.com/OpenWonderLabs)",
|