Skip to content

Commit

Permalink
Merge pull request #143 from svrooij/beta
Browse files Browse the repository at this point in the history
Release new version
  • Loading branch information
svrooij authored Sep 15, 2021
2 parents 0819891 + a6346f2 commit 25d4a6f
Show file tree
Hide file tree
Showing 22 changed files with 2,213 additions and 2,990 deletions.
4 changes: 3 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"outFiles": ["${workspaceFolder}/lib/**/*.js"],
"env": {
"DEBUG":"sonos:*",
"SONOS_HOST":"192.168.96.56"
"SONOS_HOST":"192.168.96.56",
"SONOS_TTS_ENDPOINT": "https://xxx/api/generate",
"SONOS_TTS_LANG": "nl-NL"
},
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
Expand Down
2 changes: 2 additions & 0 deletions docs/sonos-device/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Each **Sonos Device** has the following shortcuts (things you could also do by u
- **.Next()** - Go to next song (when playing the queue) *.
- **.Previous()** - Go to previous song (when playing the queue) *.
- **.SetNightMode(desiredState)** - Turn on/off nightmode on your playbar.
- **.SetRelativeGroupVolume(adjustment)** - Change the group volume relative to current *.
- **.SetRelativeVolume(adjustment)** - Change the volume relative to current.
- **.SetSpeechEnhancement(desiredState)** - Turn on/off speech enhancement on your playbar.
- **.SetVolume(newVolume)** - Change the volume.
Expand Down Expand Up @@ -80,6 +81,7 @@ Currently supported url's for metadata guessing:
- `spotify:artistTopTracks:72qVrKXRp9GeFQOesj0Pmv` - Spotify artist top tracks (has to be added to queue).
- `spotify:album:5c4y5oD0jCAVHJNusKpy4d` - Spotify album (has to be added to queue).
- `spotify:playlist:37i9dQZF1DXcx1szy2g67M` - Spotify playlist (has to be added to queue).
- `spotify:user:spotify:playlist:37i9dQZF1DX1htCFhfVtyK` - Spotify playlist of a different user (summer rewind from user spotify in this case).
- `radio:s113577` - Tunein radio station.

This library will guess the metadata automatically for the following methods, but you can also use the **MetadataHelper**, yourself.
Expand Down
10 changes: 10 additions & 0 deletions examples/mute.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const SonosDevice = require('../lib').SonosDevice

const sonos = new SonosDevice(process.env.SONOS_HOST || '192.168.96.56')
sonos.RenderingControlService.GetMute({ InstanceID: 0, Channel: 'Master' })
.then(data => {
console.log('Device muted', data);
})
.catch(err => {
console.log(err)
})
19 changes: 12 additions & 7 deletions examples/play-notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,37 @@ sonos.Events.on('currentTrack', (track) => {

setTimeout(async () => {
// Add a second notification (by some other event)
sonos.PlayNotification({
await sonos.PlayNotification({
trackUri: 'https://cdn.smartersoft-group.com/various/someone-at-the-door.mp3', // Cached text-to-speech file.
onlyWhenPlaying: false, // make sure that it only plays when you're listening to music. So it won't play when you're sleeping.
notificationFired: (played) => {
console.log('Second notification %o', played);
},
timeout: 10, // If the events don't work (to see when it stops playing) or if you turned on a stream, it will revert back after this amount of seconds.
volume: 16, // Set the volume for the notification (and revert back afterwards)
delayMs: 100 // Pause between commands in ms, (when sonos fails to play notification often).
volume: 20, // Set the volume for the notification (and revert back afterwards)
delayMs: 700 // Pause between commands in ms, (when sonos fails to play notification often).
});
await sonos.PlayTTS({
text: 'Iemand aan de deur', // Text to speech input
timeout: 10, // If the events don't work (to see when it stops playing) or if you turned on a stream, it will revert back after this amount of seconds.
volume: 20, // Set the volume for the notification (and revert back afterwards)
delayMs: 700 // Pause between commands in ms, (when sonos fails to play notification often).
})
}, 500)
}, 1000)

sonos.PlayNotification({
trackUri: 'https://cdn.smartersoft-group.com/various/pull-bell-short.mp3', // Can be any uri sonos understands
// trackUri: 'https://cdn.smartersoft-group.com/various/someone-at-the-door.mp3', // Cached text-to-speech file.
onlyWhenPlaying: false, // make sure that it only plays when you're listening to music. So it won't play when you're sleeping.
timeout: 10, // If the events don't work (to see when it stops playing) or if you turned on a stream, it will revert back after this amount of seconds.
volume: 15, // Set the volume for the notification (and revert back afterwards)
delayMs: 100 // Pause between commands in ms, (when sonos fails to play notification often).
delayMs: 700 // Pause between commands in ms, (when sonos fails to play notification often).
})
.then(played => {
console.log('Played notification(s) %o', played)
sonos.CancelEvents();
setTimeout(() => {
process.exit(0)
}, 1000)
}, 5000)
})
.catch(console.error)

Expand Down
6 changes: 3 additions & 3 deletions examples/playback.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ const sonos = new SonosDevice(process.env.SONOS_HOST || '192.168.96.56')
// .catch(err => console.error(err))

// // sonos.AddUriToQueue('spotify:track:7dVjKRYCkszdHEHIBj9OMc')
// // .then(success => console.log(success))
// // .catch(err => console.error(err))
// // .then(success => console.log(success))
// // .catch(err => console.error(err))

// sonos.SetAVTransportURI('x-sonosapi-stream:station_KISNFM?sid=162')
// .then(success => {
// return sonos.Play()
// })
// .catch(console.error)

sonos.AVTransportService.Play({ InstanceID: 1, Speed: '4' })
sonos.AVTransportService.Play({ InstanceID: 0, Speed: '1' })
.catch(err => {
console.log('Sonos error', err)
})
Loading

0 comments on commit 25d4a6f

Please sign in to comment.