Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Stephan van Rooij
committed
May 26, 2020
1 parent
32f67bb
commit 617818a
Showing
2 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const SonosManager = require('../lib/').SonosManager | ||
|
||
const manager = new SonosManager(); | ||
manager.InitializeFromDevice(process.env.SONOS_HOST || '192.168.96.56', 1400) | ||
.then(result => { | ||
if(result) { | ||
manager.Devices.forEach(d => { | ||
console.log('Start listening for event from %s', d.Name); | ||
d.Events.on('groupname', name => { | ||
console.log('Device %s has a new group name %s', d.Name, name); | ||
}); | ||
}) | ||
} | ||
}) | ||
|
||
process.on('SIGINT', () => { | ||
console.log('Hold-on cancelling all subscriptions') | ||
manager.Devices.forEach(d => d.CancelEvents()); | ||
manager.CancelSubscription(); | ||
|
||
setTimeout(() => { | ||
process.exit(0) | ||
}, 300) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters