-
Notifications
You must be signed in to change notification settings - Fork 39
/
index.js
33 lines (30 loc) · 1.29 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const MiAqara = require('./libs/MiAqara');
let miAqaraSDK = {
_miAqara: null,
_start: false,
create (gateways, opts) {
this._miAqara = new MiAqara(gateways, opts);
this.extend();
},
start () {
this._miAqara.start();
this._start = true;
},
extend () { // 初始化后再添加更多接口
let miAqara = this._miAqara;
let gatewayHelper = miAqara.gatewayHelper;
let deviceHelper = miAqara.deviceHelper;
this.parser = miAqara.parser;
this.getGatewayBySid = gatewayHelper.getBySid.bind(gatewayHelper);
this.getGatewayList = gatewayHelper.getGatewayList.bind(gatewayHelper);
this.controlLight = gatewayHelper.controlLight.bind(gatewayHelper);
this.getDeviceBySid = deviceHelper.getBySid.bind(deviceHelper);
this.getDevicesByGatewaySid = deviceHelper.getDevicesByGatewaySid.bind(deviceHelper);
this.getDevicesByGatewaySidAndModel = deviceHelper.getDevicesByGatewaySidAndModel.bind(deviceHelper);
this.getDevicesByModel = deviceHelper.getDevicesByModel.bind(deviceHelper);
this.getDeviceList = deviceHelper.getDeviceList.bind(deviceHelper);
this.change = deviceHelper.change.bind(deviceHelper);
}
};
// 收敛暴露的接口
module.exports = miAqaraSDK;