node-switchbot 2.5.0-beta.30 → 2.5.0-beta.31
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 +10 -10
- package/OpenAPI.md +6 -6
- package/dist/advertising.d.ts +3 -3
- package/dist/advertising.d.ts.map +1 -1
- package/dist/advertising.js +25 -26
- package/dist/advertising.js.map +1 -1
- package/dist/device/woblindtilt.d.ts +3 -2
- package/dist/device/woblindtilt.d.ts.map +1 -1
- package/dist/device/woblindtilt.js +3 -7
- package/dist/device/woblindtilt.js.map +1 -1
- package/dist/device/wobulb.d.ts +3 -2
- package/dist/device/wobulb.d.ts.map +1 -1
- package/dist/device/wobulb.js +4 -8
- package/dist/device/wobulb.js.map +1 -1
- package/dist/device/woceilinglight.d.ts +4 -4
- package/dist/device/woceilinglight.d.ts.map +1 -1
- package/dist/device/woceilinglight.js +5 -10
- package/dist/device/woceilinglight.js.map +1 -1
- package/dist/device/wocontact.d.ts +3 -2
- package/dist/device/wocontact.d.ts.map +1 -1
- package/dist/device/wocontact.js +3 -3
- package/dist/device/wocontact.js.map +1 -1
- package/dist/device/wocurtain.d.ts +3 -2
- package/dist/device/wocurtain.d.ts.map +1 -1
- package/dist/device/wocurtain.js +3 -7
- package/dist/device/wocurtain.js.map +1 -1
- package/dist/device/wohand.d.ts +3 -2
- package/dist/device/wohand.d.ts.map +1 -1
- package/dist/device/wohand.js +3 -7
- package/dist/device/wohand.js.map +1 -1
- package/dist/device/wohub2.d.ts +3 -2
- package/dist/device/wohub2.d.ts.map +1 -1
- package/dist/device/wohub2.js +3 -3
- package/dist/device/wohub2.js.map +1 -1
- package/dist/device/wohumi.d.ts +3 -2
- package/dist/device/wohumi.d.ts.map +1 -1
- package/dist/device/wohumi.js +3 -7
- package/dist/device/wohumi.js.map +1 -1
- package/dist/device/woiosensorth.d.ts +3 -2
- package/dist/device/woiosensorth.d.ts.map +1 -1
- package/dist/device/woiosensorth.js +4 -4
- package/dist/device/woiosensorth.js.map +1 -1
- package/dist/device/woplugmini.d.ts +4 -5
- package/dist/device/woplugmini.d.ts.map +1 -1
- package/dist/device/woplugmini.js +7 -13
- package/dist/device/woplugmini.js.map +1 -1
- package/dist/device/wopresence.d.ts +3 -2
- package/dist/device/wopresence.d.ts.map +1 -1
- package/dist/device/wopresence.js +3 -3
- package/dist/device/wopresence.js.map +1 -1
- package/dist/device/wosensorth.d.ts +4 -4
- package/dist/device/wosensorth.d.ts.map +1 -1
- package/dist/device/wosensorth.js +5 -6
- package/dist/device/wosensorth.js.map +1 -1
- package/dist/device/wosmartlock.d.ts +3 -1
- package/dist/device/wosmartlock.d.ts.map +1 -1
- package/dist/device/wosmartlock.js +3 -2
- package/dist/device/wosmartlock.js.map +1 -1
- package/dist/device/wosmartlockpro.d.ts +3 -1
- package/dist/device/wosmartlockpro.d.ts.map +1 -1
- package/dist/device/wosmartlockpro.js +3 -2
- package/dist/device/wosmartlockpro.js.map +1 -1
- package/dist/device/wostrip.d.ts +3 -2
- package/dist/device/wostrip.d.ts.map +1 -1
- package/dist/device/wostrip.js +3 -3
- package/dist/device/wostrip.js.map +1 -1
- package/dist/switchbot-ble.d.ts +9 -2
- package/dist/switchbot-ble.d.ts.map +1 -1
- package/dist/switchbot-ble.js +20 -4
- package/dist/switchbot-ble.js.map +1 -1
- package/dist/test/advertising.test.js +1 -1
- package/dist/test/advertising.test.js.map +1 -1
- package/dist/test/device.test.js +0 -22
- package/dist/test/device.test.js.map +1 -1
- package/dist/test/index.test.js +1 -0
- package/dist/test/index.test.js.map +1 -1
- package/dist/test/settings.test.js +1 -0
- package/dist/test/settings.test.js.map +1 -1
- package/dist/test/switchbot-openapi.test.js +1 -0
- package/dist/test/switchbot-openapi.test.js.map +1 -1
- package/dist/test/woblindtilt.test.js +1 -96
- package/dist/test/woblindtilt.test.js.map +1 -1
- package/dist/test/wobulb.test.js +1 -103
- package/dist/test/wobulb.test.js.map +1 -1
- package/dist/test/woceilinglight.test.js +1 -94
- package/dist/test/woceilinglight.test.js.map +1 -1
- package/dist/test/wocontact.test.js +1 -37
- package/dist/test/wocontact.test.js.map +1 -1
- package/dist/test/wocurtain.test.js +1 -75
- package/dist/test/wocurtain.test.js.map +1 -1
- package/dist/test/wohand.test.js +1 -75
- package/dist/test/wohand.test.js.map +1 -1
- package/dist/test/wohub2.test.js +1 -51
- package/dist/test/wohub2.test.js.map +1 -1
- package/dist/test/wohumi.test.js +1 -63
- package/dist/test/wohumi.test.js.map +1 -1
- package/dist/test/woiosensorth.test.js +1 -40
- package/dist/test/woiosensorth.test.js.map +1 -1
- package/dist/test/woplugmini.test.js +1 -95
- package/dist/test/woplugmini.test.js.map +1 -1
- package/dist/test/wopresence.test.js +1 -45
- package/dist/test/wopresence.test.js.map +1 -1
- package/dist/test/wosensorth.test.js +1 -49
- package/dist/test/wosensorth.test.js.map +1 -1
- package/dist/test/wosmartlock.test.js +1 -146
- package/dist/test/wosmartlock.test.js.map +1 -1
- package/dist/test/wosmartlockpro.test.js +1 -127
- package/dist/test/wosmartlockpro.test.js.map +1 -1
- package/dist/test/wostrip.test.js +1 -113
- package/dist/test/wostrip.test.js.map +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wosmartlockpro.test.js","sourceRoot":"","sources":["../../src/test/wosmartlockpro.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wosmartlockpro.test.js","sourceRoot":"","sources":["../../src/test/wosmartlockpro.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,114 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { WoStrip } from '../device/wostrip.js';
|
|
3
|
-
describe('woStrip', () => {
|
|
4
|
-
describe('parseServiceData', () => {
|
|
5
|
-
it('should return null if serviceData length is not 18', async () => {
|
|
6
|
-
const serviceData = Buffer.alloc(10);
|
|
7
|
-
const result = await WoStrip.parseServiceData(serviceData, () => { });
|
|
8
|
-
expect(result).toBeNull();
|
|
9
|
-
});
|
|
10
|
-
it('should parse serviceData correctly', async () => {
|
|
11
|
-
const serviceData = Buffer.from([0, 0, 0, 255, 255, 255, 0, 128, 8, 127, 254, 0, 0, 0, 0, 0, 0, 0]);
|
|
12
|
-
const result = await WoStrip.parseServiceData(serviceData, () => { });
|
|
13
|
-
expect(result).toEqual({
|
|
14
|
-
model: 'StripLight',
|
|
15
|
-
modelName: 'StripLight',
|
|
16
|
-
modelFriendlyName: 'StripLight',
|
|
17
|
-
power: true,
|
|
18
|
-
state: true,
|
|
19
|
-
brightness: 127,
|
|
20
|
-
red: 255,
|
|
21
|
-
green: 255,
|
|
22
|
-
blue: 255,
|
|
23
|
-
delay: true,
|
|
24
|
-
preset: true,
|
|
25
|
-
color_mode: 0,
|
|
26
|
-
speed: 127,
|
|
27
|
-
loop_index: 254,
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
describe('readState', () => {
|
|
32
|
-
it('should return the state of the strip light', async () => {
|
|
33
|
-
const peripheral = {}; // Replace with actual peripheral object
|
|
34
|
-
const noble = {}; // Replace with actual noble object
|
|
35
|
-
const woStrip = new WoStrip(peripheral, noble);
|
|
36
|
-
woStrip.operateStripLight = async () => true;
|
|
37
|
-
const result = await woStrip.readState();
|
|
38
|
-
expect(result).toBe(true);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
describe('turnOn', () => {
|
|
42
|
-
it('should turn on the strip light', async () => {
|
|
43
|
-
const peripheral = {}; // Replace with actual peripheral object
|
|
44
|
-
const noble = {}; // Replace with actual noble object
|
|
45
|
-
const woStrip = new WoStrip(peripheral, noble);
|
|
46
|
-
woStrip.setState = async () => true;
|
|
47
|
-
const result = await woStrip.turnOn();
|
|
48
|
-
expect(result).toBe(true);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
describe('turnOff', () => {
|
|
52
|
-
it('should turn off the strip light', async () => {
|
|
53
|
-
const peripheral = {}; // Replace with actual peripheral object
|
|
54
|
-
const noble = {}; // Replace with actual noble object
|
|
55
|
-
const woStrip = new WoStrip(peripheral, noble);
|
|
56
|
-
woStrip.setState = async () => true;
|
|
57
|
-
const result = await woStrip.turnOff();
|
|
58
|
-
expect(result).toBe(true);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
describe('setBrightness', () => {
|
|
62
|
-
it('should set the brightness of the strip light', async () => {
|
|
63
|
-
const peripheral = {}; // Replace with actual peripheral object
|
|
64
|
-
const noble = {}; // Replace with actual noble object
|
|
65
|
-
const woStrip = new WoStrip(peripheral, noble);
|
|
66
|
-
woStrip.setState = async () => true;
|
|
67
|
-
const result = await woStrip.setBrightness(50);
|
|
68
|
-
expect(result).toBe(true);
|
|
69
|
-
});
|
|
70
|
-
it('should throw an error if brightness is not a number', async () => {
|
|
71
|
-
const peripheral = {}; // Replace with actual peripheral object
|
|
72
|
-
const noble = {}; // Replace with actual noble object
|
|
73
|
-
const woStrip = new WoStrip(peripheral, noble);
|
|
74
|
-
try {
|
|
75
|
-
await woStrip.setBrightness('50');
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
if (error instanceof Error) {
|
|
79
|
-
expect(error.message).toBe('Invalid brightness value: 50');
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
throw error;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
describe('setRGB', () => {
|
|
88
|
-
it('should set the RGB values of the strip light', async () => {
|
|
89
|
-
const peripheral = {}; // Replace with actual peripheral object
|
|
90
|
-
const noble = {}; // Replace with actual noble object
|
|
91
|
-
const woStrip = new WoStrip(peripheral, noble);
|
|
92
|
-
woStrip.setState = async () => true;
|
|
93
|
-
const result = await woStrip.setRGB(50, 255, 255, 255);
|
|
94
|
-
expect(result).toBe(true);
|
|
95
|
-
});
|
|
96
|
-
it('should throw an error if any RGB value is not a number', async () => {
|
|
97
|
-
const peripheral = {}; // Replace with actual peripheral object
|
|
98
|
-
const noble = {}; // Replace with actual noble object
|
|
99
|
-
const woStrip = new WoStrip(peripheral, noble);
|
|
100
|
-
try {
|
|
101
|
-
await woStrip.setRGB(50, '255', 255, 255);
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
if (error instanceof Error) {
|
|
105
|
-
expect(error.message).toBe('Invalid RGB or brightness value');
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
throw error;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
});
|
|
1
|
+
export {};
|
|
114
2
|
//# sourceMappingURL=wostrip.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wostrip.test.js","sourceRoot":"","sources":["../../src/test/wostrip.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wostrip.test.js","sourceRoot":"","sources":["../../src/test/wostrip.test.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-switchbot",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.5.0-beta.
|
|
4
|
+
"version": "2.5.0-beta.31",
|
|
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",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"main": "dist/index.js",
|
|
30
30
|
"types": "dist/index.d.ts",
|
|
31
31
|
"engines": {
|
|
32
|
-
"node": "^
|
|
32
|
+
"node": "^20 || ^22"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"check": "npm install && npm outdated",
|
|
@@ -48,14 +48,12 @@
|
|
|
48
48
|
},
|
|
49
49
|
"readmeFilename": "README.md",
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@stoprocent/noble": "^1.15.
|
|
52
|
-
"@types/sinon": "^17.0.3",
|
|
51
|
+
"@stoprocent/noble": "^1.15.1",
|
|
53
52
|
"async-mutex": "^0.5.0",
|
|
54
|
-
"sinon": "^19.0.2",
|
|
55
53
|
"undici": "^6.19.8"
|
|
56
54
|
},
|
|
57
55
|
"optionalDependencies": {
|
|
58
|
-
"@stoprocent/bluetooth-hci-socket": "^1.4.
|
|
56
|
+
"@stoprocent/bluetooth-hci-socket": "^1.4.1"
|
|
59
57
|
},
|
|
60
58
|
"devDependencies": {
|
|
61
59
|
"@antfu/eslint-config": "^3.7.3",
|
|
@@ -66,17 +64,19 @@
|
|
|
66
64
|
"@types/mdast": "^4.0.4",
|
|
67
65
|
"@types/node": "^22.7.4",
|
|
68
66
|
"@types/semver": "^7.5.8",
|
|
67
|
+
"@types/sinon": "^17.0.3",
|
|
69
68
|
"@types/source-map-support": "^0.5.10",
|
|
70
|
-
"@vitest/coverage-v8": "^2.1.
|
|
69
|
+
"@vitest/coverage-v8": "^2.1.2",
|
|
71
70
|
"eslint": "^9.11.1",
|
|
72
71
|
"eslint-plugin-format": "^0.1.2",
|
|
73
72
|
"jest": "^29.7.0",
|
|
74
73
|
"nodemon": "^3.1.7",
|
|
75
74
|
"npm-check-updates": "^17.1.3",
|
|
76
75
|
"shx": "^0.3.4",
|
|
76
|
+
"sinon": "^19.0.2",
|
|
77
77
|
"ts-node": "^10.9.2",
|
|
78
78
|
"typedoc": "^0.26.7",
|
|
79
79
|
"typescript": "^5.6.2",
|
|
80
|
-
"vitest": "^2.1.
|
|
80
|
+
"vitest": "^2.1.2"
|
|
81
81
|
}
|
|
82
82
|
}
|