node-switchbot 2.5.0-beta.13 → 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 +8 -33
- package/dist/switchbot.d.ts.map +1 -1
- package/dist/switchbot.js +426 -133
- package/dist/switchbot.js.map +1 -1
- package/package.json +1 -1
package/dist/switchbot.d.ts
CHANGED
|
@@ -1,48 +1,23 @@
|
|
|
1
1
|
import type * as Noble from '@stoprocent/noble';
|
|
2
2
|
import type { Ad, Params } from './types/types.js';
|
|
3
3
|
import { SwitchbotDevice } from './device.js';
|
|
4
|
-
/**
|
|
5
|
-
* SwitchBot class to interact with SwitchBot devices via BLE.
|
|
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:
|
|
11
|
+
PRIMARY_SERVICE_UUID_LIST: never[];
|
|
15
12
|
constructor(params?: Params);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Ensures the noble object is powered on.
|
|
23
|
-
*/
|
|
24
|
-
private ensureNobleReady;
|
|
25
|
-
/**
|
|
26
|
-
* Discover SwitchBot devices.
|
|
27
|
-
* @param params Optional parameters for discovery.
|
|
28
|
-
*/
|
|
29
|
-
discover(params?: Params): Promise<SwitchbotDevice[]>;
|
|
30
|
-
/**
|
|
31
|
-
* Start monitoring advertising packets from SwitchBot devices.
|
|
32
|
-
* @param params Optional parameters for scanning.
|
|
33
|
-
*/
|
|
13
|
+
init(params?: Params): Promise<void>;
|
|
14
|
+
discover(params?: Params): Promise<unknown>;
|
|
15
|
+
_init(): Promise<void>;
|
|
16
|
+
getDeviceObject(peripheral: Noble.Peripheral, id: string, model: string): Promise<SwitchbotDevice | null | undefined>;
|
|
17
|
+
filterAdvertising(ad: Ad, id: string, model: string): boolean;
|
|
34
18
|
startScan(params?: Params): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* Stop monitoring advertising packets from SwitchBot devices.
|
|
37
|
-
*/
|
|
38
19
|
stopScan(): void;
|
|
39
|
-
|
|
40
|
-
* Wait for the specified time.
|
|
41
|
-
* @param msec Time in milliseconds.
|
|
42
|
-
*/
|
|
43
|
-
wait(msec: number): Promise<void>;
|
|
44
|
-
private getDeviceObject;
|
|
45
|
-
private filterAdvertising;
|
|
20
|
+
wait(msec: number): Promise<unknown>;
|
|
46
21
|
}
|
|
47
22
|
export { SwitchbotDevice };
|
|
48
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":"
|
|
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
|
@@ -17,9 +17,6 @@ import { WoSmartLockPro } from './device/wosmartlockpro.js';
|
|
|
17
17
|
import { WoStrip } from './device/wostrip.js';
|
|
18
18
|
import { parameterChecker } from './parameter-checker.js';
|
|
19
19
|
import { SwitchBotBLEModel } from './types/types.js';
|
|
20
|
-
/**
|
|
21
|
-
* SwitchBot class to interact with SwitchBot devices via BLE.
|
|
22
|
-
*/
|
|
23
20
|
export class SwitchBot {
|
|
24
21
|
ready;
|
|
25
22
|
noble;
|
|
@@ -28,167 +25,463 @@ export class SwitchBot {
|
|
|
28
25
|
onlog;
|
|
29
26
|
DEFAULT_DISCOVERY_DURATION = 5000;
|
|
30
27
|
PRIMARY_SERVICE_UUID_LIST = [];
|
|
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
|
+
* ---------------------------------------------------------------- */
|
|
31
38
|
constructor(params) {
|
|
32
39
|
this.ready = this.init(params);
|
|
33
40
|
}
|
|
34
|
-
|
|
35
|
-
* Initializes the noble object.
|
|
36
|
-
* @param params Optional parameters.
|
|
37
|
-
*/
|
|
41
|
+
// Check parameters
|
|
38
42
|
async init(params) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
* Ensures the noble object is powered on.
|
|
43
|
-
*/
|
|
44
|
-
async ensureNobleReady() {
|
|
45
|
-
await this.ready;
|
|
46
|
-
if (this.noble._state === 'poweredOn') {
|
|
47
|
-
return;
|
|
43
|
+
let noble;
|
|
44
|
+
if (params && params.noble) {
|
|
45
|
+
noble = params.noble;
|
|
48
46
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (state === 'poweredOn') {
|
|
52
|
-
resolve();
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
reject(new Error(`Noble state: ${state}`));
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Discover SwitchBot devices.
|
|
62
|
-
* @param params Optional parameters for discovery.
|
|
63
|
-
*/
|
|
64
|
-
async discover(params = {}) {
|
|
65
|
-
const valid = parameterChecker.check(params, {
|
|
66
|
-
duration: { required: false, type: 'integer', min: 1, max: 60000 },
|
|
67
|
-
model: { required: false, type: 'string', enum: Object.values(SwitchBotBLEModel) },
|
|
68
|
-
id: { required: false, type: 'string', min: 12, max: 17 },
|
|
69
|
-
quick: { required: false, type: 'boolean' },
|
|
70
|
-
}, false);
|
|
71
|
-
if (!valid) {
|
|
72
|
-
throw new Error(parameterChecker.error.message);
|
|
47
|
+
else {
|
|
48
|
+
noble = (await import('@stoprocent/noble')).default;
|
|
73
49
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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,
|
|
82
138
|
};
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
|
160
|
+
this.noble.on('discover', async (peripheral) => {
|
|
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) {
|
|
89
171
|
finishDiscovery();
|
|
90
172
|
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
173
|
+
});
|
|
174
|
+
// Start scanning
|
|
175
|
+
this.noble.startScanning(this.PRIMARY_SERVICE_UUID_LIST, false, (error) => {
|
|
176
|
+
if (error) {
|
|
177
|
+
reject(error);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
timer = setTimeout(() => {
|
|
181
|
+
finishDiscovery();
|
|
182
|
+
}, p.duration);
|
|
183
|
+
});
|
|
184
|
+
})
|
|
185
|
+
.catch((error) => {
|
|
186
|
+
reject(error);
|
|
98
187
|
});
|
|
99
188
|
});
|
|
189
|
+
return promise;
|
|
100
190
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
id: { required: false, type: 'string', min: 12, max: 17 },
|
|
109
|
-
}, false);
|
|
110
|
-
if (!valid) {
|
|
111
|
-
throw new Error(parameterChecker.error.message);
|
|
112
|
-
}
|
|
113
|
-
const { model = '', id = '' } = params;
|
|
114
|
-
await this.ensureNobleReady();
|
|
115
|
-
this.noble.on('discover', async (peripheral) => {
|
|
116
|
-
const ad = await Advertising.parse(peripheral, this.onlog);
|
|
117
|
-
if (ad && this.filterAdvertising(ad, id, model)) {
|
|
118
|
-
this.onadvertisement?.(ad);
|
|
191
|
+
async _init() {
|
|
192
|
+
await this.ready;
|
|
193
|
+
const promise = new Promise((resolve, reject) => {
|
|
194
|
+
let err;
|
|
195
|
+
if (this.noble._state === 'poweredOn') {
|
|
196
|
+
resolve();
|
|
197
|
+
return;
|
|
119
198
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
199
|
+
this.noble.once('stateChange', (state) => {
|
|
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);
|
|
128
218
|
}
|
|
129
219
|
});
|
|
130
220
|
});
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Stop monitoring advertising packets from SwitchBot devices.
|
|
134
|
-
*/
|
|
135
|
-
stopScan() {
|
|
136
|
-
if (this.noble) {
|
|
137
|
-
this.noble.removeAllListeners('discover');
|
|
138
|
-
this.noble.stopScanning();
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Wait for the specified time.
|
|
143
|
-
* @param msec Time in milliseconds.
|
|
144
|
-
*/
|
|
145
|
-
wait(msec) {
|
|
146
|
-
const valid = parameterChecker.check({ msec }, { msec: { required: true, type: 'integer', min: 0 } }, true);
|
|
147
|
-
if (!valid) {
|
|
148
|
-
return Promise.reject(new Error(parameterChecker.error.message));
|
|
149
|
-
}
|
|
150
|
-
return new Promise(resolve => setTimeout(resolve, msec));
|
|
221
|
+
return promise;
|
|
151
222
|
}
|
|
152
223
|
async getDeviceObject(peripheral, id, model) {
|
|
153
224
|
const ad = await Advertising.parse(peripheral, this.onlog);
|
|
154
225
|
if (ad && this.filterAdvertising(ad, id, model)) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
+
}
|
|
176
285
|
}
|
|
286
|
+
return device;
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
return null;
|
|
177
290
|
}
|
|
178
|
-
return null;
|
|
179
291
|
}
|
|
180
292
|
filterAdvertising(ad, id, model) {
|
|
181
293
|
if (!ad) {
|
|
182
294
|
return false;
|
|
183
295
|
}
|
|
184
|
-
if (id
|
|
185
|
-
|
|
296
|
+
if (id) {
|
|
297
|
+
id = id.toLowerCase().replace(/:/g, '');
|
|
298
|
+
const ad_id = ad.address.toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
299
|
+
if (ad_id !== id) {
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
186
302
|
}
|
|
187
|
-
if (model
|
|
188
|
-
|
|
303
|
+
if (model) {
|
|
304
|
+
if (ad.serviceData.model !== model) {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
189
307
|
}
|
|
190
308
|
return true;
|
|
191
309
|
}
|
|
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;
|
|
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
|
+
});
|
|
440
|
+
});
|
|
441
|
+
return promise;
|
|
442
|
+
}
|
|
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) {
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
this.noble.removeAllListeners('discover');
|
|
458
|
+
this.noble.stopScanning();
|
|
459
|
+
}
|
|
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
|
+
});
|
|
484
|
+
}
|
|
192
485
|
}
|
|
193
486
|
export { SwitchbotDevice };
|
|
194
487
|
//# sourceMappingURL=switchbot.js.map
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,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",
|