This module exports 4 items:
var sonos = require('sonos');
// sonos.search - searches for Sonos devices on network
sonos.search(function(device) {
// device is an instance of sonos.Sonos
device.currentTrack(console.log);
});
// var s = new sonos.Sonos(host, [port]);
var s = new sonos.Sonos('192.168.2.17')
s.currentTrack(console.log);
// sonos.Services - wrappers arounds all UPNP services provided by sonsos
// These aren't used internally by the module at all but may be useful
// for more complex projects.
// sonos.SpotifyRegion - map with service IDs for different Spotify regions
var s = new sonos.Sonos('192.168.2.17')
s.setSpotifyRegion(sonos.SpotifyRegion.EU);
// OR (US is default)
s.setSpotifyRegion(sonos.SpotifyRegion.US);
Sonos "Class"
- host String IP/DNS
- port Number undefined
UPnP HTTP Request
- endpoint String HTTP Path
- action String UPnP Call/Function/Action
- body String undefined
- responseTag String Expected Response Container XML Tag
- callback Function (err, data)
Void undefined
Get Music Library
- search String artists, albumArtists, albums, genres, composers, tracks, playlists, sonos_playlists, or share
- options Object Default {start:0, total:100}
- callback Function (err, data) data - {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]}
Void undefined
Get Current Track
- callback Function (err, track)
Void undefined
Get current playback state
- callback Function (err, state)
Void undefined
Parse DIDL into track structure
- didl String undefined
object undefined
Get Current Volume
- callback Function (err, volume)
Void undefined
Get Current Muted
- callback Function (err, muted)
Void undefined
Resumes Queue or adds provided url to queue and starts playing
- uri String Optional - URI to Audio Stream, also supports Spotify resource ids (see notes)
- callback Function (err, playing)
Void undefined
spotify:track:<id>
spotify:album:<id>
spotify:artistTopTracks:<id>
spotify:user:<userid>:playlist:<id>
Plays an uri without using the queue
- uri String Optional - URI to Audio Stream, also supports Spotify resource ids (see notes)
- callback Function (err, playing)
Void undefined
spotify:track:<id>
spotify:album:<id>
spotify:artistTopTracks:<id>
spotify:user:<userid>:playlist:<id>
Stop What's Playing
- callback Function (err, stopped)
Void undefined
Pause Current Queue
- callback Function (err, paused)
Void undefined
Seek the current track
- callback Function (err, seeked)
Void undefined
Select specific track in queue
- trackNr Number Number of track in queue (optional, indexed from 1)
- callback Function (err, seeked)
Void undefined
Play next in queue
- callback Function (err, movedToNext)
Void undefined
Play previous in queue
- callback Function (err, movedToPrevious)
Void undefined
Queue a Song Next
- uri String URI to Audio Stream, also supports Spotify resources ids (see play)
- callback Function (err, queued)
[type] undefined
Directly plays a TuneIn station (queue isn't used)
- stationId String tunein radio station id
- stationTitle String tunein radio station title
- callback Function (err, queued)
[type] undefined
Starts playing the artists radio (queue isn't used)
- artistId String Spotify Id to for artist (e.g.
spotify:artist:<id>
) - artistName String Name of artist to use for radio station name
- callback Function (err, queued)
[type] undefined
Add a song to the queue
- uri String URI to Audio Stream, also supports Spotify resource ids (see notes)
- positionInQueue Number Position in queue at which to add song (optional, indexed from 1, defaults to end of queue, 0 to explicitly set end of queue)
- callback Function (err, queued)
[type] undefined
spotify:track:<id>
spotify:album:<id>
spotify:artistTopTracks:<id>
spotify:user:<userid>:playlist:<id>
Get elements in queue
- callback Function (err, data)
[type] undefined
Flush queue
- callback Function (err, flushed)
Void undefined
Get the LED State
- callback Function (err, state) state is a string, "On" or "Off"
Set the LED State
- desiredState String "On"/"Off"
- callback Function (err)
Get Zone Info
- callback Function (err, info)
Get Zone Attributes
- callback Function (err, data)
Get Zones in contact with current Zone with Group Data
- callback Function (err, topology)
Get Information provided by /xml/device_description.xml
- callback Function (err, info)
Set Name
- name String undefined
- callback Function (err, data)
[type] undefined
Set Play Mode
- undefined String undefined
- callback Function (err, data)
[type] undefined
Set Volume
- volume String 0..100
- callback Function (err, data)
[type] undefined
Set Muted
- muted Boolean undefined
- callback Function (err, data)
[type] undefined
Get Favorites Radio Stations
- options Object Default {start:0, total:100}
- callback Function (err, data) data - {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]}
Void undefined
Get Favorites Radio Shows
- options Object Default {start:0, total:100}
- callback Function (err, data) data - {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]}
Void undefined
Get Favorites Radio for a given type
- favoriteRadioType String stations, shows
- options Object Default {start:0, total:100}
- callback Function (err, data) data - {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]}
Void undefined
Sets the Spotify Region
- region String region service id (US: 3079, EU: 2311)
Void undefined
Get an instance of the new AlarmClock service
AlarmClock
Search "Class" Emits 'DeviceAvailable' on a Sonos Component Discovery Listens on a random UDP port, or the specified port in options
- Optional Object with options - {port: {Number}}
Create a Search Instance (emits 'DeviceAvailable' with a found Sonos Component) Listens on a random UDP port, or the specified port in options
- Optional Object with options - {port: {Number}}
- Optional Function 'DeviceAvailable' listener (sonos)
{Search/EventEmitter Instance}
Stops searching and destroy the Search object
- callback Function ()
[type] undefined