-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
40 lines (29 loc) · 799 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
37
38
39
40
'use strict';
const Homey = require('homey');
const events = require('events');
const eventEmitter = new events.EventEmitter();
class MyApp extends Homey.App {
onInit() {
console.log(`${Homey.manifest.id} initializing...`);
this._bridges = [];
}
addBridge(bridge) {
bridge.icon = `/app/bridge/assets/icon.svg`;
this._bridges.push(bridge);
console.log(`added ${bridge.device_id}`);
eventEmitter.emit('bridgeAdded', bridge);
}
getBridge(bridgeId) {
var foundBridge = this._bridges.find(x => x.device_id === bridgeId);
if (foundBridge) {
console.log(`Found bridge with id ${foundBridge.device_id}`)
} else {
console.log(`Could not find bridge with id ${bridgeId}`)
}
return foundBridge;
}
getBridges() {
return this._bridges;
}
}
module.exports = MyApp;