node-switchbot 3.0.2-beta.5 → 3.1.0
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/BLE.md
CHANGED
|
@@ -731,6 +731,7 @@ Actually, the `WoSmartLock ` is an object inherited from the [`SwitchbotDevice`]
|
|
|
731
731
|
The `setKey()` method initialises the key information required for encrypted communication with the SmartLock
|
|
732
732
|
|
|
733
733
|
This must be set before any control commands are sent to the device. To obtain the key information you will need to use an external tool - see [`pySwitchbot`](https://github.com/Danielhiversen/pySwitchbot/tree/master?tab=readme-ov-file#obtaining-locks-encryption-key) project for an example script.
|
|
734
|
+
Or, use [`switchbot-get-encryption-key`](https://www.npmjs.com/package/switchbot-get-encryption-key) npm script.
|
|
734
735
|
|
|
735
736
|
| Property | Type | Description |
|
|
736
737
|
| :-------------- | :----- | :----------------------------------------------------------------------------------------------- |
|
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
|
+
## [3.1.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v3.1.0) (2024-10-11)
|
|
6
|
+
|
|
7
|
+
### What's Changed
|
|
8
|
+
- Added support for emitting logs from this module from the `SwitchBotBLE` class.
|
|
9
|
+
- Housekeeping and update dependencies
|
|
10
|
+
|
|
11
|
+
**Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v3.0.1...v3.1.0
|
|
12
|
+
|
|
5
13
|
## [3.0.1](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v3.0.1) (2024-10-05)
|
|
6
14
|
|
|
7
15
|
### What's Changed
|
|
@@ -16,6 +24,7 @@ All notable changes to this project will be documented in this file. This projec
|
|
|
16
24
|
#### ⚠️ Breaking Changes
|
|
17
25
|
- Have added OpenAPI Functionality into `node-switchbot`, so now it is able to handle both APIs with just one module.
|
|
18
26
|
- There are now two different Classes `SwitchBotBLE` and `SwitchBotOpenAPI` that can be used interact with the two different APIs
|
|
27
|
+
- `SwitchBotOpenApi` support emitting logs from this module.
|
|
19
28
|
- You will need to update your current setup from`SwitchBot` to `SwitchBotBLE` to be able to interact with the BLE API
|
|
20
29
|
- Updated the documents to explain both the `BLE` and the `OpenAPI` Functionality within `node-switchbot`
|
|
21
30
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Server } from 'node:http';
|
|
2
2
|
import type { pushResponse } from './types/devicepush.js';
|
|
3
3
|
import type { devices } from './types/deviceresponse.js';
|
|
4
|
-
import type { deviceStatus } from './types/devicestatus.js';
|
|
4
|
+
import type { deviceStatus, deviceStatusRequest } from './types/devicestatus.js';
|
|
5
5
|
import { EventEmitter } from 'node:events';
|
|
6
6
|
/**
|
|
7
7
|
* The `SwitchBotOpenAPI` class provides methods to interact with the SwitchBot OpenAPI.
|
|
@@ -85,12 +85,12 @@ export declare class SwitchBotOpenAPI extends EventEmitter {
|
|
|
85
85
|
* Retrieves the status of a specific device.
|
|
86
86
|
*
|
|
87
87
|
* @param deviceId - The unique identifier of the device.
|
|
88
|
-
* @returns {Promise<{ response: deviceStatus, statusCode:
|
|
88
|
+
* @returns {Promise<{ response: deviceStatus, statusCode: deviceStatusRequest['statusCode'] }>} A promise that resolves to the device status.
|
|
89
89
|
* @throws An error if the request fails.
|
|
90
90
|
*/
|
|
91
91
|
getDeviceStatus(deviceId: string): Promise<{
|
|
92
92
|
response: deviceStatus;
|
|
93
|
-
statusCode:
|
|
93
|
+
statusCode: deviceStatusRequest['statusCode'];
|
|
94
94
|
}>;
|
|
95
95
|
/**
|
|
96
96
|
* Generates the headers required for authentication with the SwitchBot OpenAPI.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switchbot-openapi.d.ts","sourceRoot":"","sources":["../src/switchbot-openapi.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAmB,MAAM,EAAkB,MAAM,WAAW,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YAAY,CAAC,CAAA;KAAE,CAAC;IAqB/L;;;;;;OAMG;IACG,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,YAAY,CAAC;QAAC,UAAU,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAA;KAAE,CAAC;IAgB3H;;;;;;;;;OASG;IACH,OAAO,CAAC,eAAe,CAiBtB;IAED;;;;;;;;;;;;;OAaG;IACG,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA6F9C;;;;;;;OAOG;IACG,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAqBhD"}
|
|
@@ -119,7 +119,7 @@ export class SwitchBotOpenAPI extends EventEmitter {
|
|
|
119
119
|
* Retrieves the status of a specific device.
|
|
120
120
|
*
|
|
121
121
|
* @param deviceId - The unique identifier of the device.
|
|
122
|
-
* @returns {Promise<{ response: deviceStatus, statusCode:
|
|
122
|
+
* @returns {Promise<{ response: deviceStatus, statusCode: deviceStatusRequest['statusCode'] }>} A promise that resolves to the device status.
|
|
123
123
|
* @throws An error if the request fails.
|
|
124
124
|
*/
|
|
125
125
|
async getDeviceStatus(deviceId) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-switchbot",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0
|
|
4
|
+
"version": "3.1.0",
|
|
5
5
|
"description": "The node-switchbot is a Node.js module which allows you to control your Switchbot Devices through Bluetooth (BLE).",
|
|
6
6
|
"author": "OpenWonderLabs (https://github.com/OpenWonderLabs)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@stoprocent/noble": "^1.15.1",
|
|
52
52
|
"async-mutex": "^0.5.0",
|
|
53
|
-
"undici": "^6.
|
|
53
|
+
"undici": "^6.20.0"
|
|
54
54
|
},
|
|
55
55
|
"optionalDependencies": {
|
|
56
56
|
"@stoprocent/bluetooth-hci-socket": "^1.4.1"
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"@types/fs-extra": "^11.0.4",
|
|
63
63
|
"@types/jest": "^29.5.13",
|
|
64
64
|
"@types/mdast": "^4.0.4",
|
|
65
|
-
"@types/node": "^22.7.
|
|
65
|
+
"@types/node": "^22.7.5",
|
|
66
66
|
"@types/semver": "^7.5.8",
|
|
67
67
|
"@types/sinon": "^17.0.3",
|
|
68
68
|
"@types/source-map-support": "^0.5.10",
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"shx": "^0.3.4",
|
|
76
76
|
"sinon": "^19.0.2",
|
|
77
77
|
"ts-node": "^10.9.2",
|
|
78
|
-
"typedoc": "^0.26.
|
|
79
|
-
"typescript": "^5.6.
|
|
78
|
+
"typedoc": "^0.26.9",
|
|
79
|
+
"typescript": "^5.6.3",
|
|
80
80
|
"vitest": "^2.1.2"
|
|
81
81
|
}
|
|
82
82
|
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
#!/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This scripts queries the npm registry to pull out the latest version for a given tag.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const fs = require("fs");
|
|
8
|
-
const semver = require("semver");
|
|
9
|
-
const child_process = require("child_process");
|
|
10
|
-
const assert = require("assert");
|
|
11
|
-
|
|
12
|
-
const BRANCH_VERSION_PATTERN = /^([A-Za-z]*)-(\d+.\d+.\d+)$/
|
|
13
|
-
|
|
14
|
-
// Load the contents of the package.json file
|
|
15
|
-
const packageJSON = JSON.parse(fs.readFileSync("package.json", "utf8"));
|
|
16
|
-
|
|
17
|
-
let refArgument = process.argv[2];
|
|
18
|
-
let tagArgument = process.argv[3] || "latest";
|
|
19
|
-
|
|
20
|
-
if (refArgument == null) {
|
|
21
|
-
console.error("ref argument is missing");
|
|
22
|
-
console.error("Usage: npm-version-script.cjs <ref> [tag]");
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Queries the NPM registry for the latest version for the provided tag.
|
|
28
|
-
* @param tag The tag to query for.
|
|
29
|
-
* @returns {string} Returns the version.
|
|
30
|
-
*/
|
|
31
|
-
function getTagVersionFromNpm(tag) {
|
|
32
|
-
try {
|
|
33
|
-
return child_process.execSync(`npm info ${packageJSON.name} version --tag="${tag}"`).toString("utf8").trim();
|
|
34
|
-
} catch (e) {
|
|
35
|
-
throw e;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function desiredTargetVersion(ref) {
|
|
40
|
-
// ref is a GitHub action ref string
|
|
41
|
-
if (ref.startsWith("refs/pull/")) {
|
|
42
|
-
throw Error("The version script was executed inside a PR!");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
assert(ref.startsWith("refs/heads/"))
|
|
46
|
-
let branchName = ref.slice("refs/heads/".length);
|
|
47
|
-
|
|
48
|
-
let results = branchName.match(BRANCH_VERSION_PATTERN);
|
|
49
|
-
if (results != null) {
|
|
50
|
-
if (results[1] !== tagArgument) {
|
|
51
|
-
console.warn(`The base branch name (${results[1]}) differs from the tag name ${tagArgument}`);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return results[2];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// legacy mode were we use the `betaVersion` property in the package.json
|
|
58
|
-
if (branchName === "beta" && packageJSON.betaVersion) {
|
|
59
|
-
return packageJSON.betaVersion
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
throw new Error("Malformed branch name for ref: " + ref + ". Can't derive the base version. Use a branch name like: beta-x.x.x!");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// derive the base version from the branch ref
|
|
66
|
-
const baseVersion = desiredTargetVersion(refArgument);
|
|
67
|
-
|
|
68
|
-
// query the npm registry for the latest version of the provided tag name
|
|
69
|
-
const latestReleasedVersion = getTagVersionFromNpm(tagArgument); // e.g. 0.7.0-beta.12
|
|
70
|
-
const latestReleaseBase = semver.inc(latestReleasedVersion, "patch"); // will produce 0.7.0 (removing the preid, needed for the equality check below)
|
|
71
|
-
|
|
72
|
-
let publishTag;
|
|
73
|
-
if (semver.eq(baseVersion, latestReleaseBase)) { // check if we are releasing another version for the latest beta
|
|
74
|
-
publishTag = latestReleasedVersion; // set the current latest beta to be incremented
|
|
75
|
-
} else {
|
|
76
|
-
publishTag = baseVersion; // start of with a new beta version
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// save the package.json
|
|
80
|
-
packageJSON.version = publishTag;
|
|
81
|
-
fs.writeFileSync("package.json", JSON.stringify(packageJSON, null, 2));
|