-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathapp.js
36 lines (30 loc) · 830 Bytes
/
app.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
34
35
36
"use strict";
const Homey = require("homey");
const EwelinkApi = require("./lib/index");
const { ManagerSettings } = Homey;
class Ewelink extends Homey.App {
onInit() {
this.log("Ewelink is running...");
this.ewelinkApi = new EwelinkApi(this.log);
this.onSettingsChanged = this.onSettingsChanged.bind(this);
ManagerSettings.on("set", this.onSettingsChanged);
ManagerSettings.on("unset", this.onSettingsChanged);
}
onSettingsChanged(key) {
switch (key) {
case "account":
this.ewelinkApi.eWeLinkShutdown();
this.ewelinkApi.connect();
break;
default:
break;
}
}
sign(signData) {
return Homey.app.ewelinkApi.sign(signData);
}
getDevices(signData) {
return Homey.app.ewelinkApi.getAllDevices(signData);
}
}
module.exports = Ewelink;