node-switchbot 2.5.0-beta.12 → 2.5.0-beta.14
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/dist/switchbot.d.ts +7 -67
- package/dist/switchbot.d.ts.map +1 -1
- package/dist/switchbot.js +412 -190
- package/dist/switchbot.js.map +1 -1
- package/package.json +1 -1
package/dist/switchbot.d.ts
CHANGED
|
@@ -1,83 +1,23 @@
|
|
|
1
|
+
import type * as Noble from '@stoprocent/noble';
|
|
1
2
|
import type { Ad, Params } from './types/types.js';
|
|
2
|
-
import * as Noble from '@stoprocent/noble';
|
|
3
3
|
import { SwitchbotDevice } from './device.js';
|
|
4
|
-
/**
|
|
5
|
-
* SwitchBot class to interact with SwitchBot devices.
|
|
6
|
-
*/
|
|
7
4
|
export declare class SwitchBot {
|
|
8
5
|
private ready;
|
|
9
6
|
noble: typeof Noble;
|
|
10
7
|
ondiscover?: (device: SwitchbotDevice) => void;
|
|
11
8
|
onadvertisement?: (ad: Ad) => void;
|
|
12
|
-
onlog
|
|
9
|
+
onlog: ((message: string) => void) | undefined;
|
|
13
10
|
DEFAULT_DISCOVERY_DURATION: number;
|
|
14
|
-
PRIMARY_SERVICE_UUID_LIST:
|
|
15
|
-
/**
|
|
16
|
-
* Constructor
|
|
17
|
-
*
|
|
18
|
-
* @param {Params} [params] - Optional parameters
|
|
19
|
-
* @param {typeof Noble} [params.noble] - Optional noble instance
|
|
20
|
-
*/
|
|
11
|
+
PRIMARY_SERVICE_UUID_LIST: never[];
|
|
21
12
|
constructor(params?: Params);
|
|
22
|
-
/**
|
|
23
|
-
* Initializes the noble object.
|
|
24
|
-
*
|
|
25
|
-
* @param {Params} [params] - Optional parameters
|
|
26
|
-
* @param {typeof Noble} [params.noble] - Optional noble instance
|
|
27
|
-
* @returns {Promise<void>} - Resolves when initialization is complete
|
|
28
|
-
*/
|
|
29
13
|
init(params?: Params): Promise<void>;
|
|
30
|
-
|
|
31
|
-
* Discover SwitchBot devices based on the provided parameters.
|
|
32
|
-
*
|
|
33
|
-
* @param {Params} params - The parameters for discovery.
|
|
34
|
-
* @returns {Promise<SwitchbotDevice[]>} - A promise that resolves with a list of discovered devices.
|
|
35
|
-
*/
|
|
36
|
-
discover(params?: Params): Promise<SwitchbotDevice[]>;
|
|
37
|
-
/**
|
|
38
|
-
* Initializes the noble object and waits for it to be powered on.
|
|
39
|
-
*
|
|
40
|
-
* @returns {Promise<void>} - Resolves when the noble object is powered on.
|
|
41
|
-
*/
|
|
14
|
+
discover(params?: Params): Promise<unknown>;
|
|
42
15
|
_init(): Promise<void>;
|
|
43
|
-
|
|
44
|
-
* Gets the device object based on the peripheral, id, and model.
|
|
45
|
-
*
|
|
46
|
-
* @param {Noble.Peripheral} peripheral - The peripheral object.
|
|
47
|
-
* @param {string} id - The device id.
|
|
48
|
-
* @param {string} model - The device model.
|
|
49
|
-
* @returns {Promise<SwitchbotDevice | null>} - The device object or null.
|
|
50
|
-
*/
|
|
51
|
-
getDeviceObject(peripheral: Noble.Peripheral, id: string, model: string): Promise<SwitchbotDevice | null>;
|
|
52
|
-
/**
|
|
53
|
-
* Filters advertising data based on id and model.
|
|
54
|
-
*
|
|
55
|
-
* @param {Ad} ad - The advertising data.
|
|
56
|
-
* @param {string} id - The device id.
|
|
57
|
-
* @param {string} model - The device model.
|
|
58
|
-
* @returns {boolean} - True if the advertising data matches the id and model, false otherwise.
|
|
59
|
-
*/
|
|
16
|
+
getDeviceObject(peripheral: Noble.Peripheral, id: string, model: string): Promise<SwitchbotDevice | null | undefined>;
|
|
60
17
|
filterAdvertising(ad: Ad, id: string, model: string): boolean;
|
|
61
|
-
/**
|
|
62
|
-
* Starts scanning for SwitchBot devices.
|
|
63
|
-
*
|
|
64
|
-
* @param {Params} [params] - Optional parameters.
|
|
65
|
-
* @returns {Promise<void>} - Resolves when scanning starts successfully.
|
|
66
|
-
*/
|
|
67
18
|
startScan(params?: Params): Promise<void>;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
*
|
|
71
|
-
* @returns {Promise<void>} - Resolves when scanning stops successfully.
|
|
72
|
-
*/
|
|
73
|
-
stopScan(): Promise<void>;
|
|
74
|
-
/**
|
|
75
|
-
* Waits for the specified time.
|
|
76
|
-
*
|
|
77
|
-
* @param {number} msec - The time to wait in milliseconds.
|
|
78
|
-
* @returns {Promise<void>} - Resolves after the specified time.
|
|
79
|
-
*/
|
|
80
|
-
wait(msec: number): Promise<void>;
|
|
19
|
+
stopScan(): void;
|
|
20
|
+
wait(msec: number): Promise<unknown>;
|
|
81
21
|
}
|
|
82
22
|
export { SwitchbotDevice };
|
|
83
23
|
//# sourceMappingURL=switchbot.d.ts.map
|
package/dist/switchbot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switchbot.d.ts","sourceRoot":"","sources":["../src/switchbot.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"switchbot.d.ts","sourceRoot":"","sources":["../src/switchbot.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,KAAK,MAAM,mBAAmB,CAAA;AAE/C,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAGlD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAmB7C,qBAAa,SAAS;IACpB,OAAO,CAAC,KAAK,CAAe;IAC5B,KAAK,EAAG,OAAO,KAAK,CAAA;IACpB,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAA;IAC9C,eAAe,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,IAAI,CAAA;IAClC,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAA;IAC9C,0BAA0B,SAAO;IACjC,yBAAyB,UAAK;gBAYlB,MAAM,CAAC,EAAE,MAAM;IAKrB,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM;IAmD1B,QAAQ,CAAC,MAAM,GAAE,MAAW;IAsHtB,KAAK;IAuCL,eAAe,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAqE7E,iBAAiB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAgFnD,SAAS,CAAC,MAAM,GAAE,MAAW;IA+F7B,QAAQ;IAoBR,IAAI,CAAC,IAAI,EAAE,MAAM;CAmBlB;AAED,OAAO,EAAE,eAAe,EAAE,CAAA"}
|
package/dist/switchbot.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as Noble from '@stoprocent/noble';
|
|
2
1
|
import { Advertising } from './advertising.js';
|
|
3
2
|
import { SwitchbotDevice } from './device.js';
|
|
4
3
|
import { WoBlindTilt } from './device/woblindtilt.js';
|
|
@@ -18,9 +17,6 @@ import { WoSmartLockPro } from './device/wosmartlockpro.js';
|
|
|
18
17
|
import { WoStrip } from './device/wostrip.js';
|
|
19
18
|
import { parameterChecker } from './parameter-checker.js';
|
|
20
19
|
import { SwitchBotBLEModel } from './types/types.js';
|
|
21
|
-
/**
|
|
22
|
-
* SwitchBot class to interact with SwitchBot devices.
|
|
23
|
-
*/
|
|
24
20
|
export class SwitchBot {
|
|
25
21
|
ready;
|
|
26
22
|
noble;
|
|
@@ -29,236 +25,462 @@ export class SwitchBot {
|
|
|
29
25
|
onlog;
|
|
30
26
|
DEFAULT_DISCOVERY_DURATION = 5000;
|
|
31
27
|
PRIMARY_SERVICE_UUID_LIST = [];
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
/* ------------------------------------------------------------------
|
|
29
|
+
* Constructor
|
|
30
|
+
*
|
|
31
|
+
* [Arguments]
|
|
32
|
+
* - params | Object | Optional |
|
|
33
|
+
* - noble | Noble | Optional | The Noble object created by the noble module.
|
|
34
|
+
* | | | This parameter is optional.
|
|
35
|
+
* | | | If you don't specify this parameter, this
|
|
36
|
+
* | | | module automatically creates it.
|
|
37
|
+
* ---------------------------------------------------------------- */
|
|
38
38
|
constructor(params) {
|
|
39
39
|
this.ready = this.init(params);
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
* Initializes the noble object.
|
|
43
|
-
*
|
|
44
|
-
* @param {Params} [params] - Optional parameters
|
|
45
|
-
* @param {typeof Noble} [params.noble] - Optional noble instance
|
|
46
|
-
* @returns {Promise<void>} - Resolves when initialization is complete
|
|
47
|
-
*/
|
|
41
|
+
// Check parameters
|
|
48
42
|
async init(params) {
|
|
49
|
-
|
|
50
|
-
if (
|
|
51
|
-
|
|
43
|
+
let noble;
|
|
44
|
+
if (params && params.noble) {
|
|
45
|
+
noble = params.noble;
|
|
52
46
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
* Discover SwitchBot devices based on the provided parameters.
|
|
56
|
-
*
|
|
57
|
-
* @param {Params} params - The parameters for discovery.
|
|
58
|
-
* @returns {Promise<SwitchbotDevice[]>} - A promise that resolves with a list of discovered devices.
|
|
59
|
-
*/
|
|
60
|
-
async discover(params = {}) {
|
|
61
|
-
const valid = parameterChecker.check(params, {
|
|
62
|
-
duration: { required: false, type: 'integer', min: 1, max: 60000 },
|
|
63
|
-
model: { required: false, type: 'string', enum: Object.values(SwitchBotBLEModel) },
|
|
64
|
-
id: { required: false, type: 'string', min: 12, max: 17 },
|
|
65
|
-
quick: { required: false, type: 'boolean' },
|
|
66
|
-
}, false);
|
|
67
|
-
if (!valid) {
|
|
68
|
-
throw new Error(parameterChecker.error.message);
|
|
69
|
-
}
|
|
70
|
-
const { duration = this.DEFAULT_DISCOVERY_DURATION, model = '', id = '', quick = false } = params;
|
|
71
|
-
await this._init();
|
|
72
|
-
if (!this.noble) {
|
|
73
|
-
throw new Error('noble failed to initialize');
|
|
47
|
+
else {
|
|
48
|
+
noble = (await import('@stoprocent/noble')).default;
|
|
74
49
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
50
|
+
// Public properties
|
|
51
|
+
this.noble = noble;
|
|
52
|
+
}
|
|
53
|
+
/* ------------------------------------------------------------------
|
|
54
|
+
* discover([params])
|
|
55
|
+
* - Discover switchbot devices
|
|
56
|
+
*
|
|
57
|
+
* [Arguments]
|
|
58
|
+
* - params | Object | Optional |
|
|
59
|
+
* - duration | Integer | Optional | Duration for discovery process (msec).
|
|
60
|
+
* | | | The value must be in the range of 1 to 60000.
|
|
61
|
+
* | | | The default value is 5000 (msec).
|
|
62
|
+
* - model | String | Optional | "H", "T", "e", "s", "d", "c", "{", "u", "g", "o", "i", or "r".
|
|
63
|
+
* | | | If "H" is specified, this method will discover only Bots.
|
|
64
|
+
* | | | If "T" is specified, this method will discover only Meters.
|
|
65
|
+
* | | | If "e" is specified, this method will discover only Humidifiers.
|
|
66
|
+
* | | | If "s" is specified, this method will discover only Motion Sensors.
|
|
67
|
+
* | | | If "d" is specified, this method will discover only Contact Sensors.
|
|
68
|
+
* | | | If "c" is specified, this method will discover only Curtains.
|
|
69
|
+
* | | | If "{" is specified, this method will discover only Curtain 3.
|
|
70
|
+
* | | | If "u" is specified, this method will discover only Color Bulbs.
|
|
71
|
+
* | | | If "g" is specified, this method will discover only Plugs.
|
|
72
|
+
* | | | If "o" is specified, this method will discover only Locks.
|
|
73
|
+
* | | | If "$" is specified, this method will discover only Lock Pros.
|
|
74
|
+
* | | | If "i" is specified, this method will discover only Meter Pluses.
|
|
75
|
+
* | | | If "r" is specified, this method will discover only Locks.
|
|
76
|
+
* - id | String | Optional | If this value is set, this method will discover
|
|
77
|
+
* | | | only a device whose ID is as same as this value.
|
|
78
|
+
* | | | The ID is identical to the MAC address.
|
|
79
|
+
* | | | This parameter is case-insensitive, and
|
|
80
|
+
* | | | colons are ignored.
|
|
81
|
+
* - quick | Boolean | Optional | If this value is true, this method finishes
|
|
82
|
+
* | | | the discovery process when the first device
|
|
83
|
+
* | | | is found, then calls the resolve() function
|
|
84
|
+
* | | | without waiting the specified duration.
|
|
85
|
+
* | | | The default value is false.
|
|
86
|
+
*
|
|
87
|
+
* [Return value]
|
|
88
|
+
* - Promise object
|
|
89
|
+
* An array will be passed to the `resolve()`, which includes
|
|
90
|
+
* `SwitchbotDevice` objects representing the found devices.
|
|
91
|
+
* ---------------------------------------------------------------- */
|
|
92
|
+
discover(params = {}) {
|
|
93
|
+
const promise = new Promise((resolve, reject) => {
|
|
94
|
+
// Check the parameters
|
|
95
|
+
const valid = parameterChecker.check(params, {
|
|
96
|
+
duration: { required: false, type: 'integer', min: 1, max: 60000 },
|
|
97
|
+
model: {
|
|
98
|
+
required: false,
|
|
99
|
+
type: 'string',
|
|
100
|
+
enum: [
|
|
101
|
+
SwitchBotBLEModel.Bot,
|
|
102
|
+
SwitchBotBLEModel.Curtain,
|
|
103
|
+
SwitchBotBLEModel.Curtain3,
|
|
104
|
+
SwitchBotBLEModel.Humidifier,
|
|
105
|
+
SwitchBotBLEModel.Meter,
|
|
106
|
+
SwitchBotBLEModel.MeterPlus,
|
|
107
|
+
SwitchBotBLEModel.Hub2,
|
|
108
|
+
SwitchBotBLEModel.OutdoorMeter,
|
|
109
|
+
SwitchBotBLEModel.MotionSensor,
|
|
110
|
+
SwitchBotBLEModel.ContactSensor,
|
|
111
|
+
SwitchBotBLEModel.ColorBulb,
|
|
112
|
+
SwitchBotBLEModel.CeilingLight,
|
|
113
|
+
SwitchBotBLEModel.CeilingLightPro,
|
|
114
|
+
SwitchBotBLEModel.StripLight,
|
|
115
|
+
SwitchBotBLEModel.PlugMiniUS,
|
|
116
|
+
SwitchBotBLEModel.PlugMiniJP,
|
|
117
|
+
SwitchBotBLEModel.Lock,
|
|
118
|
+
SwitchBotBLEModel.LockPro,
|
|
119
|
+
SwitchBotBLEModel.BlindTilt,
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
id: { required: false, type: 'string', min: 12, max: 17 },
|
|
123
|
+
quick: { required: false, type: 'boolean' },
|
|
124
|
+
}, false);
|
|
125
|
+
if (!valid) {
|
|
126
|
+
reject(new Error(parameterChecker.error.message));
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (!params) {
|
|
130
|
+
params = {};
|
|
131
|
+
}
|
|
132
|
+
// Determine the values of the parameters
|
|
133
|
+
const p = {
|
|
134
|
+
duration: params.duration || this.DEFAULT_DISCOVERY_DURATION,
|
|
135
|
+
model: params.model || '',
|
|
136
|
+
id: params.id || '',
|
|
137
|
+
quick: !!params.quick,
|
|
138
|
+
};
|
|
139
|
+
// Initialize the noble object
|
|
140
|
+
this._init()
|
|
141
|
+
.then(() => {
|
|
142
|
+
if (this.noble === null) {
|
|
143
|
+
return reject(new Error('noble failed to initialize'));
|
|
144
|
+
}
|
|
145
|
+
const peripherals = {};
|
|
146
|
+
let timer = setTimeout(() => { }, 0);
|
|
147
|
+
const finishDiscovery = () => {
|
|
148
|
+
if (timer) {
|
|
149
|
+
clearTimeout(timer);
|
|
150
|
+
}
|
|
151
|
+
this.noble.removeAllListeners('discover');
|
|
152
|
+
this.noble.stopScanning();
|
|
153
|
+
const device_list = [];
|
|
154
|
+
for (const addr in peripherals) {
|
|
155
|
+
device_list.push(peripherals[addr]);
|
|
156
|
+
}
|
|
157
|
+
resolve(device_list);
|
|
158
|
+
};
|
|
159
|
+
// Set a handler for the 'discover' event
|
|
85
160
|
this.noble.on('discover', async (peripheral) => {
|
|
86
|
-
const device = await this.getDeviceObject(peripheral, id, model);
|
|
87
|
-
if (device) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
161
|
+
const device = await this.getDeviceObject(peripheral, p.id, p.model);
|
|
162
|
+
if (!device) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const id = device.id;
|
|
166
|
+
peripherals[id] = device;
|
|
167
|
+
if (this.ondiscover && typeof this.ondiscover === 'function') {
|
|
168
|
+
this.ondiscover(device);
|
|
169
|
+
}
|
|
170
|
+
if (p.quick) {
|
|
171
|
+
finishDiscovery();
|
|
95
172
|
}
|
|
96
173
|
});
|
|
97
|
-
|
|
98
|
-
|
|
174
|
+
// Start scanning
|
|
175
|
+
this.noble.startScanning(this.PRIMARY_SERVICE_UUID_LIST, false, (error) => {
|
|
176
|
+
if (error) {
|
|
177
|
+
reject(error);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
99
180
|
timer = setTimeout(() => {
|
|
100
|
-
|
|
101
|
-
}, duration);
|
|
102
|
-
})
|
|
103
|
-
.catch((error) => {
|
|
104
|
-
reject(new Error(error.message));
|
|
181
|
+
finishDiscovery();
|
|
182
|
+
}, p.duration);
|
|
105
183
|
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
reject(
|
|
109
|
-
}
|
|
184
|
+
})
|
|
185
|
+
.catch((error) => {
|
|
186
|
+
reject(error);
|
|
187
|
+
});
|
|
110
188
|
});
|
|
189
|
+
return promise;
|
|
111
190
|
}
|
|
112
|
-
/**
|
|
113
|
-
* Initializes the noble object and waits for it to be powered on.
|
|
114
|
-
*
|
|
115
|
-
* @returns {Promise<void>} - Resolves when the noble object is powered on.
|
|
116
|
-
*/
|
|
117
191
|
async _init() {
|
|
118
192
|
await this.ready;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return reject(new Error('noble.once is not a function'));
|
|
193
|
+
const promise = new Promise((resolve, reject) => {
|
|
194
|
+
let err;
|
|
195
|
+
if (this.noble._state === 'poweredOn') {
|
|
196
|
+
resolve();
|
|
197
|
+
return;
|
|
125
198
|
}
|
|
126
199
|
this.noble.once('stateChange', (state) => {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
200
|
+
switch (state) {
|
|
201
|
+
case 'unsupported':
|
|
202
|
+
case 'unauthorized':
|
|
203
|
+
case 'poweredOff':
|
|
204
|
+
err = new Error(`Failed to initialize the Noble object: ${this.noble._state}`);
|
|
205
|
+
reject(err);
|
|
206
|
+
return;
|
|
207
|
+
case 'resetting':
|
|
208
|
+
case 'unknown':
|
|
209
|
+
err = new Error(`Adapter is not ready: ${this.noble._state}`);
|
|
210
|
+
reject(err);
|
|
211
|
+
return;
|
|
212
|
+
case 'poweredOn':
|
|
213
|
+
resolve();
|
|
214
|
+
return;
|
|
215
|
+
default:
|
|
216
|
+
err = new Error(`Unknown state: ${this.noble._state}`);
|
|
217
|
+
reject(err);
|
|
138
218
|
}
|
|
139
219
|
});
|
|
140
220
|
});
|
|
221
|
+
return promise;
|
|
141
222
|
}
|
|
142
|
-
/**
|
|
143
|
-
* Gets the device object based on the peripheral, id, and model.
|
|
144
|
-
*
|
|
145
|
-
* @param {Noble.Peripheral} peripheral - The peripheral object.
|
|
146
|
-
* @param {string} id - The device id.
|
|
147
|
-
* @param {string} model - The device model.
|
|
148
|
-
* @returns {Promise<SwitchbotDevice | null>} - The device object or null.
|
|
149
|
-
*/
|
|
150
223
|
async getDeviceObject(peripheral, id, model) {
|
|
151
224
|
const ad = await Advertising.parse(peripheral, this.onlog);
|
|
152
|
-
if (
|
|
225
|
+
if (ad && this.filterAdvertising(ad, id, model)) {
|
|
226
|
+
let device;
|
|
227
|
+
if (ad && ad.serviceData && ad.serviceData.model) {
|
|
228
|
+
switch (ad.serviceData.model) {
|
|
229
|
+
case SwitchBotBLEModel.Bot:
|
|
230
|
+
device = new WoHand(peripheral, this.noble);
|
|
231
|
+
break;
|
|
232
|
+
case SwitchBotBLEModel.Curtain:
|
|
233
|
+
case SwitchBotBLEModel.Curtain3:
|
|
234
|
+
device = new WoCurtain(peripheral, this.noble);
|
|
235
|
+
break;
|
|
236
|
+
case SwitchBotBLEModel.Humidifier:
|
|
237
|
+
device = new WoHumi(peripheral, this.noble);
|
|
238
|
+
break;
|
|
239
|
+
case SwitchBotBLEModel.Meter:
|
|
240
|
+
device = new WoSensorTH(peripheral, this.noble);
|
|
241
|
+
break;
|
|
242
|
+
case SwitchBotBLEModel.MeterPlus:
|
|
243
|
+
device = new WoSensorTH(peripheral, this.noble);
|
|
244
|
+
break;
|
|
245
|
+
case SwitchBotBLEModel.Hub2:
|
|
246
|
+
device = new WoHub2(peripheral, this.noble);
|
|
247
|
+
break;
|
|
248
|
+
case SwitchBotBLEModel.OutdoorMeter:
|
|
249
|
+
device = new WoIOSensorTH(peripheral, this.noble);
|
|
250
|
+
break;
|
|
251
|
+
case SwitchBotBLEModel.MotionSensor:
|
|
252
|
+
device = new WoPresence(peripheral, this.noble);
|
|
253
|
+
break;
|
|
254
|
+
case SwitchBotBLEModel.ContactSensor:
|
|
255
|
+
device = new WoContact(peripheral, this.noble);
|
|
256
|
+
break;
|
|
257
|
+
case SwitchBotBLEModel.ColorBulb:
|
|
258
|
+
device = new WoBulb(peripheral, this.noble);
|
|
259
|
+
break;
|
|
260
|
+
case SwitchBotBLEModel.CeilingLight:
|
|
261
|
+
device = new WoCeilingLight(peripheral, this.noble);
|
|
262
|
+
break;
|
|
263
|
+
case SwitchBotBLEModel.CeilingLightPro:
|
|
264
|
+
device = new WoCeilingLight(peripheral, this.noble);
|
|
265
|
+
break;
|
|
266
|
+
case SwitchBotBLEModel.StripLight:
|
|
267
|
+
device = new WoStrip(peripheral, this.noble);
|
|
268
|
+
break;
|
|
269
|
+
case SwitchBotBLEModel.PlugMiniUS:
|
|
270
|
+
case SwitchBotBLEModel.PlugMiniJP:
|
|
271
|
+
device = new WoPlugMini(peripheral, this.noble);
|
|
272
|
+
break;
|
|
273
|
+
case SwitchBotBLEModel.Lock:
|
|
274
|
+
device = new WoSmartLock(peripheral, this.noble);
|
|
275
|
+
break;
|
|
276
|
+
case SwitchBotBLEModel.LockPro:
|
|
277
|
+
device = new WoSmartLockPro(peripheral, this.noble);
|
|
278
|
+
break;
|
|
279
|
+
case SwitchBotBLEModel.BlindTilt:
|
|
280
|
+
device = new WoBlindTilt(peripheral, this.noble);
|
|
281
|
+
break;
|
|
282
|
+
default: // 'resetting', 'unknown'
|
|
283
|
+
device = new SwitchbotDevice(peripheral, this.noble);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return device;
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
153
289
|
return null;
|
|
154
290
|
}
|
|
155
|
-
const modelMapping = {
|
|
156
|
-
[SwitchBotBLEModel.Bot]: WoHand,
|
|
157
|
-
[SwitchBotBLEModel.Curtain]: WoCurtain,
|
|
158
|
-
[SwitchBotBLEModel.Curtain3]: WoCurtain,
|
|
159
|
-
[SwitchBotBLEModel.Humidifier]: WoHumi,
|
|
160
|
-
[SwitchBotBLEModel.Meter]: WoSensorTH,
|
|
161
|
-
[SwitchBotBLEModel.MeterPlus]: WoSensorTH,
|
|
162
|
-
[SwitchBotBLEModel.Hub2]: WoHub2,
|
|
163
|
-
[SwitchBotBLEModel.OutdoorMeter]: WoIOSensorTH,
|
|
164
|
-
[SwitchBotBLEModel.MotionSensor]: WoPresence,
|
|
165
|
-
[SwitchBotBLEModel.ContactSensor]: WoContact,
|
|
166
|
-
[SwitchBotBLEModel.ColorBulb]: WoBulb,
|
|
167
|
-
[SwitchBotBLEModel.CeilingLight]: WoCeilingLight,
|
|
168
|
-
[SwitchBotBLEModel.CeilingLightPro]: WoCeilingLight,
|
|
169
|
-
[SwitchBotBLEModel.StripLight]: WoStrip,
|
|
170
|
-
[SwitchBotBLEModel.PlugMiniUS]: WoPlugMini,
|
|
171
|
-
[SwitchBotBLEModel.PlugMiniJP]: WoPlugMini,
|
|
172
|
-
[SwitchBotBLEModel.Lock]: WoSmartLock,
|
|
173
|
-
[SwitchBotBLEModel.LockPro]: WoSmartLockPro,
|
|
174
|
-
[SwitchBotBLEModel.BlindTilt]: WoBlindTilt,
|
|
175
|
-
};
|
|
176
|
-
const DeviceClass = ad?.serviceData?.model ? modelMapping[ad.serviceData.model] : SwitchbotDevice;
|
|
177
|
-
return new DeviceClass(peripheral, this.noble);
|
|
178
291
|
}
|
|
179
|
-
/**
|
|
180
|
-
* Filters advertising data based on id and model.
|
|
181
|
-
*
|
|
182
|
-
* @param {Ad} ad - The advertising data.
|
|
183
|
-
* @param {string} id - The device id.
|
|
184
|
-
* @param {string} model - The device model.
|
|
185
|
-
* @returns {boolean} - True if the advertising data matches the id and model, false otherwise.
|
|
186
|
-
*/
|
|
187
292
|
filterAdvertising(ad, id, model) {
|
|
188
293
|
if (!ad) {
|
|
189
294
|
return false;
|
|
190
295
|
}
|
|
191
296
|
if (id) {
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
if (
|
|
297
|
+
id = id.toLowerCase().replace(/:/g, '');
|
|
298
|
+
const ad_id = ad.address.toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
299
|
+
if (ad_id !== id) {
|
|
195
300
|
return false;
|
|
196
301
|
}
|
|
197
302
|
}
|
|
198
|
-
if (model
|
|
199
|
-
|
|
303
|
+
if (model) {
|
|
304
|
+
if (ad.serviceData.model !== model) {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
200
307
|
}
|
|
201
308
|
return true;
|
|
202
309
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
310
|
+
/* ------------------------------------------------------------------
|
|
311
|
+
* startScan([params])
|
|
312
|
+
* - Start to monitor advertising packets coming from switchbot devices
|
|
313
|
+
*
|
|
314
|
+
* [Arguments]
|
|
315
|
+
* - params | Object | Optional |
|
|
316
|
+
* - model | String | Optional | "H", "T", "e", "s", "d", "c", "{", "u", "g", "o", "i", "x", or "r".
|
|
317
|
+
* | | | If "H" is specified, the `onadvertisement`
|
|
318
|
+
* | | | event handler will be called only when advertising
|
|
319
|
+
* | | | packets comes from Bots.
|
|
320
|
+
* | | | If "T" is specified, the `onadvertisement`
|
|
321
|
+
* | | | event handler will be called only when advertising
|
|
322
|
+
* | | | packets comes from Meters.
|
|
323
|
+
* | | | If "e" is specified, the `onadvertisement`
|
|
324
|
+
* | | | event handler will be called only when advertising
|
|
325
|
+
* | | | packets comes from Humidifiers.
|
|
326
|
+
* | | | If "s" is specified, the `onadvertisement`
|
|
327
|
+
* | | | event handler will be called only when advertising
|
|
328
|
+
* | | | packets comes from Motion Sensor.
|
|
329
|
+
* | | | If "d" is specified, the `onadvertisement`
|
|
330
|
+
* | | | event handler will be called only when advertising
|
|
331
|
+
* | | | packets comes from Contact Sensor.
|
|
332
|
+
* | | | If "c" is specified, the `onadvertisement`
|
|
333
|
+
* | | | event handler will be called only when advertising
|
|
334
|
+
* | | | packets comes from Curtains.
|
|
335
|
+
* | | | If "{" is specified, the `onadvertisement`
|
|
336
|
+
* | | | event handler will be called only when advertising
|
|
337
|
+
* | | | packets comes from Curtain 3.
|
|
338
|
+
* | | | If "x" is specified, the `onadvertisement`
|
|
339
|
+
* | | | event handler will be called only when advertising
|
|
340
|
+
* | | | packets comes from BlindTilt.
|
|
341
|
+
* | | | If "u" is specified, the `onadvertisement`
|
|
342
|
+
* | | | event handler will be called only when advertising
|
|
343
|
+
* | | | packets comes from Color Bulb.
|
|
344
|
+
* | | | If "g" is specified, the `onadvertisement`
|
|
345
|
+
* | | | event handler will be called only when advertising
|
|
346
|
+
* | | | packets comes from Plug Mini.
|
|
347
|
+
* | | | If "o" is specified, the `onadvertisement`
|
|
348
|
+
* | | | event handler will be called only when advertising
|
|
349
|
+
* | | | packets comes from Smart Lock.
|
|
350
|
+
* | | | If "$" is specified, the `onadvertisement`
|
|
351
|
+
* | | | event handler will be called only when advertising
|
|
352
|
+
* | | | packets comes from Smart Lock Pro.
|
|
353
|
+
* | | | If "i" is specified, the `onadvertisement`
|
|
354
|
+
* | | | event handler will be called only when advertising
|
|
355
|
+
* | | | packets comes from Meter Plus.
|
|
356
|
+
* | | | If "r" is specified, the `onadvertisement`
|
|
357
|
+
* | | | event handler will be called only when advertising
|
|
358
|
+
* | | | packets comes from LED Strip Light.
|
|
359
|
+
* - id | String | Optional | If this value is set, the `onadvertisement`
|
|
360
|
+
* | | | event handler will be called only when advertising
|
|
361
|
+
* | | | packets comes from devices whose ID is as same as
|
|
362
|
+
* | | | this value.
|
|
363
|
+
* | | | The ID is identical to the MAC address.
|
|
364
|
+
* | | | This parameter is case-insensitive, and
|
|
365
|
+
* | | | colons are ignored.
|
|
366
|
+
*
|
|
367
|
+
* [Return value]
|
|
368
|
+
* - Promise object
|
|
369
|
+
* Nothing will be passed to the `resolve()`.
|
|
370
|
+
* ---------------------------------------------------------------- */
|
|
371
|
+
startScan(params = {}) {
|
|
372
|
+
const promise = new Promise((resolve, reject) => {
|
|
373
|
+
// Check the parameters
|
|
374
|
+
const valid = parameterChecker.check(params, {
|
|
375
|
+
model: {
|
|
376
|
+
required: false,
|
|
377
|
+
type: 'string',
|
|
378
|
+
enum: [
|
|
379
|
+
SwitchBotBLEModel.Bot,
|
|
380
|
+
SwitchBotBLEModel.Curtain,
|
|
381
|
+
SwitchBotBLEModel.Curtain3,
|
|
382
|
+
SwitchBotBLEModel.Humidifier,
|
|
383
|
+
SwitchBotBLEModel.Meter,
|
|
384
|
+
SwitchBotBLEModel.MeterPlus,
|
|
385
|
+
SwitchBotBLEModel.Hub2,
|
|
386
|
+
SwitchBotBLEModel.OutdoorMeter,
|
|
387
|
+
SwitchBotBLEModel.MotionSensor,
|
|
388
|
+
SwitchBotBLEModel.ContactSensor,
|
|
389
|
+
SwitchBotBLEModel.ColorBulb,
|
|
390
|
+
SwitchBotBLEModel.CeilingLight,
|
|
391
|
+
SwitchBotBLEModel.CeilingLightPro,
|
|
392
|
+
SwitchBotBLEModel.StripLight,
|
|
393
|
+
SwitchBotBLEModel.PlugMiniUS,
|
|
394
|
+
SwitchBotBLEModel.PlugMiniJP,
|
|
395
|
+
SwitchBotBLEModel.Lock,
|
|
396
|
+
SwitchBotBLEModel.LockPro,
|
|
397
|
+
SwitchBotBLEModel.BlindTilt,
|
|
398
|
+
],
|
|
399
|
+
},
|
|
400
|
+
id: { required: false, type: 'string', min: 12, max: 17 },
|
|
401
|
+
}, false);
|
|
402
|
+
if (!valid) {
|
|
403
|
+
reject(new Error(parameterChecker.error.message));
|
|
404
|
+
return;
|
|
232
405
|
}
|
|
406
|
+
// Initialize the noble object
|
|
407
|
+
this._init()
|
|
408
|
+
.then(() => {
|
|
409
|
+
if (this.noble === null) {
|
|
410
|
+
return reject(new Error('noble object failed to initialize'));
|
|
411
|
+
}
|
|
412
|
+
// Determine the values of the parameters
|
|
413
|
+
const p = {
|
|
414
|
+
model: params.model || '',
|
|
415
|
+
id: params.id || '',
|
|
416
|
+
};
|
|
417
|
+
// Set a handler for the 'discover' event
|
|
418
|
+
this.noble.on('discover', async (peripheral) => {
|
|
419
|
+
const ad = await Advertising.parse(peripheral, this.onlog);
|
|
420
|
+
if (ad && this.filterAdvertising(ad, p.id, p.model)) {
|
|
421
|
+
if (this.onadvertisement
|
|
422
|
+
&& typeof this.onadvertisement === 'function') {
|
|
423
|
+
this.onadvertisement(ad);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
// Start scanning
|
|
428
|
+
this.noble.startScanning(this.PRIMARY_SERVICE_UUID_LIST, true, (error) => {
|
|
429
|
+
if (error) {
|
|
430
|
+
reject(error);
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
resolve();
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
})
|
|
437
|
+
.catch((error) => {
|
|
438
|
+
reject(error);
|
|
439
|
+
});
|
|
233
440
|
});
|
|
234
|
-
|
|
441
|
+
return promise;
|
|
235
442
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
443
|
+
/* ------------------------------------------------------------------
|
|
444
|
+
* stopScan()
|
|
445
|
+
* - Stop to monitor advertising packets coming from switchbot devices
|
|
446
|
+
*
|
|
447
|
+
* [Arguments]
|
|
448
|
+
* - none
|
|
449
|
+
*
|
|
450
|
+
* [Return value]
|
|
451
|
+
* - none
|
|
452
|
+
* ---------------------------------------------------------------- */
|
|
453
|
+
stopScan() {
|
|
454
|
+
if (this.noble === null) {
|
|
243
455
|
return;
|
|
244
456
|
}
|
|
245
457
|
this.noble.removeAllListeners('discover');
|
|
246
|
-
|
|
458
|
+
this.noble.stopScanning();
|
|
247
459
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
460
|
+
/* ------------------------------------------------------------------
|
|
461
|
+
* wait(msec) {
|
|
462
|
+
* - Wait for the specified time (msec)
|
|
463
|
+
*
|
|
464
|
+
* [Arguments]
|
|
465
|
+
* - msec | Integer | Required | Msec.
|
|
466
|
+
*
|
|
467
|
+
* [Return value]
|
|
468
|
+
* - Promise object
|
|
469
|
+
* Nothing will be passed to the `resolve()`.
|
|
470
|
+
* ---------------------------------------------------------------- */
|
|
471
|
+
wait(msec) {
|
|
472
|
+
return new Promise((resolve, reject) => {
|
|
473
|
+
// Check the parameters
|
|
474
|
+
const valid = parameterChecker.check({ msec }, {
|
|
475
|
+
msec: { required: true, type: 'integer', min: 0 },
|
|
476
|
+
}, true);
|
|
477
|
+
if (!valid) {
|
|
478
|
+
reject(new Error(parameterChecker.error.message));
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
// Set a timer
|
|
482
|
+
setTimeout(resolve, msec);
|
|
483
|
+
});
|
|
262
484
|
}
|
|
263
485
|
}
|
|
264
486
|
export { SwitchbotDevice };
|
package/dist/switchbot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switchbot.js","sourceRoot":"","sources":["../src/switchbot.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAA;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAA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CAAC,KAAK,EAAE,EAAE;gBACf,MAAM,CAAC,KAAK,CAAC,CAAA;YACf,CAAC,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;QACF,OAAO,OAAO,CAAA;IAChB,CAAC;IAED;;;;;;;;;4EASwE;IACxE,QAAQ;QACN,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YACxB,OAAM;QACR,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAA;QACzC,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAA;IAC3B,CAAC;IAED;;;;;;;;;;4EAUwE;IACxE,IAAI,CAAC,IAAY;QACf,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,uBAAuB;YACvB,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,CAClC,EAAE,IAAI,EAAE,EACR;gBACE,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,EAAE;aAClD,EACD,IAAI,CACL,CAAA;YAED,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,MAAM,CAAC,IAAI,KAAK,CAAC,gBAAgB,CAAC,KAAM,CAAC,OAAO,CAAC,CAAC,CAAA;gBAClD,OAAM;YACR,CAAC;YACD,cAAc;YACd,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QAC3B,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AAED,OAAO,EAAE,eAAe,EAAE,CAAA"}
|
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.14",
|
|
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",
|