-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
39 lines (33 loc) · 1.21 KB
/
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
'use strict';
const debug = require('debug')('neeo-roon-driver'),
config = require('./lib/util/settings')(),
Promise = require('bluebird');
const RoonDevice = require('./roonDevice'),
Neeo = require('./lib/neeo'),
Roon = require('./lib/roon');
// Setup Roon
// TODO: Parameter object pattern
const roonAdapter = new Roon.Adapter("org.pruessmann.neeo-roon-driver", "NEEO Driver", "0.0.1", "Doc Bobo", "boris@pruessmann.org");
const roonDeviceConfig = {
driverName: config.roon.driverName || 'Zone',
driverManufacturer: config.roon.driverManufacturer || 'Roon'
};
const roonDevice = new RoonDevice(roonAdapter, roonDeviceConfig);
// Setup Neeo
const neeoConfig = {
name: "neeo-roon-driver",
driverManufacturer: config.roon.driverManufacturer || 'Roon',
port: config.neeo.port || 4242,
brain: config.neeo.brain || null
};
const neeoAdapter = new Neeo.Adapter(neeoConfig);
neeoAdapter.addDevice(roonDevice);
Promise.join(
roonAdapter.start(),
neeoAdapter.start()
).then(() => {
neeoAdapter.devices.forEach((device) => device.emit('registered'));
}).catch((error) => {
console.error('[neeo-roon-driver] ERROR: "%s"', error.message);
process.exit(1);
});