node-switchbot 2.1.2-beta.2 → 2.1.2-beta.3

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 CHANGED
@@ -2,6 +2,14 @@
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
+ ## [2.2.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v2.2.0) (2024-XX-XX)
6
+
7
+ ### What's Changed
8
+ - Add SwitchBot Hub 2 Support
9
+ - Housekeeping and update dependencies
10
+
11
+ **Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v2.1.1...v2.2.0
12
+
5
13
  ## [2.1.1](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v2.1.1) (2024-05-26)
6
14
 
7
15
  ### What's Changed
@@ -12,7 +20,7 @@ All notable changes to this project will be documented in this file. This projec
12
20
  ## [2.1.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v2.1.0) (2024-05-14)
13
21
 
14
22
  ### What's Changed
15
- - Add Full Switchbot Lock Support [#232](https://github.com/OpenWonderLabs/node-switchbot/pull/232), Thanks [@brozef](https://github.com/brozef)
23
+ - Add SwitchBot Lock Support [#232](https://github.com/OpenWonderLabs/node-switchbot/pull/232), Thanks [@brozef](https://github.com/brozef)
16
24
  - Fix TypeScript issues & warnings [#239](https://github.com/OpenWonderLabs/node-switchbot/pull/239) [#240](https://github.com/OpenWonderLabs/node-switchbot/pull/240) [#241](https://github.com/OpenWonderLabs/node-switchbot/pull/241), Thanks [@dnicolson](https://github.com/dnicolson)
17
25
  - Update Noble [#242](https://github.com/OpenWonderLabs/node-switchbot/pull/242), Thanks [@dnicolson](https://github.com/dnicolson)
18
26
  dnicolson
@@ -34,6 +34,23 @@ export declare class Advertising {
34
34
  fahrenheit: boolean;
35
35
  humidity: number;
36
36
  battery: number;
37
+ } | {
38
+ model: string;
39
+ modelName: string;
40
+ temperature: {
41
+ /**
42
+ * Parses the advertisement data of a peripheral device.
43
+ *
44
+ * @param peripheral - The peripheral device.
45
+ * @param onlog - The logging function.
46
+ * @returns The parsed data of the peripheral device.
47
+ */
48
+ c: number;
49
+ f: number;
50
+ };
51
+ fahrenheit: boolean;
52
+ humidity: number;
53
+ lightLevel: number;
37
54
  } | {
38
55
  model: string;
39
56
  modelName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"advertising.d.ts","sourceRoot":"","sources":["../src/advertising.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAgB/C,MAAM,MAAM,EAAE,GAAG;IACf,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC,GAAG,IAAI,CAAC;AAET,qBAAa,WAAW;;IA6DtB;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmGvE"}
1
+ {"version":3,"file":"advertising.d.ts","sourceRoot":"","sources":["../src/advertising.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAgB/C,MAAM,MAAM,EAAE,GAAG;IACf,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC,GAAG,IAAI,CAAC;AAET,qBAAa,WAAW;;IA6DtB;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;gBAPtE;;;;;;mBAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoGJ"}
@@ -10,7 +10,7 @@ export declare class WoHub2 extends SwitchbotDevice {
10
10
  };
11
11
  fahrenheit: boolean;
12
12
  humidity: number;
13
- battery: number;
13
+ lightLevel: number;
14
14
  } | null;
15
15
  }
16
16
  //# sourceMappingURL=wohub2.d.ts.map
@@ -1 +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"}
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;;;;;;;;;;;CAiCpF"}
@@ -5,19 +5,20 @@
5
5
  import { SwitchbotDevice } from '../device.js';
6
6
  export class WoHub2 extends SwitchbotDevice {
7
7
  static parseServiceData(buf, onlog) {
8
- if (buf.length !== 6) {
8
+ if (buf.length !== 16) {
9
9
  if (onlog && typeof onlog === 'function') {
10
- onlog(`[parseServiceDataForWoSensorTH] Buffer length ${buf.length} !== 6!`);
10
+ onlog(`[parseServiceDataForWoSensorTH] Buffer length ${buf.length} !== 16!`);
11
11
  }
12
12
  return null;
13
13
  }
14
+ const byte0 = buf.readUInt8(0);
15
+ const byte1 = buf.readUInt8(1);
14
16
  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);
17
+ const byte12 = buf.readUInt8(12);
18
+ const temp_sign = byte1 & 0b10000000 ? 1 : -1;
19
+ const temp_c = temp_sign * ((byte1 & 0b01111111) + (byte0 & 0b00001111) / 10);
20
20
  const temp_f = Math.round(((temp_c * 9 / 5) + 32) * 10) / 10;
21
+ const light_level = byte12 & 0b11111;
21
22
  const data = {
22
23
  model: 'v',
23
24
  modelName: 'WoHub2',
@@ -25,9 +26,9 @@ export class WoHub2 extends SwitchbotDevice {
25
26
  c: temp_c,
26
27
  f: temp_f,
27
28
  },
28
- fahrenheit: byte5 & 0b10000000 ? true : false,
29
- humidity: byte5 & 0b01111111,
30
- battery: byte2 & 0b01111111,
29
+ fahrenheit: byte2 & 0b10000000 ? true : false,
30
+ humidity: byte2 & 0b01111111,
31
+ lightLevel: light_level,
31
32
  };
32
33
  return data;
33
34
  }
@@ -1 +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,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AE,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;YAC7C,QAAQ,EAAE,KAAK,GAAG,UAAU;YAC5B,UAAU,EAAE,WAAW;SACxB,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.2",
3
+ "version": "2.1.2-beta.3",
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)",
@@ -42,11 +42,11 @@
42
42
  "@stoprocent/bluetooth-hci-socket": "^1.2.1"
43
43
  },
44
44
  "devDependencies": {
45
- "@eslint/js": "^9.3.0",
46
- "@stylistic/eslint-plugin-js": "^2.1.0",
45
+ "@eslint/js": "^9.4.0",
46
+ "@stylistic/eslint-plugin": "^2.1.0",
47
47
  "@types/eslint__js": "^8.42.3",
48
- "@types/node": "^20.12.12",
49
- "eslint": "^9.3.0",
48
+ "@types/node": "^20.13.0",
49
+ "eslint": "^9.4.0",
50
50
  "globals": "^15.3.0",
51
51
  "homebridge": "^1.8.2",
52
52
  "homebridge-config-ui-x": "4.56.2",
@@ -55,6 +55,6 @@
55
55
  "rimraf": "^5.0.7",
56
56
  "ts-node": "^10.9.2",
57
57
  "typescript": "^5.4.5",
58
- "typescript-eslint": "^8.0.0-alpha.20"
58
+ "typescript-eslint": "^8.0.0-alpha.24"
59
59
  }
60
60
  }