-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (28 loc) · 1.2 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
34
/**
* Dependencies
*/
var NodeSonos = require('sonos');
var SonosLCD = require('./lib/sonosLCD');
var LCDdClient = require('node-lcdd');
// Connect to the LCD Display Server
var lcd = new LCDdClient('localhost', 13666, 'sonos');
// Once the LCD is ready, look for Sonos devices
lcd.on('ready', function() {
console.log('\nSearching for Sonos devices on network...');
var search = NodeSonos.search();
if (process.env.SONOS_HOST) {
// Connect to the Sonos device specified in the environment
// HACK - For cloud9, I'm using localhost, and setting up an SSH Tunnel to the real Sonos
var s = new SonosLCD(process.env.SONOS_HOST || 'localhost', process.env.SONOS_PORT || 1400, process.env.SONOS_NAME || 'Default', lcd);
}
// Whenever a Sonos device is found, create a new screen on the LCD for it
search.on('DeviceAvailable', function DeviceFound(device, model) {
var host = device.host;
var port = device.port;
device.getZoneAttrs(function ZoneAttrsFound(err, attrs) {
var name = attrs.CurrentZoneName;
console.log('Found:', name, '(@'+host+':'+port+')');
var s = new SonosLCD(host, port, name, lcd);
});
});
});