-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
34 lines (27 loc) · 872 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
const Homey = require('homey');
if (Homey.env.SYSLOG_HOST) {
require('homey-syslog')();
}
module.exports = class TasmotaApp extends Homey.App {
onInit() {
this.log('TasmotaApp is running...');
// Various debugging/development tools.
Homey.env.INSPECTOR && require('inspector').open(9229, '0.0.0.0');
Homey.env.UPLOADER && require('homey-app-upload-lib')(this.manifest);
// Let devices register themselves with the app (useful in settings).
this.tasmotaDevices = [];
}
registerTasmotaDevice(device) {
this.tasmotaDevices.push(device);
}
unregisterTasmotaDevice(device) {
let id = device.getData().id;
let idx = this.tasmotaDevices.findIndex(d => d.getData().id === id);
if (idx !== -1) {
this.tasmotaDevices.splice(idx, 1);
}
}
async apiListTasmotaDevices() {
return this.tasmotaDevices;
}
}