From bca2399dfc426b7374c1982785aa41fb3a1de82c Mon Sep 17 00:00:00 2001 From: Stephan van Rooij <1292510+svrooij@users.noreply.github.com> Date: Wed, 29 Sep 2021 23:27:50 +0200 Subject: [PATCH 1/6] chore: Converted Device discovery to class --- examples/deviceDiscovery.js | 8 +-- lib/deviceDiscovery.js | 136 +++++++++++++++++++++--------------- 2 files changed, 83 insertions(+), 61 deletions(-) diff --git a/examples/deviceDiscovery.js b/examples/deviceDiscovery.js index 28443ffe..e17b1ec9 100644 --- a/examples/deviceDiscovery.js +++ b/examples/deviceDiscovery.js @@ -1,20 +1,20 @@ const Sonos = require('../') -console.log('Searching for Sonos devices for 5 seconds...') +console.log('Searching for Sonos devices for 10 seconds...') const discovery = new Sonos.AsyncDeviceDiscovery() -discovery.discover().then((device, model) => { +discovery.discover({ port: 50333, timeout: 10000 }).then((device, model) => { console.log('Found one sonos device %s getting all groups', device.host) return device.getAllGroups().then((groups) => { console.log('Groups %s', JSON.stringify(groups, null, 2)) return groups[0].CoordinatorDevice().togglePlayback() }) }).catch(e => { - console.warn(' Error in discovery %j', e) + console.warn(' Error in discovery %o', e) }) -// discovery.discoverMultiple({ timeout: 5000 }).then((devices) => { +// discovery.discoverMultiple({ port: 50333, timeout: 10000 }).then((devices) => { // console.log('Found %d sonos devices', devices.length) // devices.forEach(device => { // console.log('Device IP: %s', device.host) diff --git a/lib/deviceDiscovery.js b/lib/deviceDiscovery.js index 91e64de7..052ac0e2 100644 --- a/lib/deviceDiscovery.js +++ b/lib/deviceDiscovery.js @@ -7,79 +7,101 @@ */ const dgram = require('dgram') -const util = require('util') const EventEmitter = require('events').EventEmitter const Sonos = require('./sonos').Sonos +const PLAYER_SEARCH = Buffer.from(['M-SEARCH * HTTP/1.1', + 'HOST: 239.255.255.250:1900', + 'MAN: ssdp:discover', + 'MX: 1', + 'ST: urn:schemas-upnp-org:device:ZonePlayer:1'].join('\r\n')) + /** * Create a new instance of DeviceDiscovery * @class DeviceDiscovery * @emits 'DeviceAvailable' on a Sonos Component Discovery */ -const DeviceDiscovery = function DeviceDiscovery (options) { - const self = this - self.foundSonosDevices = {} - self.onTimeout = function () { - clearTimeout(self.pollTimer) - } - const PLAYER_SEARCH = Buffer.from(['M-SEARCH * HTTP/1.1', - 'HOST: 239.255.255.250:1900', - 'MAN: ssdp:discover', - 'MX: 1', - 'ST: urn:schemas-upnp-org:device:ZonePlayer:1'].join('\r\n')) - const sendDiscover = function () { - ['239.255.255.250', '255.255.255.255'].forEach(function (addr) { - self.socket.send(PLAYER_SEARCH, 0, PLAYER_SEARCH.length, 1900, addr) +class DeviceDiscovery extends EventEmitter { + constructor (options) { + super() + // this.options = options + this.foundSonosDevices = {} + this.socket = dgram.createSocket('udp4') + + this.socket.on('message', (buffer, rinfo) => { + const data = buffer.toString() + if (data.match(/.+Sonos.+/)) { + const modelCheck = data.match(/SERVER.*\((.*)\)/) + const model = (modelCheck.length > 1 ? modelCheck[1] : null) + const addr = rinfo.address + if (!(addr in this.foundSonosDevices)) { + const sonos = this.foundSonosDevices[addr] = new Sonos(addr) + this.emit('DeviceAvailable', sonos, model) + } + } + }) + + this.socket.on('close', () => { + if (this.searchTimer) { + clearTimeout(this.searchTimer) + } + clearTimeout(this.pollTimer) }) + + this.socket.on('error', (err) => { + this.emit('error', err) + }) + + this.socket.on('listening', () => { + console.log('UDP port %d opened for discovery', this.socket.address().port) + this.socket.setBroadcast(true) + this.sendDiscover() + }) + + this.socket.bind(options.port) + + if (options.timeout) { + this.searchTimer = setTimeout(() => { + this.socket.close() + this.emit('timeout') + }, options.timeout) + } + } + + onTimeout () { + clearTimeout(this.pollTimer) + } + + sendDiscover () { + this.sendDiscoveryOnAddress('239.255.255.250') + this.sendDiscoveryOnAddress('255.255.255.255') + // Periodically send discover packet to find newly added devices - self.pollTimer = setTimeout(sendDiscover, 10000) + this.pollTimer = setTimeout(() => { + this.sendDiscover() + }, 10000) // Remove the on timeout listener and add back in every iteration - self.removeListener('timeout', self.onTimeout) - self.on('timeout', self.onTimeout) + this.removeListener('timeout', this.onTimeout) + this.on('timeout', this.onTimeout) } - this.socket = dgram.createSocket('udp4', function (buffer, rinfo) { - buffer = buffer.toString() - if (buffer.match(/.+Sonos.+/)) { - const modelCheck = buffer.match(/SERVER.*\((.*)\)/) - const model = (modelCheck.length > 1 ? modelCheck[1] : null) - const addr = rinfo.address - if (!(addr in self.foundSonosDevices)) { - const sonos = self.foundSonosDevices[addr] = new Sonos(addr) - self.emit('DeviceAvailable', sonos, model) + + sendDiscoveryOnAddress (address) { + this.socket.send(PLAYER_SEARCH, 0, PLAYER_SEARCH.length, 1900, address, (err, bytes) => { + if (err) { + console.error(err) } + }) + } + + destroy () { + if (this.searchTimer) { + clearTimeout(this.searchTimer) } - }) - this.socket.on('close', function () { - if (self.searchTimer) { - clearTimeout(self.searchTimer) + if (this.pollTimer) { + clearTimeout(this.pollTimer) } - clearTimeout(self.pollTimer) - }) - this.socket.on('error', function (err) { - self.emit('error', err) - }) - this.socket.bind(options, function () { - self.socket.setBroadcast(true) - sendDiscover() - }) - if (options.timeout) { - self.searchTimer = setTimeout(function () { - self.socket.close() - self.emit('timeout') - }, options.timeout) + this.socket.close() } - return this -} -util.inherits(DeviceDiscovery, EventEmitter) - -/** - * Destroys DeviceDiscovery class, stop searching, clean up - * @param {Function} callback () - */ -DeviceDiscovery.prototype.destroy = function (callback) { - clearTimeout(this.searchTimer) - clearTimeout(this.pollTimer) - this.socket.close(callback) } /** From ba3da910920fe0288e05c405c793e4468d9d2929 Mon Sep 17 00:00:00 2001 From: Stephan van Rooij <1292510+svrooij@users.noreply.github.com> Date: Thu, 30 Sep 2021 00:39:24 +0200 Subject: [PATCH 2/6] wip: Generating types from existing library --- .generator/node/all-services.hbs | 9 +- .generator/node/service.hbs | 9 +- lib/events/adv-listener.js | 4 +- lib/helpers.js | 7 +- lib/services/AVTransport.js | 26 +++--- lib/services/AlarmClock.js | 28 +++--- lib/services/RenderingControl.js | 9 +- lib/services/ZoneGroupTopology.js | 2 +- lib/sonos.js | 137 +++++++++++++++--------------- package-lock.json | 35 +++++++- package.json | 12 ++- tsconfig.json | 24 ++++++ 12 files changed, 189 insertions(+), 113 deletions(-) create mode 100644 tsconfig.json diff --git a/.generator/node/all-services.hbs b/.generator/node/all-services.hbs index 18671020..c0422662 100644 --- a/.generator/node/all-services.hbs +++ b/.generator/node/all-services.hbs @@ -12,16 +12,21 @@ const {{serviceName}} = require('./{{#if data.filename}}{{data.filename}}{{else} * @class AllServices */ class AllServices { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ constructor (host, port) { this.host = host - this.port = port + this.port = port || 1400 } {{#each services}} /** * Get instance of {{name}} service * - * @returns {{serviceName}} + * @returns { {{~ serviceName ~}} } */ {{serviceName}} () { if (!this.{{lower serviceName}}) { diff --git a/.generator/node/service.hbs b/.generator/node/service.hbs index 88f13ed5..6d3871da 100644 --- a/.generator/node/service.hbs +++ b/.generator/node/service.hbs @@ -13,6 +13,11 @@ const Service = require('./Service') * @extends {Service} */ class {{serviceName}} extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ constructor (host, port) { super() this.name = '{{name}}' @@ -38,7 +43,9 @@ class {{serviceName}} extends Service { * @remarks {{{remarks}}} {{/if}} {{#if outputs}} - * @returns {Object} response object, with these properties {{#each outputs}}'{{name}}'{{#unless @last}}, {{/unless}}{{/each}} + * @returns {Promise} response object, with these properties {{#each outputs}}`{{name}}`{{#unless @last}}, {{/unless}}{{/each}} + {{else}} + * @returns {Promise} request succeeded {{/if}} */ {{#if inputs}} diff --git a/lib/events/adv-listener.js b/lib/events/adv-listener.js index dbe5fa6a..a05a9e12 100644 --- a/lib/events/adv-listener.js +++ b/lib/events/adv-listener.js @@ -38,7 +38,7 @@ class SonosListener extends EventEmitter { */ constructor () { super() - this.port = parseInt(process.env.SONOS_LISTENER_PORT || 4000) + this.port = parseInt(process.env.SONOS_LISTENER_PORT || '4000') this._listening = false this._deviceSubscriptions = [] @@ -339,7 +339,7 @@ class DeviceSubscription { /** * Convert the Timeout header to datetime (legacy code...) - * @param {String} timeout TimeOut header + * @param {String | Number} timeout TimeOut header */ headerToDateTime (timeout) { let seconds diff --git a/lib/helpers.js b/lib/helpers.js index 5aadeab2..6df1fd32 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -274,9 +274,10 @@ Helpers.GenerateMetadata = function (uri, title = '', region = '3079') { /** * Parse DIDL into track structure - * @param {String} didl - * @param {String} host host ip - * @param {Number} port port numer + * @param {String} didl + * @param {String} host host ip + * @param {Number} port port numer + * @param {String} trackUri Track Uri * @return {object} */ Helpers.ParseDIDL = function (didl, host, port, trackUri) { diff --git a/lib/services/AVTransport.js b/lib/services/AVTransport.js index aa686b92..b1ecec12 100644 --- a/lib/services/AVTransport.js +++ b/lib/services/AVTransport.js @@ -31,7 +31,7 @@ class AVTransport extends Service { * @param {number} options.InstanceID The instance you want to control is always `0` * @param {string} options.CurrentURI The new URI you wish to set. * @param {string} options.CurrentURIMetaData The metadata of the uri you wish to set. - * @returns {Object} Parsed response data. + * @returns {Promise} Parsed response data. */ async SetAVTransportURI (options) { return this._request('SetAVTransportURI', options) } @@ -39,11 +39,11 @@ class AVTransport extends Service { * Add an URI to the queue * @param {object} options The the required properties * @param {number} options.InstanceID The instance you want to control is always `0` - * @param {number} options.EnqueuedURI The URI of the track you want to add - * @param {number} options.EnqueuedURIMetaData The Metadata of the track you wish to add, see `Helpers.GenerateMetadata` + * @param {string} options.EnqueuedURI The URI of the track you want to add + * @param {string} options.EnqueuedURIMetaData The Metadata of the track you wish to add, see `Helpers.GenerateMetadata` * @param {number} options.DesiredFirstTrackNumberEnqueued The position in the queue * @param {number} options.EnqueueAsNext To Queue this item as the next item set to `1` - * @returns {Object} Parsed response data. + * @returns {Promise} Parsed response data. */ async AddURIToQueue (options) { return this._request('AddURIToQueue', options) } @@ -59,7 +59,7 @@ class AVTransport extends Service { * @param {number} options.StartingIndex The index of the first song you want to move. * @param {number} options.NumberOfTracks How many tracks do you want to move? * @param {number} options.InsertBefore Where should these tracks be inserted? - * @returns {Object} Parsed response data. + * @returns {Promise} Parsed response data. */ async ReorderTracksInQueue (options) { return this._request('ReorderTracksInQueue', options) } @@ -71,7 +71,7 @@ class AVTransport extends Service { * @param {number} options.InstanceID The instance you want to control is always `0` * @param {string} options.ObjectID The object to remove * @param {string} options.UpdateID The update id, not a clue what this means. Just specify `0` - * @returns {Object} Parsed response data. + * @returns {Promise} Parsed response data. */ async RemoveTrackFromQueue (options) { return this._request('RemoveTrackFromQueue', options) } @@ -82,7 +82,7 @@ class AVTransport extends Service { * @param {number} options.UpdateID The update id, not a clue what this means. Just specify `0` * @param {number} options.StartingIndex Index of the first song to remove * @param {number} options.NumberOfTracks How many tracks to remove - * @returns {Object} Parsed response data. + * @returns {Promise} Parsed response data. */ async RemoveTrackRangeFromQueue (options) { return this._request('RemoveTrackRangeFromQueue', options) } @@ -122,8 +122,8 @@ class AVTransport extends Service { * Skip to other track or time * @param {object} options Object with required options * @param {number} options.InstanceID The instance you want to control is always `0` - * @param {number} options.Unit One of these `TRACK_NR`, `REL_TIME`, `TIME_DELTA` - * @param {number} options.Target Skip to what track number, relative time as hh:mm:ss, or ? + * @param {'TRACK_NR' | 'REL_TIME' | 'TIME_DELTA'} options.Unit One of these `TRACK_NR`, `REL_TIME`, `TIME_DELTA` + * @param {string | number} options.Target Skip to what track number, relative time as hh:mm:ss, or track number */ async Seek (options) { return this._request('Seek', options) } @@ -140,7 +140,7 @@ class AVTransport extends Service { /** * Set the new playmode * @param {string} playmode One of the following `NORMAL` `REPEAT_ALL` `SHUFFLE` `SHUFFLE_NOREPEAT` - * @returns {Object} Parsed response data. + * @returns {Promise} Parsed response data. */ async SetPlayMode (playmode) { return this._request('SetPlayMode', { InstanceID: 0, NewPlayMode: playmode }) } @@ -161,7 +161,7 @@ class AVTransport extends Service { /** * Configure a sleeptimer. * @param {string} duration the duration as 'ISO8601Time', needs sample! - * @returns {Object} Parsed response data. + * @returns {Promise} Parsed response data. */ async ConfigureSleepTimer (duration) { return this._request('ConfigureSleepTimer', { InstanceID: 0, NewSleepTimerDuration: duration }) } @@ -176,13 +176,13 @@ class AVTransport extends Service { /** * Snooze the current running alarm for a number of minutes. * @param {string} duration The duration, as 'ISO8601Time', needs sample! - * @returns {Object} Parsed response data. + * @returns {Promise} Parsed response data. */ async SnoozeAlarm (duration) { return this._request('SnoozeAlarm', { InstanceID: 0, Duration: duration }) } /** * Get information about the current track, parsed version of `GetPositionInfo()` - * @returns {Object} The current playing track + * @returns {Promise} The current playing track */ async CurrentTrack () { return this.GetPositionInfo() diff --git a/lib/services/AlarmClock.js b/lib/services/AlarmClock.js index 5b9c5ea1..b704140b 100644 --- a/lib/services/AlarmClock.js +++ b/lib/services/AlarmClock.js @@ -37,7 +37,7 @@ class AlarmClock extends Service { * @param {String} options.PlayMode The playmode ['??','SHUFFLE'] * @param {String} options.Volume What should the volume be * @param {String} options.IncludeLinkedZones Should linked zones be included? ['0', '1'] - * @returns {Object} parsed response object + * @returns {Promise} parsed response object */ async CreateAlarm (options) { // Encode 2 params (they are required anyway, so no checking) @@ -49,7 +49,7 @@ class AlarmClock extends Service { /** * Delete an alarm * @param {String} id the id of the alarm you want to delete - * @returns {Object} parsed response object + * @returns {Promise} parsed response object */ async DestroyAlarm (id) { return this._request('DestroyAlarm', { ID: id.toString() }) @@ -75,7 +75,7 @@ class AlarmClock extends Service { * Enable/disable an alarm * @param {String} id the id of the alarm you want to set * @param {Boolean} enabled Should the alarm be enabled or not - * @returns {Object} parsed response object + * @returns {Promise} parsed response object */ async SetAlarm (id, enabled) { return this.PatchAlarm(id, { Enabled: (enabled ? '1' : '0') }) @@ -85,17 +85,17 @@ class AlarmClock extends Service { * Update only some properties of an Alarm * @param {String} id the id of the alarm you want to update * @param {Object} [options] An object with the settings you wish to update - * @param {String} options.StartLocalTime Time string when you want the alarm to sound. - * @param {String} options.Duration How many minutes should the alarm sound. - * @param {String} options.Recurrance What should the recurrence be ['DAILY','ONCE','WEEKDAYS'] - * @param {String} options.Enabled Should the alarm be enabled ['1','0'] - * @param {String} options.RoomUUID The UUID of the room `RINCON_xxxxxxxxxxxx01400` - * @param {String} options.ProgramURI The programUri you want, this is the difficult part. `x-rincon-buzzer:0` for ringer - * @param {String} options.ProgramMetaData The metadata for the programURI, this is the hard part. - * @param {String} options.PlayMode The playmode ['??','SHUFFLE'] - * @param {String} options.Volume What should the volume be - * @param {String} options.IncludeLinkedZones Should linked zones be included? ['0', '1'] - * @returns {Object} parsed response object + * @param {String?} options.StartLocalTime Time string when you want the alarm to sound. + * @param {String?} options.Duration How many minutes should the alarm sound. + * @param {String?} options.Recurrance What should the recurrence be ['DAILY','ONCE','WEEKDAYS'] + * @param {String?} options.Enabled Should the alarm be enabled ['1','0'] + * @param {String?} options.RoomUUID The UUID of the room `RINCON_xxxxxxxxxxxx01400` + * @param {String?} options.ProgramURI The programUri you want, this is the difficult part. `x-rincon-buzzer:0` for ringer + * @param {String?} options.ProgramMetaData The metadata for the programURI, this is the hard part. + * @param {String?} options.PlayMode The playmode ['??','SHUFFLE'] + * @param {String?} options.Volume What should the volume be + * @param {String?} options.IncludeLinkedZones Should linked zones be included? ['0', '1'] + * @returns {Promise} parsed response object */ async PatchAlarm (id, options) { this.debug('AlarmClock.PatchAlarm(%j %j)', id, options) diff --git a/lib/services/RenderingControl.js b/lib/services/RenderingControl.js index 7f3f3fd3..146418e4 100644 --- a/lib/services/RenderingControl.js +++ b/lib/services/RenderingControl.js @@ -79,7 +79,7 @@ class RenderingControl extends Service { /** * Get loudness value of a speaker. - * @param {string} channel What channel do you want to check? `Master` is default + * @param {string} Channel What channel do you want to check? `Master` is default */ async GetLoudness (Channel = 'Master') { return this._request('GetLoudness', { @@ -91,7 +91,7 @@ class RenderingControl extends Service { /** * (Un)set loudness of a speaker. * @param {boolean} loudness Should it be with or without loudness? - * @param {string} channel The channel you want to set. `Master` is default + * @param {string} Channel The channel you want to set. `Master` is default */ async SetLoudness (loudness, Channel = 'Master') { return this._request('SetLoudness', { @@ -112,7 +112,7 @@ class RenderingControl extends Service { /** * Set bass of a speaker. - * @param {integer} bass desired level of bass, range from -10 to +10 + * @param {Number} bass desired level of bass, range from -10 to +10 */ async SetBass (bass) { return this._request('SetBass', { @@ -132,7 +132,7 @@ class RenderingControl extends Service { /** * Set treble of a speaker. - * @param {integer} treble desired level of treble, range from -10 to +10 + * @param {Number} treble desired level of treble, range from -10 to +10 */ async SetTreble (treble) { return this._request('SetTreble', { @@ -143,7 +143,6 @@ class RenderingControl extends Service { /** * Get room calibration status, response payload is { RoomCalibrationEnabled, RoomCalibrationAvailable } - * @param {string} channel What channel do you want to check? `Master` is default. */ async GetRoomCalibrationStatus () { return this._request('GetRoomCalibrationStatus', { diff --git a/lib/services/ZoneGroupTopology.js b/lib/services/ZoneGroupTopology.js index c1ffa79f..53efce71 100644 --- a/lib/services/ZoneGroupTopology.js +++ b/lib/services/ZoneGroupTopology.js @@ -41,7 +41,7 @@ class ZoneGroupTopology extends Service { /** * Get all the information about the ZoneGroups - * @returns {Object} Object with one property, 'ZoneGroupState' + * @returns {Promise} Object with one property, 'ZoneGroupState' */ async GetZoneGroupState () { return this._request('GetZoneGroupState', {}) } diff --git a/lib/sonos.js b/lib/sonos.js index 3e9ae8f8..f7b0027d 100644 --- a/lib/sonos.js +++ b/lib/sonos.js @@ -48,7 +48,8 @@ const playmodes = ['NORMAL', 'REPEAT_ONE', 'REPEAT_ALL', 'SHUFFLE', 'SHUFFLE_NOR /** * Utility function which resolves a promise on an event - * @param {String} eventName + * @param {EventEmitter} eventEmitter EventEmitter to subscribe for an event once + * @param {String} eventName Event to subscribe to */ function asyncOnce (eventEmitter, eventName) { return new Promise((resolve, reject) => { @@ -62,7 +63,7 @@ function asyncOnce (eventEmitter, eventName) { * Create an instance of Sonos * @class Sonos * @param {String} host IP/DNS - * @param {Number} port + * @param {Number} port port, defaults to `1400` * @returns {Sonos} */ class Sonos extends EventEmitter { @@ -90,6 +91,11 @@ class Sonos extends EventEmitter { }) } this.on('newListener', implicitListen) + + this._isSubscribed = undefined + this._state = undefined + this._mute = undefined + this._volume = undefined // Maybe stop the eventListener once last listener is removed? } @@ -97,7 +103,7 @@ class Sonos extends EventEmitter { * Get Music Library Information * @param {String} searchType Choice - artists, albumArtists, albums, genres, composers, tracks, playlists, share * @param {Object} options Optional - default {start: 0, total: 100} - * @returns {Object} {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]} + * @returns {Promise} {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]} */ async getMusicLibrary (searchType, options) { return this.searchMusicLibrary(searchType, null, options) @@ -109,7 +115,7 @@ class Sonos extends EventEmitter { * @param {String} searchTerm Optional - search term to search for * @param {Object} requestOptions Optional - default {start: 0, total: 100} * @param {String} separator Optional - default is colon. `:` or `/` - * @returns {Object} {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]} + * @returns {Promise} {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]} */ async searchMusicLibrary (searchType, searchTerm, requestOptions = {}, separator = ':') { const searchTypes = { @@ -150,7 +156,7 @@ class Sonos extends EventEmitter { * Get Sonos Playlist * @param {String} playlistId Sonos id of the playlist * @param {Object} requestOptions Optional - default {start: 0, total: 100} - * @returns {Object} {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]} + * @returns {Promise} {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]} */ async getPlaylist (playlistId, requestOptions = {}) { return this.searchMusicLibrary('sonos_playlists', playlistId, requestOptions) @@ -159,7 +165,7 @@ class Sonos extends EventEmitter { /** * Create a new sonos playlist * @param {String} title Name of the playlist - * @returns {Object} { NumTracksAdded: 0, NewQueueLength: 0, NewUpdateID: 0, AssignedObjectID: 'SQ:3' } + * @returns {Promise} { NumTracksAdded: 0, NewQueueLength: 0, NewUpdateID: 0, AssignedObjectID: 'SQ:3' } */ async createPlaylist (title) { debug('Sonos.createPlaylist(%j)', title) @@ -182,8 +188,8 @@ class Sonos extends EventEmitter { /** * Delete sonos playlist - * @param {Number} objectId Sonos id of the playlist - * @returns {Boolean} Playlist deleted + * @param {Number} playlistId Sonos id of the playlist + * @returns {Promise} Playlist deleted */ async deletePlaylist (playlistId) { debug('Sonos.deletePlaylist()') @@ -192,9 +198,9 @@ class Sonos extends EventEmitter { /** * Add uri to sonos playlist - * @param {Number} playlistId Sonos id of the playlist + * @param {String} playlistId Sonos id of the playlist * @param {String} uri Uri to add to the playlist - * @returns {Object} { NumTracksAdded: 1, NewQueueLength: 2, NewUpdateID: 2 } + * @returns {Promise} { NumTracksAdded: 1, NewQueueLength: 2, NewUpdateID: 2 } */ async addToPlaylist (playlistId, uri) { debug('Sonos.addToPlaylist(%j, %j)', playlistId, uri) @@ -226,9 +232,9 @@ class Sonos extends EventEmitter { /** * Remove track from playlist - * @param {Number} playlistId Sonos id of the playlist + * @param {String} playlistId Sonos id of the playlist * @param {String} index Index of song to remove - * @returns {Object} { QueueLengthChange: -1, NewQueueLength: 2, NewUpdateID: 2 } + * @returns {Promise} { QueueLengthChange: -1, NewQueueLength: 2, NewUpdateID: 2 } */ async removeFromPlaylist (playlistId, index) { debug('Sonos.removeFromPlaylist(%j, %j)', playlistId, index) @@ -257,7 +263,7 @@ class Sonos extends EventEmitter { /** * Get Sonos Favorites - * @returns {Object} {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]} + * @returns {Promise} {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]} */ async getFavorites () { const options = { @@ -274,7 +280,7 @@ class Sonos extends EventEmitter { /** * Get Current Track - * @returns {Object} All the info of the current track + * @returns {Promise} All the info of the current track */ async currentTrack () { debug('Sonos.currentTrack()') @@ -283,7 +289,7 @@ class Sonos extends EventEmitter { /** * Get Current Volume - * @returns {Number} The current volume + * @returns {Promise} The current volume */ async getVolume () { debug('Sonos.getVolume()') @@ -293,7 +299,7 @@ class Sonos extends EventEmitter { /** * Get Current Muted - * @returns {Boolean} + * @returns {Promise} */ async getMuted () { debug('Sonos.getMuted()') @@ -304,7 +310,7 @@ class Sonos extends EventEmitter { /** * Resumes Queue or Plays Provided URI * @param {String|Object} options Optional - URI to a Audio Stream or Object with play options - * @returns {Boolean} Started playing? + * @returns {Promise} Started playing? */ async play (options) { debug('Sonos.play(%j)', options) @@ -323,13 +329,13 @@ class Sonos extends EventEmitter { /** * Plays a uri directly (the queue stays the same) * @param {String|Object} options URI to a Audio Stream or Object with play options see `Helpers.GenerateMetadata` - * @returns {Boolean} + * @returns {Promise} */ async setAVTransportURI (options) { debug('Sonos.setAVTransportURI(%j)', options) if (typeof options !== 'string' && typeof options !== 'object') { - return new Error('Options should be an object or a string') + throw new Error('Options should be an object or a string') } // If the options is a string try to generate metadata from it @@ -351,13 +357,13 @@ class Sonos extends EventEmitter { return true }) } else { - return new Error('Error with uri') + throw new Error('Error with uri') } } /** * Stop What's Playing - * @returns {boolean} + * @returns {Promise} */ async stop () { debug('Sonos.stop()') @@ -397,7 +403,7 @@ class Sonos extends EventEmitter { /** * Become Coordinator of Standalone Group - * @returns {boolean} + * @returns {Promise} */ async becomeCoordinatorOfStandaloneGroup () { debug('Sonos.becomeCoordinatorOfStandaloneGroup()') @@ -406,7 +412,7 @@ class Sonos extends EventEmitter { /** * Leave the group (shortcut to becomeCoordinatorOfStandaloneGroup) - * @returns {boolean} + * @returns {Promise} */ async leaveGroup () { return this.becomeCoordinatorOfStandaloneGroup() @@ -415,7 +421,7 @@ class Sonos extends EventEmitter { /** * Join an other device by name * @param {String} otherDeviceName The name of de device you want to join, doesn't matter if that isn't the coordinator - * @returns {Boolean} + * @returns {Promise} */ async joinGroup (otherDeviceName) { debug('Sonos.joinGroup(%j)', otherDeviceName) @@ -427,7 +433,7 @@ class Sonos extends EventEmitter { member.ZoneName.toLowerCase() === otherDeviceName.toLowerCase())) if (!groupToJoin) { - return new Error(`Device with name ${otherDeviceName} isn't found`) + throw new Error(`Device with name ${otherDeviceName} isn't found`) } else { debug('Found coordinator %s', groupToJoin.Coordinator) return this.setAVTransportURI({ uri: `x-rincon:${groupToJoin.Coordinator}`, onlySetUri: true }) @@ -437,7 +443,7 @@ class Sonos extends EventEmitter { /** * Pause Current Queue - * @returns {Boolean} + * @returns {Promise} */ async pause () { debug('Sonos.pause()') @@ -447,27 +453,24 @@ class Sonos extends EventEmitter { /** * Seek in the current track * @param {Number} seconds jump to x seconds. - * @returns {Boolean} + * @returns {Promise} */ async seek (seconds) { debug('Sonos.seek()') - let hh = Math.floor(seconds / 3600) - let mm = Math.floor((seconds - (hh * 3600)) / 60) - let ss = seconds - ((hh * 3600) + (mm * 60)) - if (hh < 10) hh = '0' + hh - if (mm < 10) mm = '0' + mm - if (ss < 10) ss = '0' + ss + const hh = Math.floor(seconds / 3600) + const mm = Math.floor((seconds - (hh * 3600)) / 60) + const ss = seconds - ((hh * 3600) + (mm * 60)) return this.avTransportService().Seek({ InstanceID: 0, Unit: 'REL_TIME', - Target: hh + ':' + mm + ':' + ss + Target: hh.toString().padStart(2, '0') + ':' + mm.toString().padStart(2, '0') + ':' + ss.toString().padStart(2, '0') }).then(result => { return true }) } /** * Select specific track in queue * @param {Number} trackNr Number of track in queue (optional, indexed from 1) - * @returns {Boolean} + * @returns {Promise} */ async selectTrack (trackNr) { debug('Sonos.selectTrack(%j)', trackNr) @@ -480,7 +483,7 @@ class Sonos extends EventEmitter { /** * Play next in queue - * @returns {Boolean} + * @returns {Promise} */ async next () { debug('Sonos.next()') @@ -489,7 +492,7 @@ class Sonos extends EventEmitter { /** * Play previous in queue - * @returns {Boolean} + * @returns {Promise} */ async previous () { debug('Sonos.previous()') @@ -498,7 +501,7 @@ class Sonos extends EventEmitter { /** * Select Queue. Mostly required after turning on the speakers otherwise play, setPlaymode and other commands will fail. - * @returns {Boolean} success + * @returns {Promise} success */ async selectQueue () { debug('Sonos.selectQueue()') @@ -512,7 +515,7 @@ class Sonos extends EventEmitter { /** * Plays tunein based on radio station id * @param {String} stationId tunein radio station id - * @returns {Boolean} + * @returns {Promise} */ async playTuneinRadio (stationId, stationTitle) { debug('Sonos.playTuneinRadio(%j, %j)', stationId, stationTitle) @@ -524,7 +527,7 @@ class Sonos extends EventEmitter { /** * Plays Spotify radio based on artist uri * @param {String} artistId Spotify artist id - * @returns {Boolean} + * @returns {Promise} */ async playSpotifyRadio (artistId, artistName) { debug('Sonos.playSpotifyRadio(%j, %j)', artistId, artistName) @@ -537,7 +540,7 @@ class Sonos extends EventEmitter { * @param {String|Object} options Uri with audio stream of object with `uri` and `metadata` * @param {Number} positionInQueue Position in queue at which to add song (optional, indexed from 1, * defaults to end of queue, 0 to explicitly set end of queue) - * @returns {Object} Some info about the last queued file. + * @returns {Promise} Some info about the last queued file. */ async queue (options, positionInQueue = 0) { debug('Sonos.queue(%j, %j)', options, positionInQueue) @@ -568,7 +571,7 @@ class Sonos extends EventEmitter { /** * Flush queue - * @returns {Object} + * @returns {Promise} */ async flush () { debug('Sonos.flush()') @@ -577,7 +580,7 @@ class Sonos extends EventEmitter { /** * Get the LED State - * @returns {String} state is a string, "On" or "Off" + * @returns {Promise} state is a string, "On" or "Off" */ async getLEDState () { debug('Sonos.getLEDState()') @@ -587,7 +590,7 @@ class Sonos extends EventEmitter { /** * Set the LED State * @param {String} newState "On"/"Off" - * @returns {Boolean} + * @returns {Promise} */ async setLEDState (newState) { debug('Sonos.setLEDState(%j)', newState) @@ -596,7 +599,7 @@ class Sonos extends EventEmitter { /** * Get Zone Info - * @returns {Object} + * @returns {Promise} */ async getZoneInfo () { debug('Sonos.getZoneInfo()') @@ -605,7 +608,7 @@ class Sonos extends EventEmitter { /** * Get Zone Attributes - * @returns {Object} + * @returns {Promise} */ async getZoneAttrs () { debug('Sonos.getZoneAttrs()') @@ -614,7 +617,7 @@ class Sonos extends EventEmitter { /** * Get Information provided by /xml/device_description.xml - * @returns {Object} + * @returns {Promise} */ async deviceDescription () { debug('Sonos.deviceDescription()') @@ -630,7 +633,7 @@ class Sonos extends EventEmitter { /** * Set Name * @param {String} name - * @returns {Object} + * @returns {Promise} */ async setName (name) { debug('Sonos.setName(%j)', name) @@ -644,7 +647,7 @@ class Sonos extends EventEmitter { /** * Get the CurrentZoneName - * @returns {String} + * @returns {Promise} */ async getName () { debug('Sonos.getName()') @@ -655,7 +658,7 @@ class Sonos extends EventEmitter { /** * Get Play Mode - * @returns {String} + * @returns {Promise} */ async getPlayMode () { debug('Sonos.getPlayMode()') @@ -668,7 +671,7 @@ class Sonos extends EventEmitter { /** * Set Play Mode * @param {String} playmode - * @returns {Object} + * @returns {Promise} */ async setPlayMode (playmode) { debug('Sonos.setPlayMode(%j)', playmode) @@ -681,7 +684,7 @@ class Sonos extends EventEmitter { * Set Volume * @param {number} volume 0..100 * @param {string} channel What channel to change, `Master` is default. - * @returns {Object} + * @returns {Promise} */ async setVolume (volume, channel = 'Master') { debug('Sonos.setVolume(%j)', volume) @@ -701,7 +704,7 @@ class Sonos extends EventEmitter { /** * Configure Sleep Timer * @param {String} sleepTimerDuration - * @returns {Object} + * @returns {Promise} */ async configureSleepTimer (sleepTimerDuration) { debug('Sonos.sleepTimerDuration(%j)', sleepTimerDuration) @@ -712,7 +715,7 @@ class Sonos extends EventEmitter { * Set Muted * @param {Boolean} muted * @param {string} channel What channel to change, `Master` is default. - * @returns {Object} + * @returns {Promise} */ async setMuted (muted, channel = 'Master') { debug('Sonos.setMuted(%j)', muted) @@ -753,7 +756,7 @@ class Sonos extends EventEmitter { /** * Get Zones in contact with current Zone with Group Data * @deprecated Doesn't work if you upgraded your system to Sonos v9.1 - * @returns {Object} + * @returns {Promise} */ async getTopology () { debug('Sonos.getTopology()') @@ -794,7 +797,7 @@ class Sonos extends EventEmitter { /** * Get Current Playback State - * @returns {String} the current playback state + * @returns {Promise} the current playback state */ async getCurrentState () { debug('Sonos.currentState()') @@ -807,7 +810,7 @@ class Sonos extends EventEmitter { /** * Toggle the current playback, like the button. Currently only works for state `playing` or `paused` - * @returns {Boolean} + * @returns {Promise} */ async togglePlayback () { debug('Sonos.togglePlayback()') @@ -827,7 +830,7 @@ class Sonos extends EventEmitter { /** * Get Favorites Radio Stations * @param {Object} options Optional - default {start: 0, total: 100} - * @returns {Object} {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]} + * @returns {Promise} {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]} */ async getFavoritesRadioStations (options) { return this.getFavoritesRadio('stations', options) @@ -836,7 +839,7 @@ class Sonos extends EventEmitter { /** * Get Favorites Radio Shows * @param {Object} options Optional - default {start: 0, total: 100} - * @returns {Object} {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]} + * @returns {Promise} {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]} */ async getFavoritesRadioShows (options) { return this.getFavoritesRadio('shows', options) @@ -845,8 +848,8 @@ class Sonos extends EventEmitter { /** * Get Favorites Radio for a given radio type * @param {String} favoriteRadioType Choice - stations, shows - * @param {Object} options Optional - default {start: 0, total: 100} - * @returns {Object} {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]} + * @param {Object} requestOptions Optional - default {start: 0, total: 100} + * @returns {Promise} {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]} */ async getFavoritesRadio (favoriteRadioType, requestOptions = {}) { const radioTypes = { @@ -875,7 +878,7 @@ class Sonos extends EventEmitter { /** * Get the current queue - * @returns {Object} {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]} + * @returns {Promise} {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]} */ async getQueue () { const options = { @@ -891,12 +894,12 @@ class Sonos extends EventEmitter { /** * Play uri and restore last state - * @param {String|Object} options URI to a Audio Stream or Object with play options see `Helpers.GenerateMetadata` + * @param {Object} options URI to a Audio Stream or Object with play options see `Helpers.GenerateMetadata` * @param {String} options.uri The URI of the stream * @param {String} options.metadata The metadata of the stream see `Helpers.GenerateMetadata` * @param {Boolean} options.onlyWhenPlaying Only play this notification on players currently 'playing' * @param {Number} options.volume The volume used for the notification. - * @returns {Boolean} Did the notification play? Only returns when finished reverting to old play settings. + * @returns {Promise} Did the notification play? Only returns when finished reverting to old play settings. */ async playNotification (options) { debug('sonos.playNotification(%j)', options) @@ -964,7 +967,7 @@ class Sonos extends EventEmitter { * @param {number} numberOfTracks How many tracks do we want to move * @param {number} insertBefore Index of place where the tracks should be moved to * @param {number} updateId Not sure what this means, just leave it at `0` - * @returns {Boolean} + * @returns {Promise} */ async reorderTracksInQueue (startingIndex, numberOfTracks, insertBefore, updateId = 0) { return this.avTransportService().ReorderTracksInQueue({ @@ -978,7 +981,7 @@ class Sonos extends EventEmitter { /** * Get SpotifyConnect info, will error when no premium account is present - * @returns {Object} + * @returns {Promise} */ async getSpotifyConnectInfo () { const uri = `http://${this.host}:${this.port}/spotifyzc?action=getInfo` @@ -989,7 +992,7 @@ class Sonos extends EventEmitter { /** * Get device spicific ZPInfo, will return empty object if failed for some reason * This is useful for extracting the HouseholdControlID, Mac Address, serial number etc - * @returns {Object} + * @returns {Promise} */ async getZPInfo () { try { diff --git a/package-lock.json b/package-lock.json index 7892cd88..df048a8a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,10 +16,12 @@ }, "devDependencies": { "@bencevans/jsdox": "0.4.11", + "@types/node": "^16.10.2", "mocha": "^8.3.2", "nock": "^13.0.11", "pre-commit": "1.2.2", - "standard": "^16.0.3" + "standard": "^16.0.3", + "typescript": "^4.4.3" } }, "node_modules/@babel/code-frame": { @@ -119,6 +121,12 @@ "integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=", "dev": true }, + "node_modules/@types/node": { + "version": "16.10.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.10.2.tgz", + "integrity": "sha512-zCclL4/rx+W5SQTzFs9wyvvyCwoK9QtBpratqz2IYJ3O8Umrn0m3nsTv0wQBk9sRGpvUe9CwPDrQFB10f1FIjQ==", + "dev": true + }, "node_modules/@ungap/promise-all-settled": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", @@ -3548,6 +3556,19 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, + "node_modules/typescript": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.3.tgz", + "integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "node_modules/uc.micro": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", @@ -4019,6 +4040,12 @@ "integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=", "dev": true }, + "@types/node": { + "version": "16.10.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.10.2.tgz", + "integrity": "sha512-zCclL4/rx+W5SQTzFs9wyvvyCwoK9QtBpratqz2IYJ3O8Umrn0m3nsTv0wQBk9sRGpvUe9CwPDrQFB10f1FIjQ==", + "dev": true + }, "@ungap/promise-all-settled": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", @@ -6599,6 +6626,12 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, + "typescript": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.3.tgz", + "integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==", + "dev": true + }, "uc.micro": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", diff --git a/package.json b/package.json index f23f9349..86f8d9e2 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,8 @@ "test": "npm run lint && mocha test/sonos.test.js --exit --timeout 20000", "env-run": "npm run $CMD", "docs": "jsdox -t ./docs/generator/templates --output docs lib/ && jsdox -t ./docs/generator/templates --output docs/services lib/services && jsdox -t ./docs/generator/templates --output docs/events lib/events", - "generator": "npx @svrooij/sonos-docs combine && npx @svrooij/sonos-docs generate ./.generator/node/ ./ && npx standard --fix" - + "generator": "npx @svrooij/sonos-docs combine && npx @svrooij/sonos-docs generate ./.generator/node/ ./ && npx standard --fix", + "prepack": "tsc" }, "repository": { "type": "git", @@ -40,8 +40,10 @@ ], "files": [ "index.js", - "lib" + "lib", + "types/**/*.d.ts" ], + "types": "./types/index.d.ts", "license": "MIT", "dependencies": { "axios": "^0.21.4", @@ -54,10 +56,12 @@ }, "devDependencies": { "@bencevans/jsdox": "0.4.11", + "@types/node": "^16.10.2", "mocha": "^8.3.2", "nock": "^13.0.11", "pre-commit": "1.2.2", - "standard": "^16.0.3" + "standard": "^16.0.3", + "typescript": "^4.4.3" }, "pre-commit": [ "lint" diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..539f48e6 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,24 @@ +{ + // Change this to match your project + "include": ["index.js", "lib/**/*.js", "lib/*.js"], + "compilerOptions": { + // Tells TypeScript to read JS files, as + // normally they are ignored as source files + "allowJs": true, + // "checkJs": true, + // Generate d.ts files + "declaration": true, + // This compiler run should + // only output d.ts files + "emitDeclarationOnly": true, + "strict":false, + "target": "ES5", + // "module": "commonJS", + // "moduleResolution": "node", + // "lib": ["ES2018"], + // Types should go into this directory. + // Removing this would place the .d.ts files + // next to the .js files + "outDir": "types" + } +} \ No newline at end of file From 3c40f3d0f7e657b406b0c09a3ae29a6182528c93 Mon Sep 17 00:00:00 2001 From: Stephan van Rooij <1292510+svrooij@users.noreply.github.com> Date: Thu, 30 Sep 2021 00:40:47 +0200 Subject: [PATCH 3/6] chore: Regenerated services --- lib/services/alarm-clock.service.js | 32 +++++++--- lib/services/all-services.js | 39 ++++++----- lib/services/audio-in.service.js | 15 ++++- lib/services/av-transport.service.js | 64 ++++++++++++++----- lib/services/connection-manager.service.js | 11 +++- lib/services/content-directory.service.js | 32 ++++++---- lib/services/device-properties.service.js | 44 +++++++++---- lib/services/group-management.service.js | 10 ++- .../group-rendering-control.service.js | 14 +++- lib/services/ht-control.service.js | 16 ++++- lib/services/music-services.service.js | 10 ++- lib/services/q-play.service.js | 7 +- lib/services/queue.service.js | 26 +++++--- lib/services/rendering-control.service.js | 48 +++++++++----- lib/services/system-properties.service.js | 29 +++++++-- lib/services/virtual-line-in.service.js | 14 +++- lib/services/zone-group-topology.service.js | 17 +++-- 17 files changed, 308 insertions(+), 120 deletions(-) diff --git a/lib/services/alarm-clock.service.js b/lib/services/alarm-clock.service.js index 4bf5ca32..50c3424f 100644 --- a/lib/services/alarm-clock.service.js +++ b/lib/services/alarm-clock.service.js @@ -11,6 +11,11 @@ const Service = require('./Service') * @extends {Service} */ class AlarmClockService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ constructor (host, port) { super() this.name = 'AlarmClock' @@ -36,7 +41,7 @@ class AlarmClockService extends Service { * @param {string} options.PlayMode - Alarm play mode [ 'NORMAL' / 'REPEAT_ALL' / 'SHUFFLE_NOREPEAT' / 'SHUFFLE' ] * @param {number} options.Volume - Volume between 0 and 100 * @param {boolean} options.IncludeLinkedZones - Should grouped players also play the alarm? - * @returns {Object} response object, with these properties 'AssignedID' + * @returns {Promise} response object, with these properties `AssignedID` */ async CreateAlarm (options) { return this._request('CreateAlarm', options) } @@ -45,18 +50,19 @@ class AlarmClockService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.ID - The Alarm ID from ListAlarms + * @returns {Promise} request succeeded */ async DestroyAlarm (options) { return this._request('DestroyAlarm', options) } /** * GetDailyIndexRefreshTime - * @returns {Object} response object, with these properties 'CurrentDailyIndexRefreshTime' + * @returns {Promise} response object, with these properties `CurrentDailyIndexRefreshTime` */ async GetDailyIndexRefreshTime () { return this._request('GetDailyIndexRefreshTime') } /** * GetFormat - * @returns {Object} response object, with these properties 'CurrentTimeFormat', 'CurrentDateFormat' + * @returns {Promise} response object, with these properties `CurrentTimeFormat`, `CurrentDateFormat` */ async GetFormat () { return this._request('GetFormat') } @@ -65,31 +71,31 @@ class AlarmClockService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.TimeStamp - * @returns {Object} response object, with these properties 'HouseholdUTCTime' + * @returns {Promise} response object, with these properties `HouseholdUTCTime` */ async GetHouseholdTimeAtStamp (options) { return this._request('GetHouseholdTimeAtStamp', options) } /** * GetTimeNow - * @returns {Object} response object, with these properties 'CurrentUTCTime', 'CurrentLocalTime', 'CurrentTimeZone', 'CurrentTimeGeneration' + * @returns {Promise} response object, with these properties `CurrentUTCTime`, `CurrentLocalTime`, `CurrentTimeZone`, `CurrentTimeGeneration` */ async GetTimeNow () { return this._request('GetTimeNow') } /** * GetTimeServer - * @returns {Object} response object, with these properties 'CurrentTimeServer' + * @returns {Promise} response object, with these properties `CurrentTimeServer` */ async GetTimeServer () { return this._request('GetTimeServer') } /** * GetTimeZone - * @returns {Object} response object, with these properties 'Index', 'AutoAdjustDst' + * @returns {Promise} response object, with these properties `Index`, `AutoAdjustDst` */ async GetTimeZone () { return this._request('GetTimeZone') } /** * GetTimeZoneAndRule - * @returns {Object} response object, with these properties 'Index', 'AutoAdjustDst', 'CurrentTimeZone' + * @returns {Promise} response object, with these properties `Index`, `AutoAdjustDst`, `CurrentTimeZone` */ async GetTimeZoneAndRule () { return this._request('GetTimeZoneAndRule') } @@ -98,14 +104,14 @@ class AlarmClockService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.Index - * @returns {Object} response object, with these properties 'TimeZone' + * @returns {Promise} response object, with these properties `TimeZone` */ async GetTimeZoneRule (options) { return this._request('GetTimeZoneRule', options) } /** * ListAlarms - Get the AlarmList as XML * @remarks Some libraries also provide a ListAndParseAlarms where the alarm list xml is parsed - * @returns {Object} response object, with these properties 'CurrentAlarmList', 'CurrentAlarmListVersion' + * @returns {Promise} response object, with these properties `CurrentAlarmList`, `CurrentAlarmListVersion` */ async ListAlarms () { return this._request('ListAlarms') } @@ -114,6 +120,7 @@ class AlarmClockService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.DesiredDailyIndexRefreshTime + * @returns {Promise} request succeeded */ async SetDailyIndexRefreshTime (options) { return this._request('SetDailyIndexRefreshTime', options) } @@ -123,6 +130,7 @@ class AlarmClockService extends Service { * @param {Object} [options] - An object with the following properties * @param {string} options.DesiredTimeFormat * @param {string} options.DesiredDateFormat + * @returns {Promise} request succeeded */ async SetFormat (options) { return this._request('SetFormat', options) } @@ -132,6 +140,7 @@ class AlarmClockService extends Service { * @param {Object} [options] - An object with the following properties * @param {string} options.DesiredTime * @param {string} options.TimeZoneForDesiredTime + * @returns {Promise} request succeeded */ async SetTimeNow (options) { return this._request('SetTimeNow', options) } @@ -140,6 +149,7 @@ class AlarmClockService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.DesiredTimeServer + * @returns {Promise} request succeeded */ async SetTimeServer (options) { return this._request('SetTimeServer', options) } @@ -149,6 +159,7 @@ class AlarmClockService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.Index * @param {boolean} options.AutoAdjustDst + * @returns {Promise} request succeeded */ async SetTimeZone (options) { return this._request('SetTimeZone', options) } @@ -168,6 +179,7 @@ class AlarmClockService extends Service { * @param {number} options.Volume - Volume between 0 and 100 * @param {boolean} options.IncludeLinkedZones - Should grouped players also play the alarm? * @remarks Some libraries support PatchAlarm where you can update a single parameter + * @returns {Promise} request succeeded */ async UpdateAlarm (options) { return this._request('UpdateAlarm', options) } // #endregion diff --git a/lib/services/all-services.js b/lib/services/all-services.js index cf7741f4..7cae5a9c 100644 --- a/lib/services/all-services.js +++ b/lib/services/all-services.js @@ -25,15 +25,20 @@ const ZoneGroupTopologyService = require('./zone-group-topology.service') * @class AllServices */ class AllServices { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ constructor (host, port) { this.host = host - this.port = port + this.port = port || 1400 } /** * Get instance of AlarmClock service * - * @returns AlarmClockService + * @returns {AlarmClockService} */ AlarmClockService () { if (!this.alarmclockservice) { @@ -45,7 +50,7 @@ class AllServices { /** * Get instance of AudioIn service * - * @returns AudioInService + * @returns {AudioInService} */ AudioInService () { if (!this.audioinservice) { @@ -57,7 +62,7 @@ class AllServices { /** * Get instance of AVTransport service * - * @returns AVTransportService + * @returns {AVTransportService} */ AVTransportService () { if (!this.avtransportservice) { @@ -69,7 +74,7 @@ class AllServices { /** * Get instance of ConnectionManager service * - * @returns ConnectionManagerService + * @returns {ConnectionManagerService} */ ConnectionManagerService () { if (!this.connectionmanagerservice) { @@ -81,7 +86,7 @@ class AllServices { /** * Get instance of ContentDirectory service * - * @returns ContentDirectoryService + * @returns {ContentDirectoryService} */ ContentDirectoryService () { if (!this.contentdirectoryservice) { @@ -93,7 +98,7 @@ class AllServices { /** * Get instance of DeviceProperties service * - * @returns DevicePropertiesService + * @returns {DevicePropertiesService} */ DevicePropertiesService () { if (!this.devicepropertiesservice) { @@ -105,7 +110,7 @@ class AllServices { /** * Get instance of GroupManagement service * - * @returns GroupManagementService + * @returns {GroupManagementService} */ GroupManagementService () { if (!this.groupmanagementservice) { @@ -117,7 +122,7 @@ class AllServices { /** * Get instance of GroupRenderingControl service * - * @returns GroupRenderingControlService + * @returns {GroupRenderingControlService} */ GroupRenderingControlService () { if (!this.grouprenderingcontrolservice) { @@ -129,7 +134,7 @@ class AllServices { /** * Get instance of HTControl service * - * @returns HTControlService + * @returns {HTControlService} */ HTControlService () { if (!this.htcontrolservice) { @@ -141,7 +146,7 @@ class AllServices { /** * Get instance of MusicServices service * - * @returns MusicServicesService + * @returns {MusicServicesService} */ MusicServicesService () { if (!this.musicservicesservice) { @@ -153,7 +158,7 @@ class AllServices { /** * Get instance of QPlay service * - * @returns QPlayService + * @returns {QPlayService} */ QPlayService () { if (!this.qplayservice) { @@ -165,7 +170,7 @@ class AllServices { /** * Get instance of Queue service * - * @returns QueueService + * @returns {QueueService} */ QueueService () { if (!this.queueservice) { @@ -177,7 +182,7 @@ class AllServices { /** * Get instance of RenderingControl service * - * @returns RenderingControlService + * @returns {RenderingControlService} */ RenderingControlService () { if (!this.renderingcontrolservice) { @@ -189,7 +194,7 @@ class AllServices { /** * Get instance of SystemProperties service * - * @returns SystemPropertiesService + * @returns {SystemPropertiesService} */ SystemPropertiesService () { if (!this.systempropertiesservice) { @@ -201,7 +206,7 @@ class AllServices { /** * Get instance of VirtualLineIn service * - * @returns VirtualLineInService + * @returns {VirtualLineInService} */ VirtualLineInService () { if (!this.virtuallineinservice) { @@ -213,7 +218,7 @@ class AllServices { /** * Get instance of ZoneGroupTopology service * - * @returns ZoneGroupTopologyService + * @returns {ZoneGroupTopologyService} */ ZoneGroupTopologyService () { if (!this.zonegrouptopologyservice) { diff --git a/lib/services/audio-in.service.js b/lib/services/audio-in.service.js index 712c1c05..091074f9 100644 --- a/lib/services/audio-in.service.js +++ b/lib/services/audio-in.service.js @@ -11,6 +11,11 @@ const Service = require('./Service') * @extends {Service} */ class AudioInService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ constructor (host, port) { super() this.name = 'AudioIn' @@ -24,13 +29,13 @@ class AudioInService extends Service { // #region actions /** * GetAudioInputAttributes - * @returns {Object} response object, with these properties 'CurrentName', 'CurrentIcon' + * @returns {Promise} response object, with these properties `CurrentName`, `CurrentIcon` */ async GetAudioInputAttributes () { return this._request('GetAudioInputAttributes') } /** * GetLineInLevel - * @returns {Object} response object, with these properties 'CurrentLeftLineInLevel', 'CurrentRightLineInLevel' + * @returns {Promise} response object, with these properties `CurrentLeftLineInLevel`, `CurrentRightLineInLevel` */ async GetLineInLevel () { return this._request('GetLineInLevel') } @@ -39,6 +44,7 @@ class AudioInService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.ObjectID + * @returns {Promise} request succeeded */ async SelectAudio (options) { return this._request('SelectAudio', options) } @@ -48,6 +54,7 @@ class AudioInService extends Service { * @param {Object} [options] - An object with the following properties * @param {string} options.DesiredName * @param {string} options.DesiredIcon + * @returns {Promise} request succeeded */ async SetAudioInputAttributes (options) { return this._request('SetAudioInputAttributes', options) } @@ -57,6 +64,7 @@ class AudioInService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.DesiredLeftLineInLevel * @param {number} options.DesiredRightLineInLevel + * @returns {Promise} request succeeded */ async SetLineInLevel (options) { return this._request('SetLineInLevel', options) } @@ -65,7 +73,7 @@ class AudioInService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.CoordinatorID - * @returns {Object} response object, with these properties 'CurrentTransportSettings' + * @returns {Promise} response object, with these properties `CurrentTransportSettings` */ async StartTransmissionToGroup (options) { return this._request('StartTransmissionToGroup', options) } @@ -74,6 +82,7 @@ class AudioInService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.CoordinatorID + * @returns {Promise} request succeeded */ async StopTransmissionToGroup (options) { return this._request('StopTransmissionToGroup', options) } // #endregion diff --git a/lib/services/av-transport.service.js b/lib/services/av-transport.service.js index 89299e02..119a71bf 100644 --- a/lib/services/av-transport.service.js +++ b/lib/services/av-transport.service.js @@ -11,6 +11,11 @@ const Service = require('./Service') * @extends {Service} */ class AVTransportService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ constructor (host, port) { super() this.name = 'AVTransport' @@ -35,7 +40,7 @@ class AVTransportService extends Service { * @param {string} options.ContainerMetaData * @param {number} options.DesiredFirstTrackNumberEnqueued * @param {boolean} options.EnqueueAsNext - * @returns {Object} response object, with these properties 'FirstTrackNumberEnqueued', 'NumTracksAdded', 'NewQueueLength', 'NewUpdateID' + * @returns {Promise} response object, with these properties `FirstTrackNumberEnqueued`, `NumTracksAdded`, `NewQueueLength`, `NewUpdateID` */ async AddMultipleURIsToQueue (options) { return this._request('AddMultipleURIsToQueue', options) } @@ -49,7 +54,7 @@ class AVTransportService extends Service { * @param {number} options.DesiredFirstTrackNumberEnqueued - use `0` to add at the end or `1` to insert at the beginning * @param {boolean} options.EnqueueAsNext * @remarks In NORMAL play mode the songs are added prior to the specified `DesiredFirstTrackNumberEnqueued`. - * @returns {Object} response object, with these properties 'FirstTrackNumberEnqueued', 'NumTracksAdded', 'NewQueueLength' + * @returns {Promise} response object, with these properties `FirstTrackNumberEnqueued`, `NumTracksAdded`, `NewQueueLength` */ async AddURIToQueue (options) { return this._request('AddURIToQueue', options) } @@ -63,7 +68,7 @@ class AVTransportService extends Service { * @param {string} options.EnqueuedURI * @param {string} options.EnqueuedURIMetaData * @param {number} options.AddAtIndex - * @returns {Object} response object, with these properties 'NumTracksAdded', 'NewQueueLength', 'NewUpdateID' + * @returns {Promise} response object, with these properties `NumTracksAdded`, `NewQueueLength`, `NewUpdateID` */ async AddURIToSavedQueue (options) { return this._request('AddURIToSavedQueue', options) } @@ -72,6 +77,7 @@ class AVTransportService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` + * @returns {Promise} request succeeded */ async BackupQueue (options = { InstanceID: 0 }) { return this._request('BackupQueue', options) } @@ -80,7 +86,7 @@ class AVTransportService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Object} response object, with these properties 'DelegatedGroupCoordinatorID', 'NewGroupID' + * @returns {Promise} response object, with these properties `DelegatedGroupCoordinatorID`, `NewGroupID` */ async BecomeCoordinatorOfStandaloneGroup (options = { InstanceID: 0 }) { return this._request('BecomeCoordinatorOfStandaloneGroup', options) } @@ -100,6 +106,7 @@ class AVTransportService extends Service { * @param {string} options.StreamRestartState * @param {string} options.CurrentQueueTrackList * @param {string} options.CurrentVLIState + * @returns {Promise} request succeeded */ async BecomeGroupCoordinator (options) { return this._request('BecomeGroupCoordinator', options) } @@ -120,6 +127,7 @@ class AVTransportService extends Service { * @param {string} options.CurrentQueueTrackList * @param {string} options.CurrentSourceState * @param {boolean} options.ResumePlayback + * @returns {Promise} request succeeded */ async BecomeGroupCoordinatorAndSource (options) { return this._request('BecomeGroupCoordinatorAndSource', options) } @@ -132,6 +140,7 @@ class AVTransportService extends Service { * @param {string} options.NewCoordinator * @param {string} options.NewTransportSettings * @param {string} options.CurrentAVTransportURI + * @returns {Promise} request succeeded */ async ChangeCoordinator (options) { return this._request('ChangeCoordinator', options) } @@ -142,6 +151,7 @@ class AVTransportService extends Service { * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.NewTransportSettings * @param {string} options.CurrentAVTransportURI + * @returns {Promise} request succeeded */ async ChangeTransportSettings (options) { return this._request('ChangeTransportSettings', options) } @@ -152,6 +162,7 @@ class AVTransportService extends Service { * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.NewSleepTimerDuration - Time to stop after, as `hh:mm:ss` or empty string to cancel * @remarks Send to non-coordinator returns error code 800 + * @returns {Promise} request succeeded */ async ConfigureSleepTimer (options) { return this._request('ConfigureSleepTimer', options) } @@ -163,7 +174,7 @@ class AVTransportService extends Service { * @param {string} options.Title * @param {string} options.EnqueuedURI * @param {string} options.EnqueuedURIMetaData - * @returns {Object} response object, with these properties 'NumTracksAdded', 'NewQueueLength', 'AssignedObjectID', 'NewUpdateID' + * @returns {Promise} response object, with these properties `NumTracksAdded`, `NewQueueLength`, `AssignedObjectID`, `NewUpdateID` */ async CreateSavedQueue (options) { return this._request('CreateSavedQueue', options) } @@ -175,6 +186,7 @@ class AVTransportService extends Service { * @param {string} options.NewCoordinator - uuid of the new coordinator - must be in same group * @param {boolean} options.RejoinGroup - Should former coordinator rejoin the group? * @remarks Send to non-coordinator has no results - should be avoided. + * @returns {Promise} request succeeded */ async DelegateGroupCoordinationTo (options) { return this._request('DelegateGroupCoordinationTo', options) } @@ -183,6 +195,7 @@ class AVTransportService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` + * @returns {Promise} request succeeded */ async EndDirectControlSession (options = { InstanceID: 0 }) { return this._request('EndDirectControlSession', options) } @@ -192,7 +205,7 @@ class AVTransportService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @remarks Send to non-coordinator may return wrong value as only the coordinator value in a group - * @returns {Object} response object, with these properties 'CrossfadeMode' + * @returns {Promise} response object, with these properties `CrossfadeMode` */ async GetCrossfadeMode (options = { InstanceID: 0 }) { return this._request('GetCrossfadeMode', options) } @@ -202,7 +215,7 @@ class AVTransportService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @remarks Send to non-coordinator returns only `Start` and `Stop` since it cannot control the stream. - * @returns {Object} response object, with these properties 'Actions' + * @returns {Promise} response object, with these properties `Actions` */ async GetCurrentTransportActions (options = { InstanceID: 0 }) { return this._request('GetCurrentTransportActions', options) } @@ -211,7 +224,7 @@ class AVTransportService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Object} response object, with these properties 'PlayMedia', 'RecMedia', 'RecQualityModes' + * @returns {Promise} response object, with these properties `PlayMedia`, `RecMedia`, `RecQualityModes` */ async GetDeviceCapabilities (options = { InstanceID: 0 }) { return this._request('GetDeviceCapabilities', options) } @@ -220,7 +233,7 @@ class AVTransportService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Object} response object, with these properties 'NrTracks', 'MediaDuration', 'CurrentURI', 'CurrentURIMetaData', 'NextURI', 'NextURIMetaData', 'PlayMedium', 'RecordMedium', 'WriteStatus' + * @returns {Promise} response object, with these properties `NrTracks`, `MediaDuration`, `CurrentURI`, `CurrentURIMetaData`, `NextURI`, `NextURIMetaData`, `PlayMedium`, `RecordMedium`, `WriteStatus` */ async GetMediaInfo (options = { InstanceID: 0 }) { return this._request('GetMediaInfo', options) } @@ -229,7 +242,7 @@ class AVTransportService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Object} response object, with these properties 'Track', 'TrackDuration', 'TrackMetaData', 'TrackURI', 'RelTime', 'AbsTime', 'RelCount', 'AbsCount' + * @returns {Promise} response object, with these properties `Track`, `TrackDuration`, `TrackMetaData`, `TrackURI`, `RelTime`, `AbsTime`, `RelCount`, `AbsCount` */ async GetPositionInfo (options = { InstanceID: 0 }) { return this._request('GetPositionInfo', options) } @@ -239,7 +252,7 @@ class AVTransportService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @remarks Send to non-coordinator returns error code 800 - * @returns {Object} response object, with these properties 'RemainingSleepTimerDuration', 'CurrentSleepTimerGeneration' + * @returns {Promise} response object, with these properties `RemainingSleepTimerDuration`, `CurrentSleepTimerGeneration` */ async GetRemainingSleepTimerDuration (options = { InstanceID: 0 }) { return this._request('GetRemainingSleepTimerDuration', options) } @@ -248,7 +261,7 @@ class AVTransportService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Object} response object, with these properties 'AlarmID', 'GroupID', 'LoggedStartTime' + * @returns {Promise} response object, with these properties `AlarmID`, `GroupID`, `LoggedStartTime` */ async GetRunningAlarmProperties (options = { InstanceID: 0 }) { return this._request('GetRunningAlarmProperties', options) } @@ -258,7 +271,7 @@ class AVTransportService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @remarks Send to non-coordinator always returns PLAYING - * @returns {Object} response object, with these properties 'CurrentTransportState', 'CurrentTransportStatus', 'CurrentSpeed' + * @returns {Promise} response object, with these properties `CurrentTransportState`, `CurrentTransportStatus`, `CurrentSpeed` */ async GetTransportInfo (options = { InstanceID: 0 }) { return this._request('GetTransportInfo', options) } @@ -268,7 +281,7 @@ class AVTransportService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @remarks Send to non-coordinator returns the settings of it's queue - * @returns {Object} response object, with these properties 'PlayMode', 'RecQualityMode' + * @returns {Promise} response object, with these properties `PlayMode`, `RecQualityMode` */ async GetTransportSettings (options = { InstanceID: 0 }) { return this._request('GetTransportSettings', options) } @@ -278,6 +291,7 @@ class AVTransportService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @remarks Possibly not supported at the moment see GetCurrentTransportActions + * @returns {Promise} request succeeded */ async Next (options = { InstanceID: 0 }) { return this._request('Next', options) } @@ -287,6 +301,7 @@ class AVTransportService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.DeletedURI + * @returns {Promise} request succeeded */ async NotifyDeletedURI (options) { return this._request('NotifyDeletedURI', options) } @@ -295,6 +310,7 @@ class AVTransportService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` + * @returns {Promise} request succeeded */ async Pause (options = { InstanceID: 0 }) { return this._request('Pause', options) } @@ -304,6 +320,7 @@ class AVTransportService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.Speed - Play speed usually 1, can be a fraction of 1 [ '1' ] + * @returns {Promise} request succeeded */ async Play (options) { return this._request('Play', options) } @@ -313,6 +330,7 @@ class AVTransportService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @remarks Possibly not supported at the moment see GetCurrentTransportActions + * @returns {Promise} request succeeded */ async Previous (options = { InstanceID: 0 }) { return this._request('Previous', options) } @@ -322,6 +340,7 @@ class AVTransportService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @remarks If queue is already empty it throw error 804. Send to non-coordinator returns error code 800. + * @returns {Promise} request succeeded */ async RemoveAllTracksFromQueue (options = { InstanceID: 0 }) { return this._request('RemoveAllTracksFromQueue', options) } @@ -332,6 +351,7 @@ class AVTransportService extends Service { * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.ObjectID * @param {number} options.UpdateID + * @returns {Promise} request succeeded */ async RemoveTrackFromQueue (options) { return this._request('RemoveTrackFromQueue', options) } @@ -343,7 +363,7 @@ class AVTransportService extends Service { * @param {number} options.UpdateID - Leave blank * @param {number} options.StartingIndex - between 1 and queue-length * @param {number} options.NumberOfTracks - * @returns {Object} response object, with these properties 'NewUpdateID' + * @returns {Promise} response object, with these properties `NewUpdateID` */ async RemoveTrackRangeFromQueue (options) { return this._request('RemoveTrackRangeFromQueue', options) } @@ -356,6 +376,7 @@ class AVTransportService extends Service { * @param {number} options.NumberOfTracks * @param {number} options.InsertBefore * @param {number} options.UpdateID + * @returns {Promise} request succeeded */ async ReorderTracksInQueue (options) { return this._request('ReorderTracksInQueue', options) } @@ -368,7 +389,7 @@ class AVTransportService extends Service { * @param {number} options.UpdateID * @param {string} options.TrackList * @param {string} options.NewPositionList - * @returns {Object} response object, with these properties 'QueueLengthChange', 'NewQueueLength', 'NewUpdateID' + * @returns {Promise} response object, with these properties `QueueLengthChange`, `NewQueueLength`, `NewUpdateID` */ async ReorderTracksInSavedQueue (options) { return this._request('ReorderTracksInSavedQueue', options) } @@ -385,6 +406,7 @@ class AVTransportService extends Service { * @param {string} options.PlayMode [ 'NORMAL' / 'REPEAT_ALL' / 'REPEAT_ONE' / 'SHUFFLE_NOREPEAT' / 'SHUFFLE' / 'SHUFFLE_REPEAT_ONE' ] * @param {number} options.Volume * @param {boolean} options.IncludeLinkedZones + * @returns {Promise} request succeeded */ async RunAlarm (options) { return this._request('RunAlarm', options) } @@ -396,7 +418,7 @@ class AVTransportService extends Service { * @param {string} options.Title - SONOS playlist title * @param {string} options.ObjectID - Leave blank * @remarks Send to non-coordinator returns error code 800 - * @returns {Object} response object, with these properties 'AssignedObjectID' + * @returns {Promise} response object, with these properties `AssignedObjectID` */ async SaveQueue (options) { return this._request('SaveQueue', options) } @@ -408,6 +430,7 @@ class AVTransportService extends Service { * @param {string} options.Unit - What to seek [ 'TRACK_NR' / 'REL_TIME' / 'TIME_DELTA' ] * @param {string} options.Target - Position of track in queue (start at 1) or `hh:mm:ss` for `REL_TIME` or `+/-hh:mm:ss` for `TIME_DELTA` * @remarks Returns error code 701 in case that content does not support Seek or send to non-coordinator + * @returns {Promise} request succeeded */ async Seek (options) { return this._request('Seek', options) } @@ -419,6 +442,7 @@ class AVTransportService extends Service { * @param {string} options.CurrentURI - The new TransportURI - its a special SONOS format * @param {string} options.CurrentURIMetaData - Track Metadata, see MetadataHelper.GuessTrack to guess based on track uri * @remarks If set to another player RINCON, the player is grouped with that one. + * @returns {Promise} request succeeded */ async SetAVTransportURI (options) { return this._request('SetAVTransportURI', options) } @@ -429,6 +453,7 @@ class AVTransportService extends Service { * @param {number} options.InstanceID - InstanceID should always be `0` * @param {boolean} options.CrossfadeMode * @remarks Send to non-coordinator returns error code 800. Same for content, which does not support crossfade mode. + * @returns {Promise} request succeeded */ async SetCrossfadeMode (options) { return this._request('SetCrossfadeMode', options) } @@ -439,6 +464,7 @@ class AVTransportService extends Service { * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.NextURI * @param {string} options.NextURIMetaData + * @returns {Promise} request succeeded */ async SetNextAVTransportURI (options) { return this._request('SetNextAVTransportURI', options) } @@ -449,6 +475,7 @@ class AVTransportService extends Service { * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.NewPlayMode - New playmode [ 'NORMAL' / 'REPEAT_ALL' / 'REPEAT_ONE' / 'SHUFFLE_NOREPEAT' / 'SHUFFLE' / 'SHUFFLE_REPEAT_ONE' ] * @remarks Send to non-coordinator returns error code 712. If SONOS queue is not activated returns error code 712. + * @returns {Promise} request succeeded */ async SetPlayMode (options) { return this._request('SetPlayMode', options) } @@ -458,6 +485,7 @@ class AVTransportService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.Duration - Snooze time as `hh:mm:ss`, 10 minutes = 00:10:00 + * @returns {Promise} request succeeded */ async SnoozeAlarm (options) { return this._request('SnoozeAlarm', options) } @@ -471,6 +499,7 @@ class AVTransportService extends Service { * @param {number} options.Volume * @param {boolean} options.IncludeLinkedZones * @param {boolean} options.ResetVolumeAfter + * @returns {Promise} request succeeded */ async StartAutoplay (options) { return this._request('StartAutoplay', options) } @@ -479,6 +508,7 @@ class AVTransportService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` + * @returns {Promise} request succeeded */ async Stop (options = { InstanceID: 0 }) { return this._request('Stop', options) } // #endregion diff --git a/lib/services/connection-manager.service.js b/lib/services/connection-manager.service.js index 2c16cc93..3da63dbc 100644 --- a/lib/services/connection-manager.service.js +++ b/lib/services/connection-manager.service.js @@ -11,6 +11,11 @@ const Service = require('./Service') * @extends {Service} */ class ConnectionManagerService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ constructor (host, port) { super() this.name = 'ConnectionManager' @@ -24,7 +29,7 @@ class ConnectionManagerService extends Service { // #region actions /** * GetCurrentConnectionIDs - * @returns {Object} response object, with these properties 'ConnectionIDs' + * @returns {Promise} response object, with these properties `ConnectionIDs` */ async GetCurrentConnectionIDs () { return this._request('GetCurrentConnectionIDs') } @@ -33,13 +38,13 @@ class ConnectionManagerService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.ConnectionID - * @returns {Object} response object, with these properties 'RcsID', 'AVTransportID', 'ProtocolInfo', 'PeerConnectionManager', 'PeerConnectionID', 'Direction', 'Status' + * @returns {Promise} response object, with these properties `RcsID`, `AVTransportID`, `ProtocolInfo`, `PeerConnectionManager`, `PeerConnectionID`, `Direction`, `Status` */ async GetCurrentConnectionInfo (options) { return this._request('GetCurrentConnectionInfo', options) } /** * GetProtocolInfo - * @returns {Object} response object, with these properties 'Source', 'Sink' + * @returns {Promise} response object, with these properties `Source`, `Sink` */ async GetProtocolInfo () { return this._request('GetProtocolInfo') } // #endregion diff --git a/lib/services/content-directory.service.js b/lib/services/content-directory.service.js index f3917529..abae5dd8 100644 --- a/lib/services/content-directory.service.js +++ b/lib/services/content-directory.service.js @@ -11,6 +11,11 @@ const Service = require('./Service') * @extends {Service} */ class ContentDirectoryService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ constructor (host, port) { super() this.name = 'ContentDirectory' @@ -33,7 +38,7 @@ class ContentDirectoryService extends Service { * @param {number} options.RequestedCount - Paging, number of items, maximum is 1,000. This parameter does NOT restrict the number of items being searched (filter) but only the number being returned. * @param {string} options.SortCriteria - Sort the results based on metadata fields. `+upnp:artist,+dc:title` for sorting on artist then on title. * @remarks (1) If the title contains an apostrophe the returned uri will contain a `'`. (2) Some libraries support a BrowseAndParse, so you don't have to parse the xml. - * @returns {Object} response object, with these properties 'Result', 'NumberReturned', 'TotalMatches', 'UpdateID' + * @returns {Promise} response object, with these properties `Result`, `NumberReturned`, `TotalMatches`, `UpdateID` */ async Browse (options) { return this._request('Browse', options) } @@ -43,7 +48,7 @@ class ContentDirectoryService extends Service { * @param {Object} [options] - An object with the following properties * @param {string} options.ContainerID * @param {string} options.Elements - * @returns {Object} response object, with these properties 'ObjectID', 'Result' + * @returns {Promise} response object, with these properties `ObjectID`, `Result` */ async CreateObject (options) { return this._request('CreateObject', options) } @@ -52,6 +57,7 @@ class ContentDirectoryService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.ObjectID + * @returns {Promise} request succeeded */ async DestroyObject (options) { return this._request('DestroyObject', options) } @@ -61,13 +67,13 @@ class ContentDirectoryService extends Service { * @param {Object} [options] - An object with the following properties * @param {string} options.ObjectID * @param {string} options.Prefix - * @returns {Object} response object, with these properties 'StartingIndex', 'UpdateID' + * @returns {Promise} response object, with these properties `StartingIndex`, `UpdateID` */ async FindPrefix (options) { return this._request('FindPrefix', options) } /** * GetAlbumArtistDisplayOption - * @returns {Object} response object, with these properties 'AlbumArtistDisplayOption' + * @returns {Promise} response object, with these properties `AlbumArtistDisplayOption` */ async GetAlbumArtistDisplayOption () { return this._request('GetAlbumArtistDisplayOption') } @@ -76,43 +82,43 @@ class ContentDirectoryService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.ObjectID - * @returns {Object} response object, with these properties 'TotalPrefixes', 'PrefixAndIndexCSV', 'UpdateID' + * @returns {Promise} response object, with these properties `TotalPrefixes`, `PrefixAndIndexCSV`, `UpdateID` */ async GetAllPrefixLocations (options) { return this._request('GetAllPrefixLocations', options) } /** * GetBrowseable - * @returns {Object} response object, with these properties 'IsBrowseable' + * @returns {Promise} response object, with these properties `IsBrowseable` */ async GetBrowseable () { return this._request('GetBrowseable') } /** * GetLastIndexChange - * @returns {Object} response object, with these properties 'LastIndexChange' + * @returns {Promise} response object, with these properties `LastIndexChange` */ async GetLastIndexChange () { return this._request('GetLastIndexChange') } /** * GetSearchCapabilities - * @returns {Object} response object, with these properties 'SearchCaps' + * @returns {Promise} response object, with these properties `SearchCaps` */ async GetSearchCapabilities () { return this._request('GetSearchCapabilities') } /** * GetShareIndexInProgress - * @returns {Object} response object, with these properties 'IsIndexing' + * @returns {Promise} response object, with these properties `IsIndexing` */ async GetShareIndexInProgress () { return this._request('GetShareIndexInProgress') } /** * GetSortCapabilities - * @returns {Object} response object, with these properties 'SortCaps' + * @returns {Promise} response object, with these properties `SortCaps` */ async GetSortCapabilities () { return this._request('GetSortCapabilities') } /** * GetSystemUpdateID - * @returns {Object} response object, with these properties 'Id' + * @returns {Promise} response object, with these properties `Id` */ async GetSystemUpdateID () { return this._request('GetSystemUpdateID') } @@ -121,6 +127,7 @@ class ContentDirectoryService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.AlbumArtistDisplayOption + * @returns {Promise} request succeeded */ async RefreshShareIndex (options) { return this._request('RefreshShareIndex', options) } @@ -129,6 +136,7 @@ class ContentDirectoryService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.SortOrder + * @returns {Promise} request succeeded */ async RequestResort (options) { return this._request('RequestResort', options) } @@ -137,6 +145,7 @@ class ContentDirectoryService extends Service { * * @param {Object} [options] - An object with the following properties * @param {boolean} options.Browseable + * @returns {Promise} request succeeded */ async SetBrowseable (options) { return this._request('SetBrowseable', options) } @@ -147,6 +156,7 @@ class ContentDirectoryService extends Service { * @param {string} options.ObjectID * @param {string} options.CurrentTagValue * @param {string} options.NewTagValue + * @returns {Promise} request succeeded */ async UpdateObject (options) { return this._request('UpdateObject', options) } // #endregion diff --git a/lib/services/device-properties.service.js b/lib/services/device-properties.service.js index 67ac7089..8eb7465f 100644 --- a/lib/services/device-properties.service.js +++ b/lib/services/device-properties.service.js @@ -11,6 +11,11 @@ const Service = require('./Service') * @extends {Service} */ class DevicePropertiesService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ constructor (host, port) { super() this.name = 'DeviceProperties' @@ -27,6 +32,7 @@ class DevicePropertiesService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.ChannelMapSet + * @returns {Promise} request succeeded */ async AddBondedZones (options) { return this._request('AddBondedZones', options) } @@ -35,6 +41,7 @@ class DevicePropertiesService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.HTSatChanMapSet + * @returns {Promise} request succeeded */ async AddHTSatellite (options) { return this._request('AddHTSatellite', options) } @@ -44,6 +51,7 @@ class DevicePropertiesService extends Service { * @param {Object} [options] - An object with the following properties * @param {string} options.ChannelMapSet - example: `RINCON_B8E9375831C001400:LF,LF;RINCON_000E58FE3AEA01400:RF,RF` * @remarks No all speakers support StereoPairs + * @returns {Promise} request succeeded */ async CreateStereoPair (options) { return this._request('CreateStereoPair', options) } @@ -53,7 +61,7 @@ class DevicePropertiesService extends Service { * @param {Object} [options] - An object with the following properties * @param {string} options.Mode * @param {string} options.Options - * @returns {Object} response object, with these properties 'State' + * @returns {Promise} response object, with these properties `State` */ async EnterConfigMode (options) { return this._request('EnterConfigMode', options) } @@ -62,6 +70,7 @@ class DevicePropertiesService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.Options + * @returns {Promise} request succeeded */ async ExitConfigMode (options) { return this._request('ExitConfigMode', options) } @@ -70,7 +79,7 @@ class DevicePropertiesService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.Source - * @returns {Object} response object, with these properties 'IncludeLinkedZones' + * @returns {Promise} response object, with these properties `IncludeLinkedZones` */ async GetAutoplayLinkedZones (options) { return this._request('GetAutoplayLinkedZones', options) } @@ -79,7 +88,7 @@ class DevicePropertiesService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.Source - * @returns {Object} response object, with these properties 'RoomUUID' + * @returns {Promise} response object, with these properties `RoomUUID` */ async GetAutoplayRoomUUID (options) { return this._request('GetAutoplayRoomUUID', options) } @@ -88,31 +97,31 @@ class DevicePropertiesService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.Source - * @returns {Object} response object, with these properties 'CurrentVolume' + * @returns {Promise} response object, with these properties `CurrentVolume` */ async GetAutoplayVolume (options) { return this._request('GetAutoplayVolume', options) } /** * GetButtonLockState - Get the current button lock state - * @returns {Object} response object, with these properties 'CurrentButtonLockState' + * @returns {Promise} response object, with these properties `CurrentButtonLockState` */ async GetButtonLockState () { return this._request('GetButtonLockState') } /** * GetButtonState - * @returns {Object} response object, with these properties 'State' + * @returns {Promise} response object, with these properties `State` */ async GetButtonState () { return this._request('GetButtonState') } /** * GetHouseholdID - * @returns {Object} response object, with these properties 'CurrentHouseholdID' + * @returns {Promise} response object, with these properties `CurrentHouseholdID` */ async GetHouseholdID () { return this._request('GetHouseholdID') } /** * GetLEDState - Get the current LED state - * @returns {Object} response object, with these properties 'CurrentLEDState' + * @returns {Promise} response object, with these properties `CurrentLEDState` */ async GetLEDState () { return this._request('GetLEDState') } @@ -121,19 +130,19 @@ class DevicePropertiesService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.Source - * @returns {Object} response object, with these properties 'UseVolume' + * @returns {Promise} response object, with these properties `UseVolume` */ async GetUseAutoplayVolume (options) { return this._request('GetUseAutoplayVolume', options) } /** * GetZoneAttributes - * @returns {Object} response object, with these properties 'CurrentZoneName', 'CurrentIcon', 'CurrentConfiguration' + * @returns {Promise} response object, with these properties `CurrentZoneName`, `CurrentIcon`, `CurrentConfiguration` */ async GetZoneAttributes () { return this._request('GetZoneAttributes') } /** * GetZoneInfo - Get information about this specific speaker - * @returns {Object} response object, with these properties 'SerialNumber', 'SoftwareVersion', 'DisplaySoftwareVersion', 'HardwareVersion', 'IPAddress', 'MACAddress', 'CopyrightInfo', 'ExtraInfo', 'HTAudioIn', 'Flags' + * @returns {Promise} response object, with these properties `SerialNumber`, `SoftwareVersion`, `DisplaySoftwareVersion`, `HardwareVersion`, `IPAddress`, `MACAddress`, `CopyrightInfo`, `ExtraInfo`, `HTAudioIn`, `Flags` */ async GetZoneInfo () { return this._request('GetZoneInfo') } @@ -143,6 +152,7 @@ class DevicePropertiesService extends Service { * @param {Object} [options] - An object with the following properties * @param {string} options.ChannelMapSet * @param {boolean} options.KeepGrouped + * @returns {Promise} request succeeded */ async RemoveBondedZones (options) { return this._request('RemoveBondedZones', options) } @@ -151,6 +161,7 @@ class DevicePropertiesService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.SatRoomUUID + * @returns {Promise} request succeeded */ async RemoveHTSatellite (options) { return this._request('RemoveHTSatellite', options) } @@ -160,7 +171,7 @@ class DevicePropertiesService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.Channel * @param {number} options.DurationMilliseconds - * @returns {Object} response object, with these properties 'PlayId', 'ChirpIfPlayingSwappableAudio' + * @returns {Promise} response object, with these properties `PlayId`, `ChirpIfPlayingSwappableAudio` */ async RoomDetectionStartChirping (options) { return this._request('RoomDetectionStartChirping', options) } @@ -169,6 +180,7 @@ class DevicePropertiesService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.PlayId + * @returns {Promise} request succeeded */ async RoomDetectionStopChirping (options) { return this._request('RoomDetectionStopChirping', options) } @@ -178,6 +190,7 @@ class DevicePropertiesService extends Service { * @param {Object} [options] - An object with the following properties * @param {string} options.ChannelMapSet - example: `RINCON_B8E9375831C001400:LF,LF;RINCON_000E58FE3AEA01400:RF,RF` * @remarks No all speakers support StereoPairs + * @returns {Promise} request succeeded */ async SeparateStereoPair (options) { return this._request('SeparateStereoPair', options) } @@ -187,6 +200,7 @@ class DevicePropertiesService extends Service { * @param {Object} [options] - An object with the following properties * @param {boolean} options.IncludeLinkedZones * @param {string} options.Source + * @returns {Promise} request succeeded */ async SetAutoplayLinkedZones (options) { return this._request('SetAutoplayLinkedZones', options) } @@ -196,6 +210,7 @@ class DevicePropertiesService extends Service { * @param {Object} [options] - An object with the following properties * @param {string} options.RoomUUID * @param {string} options.Source + * @returns {Promise} request succeeded */ async SetAutoplayRoomUUID (options) { return this._request('SetAutoplayRoomUUID', options) } @@ -205,6 +220,7 @@ class DevicePropertiesService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.Volume * @param {string} options.Source + * @returns {Promise} request succeeded */ async SetAutoplayVolume (options) { return this._request('SetAutoplayVolume', options) } @@ -213,6 +229,7 @@ class DevicePropertiesService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.DesiredButtonLockState [ 'On' / 'Off' ] + * @returns {Promise} request succeeded */ async SetButtonLockState (options) { return this._request('SetButtonLockState', options) } @@ -221,6 +238,7 @@ class DevicePropertiesService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.DesiredLEDState [ 'On' / 'Off' ] + * @returns {Promise} request succeeded */ async SetLEDState (options) { return this._request('SetLEDState', options) } @@ -230,6 +248,7 @@ class DevicePropertiesService extends Service { * @param {Object} [options] - An object with the following properties * @param {boolean} options.UseVolume * @param {string} options.Source + * @returns {Promise} request succeeded */ async SetUseAutoplayVolume (options) { return this._request('SetUseAutoplayVolume', options) } @@ -240,6 +259,7 @@ class DevicePropertiesService extends Service { * @param {string} options.DesiredZoneName * @param {string} options.DesiredIcon * @param {string} options.DesiredConfiguration + * @returns {Promise} request succeeded */ async SetZoneAttributes (options) { return this._request('SetZoneAttributes', options) } // #endregion diff --git a/lib/services/group-management.service.js b/lib/services/group-management.service.js index ce507dc8..301bf915 100644 --- a/lib/services/group-management.service.js +++ b/lib/services/group-management.service.js @@ -11,6 +11,11 @@ const Service = require('./Service') * @extends {Service} */ class GroupManagementService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ constructor (host, port) { super() this.name = 'GroupManagement' @@ -28,7 +33,7 @@ class GroupManagementService extends Service { * @param {Object} [options] - An object with the following properties * @param {string} options.MemberID * @param {number} options.BootSeq - * @returns {Object} response object, with these properties 'CurrentTransportSettings', 'CurrentURI', 'GroupUUIDJoined', 'ResetVolumeAfter', 'VolumeAVTransportURI' + * @returns {Promise} response object, with these properties `CurrentTransportSettings`, `CurrentURI`, `GroupUUIDJoined`, `ResetVolumeAfter`, `VolumeAVTransportURI` */ async AddMember (options) { return this._request('AddMember', options) } @@ -37,6 +42,7 @@ class GroupManagementService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.MemberID + * @returns {Promise} request succeeded */ async RemoveMember (options) { return this._request('RemoveMember', options) } @@ -46,6 +52,7 @@ class GroupManagementService extends Service { * @param {Object} [options] - An object with the following properties * @param {string} options.MemberID * @param {number} options.ResultCode + * @returns {Promise} request succeeded */ async ReportTrackBufferingResult (options) { return this._request('ReportTrackBufferingResult', options) } @@ -54,6 +61,7 @@ class GroupManagementService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.DesiredSourceAreaIds + * @returns {Promise} request succeeded */ async SetSourceAreaIds (options) { return this._request('SetSourceAreaIds', options) } // #endregion diff --git a/lib/services/group-rendering-control.service.js b/lib/services/group-rendering-control.service.js index 21a92c4b..6e2aeaa3 100644 --- a/lib/services/group-rendering-control.service.js +++ b/lib/services/group-rendering-control.service.js @@ -11,6 +11,11 @@ const Service = require('./Service') * @extends {Service} */ class GroupRenderingControlService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ constructor (host, port) { super() this.name = 'GroupRenderingControl' @@ -28,7 +33,7 @@ class GroupRenderingControlService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @remarks Should be send to coordinator only - * @returns {Object} response object, with these properties 'CurrentMute' + * @returns {Promise} response object, with these properties `CurrentMute` */ async GetGroupMute (options = { InstanceID: 0 }) { return this._request('GetGroupMute', options) } @@ -38,7 +43,7 @@ class GroupRenderingControlService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @remarks Should be send to coordinator only - * @returns {Object} response object, with these properties 'CurrentVolume' + * @returns {Promise} response object, with these properties `CurrentVolume` */ async GetGroupVolume (options = { InstanceID: 0 }) { return this._request('GetGroupVolume', options) } @@ -49,6 +54,7 @@ class GroupRenderingControlService extends Service { * @param {number} options.InstanceID - InstanceID should always be `0` * @param {boolean} options.DesiredMute * @remarks Should be send to coordinator only + * @returns {Promise} request succeeded */ async SetGroupMute (options) { return this._request('SetGroupMute', options) } @@ -59,6 +65,7 @@ class GroupRenderingControlService extends Service { * @param {number} options.InstanceID - InstanceID should always be `0` * @param {number} options.DesiredVolume - New volume between 0 and 100 * @remarks Should be send to coordinator only + * @returns {Promise} request succeeded */ async SetGroupVolume (options) { return this._request('SetGroupVolume', options) } @@ -69,7 +76,7 @@ class GroupRenderingControlService extends Service { * @param {number} options.InstanceID - InstanceID should always be `0` * @param {number} options.Adjustment - Number between -100 and +100 * @remarks Should be send to coordinator only - * @returns {Object} response object, with these properties 'NewVolume' + * @returns {Promise} response object, with these properties `NewVolume` */ async SetRelativeGroupVolume (options) { return this._request('SetRelativeGroupVolume', options) } @@ -79,6 +86,7 @@ class GroupRenderingControlService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @remarks Should be send to coordinator only + * @returns {Promise} request succeeded */ async SnapshotGroupVolume (options = { InstanceID: 0 }) { return this._request('SnapshotGroupVolume', options) } // #endregion diff --git a/lib/services/ht-control.service.js b/lib/services/ht-control.service.js index 264ef041..e222f79e 100644 --- a/lib/services/ht-control.service.js +++ b/lib/services/ht-control.service.js @@ -11,6 +11,11 @@ const Service = require('./Service') * @extends {Service} */ class HTControlService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ constructor (host, port) { super() this.name = 'HTControl' @@ -27,18 +32,19 @@ class HTControlService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.Name + * @returns {Promise} request succeeded */ async CommitLearnedIRCodes (options) { return this._request('CommitLearnedIRCodes', options) } /** * GetIRRepeaterState - * @returns {Object} response object, with these properties 'CurrentIRRepeaterState' + * @returns {Promise} response object, with these properties `CurrentIRRepeaterState` */ async GetIRRepeaterState () { return this._request('GetIRRepeaterState') } /** * GetLEDFeedbackState - * @returns {Object} response object, with these properties 'LEDFeedbackState' + * @returns {Promise} response object, with these properties `LEDFeedbackState` */ async GetLEDFeedbackState () { return this._request('GetLEDFeedbackState') } @@ -47,12 +53,13 @@ class HTControlService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.Timeout + * @returns {Promise} request succeeded */ async IdentifyIRRemote (options) { return this._request('IdentifyIRRemote', options) } /** * IsRemoteConfigured - * @returns {Object} response object, with these properties 'RemoteConfigured' + * @returns {Promise} response object, with these properties `RemoteConfigured` */ async IsRemoteConfigured () { return this._request('IsRemoteConfigured') } @@ -62,6 +69,7 @@ class HTControlService extends Service { * @param {Object} [options] - An object with the following properties * @param {string} options.IRCode * @param {number} options.Timeout + * @returns {Promise} request succeeded */ async LearnIRCode (options) { return this._request('LearnIRCode', options) } @@ -70,6 +78,7 @@ class HTControlService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.DesiredIRRepeaterState [ 'On' / 'Off' / 'Disabled' ] + * @returns {Promise} request succeeded */ async SetIRRepeaterState (options) { return this._request('SetIRRepeaterState', options) } @@ -78,6 +87,7 @@ class HTControlService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.LEDFeedbackState [ 'On' / 'Off' ] + * @returns {Promise} request succeeded */ async SetLEDFeedbackState (options) { return this._request('SetLEDFeedbackState', options) } // #endregion diff --git a/lib/services/music-services.service.js b/lib/services/music-services.service.js index b1e3cdba..24d39552 100644 --- a/lib/services/music-services.service.js +++ b/lib/services/music-services.service.js @@ -11,6 +11,11 @@ const Service = require('./Service') * @extends {Service} */ class MusicServicesService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ constructor (host, port) { super() this.name = 'MusicServices' @@ -28,19 +33,20 @@ class MusicServicesService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.ServiceId * @param {string} options.Username - * @returns {Object} response object, with these properties 'SessionId' + * @returns {Promise} response object, with these properties `SessionId` */ async GetSessionId (options) { return this._request('GetSessionId', options) } /** * ListAvailableServices - Load music service list as xml * @remarks Some libraries also support ListAndParseAvailableServices - * @returns {Object} response object, with these properties 'AvailableServiceDescriptorList', 'AvailableServiceTypeList', 'AvailableServiceListVersion' + * @returns {Promise} response object, with these properties `AvailableServiceDescriptorList`, `AvailableServiceTypeList`, `AvailableServiceListVersion` */ async ListAvailableServices () { return this._request('ListAvailableServices') } /** * UpdateAvailableServices + * @returns {Promise} request succeeded */ async UpdateAvailableServices () { return this._request('UpdateAvailableServices') } // #endregion diff --git a/lib/services/q-play.service.js b/lib/services/q-play.service.js index 8c39ad67..7033c3ef 100644 --- a/lib/services/q-play.service.js +++ b/lib/services/q-play.service.js @@ -11,6 +11,11 @@ const Service = require('./Service') * @extends {Service} */ class QPlayService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ constructor (host, port) { super() this.name = 'QPlay' @@ -27,7 +32,7 @@ class QPlayService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.Seed - * @returns {Object} response object, with these properties 'Code', 'MID', 'DID' + * @returns {Promise} response object, with these properties `Code`, `MID`, `DID` */ async QPlayAuth (options) { return this._request('QPlayAuth', options) } // #endregion diff --git a/lib/services/queue.service.js b/lib/services/queue.service.js index 1e15fd4c..ad4e8da9 100644 --- a/lib/services/queue.service.js +++ b/lib/services/queue.service.js @@ -11,6 +11,11 @@ const Service = require('./Service') * @extends {Service} */ class QueueService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ constructor (host, port) { super() this.name = 'Queue' @@ -34,7 +39,7 @@ class QueueService extends Service { * @param {boolean} options.EnqueueAsNext * @param {number} options.NumberOfURIs * @param {string} options.EnqueuedURIsAndMetaData - * @returns {Object} response object, with these properties 'FirstTrackNumberEnqueued', 'NumTracksAdded', 'NewQueueLength', 'NewUpdateID' + * @returns {Promise} response object, with these properties `FirstTrackNumberEnqueued`, `NumTracksAdded`, `NewQueueLength`, `NewUpdateID` */ async AddMultipleURIs (options) { return this._request('AddMultipleURIs', options) } @@ -48,7 +53,7 @@ class QueueService extends Service { * @param {string} options.EnqueuedURIMetaData * @param {number} options.DesiredFirstTrackNumberEnqueued * @param {boolean} options.EnqueueAsNext - * @returns {Object} response object, with these properties 'FirstTrackNumberEnqueued', 'NumTracksAdded', 'NewQueueLength', 'NewUpdateID' + * @returns {Promise} response object, with these properties `FirstTrackNumberEnqueued`, `NumTracksAdded`, `NewQueueLength`, `NewUpdateID` */ async AddURI (options) { return this._request('AddURI', options) } @@ -57,12 +62,13 @@ class QueueService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.QueueOwnerID - * @returns {Object} response object, with these properties 'QueueID', 'QueueOwnerContext' + * @returns {Promise} response object, with these properties `QueueID`, `QueueOwnerContext` */ async AttachQueue (options) { return this._request('AttachQueue', options) } /** * Backup + * @returns {Promise} request succeeded */ async Backup () { return this._request('Backup') } @@ -73,7 +79,7 @@ class QueueService extends Service { * @param {number} options.QueueID * @param {number} options.StartingIndex * @param {number} options.RequestedCount - * @returns {Object} response object, with these properties 'Result', 'NumberReturned', 'TotalMatches', 'UpdateID' + * @returns {Promise} response object, with these properties `Result`, `NumberReturned`, `TotalMatches`, `UpdateID` */ async Browse (options) { return this._request('Browse', options) } @@ -84,7 +90,7 @@ class QueueService extends Service { * @param {string} options.QueueOwnerID * @param {string} options.QueueOwnerContext * @param {string} options.QueuePolicy - * @returns {Object} response object, with these properties 'QueueID' + * @returns {Promise} response object, with these properties `QueueID` */ async CreateQueue (options) { return this._request('CreateQueue', options) } @@ -94,7 +100,7 @@ class QueueService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.QueueID * @param {number} options.UpdateID - * @returns {Object} response object, with these properties 'NewUpdateID' + * @returns {Promise} response object, with these properties `NewUpdateID` */ async RemoveAllTracks (options) { return this._request('RemoveAllTracks', options) } @@ -106,7 +112,7 @@ class QueueService extends Service { * @param {number} options.UpdateID * @param {number} options.StartingIndex * @param {number} options.NumberOfTracks - * @returns {Object} response object, with these properties 'NewUpdateID' + * @returns {Promise} response object, with these properties `NewUpdateID` */ async RemoveTrackRange (options) { return this._request('RemoveTrackRange', options) } @@ -119,7 +125,7 @@ class QueueService extends Service { * @param {number} options.NumberOfTracks * @param {number} options.InsertBefore * @param {number} options.UpdateID - * @returns {Object} response object, with these properties 'NewUpdateID' + * @returns {Promise} response object, with these properties `NewUpdateID` */ async ReorderTracks (options) { return this._request('ReorderTracks', options) } @@ -135,7 +141,7 @@ class QueueService extends Service { * @param {string} options.NewCurrentTrackIndices * @param {number} options.NumberOfURIs * @param {string} options.EnqueuedURIsAndMetaData - * @returns {Object} response object, with these properties 'NewQueueLength', 'NewUpdateID' + * @returns {Promise} response object, with these properties `NewQueueLength`, `NewUpdateID` */ async ReplaceAllTracks (options) { return this._request('ReplaceAllTracks', options) } @@ -146,7 +152,7 @@ class QueueService extends Service { * @param {number} options.QueueID * @param {string} options.Title * @param {string} options.ObjectID - * @returns {Object} response object, with these properties 'AssignedObjectID' + * @returns {Promise} response object, with these properties `AssignedObjectID` */ async SaveAsSonosPlaylist (options) { return this._request('SaveAsSonosPlaylist', options) } // #endregion diff --git a/lib/services/rendering-control.service.js b/lib/services/rendering-control.service.js index a93ee60a..728baf32 100644 --- a/lib/services/rendering-control.service.js +++ b/lib/services/rendering-control.service.js @@ -11,6 +11,11 @@ const Service = require('./Service') * @extends {Service} */ class RenderingControlService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ constructor (host, port) { super() this.name = 'RenderingControl' @@ -27,7 +32,7 @@ class RenderingControlService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Object} response object, with these properties 'CurrentBass' + * @returns {Promise} response object, with these properties `CurrentBass` */ async GetBass (options = { InstanceID: 0 }) { return this._request('GetBass', options) } @@ -38,7 +43,7 @@ class RenderingControlService extends Service { * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.EQType - Allowed values `DialogLevel` (bool) / `MusicSurroundLevel` (-15/+15) / `NightMode` (bool) / `SubGain` (-10/+10) / `SurroundEnable` (bool) / `SurroundLevel` (-15/+15) / `SurroundMode` (0 = full, 1 = ambient) * @remarks Not all EQ types are available on every speaker - * @returns {Object} response object, with these properties 'CurrentValue' + * @returns {Promise} response object, with these properties `CurrentValue` */ async GetEQ (options) { return this._request('GetEQ', options) } @@ -47,7 +52,7 @@ class RenderingControlService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Object} response object, with these properties 'CurrentHeadphoneConnected' + * @returns {Promise} response object, with these properties `CurrentHeadphoneConnected` */ async GetHeadphoneConnected (options = { InstanceID: 0 }) { return this._request('GetHeadphoneConnected', options) } @@ -57,7 +62,7 @@ class RenderingControlService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] - * @returns {Object} response object, with these properties 'CurrentLoudness' + * @returns {Promise} response object, with these properties `CurrentLoudness` */ async GetLoudness (options) { return this._request('GetLoudness', options) } @@ -67,7 +72,7 @@ class RenderingControlService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' / 'SpeakerOnly' ] - * @returns {Object} response object, with these properties 'CurrentMute' + * @returns {Promise} response object, with these properties `CurrentMute` */ async GetMute (options) { return this._request('GetMute', options) } @@ -76,7 +81,7 @@ class RenderingControlService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Object} response object, with these properties 'CurrentFixed' + * @returns {Promise} response object, with these properties `CurrentFixed` */ async GetOutputFixed (options = { InstanceID: 0 }) { return this._request('GetOutputFixed', options) } @@ -85,7 +90,7 @@ class RenderingControlService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Object} response object, with these properties 'RoomCalibrationEnabled', 'RoomCalibrationAvailable' + * @returns {Promise} response object, with these properties `RoomCalibrationEnabled`, `RoomCalibrationAvailable` */ async GetRoomCalibrationStatus (options = { InstanceID: 0 }) { return this._request('GetRoomCalibrationStatus', options) } @@ -94,7 +99,7 @@ class RenderingControlService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Object} response object, with these properties 'CurrentSupportsFixed' + * @returns {Promise} response object, with these properties `CurrentSupportsFixed` */ async GetSupportsOutputFixed (options = { InstanceID: 0 }) { return this._request('GetSupportsOutputFixed', options) } @@ -103,7 +108,7 @@ class RenderingControlService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Object} response object, with these properties 'CurrentTreble' + * @returns {Promise} response object, with these properties `CurrentTreble` */ async GetTreble (options = { InstanceID: 0 }) { return this._request('GetTreble', options) } @@ -113,7 +118,7 @@ class RenderingControlService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] - * @returns {Object} response object, with these properties 'CurrentVolume' + * @returns {Promise} response object, with these properties `CurrentVolume` */ async GetVolume (options) { return this._request('GetVolume', options) } @@ -123,7 +128,7 @@ class RenderingControlService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] - * @returns {Object} response object, with these properties 'CurrentVolume' + * @returns {Promise} response object, with these properties `CurrentVolume` */ async GetVolumeDB (options) { return this._request('GetVolumeDB', options) } @@ -133,7 +138,7 @@ class RenderingControlService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] - * @returns {Object} response object, with these properties 'MinValue', 'MaxValue' + * @returns {Promise} response object, with these properties `MinValue`, `MaxValue` */ async GetVolumeDBRange (options) { return this._request('GetVolumeDBRange', options) } @@ -147,7 +152,7 @@ class RenderingControlService extends Service { * @param {number} options.DesiredVolume * @param {boolean} options.ResetVolumeAfter * @param {string} options.ProgramURI - * @returns {Object} response object, with these properties 'RampTime' + * @returns {Promise} response object, with these properties `RampTime` */ async RampToVolume (options) { return this._request('RampToVolume', options) } @@ -156,7 +161,7 @@ class RenderingControlService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Object} response object, with these properties 'Bass', 'Treble', 'Loudness', 'LeftVolume', 'RightVolume' + * @returns {Promise} response object, with these properties `Bass`, `Treble`, `Loudness`, `LeftVolume`, `RightVolume` */ async ResetBasicEQ (options = { InstanceID: 0 }) { return this._request('ResetBasicEQ', options) } @@ -166,6 +171,7 @@ class RenderingControlService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.EQType + * @returns {Promise} request succeeded */ async ResetExtEQ (options) { return this._request('ResetExtEQ', options) } @@ -175,6 +181,7 @@ class RenderingControlService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] + * @returns {Promise} request succeeded */ async RestoreVolumePriorToRamp (options) { return this._request('RestoreVolumePriorToRamp', options) } @@ -184,6 +191,7 @@ class RenderingControlService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @param {number} options.DesiredBass + * @returns {Promise} request succeeded */ async SetBass (options) { return this._request('SetBass', options) } @@ -193,6 +201,7 @@ class RenderingControlService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.ChannelMap + * @returns {Promise} request succeeded */ async SetChannelMap (options) { return this._request('SetChannelMap', options) } @@ -204,6 +213,7 @@ class RenderingControlService extends Service { * @param {string} options.EQType - Allowed values `DialogLevel` (bool) / `MusicSurroundLevel` (-15/+15) / `NightMode` (bool) / `SubGain` (-10/+10) / `SurroundEnable` (bool) / `SurroundLevel` (-15/+15) / `SurroundMode` (0 = full, 1 = ambient) * @param {number} options.DesiredValue - Booleans required `1` for true or `0` for false, rest number as specified * @remarks Not supported by all speakers, TV related + * @returns {Promise} request succeeded */ async SetEQ (options) { return this._request('SetEQ', options) } @@ -214,6 +224,7 @@ class RenderingControlService extends Service { * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] * @param {boolean} options.DesiredLoudness + * @returns {Promise} request succeeded */ async SetLoudness (options) { return this._request('SetLoudness', options) } @@ -224,6 +235,7 @@ class RenderingControlService extends Service { * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' / 'SpeakerOnly' ] * @param {boolean} options.DesiredMute + * @returns {Promise} request succeeded */ async SetMute (options) { return this._request('SetMute', options) } @@ -233,6 +245,7 @@ class RenderingControlService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @param {boolean} options.DesiredFixed + * @returns {Promise} request succeeded */ async SetOutputFixed (options) { return this._request('SetOutputFixed', options) } @@ -243,7 +256,7 @@ class RenderingControlService extends Service { * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] * @param {number} options.Adjustment - * @returns {Object} response object, with these properties 'NewVolume' + * @returns {Promise} response object, with these properties `NewVolume` */ async SetRelativeVolume (options) { return this._request('SetRelativeVolume', options) } @@ -253,6 +266,7 @@ class RenderingControlService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @param {boolean} options.RoomCalibrationEnabled + * @returns {Promise} request succeeded */ async SetRoomCalibrationStatus (options) { return this._request('SetRoomCalibrationStatus', options) } @@ -264,6 +278,7 @@ class RenderingControlService extends Service { * @param {string} options.CalibrationID * @param {string} options.Coefficients * @param {string} options.CalibrationMode + * @returns {Promise} request succeeded */ async SetRoomCalibrationX (options) { return this._request('SetRoomCalibrationX', options) } @@ -273,6 +288,7 @@ class RenderingControlService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @param {number} options.DesiredTreble - between -10 and 10 + * @returns {Promise} request succeeded */ async SetTreble (options) { return this._request('SetTreble', options) } @@ -283,6 +299,7 @@ class RenderingControlService extends Service { * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] * @param {number} options.DesiredVolume + * @returns {Promise} request succeeded */ async SetVolume (options) { return this._request('SetVolume', options) } @@ -293,6 +310,7 @@ class RenderingControlService extends Service { * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] * @param {number} options.DesiredVolume + * @returns {Promise} request succeeded */ async SetVolumeDB (options) { return this._request('SetVolumeDB', options) } // #endregion diff --git a/lib/services/system-properties.service.js b/lib/services/system-properties.service.js index 6db9ebcb..031f3f69 100644 --- a/lib/services/system-properties.service.js +++ b/lib/services/system-properties.service.js @@ -11,6 +11,11 @@ const Service = require('./Service') * @extends {Service} */ class SystemPropertiesService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ constructor (host, port) { super() this.name = 'SystemProperties' @@ -29,7 +34,7 @@ class SystemPropertiesService extends Service { * @param {number} options.AccountType * @param {string} options.AccountID * @param {string} options.AccountPassword - * @returns {Object} response object, with these properties 'AccountUDN' + * @returns {Promise} response object, with these properties `AccountUDN` */ async AddAccountX (options) { return this._request('AddAccountX', options) } @@ -45,12 +50,13 @@ class SystemPropertiesService extends Service { * @param {string} options.RedirectURI * @param {string} options.UserIdHashCode * @param {number} options.AccountTier - * @returns {Object} response object, with these properties 'AccountUDN', 'AccountNickname' + * @returns {Promise} response object, with these properties `AccountUDN`, `AccountNickname` */ async AddOAuthAccountX (options) { return this._request('AddOAuthAccountX', options) } /** * DoPostUpdateTasks + * @returns {Promise} request succeeded */ async DoPostUpdateTasks () { return this._request('DoPostUpdateTasks') } @@ -61,6 +67,7 @@ class SystemPropertiesService extends Service { * @param {number} options.AccountType * @param {string} options.AccountID * @param {string} options.NewAccountMd + * @returns {Promise} request succeeded */ async EditAccountMd (options) { return this._request('EditAccountMd', options) } @@ -71,6 +78,7 @@ class SystemPropertiesService extends Service { * @param {number} options.AccountType * @param {string} options.AccountID * @param {string} options.NewAccountPassword + * @returns {Promise} request succeeded */ async EditAccountPasswordX (options) { return this._request('EditAccountPasswordX', options) } @@ -79,12 +87,13 @@ class SystemPropertiesService extends Service { * * @param {Object} [options] - An object with the following properties * @param {boolean} options.RDMValue + * @returns {Promise} request succeeded */ async EnableRDM (options) { return this._request('EnableRDM', options) } /** * GetRDM - * @returns {Object} response object, with these properties 'RDMValue' + * @returns {Promise} response object, with these properties `RDMValue` */ async GetRDM () { return this._request('GetRDM') } @@ -94,7 +103,7 @@ class SystemPropertiesService extends Service { * @param {Object} [options] - An object with the following properties * @param {string} options.VariableName - The key for this variable * @remarks Strings are saved in the system with SetString, every speaker should return the same data. Will error when not existing - * @returns {Object} response object, with these properties 'StringValue' + * @returns {Promise} response object, with these properties `StringValue` */ async GetString (options) { return this._request('GetString', options) } @@ -103,7 +112,7 @@ class SystemPropertiesService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.AccountType - * @returns {Object} response object, with these properties 'WebCode' + * @returns {Promise} response object, with these properties `WebCode` */ async GetWebCode (options) { return this._request('GetWebCode', options) } @@ -114,7 +123,7 @@ class SystemPropertiesService extends Service { * @param {number} options.AccountType * @param {string} options.AccountID * @param {string} options.AccountPassword - * @returns {Object} response object, with these properties 'IsExpired', 'AccountUDN' + * @returns {Promise} response object, with these properties `IsExpired`, `AccountUDN` */ async ProvisionCredentialedTrialAccountX (options) { return this._request('ProvisionCredentialedTrialAccountX', options) } @@ -126,6 +135,7 @@ class SystemPropertiesService extends Service { * @param {number} options.AccountUID * @param {string} options.AccountToken * @param {string} options.AccountKey + * @returns {Promise} request succeeded */ async RefreshAccountCredentialsX (options) { return this._request('RefreshAccountCredentialsX', options) } @@ -135,6 +145,7 @@ class SystemPropertiesService extends Service { * @param {Object} [options] - An object with the following properties * @param {string} options.VariableName - The key for this variable * @remarks Not sure what happens if you call this with a VariableName that doesn't exists. + * @returns {Promise} request succeeded */ async Remove (options) { return this._request('Remove', options) } @@ -144,6 +155,7 @@ class SystemPropertiesService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.AccountType * @param {string} options.AccountID + * @returns {Promise} request succeeded */ async RemoveAccount (options) { return this._request('RemoveAccount', options) } @@ -157,12 +169,13 @@ class SystemPropertiesService extends Service { * @param {string} options.AccountToken * @param {string} options.AccountKey * @param {string} options.OAuthDeviceID - * @returns {Object} response object, with these properties 'NewAccountUDN' + * @returns {Promise} response object, with these properties `NewAccountUDN` */ async ReplaceAccountX (options) { return this._request('ReplaceAccountX', options) } /** * ResetThirdPartyCredentials + * @returns {Promise} request succeeded */ async ResetThirdPartyCredentials () { return this._request('ResetThirdPartyCredentials') } @@ -172,6 +185,7 @@ class SystemPropertiesService extends Service { * @param {Object} [options] - An object with the following properties * @param {string} options.AccountUDN * @param {string} options.AccountNickname + * @returns {Promise} request succeeded */ async SetAccountNicknameX (options) { return this._request('SetAccountNicknameX', options) } @@ -182,6 +196,7 @@ class SystemPropertiesService extends Service { * @param {string} options.VariableName - The key for this variable, use something unique * @param {string} options.StringValue * @remarks Strings are saved in the system, retrieve values with GetString. + * @returns {Promise} request succeeded */ async SetString (options) { return this._request('SetString', options) } // #endregion diff --git a/lib/services/virtual-line-in.service.js b/lib/services/virtual-line-in.service.js index 64d55c0f..bf29d74e 100644 --- a/lib/services/virtual-line-in.service.js +++ b/lib/services/virtual-line-in.service.js @@ -9,6 +9,11 @@ const Service = require('./Service') * @extends {Service} */ class VirtualLineInService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ constructor (host, port) { super() this.name = 'VirtualLineIn' @@ -25,6 +30,7 @@ class VirtualLineInService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID + * @returns {Promise} request succeeded */ async Next (options = { InstanceID: 0 }) { return this._request('Next', options) } @@ -33,6 +39,7 @@ class VirtualLineInService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID + * @returns {Promise} request succeeded */ async Pause (options = { InstanceID: 0 }) { return this._request('Pause', options) } @@ -42,6 +49,7 @@ class VirtualLineInService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID * @param {string} options.Speed + * @returns {Promise} request succeeded */ async Play (options) { return this._request('Play', options) } @@ -50,6 +58,7 @@ class VirtualLineInService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID + * @returns {Promise} request succeeded */ async Previous (options = { InstanceID: 0 }) { return this._request('Previous', options) } @@ -59,6 +68,7 @@ class VirtualLineInService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID * @param {number} options.DesiredVolume + * @returns {Promise} request succeeded */ async SetVolume (options) { return this._request('SetVolume', options) } @@ -68,7 +78,7 @@ class VirtualLineInService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID * @param {string} options.CoordinatorID - * @returns {Object} response object, with these properties 'CurrentTransportSettings' + * @returns {Promise} response object, with these properties `CurrentTransportSettings` */ async StartTransmission (options) { return this._request('StartTransmission', options) } @@ -77,6 +87,7 @@ class VirtualLineInService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID + * @returns {Promise} request succeeded */ async Stop (options = { InstanceID: 0 }) { return this._request('Stop', options) } @@ -86,6 +97,7 @@ class VirtualLineInService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID * @param {string} options.CoordinatorID + * @returns {Promise} request succeeded */ async StopTransmission (options) { return this._request('StopTransmission', options) } // #endregion diff --git a/lib/services/zone-group-topology.service.js b/lib/services/zone-group-topology.service.js index a3996baf..61854ce5 100644 --- a/lib/services/zone-group-topology.service.js +++ b/lib/services/zone-group-topology.service.js @@ -11,6 +11,11 @@ const Service = require('./Service') * @extends {Service} */ class ZoneGroupTopologyService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ constructor (host, port) { super() this.name = 'ZoneGroupTopology' @@ -29,6 +34,7 @@ class ZoneGroupTopologyService extends Service { * @param {string} options.UpdateURL * @param {number} options.Flags * @param {string} options.ExtraOptions + * @returns {Promise} request succeeded */ async BeginSoftwareUpdate (options) { return this._request('BeginSoftwareUpdate', options) } @@ -39,20 +45,20 @@ class ZoneGroupTopologyService extends Service { * @param {string} options.UpdateType [ 'All' / 'Software' ] * @param {boolean} options.CachedOnly * @param {string} options.Version - * @returns {Object} response object, with these properties 'UpdateItem' + * @returns {Promise} response object, with these properties `UpdateItem` */ async CheckForUpdate (options) { return this._request('CheckForUpdate', options) } /** * GetZoneGroupAttributes - Get information about the current Zone - * @returns {Object} response object, with these properties 'CurrentZoneGroupName', 'CurrentZoneGroupID', 'CurrentZonePlayerUUIDsInGroup', 'CurrentMuseHouseholdId' + * @returns {Promise} response object, with these properties `CurrentZoneGroupName`, `CurrentZoneGroupID`, `CurrentZonePlayerUUIDsInGroup`, `CurrentMuseHouseholdId` */ async GetZoneGroupAttributes () { return this._request('GetZoneGroupAttributes') } /** * GetZoneGroupState - Get all the Sonos groups, (as XML) * @remarks Some libraries also support GetParsedZoneGroupState that parses the xml for you. - * @returns {Object} response object, with these properties 'ZoneGroupState' + * @returns {Promise} response object, with these properties `ZoneGroupState` */ async GetZoneGroupState () { return this._request('GetZoneGroupState') } @@ -63,11 +69,13 @@ class ZoneGroupTopologyService extends Service { * @param {string} options.MobileDeviceName * @param {string} options.MobileDeviceUDN * @param {string} options.MobileIPAndPort + * @returns {Promise} request succeeded */ async RegisterMobileDevice (options) { return this._request('RegisterMobileDevice', options) } /** * ReportAlarmStartedRunning + * @returns {Promise} request succeeded */ async ReportAlarmStartedRunning () { return this._request('ReportAlarmStartedRunning') } @@ -77,6 +85,7 @@ class ZoneGroupTopologyService extends Service { * @param {Object} [options] - An object with the following properties * @param {string} options.DeviceUUID * @param {string} options.DesiredAction [ 'Remove' / 'TopologyMonitorProbe' / 'VerifyThenRemoveSystemwide' ] + * @returns {Promise} request succeeded */ async ReportUnresponsiveDevice (options) { return this._request('ReportUnresponsiveDevice', options) } @@ -86,7 +95,7 @@ class ZoneGroupTopologyService extends Service { * @param {Object} [options] - An object with the following properties * @param {boolean} options.IncludeControllers * @param {string} options.Type - * @returns {Object} response object, with these properties 'DiagnosticID' + * @returns {Promise} response object, with these properties `DiagnosticID` */ async SubmitDiagnostics (options) { return this._request('SubmitDiagnostics', options) } // #endregion From 0272cbbfbc3039256ca0fc58c5c0d1e64ec02a42 Mon Sep 17 00:00:00 2001 From: Stephan van Rooij <1292510+svrooij@users.noreply.github.com> Date: Thu, 30 Sep 2021 00:42:16 +0200 Subject: [PATCH 4/6] fix: Generated types (first version) Related to #512 --- types/index.d.ts | 2 + types/lib/asyncDeviceDiscovery.d.ts | 9 + types/lib/deviceDiscovery.d.ts | 32 + types/lib/events/adv-listener.d.ts | 38 ++ types/lib/events/eventParser.d.ts | 43 ++ types/lib/helpers.d.ts | 88 +++ types/lib/services/AVTransport.d.ts | 153 +++++ types/lib/services/AlarmClock.d.ts | 98 +++ types/lib/services/AudioIn.d.ts | 18 + types/lib/services/ContentDirectory.d.ts | 43 ++ types/lib/services/DeviceProperties.d.ts | 76 +++ types/lib/services/GroupManagement.d.ts | 14 + types/lib/services/GroupRenderingControl.d.ts | 17 + types/lib/services/MusicServices.d.ts | 14 + types/lib/services/RenderingControl.d.ts | 77 +++ types/lib/services/Service.d.ts | 36 + types/lib/services/SystemProperties.d.ts | 28 + types/lib/services/ZoneGroupTopology.d.ts | 28 + types/lib/services/alarm-clock.service.d.ts | 202 ++++++ types/lib/services/all-services.d.ts | 148 ++++ types/lib/services/audio-in.service.d.ts | 85 +++ types/lib/services/av-transport.service.d.ts | 639 ++++++++++++++++++ .../services/connection-manager.service.d.ts | 41 ++ .../services/content-directory.service.d.ts | 165 +++++ .../services/device-properties.service.d.ts | 281 ++++++++ .../services/group-management.service.d.ts | 65 ++ .../group-rendering-control.service.d.ts | 93 +++ types/lib/services/ht-control.service.d.ts | 88 +++ .../lib/services/music-services.service.d.ts | 44 ++ types/lib/services/q-play.service.d.ts | 31 + types/lib/services/queue.service.d.ts | 192 ++++++ .../services/rendering-control.service.d.ts | 369 ++++++++++ .../services/system-properties.service.d.ts | 231 +++++++ .../lib/services/virtual-line-in.service.d.ts | 107 +++ .../services/zone-group-topology.service.d.ts | 103 +++ types/lib/sonos.d.ts | 393 +++++++++++ types/lib/sonosGroup.d.ts | 11 + 37 files changed, 4102 insertions(+) create mode 100644 types/index.d.ts create mode 100644 types/lib/asyncDeviceDiscovery.d.ts create mode 100644 types/lib/deviceDiscovery.d.ts create mode 100644 types/lib/events/adv-listener.d.ts create mode 100644 types/lib/events/eventParser.d.ts create mode 100644 types/lib/helpers.d.ts create mode 100644 types/lib/services/AVTransport.d.ts create mode 100644 types/lib/services/AlarmClock.d.ts create mode 100644 types/lib/services/AudioIn.d.ts create mode 100644 types/lib/services/ContentDirectory.d.ts create mode 100644 types/lib/services/DeviceProperties.d.ts create mode 100644 types/lib/services/GroupManagement.d.ts create mode 100644 types/lib/services/GroupRenderingControl.d.ts create mode 100644 types/lib/services/MusicServices.d.ts create mode 100644 types/lib/services/RenderingControl.d.ts create mode 100644 types/lib/services/Service.d.ts create mode 100644 types/lib/services/SystemProperties.d.ts create mode 100644 types/lib/services/ZoneGroupTopology.d.ts create mode 100644 types/lib/services/alarm-clock.service.d.ts create mode 100644 types/lib/services/all-services.d.ts create mode 100644 types/lib/services/audio-in.service.d.ts create mode 100644 types/lib/services/av-transport.service.d.ts create mode 100644 types/lib/services/connection-manager.service.d.ts create mode 100644 types/lib/services/content-directory.service.d.ts create mode 100644 types/lib/services/device-properties.service.d.ts create mode 100644 types/lib/services/group-management.service.d.ts create mode 100644 types/lib/services/group-rendering-control.service.d.ts create mode 100644 types/lib/services/ht-control.service.d.ts create mode 100644 types/lib/services/music-services.service.d.ts create mode 100644 types/lib/services/q-play.service.d.ts create mode 100644 types/lib/services/queue.service.d.ts create mode 100644 types/lib/services/rendering-control.service.d.ts create mode 100644 types/lib/services/system-properties.service.d.ts create mode 100644 types/lib/services/virtual-line-in.service.d.ts create mode 100644 types/lib/services/zone-group-topology.service.d.ts create mode 100644 types/lib/sonos.d.ts create mode 100644 types/lib/sonosGroup.d.ts diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 00000000..c069e9fc --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,2 @@ +declare const _exports: typeof import("./lib/sonos"); +export = _exports; diff --git a/types/lib/asyncDeviceDiscovery.d.ts b/types/lib/asyncDeviceDiscovery.d.ts new file mode 100644 index 00000000..c6fd5ebb --- /dev/null +++ b/types/lib/asyncDeviceDiscovery.d.ts @@ -0,0 +1,9 @@ +export = AsyncDeviceDiscovery; +declare class AsyncDeviceDiscovery { + discover(options?: { + timeout: number; + }): Promise; + discoverMultiple(options?: { + timeout: number; + }): Promise; +} diff --git a/types/lib/deviceDiscovery.d.ts b/types/lib/deviceDiscovery.d.ts new file mode 100644 index 00000000..3bb2d5ba --- /dev/null +++ b/types/lib/deviceDiscovery.d.ts @@ -0,0 +1,32 @@ +/// +export = deviceDiscovery; +/** + * Create a DeviceDiscovery Instance (emits 'DeviceAvailable' with a found Sonos Component) + * @param {Object} options Optional Options to control search behavior. + * Set 'timeout' to how long to search for devices + * (in milliseconds). + * Set 'port' to use a specific inbound UDP port, + * rather than a randomly assigned one + * @param {Function} listener Optional 'DeviceAvailable' listener (sonos) + * @return {DeviceDiscovery} + */ +declare function deviceDiscovery(options: any, listener: Function): DeviceDiscovery; +/** + * Create a new instance of DeviceDiscovery + * @class DeviceDiscovery + * @emits 'DeviceAvailable' on a Sonos Component Discovery + */ +declare class DeviceDiscovery extends EventEmitter { + constructor(options: any); + foundSonosDevices: {}; + socket: dgram.Socket; + searchTimer: NodeJS.Timeout; + onTimeout(): void; + sendDiscover(): void; + pollTimer: NodeJS.Timeout; + sendDiscoveryOnAddress(address: any): void; + destroy(): void; +} +import EventEmitter_1 = require("events"); +import EventEmitter = EventEmitter_1.EventEmitter; +import dgram = require("dgram"); diff --git a/types/lib/events/adv-listener.d.ts b/types/lib/events/adv-listener.d.ts new file mode 100644 index 00000000..bba36007 --- /dev/null +++ b/types/lib/events/adv-listener.d.ts @@ -0,0 +1,38 @@ +/// +export = defaultListener; +declare const defaultListener: SonosListener; +/** + * An event listener for sonos events. (Just a small http server) + * @class SonosListener + */ +declare class SonosListener extends EventEmitter { + /** + * Creates a new SonosListener (called automatically) + */ + constructor(); + port: number; + _listening: boolean; + _deviceSubscriptions: any[]; + _requestHandler: (req: any, resp: any) => void; + _eventServer: http.Server; + /** + * Start the listener, has to be called before subscribing + */ + startListener(): void; + /** + * Stop the listener and unsubscribes for all events. + * Very important to call or you'll get wrong notifications + */ + stopListener(): Promise; + isListening(): boolean; + /** + * Subscribe to all events for this device. + * @param {Sonos} device Pass in the Sonos device, it will be the eventemitter + */ + subscribeTo(device: any): Promise; + _handleMessage(req: any, resp: any, body: any): void; + _handleGlobalNotification(endpoint: any, body: any): Promise; +} +import EventEmitter_1 = require("events"); +import EventEmitter = EventEmitter_1.EventEmitter; +import http = require("http"); diff --git a/types/lib/events/eventParser.d.ts b/types/lib/events/eventParser.d.ts new file mode 100644 index 00000000..b6990149 --- /dev/null +++ b/types/lib/events/eventParser.d.ts @@ -0,0 +1,43 @@ +export function ParseAndEmitEvents(endpoint: any, body: any, device: any): Promise<{ + name: string; + eventBody: any; +}>; +export function _parseAvTransportEvent(body: any, device: any): Promise<{ + name: string; + eventBody: any; +}>; +export function _parseRenderingControlEvent(body: any, device: any): Promise<{ + name: string; + eventBody: any; +}>; +export function _genericEvent(endpoint: any, body: any, device: any): { + name: string; + endpoint: any; + eventBody: any; +}; +export function _parseContentDirectoryEvent(body: any, device: any): { + name: string; + eventBody: any; +}; +export function _parseAlarmEvent(body: any, device: any): { + name: string; + eventBody: any; +}; +export function _parseZoneGroupTopologyEvent(body: any, device: any): Promise<{ + name: string; + eventBody: { + Zones: any; + }; +}>; +export function _parseGroupRenderingControlEvent(body: any, device: any): { + name: string; + eventBody: any; + device: { + host: any; + port: any; + }; +}; +export function _parseQueueEvent(body: any, device: any): Promise<{ + name: string; + eventBody: any; +}>; diff --git a/types/lib/helpers.d.ts b/types/lib/helpers.d.ts new file mode 100644 index 00000000..7dfbeef5 --- /dev/null +++ b/types/lib/helpers.d.ts @@ -0,0 +1,88 @@ +/** + * Wrap in UPnP Envelope + * @param {String} body The SOAP body. + * @return {String} + */ +export function CreateSoapEnvelop(body: string): string; +/** + * Encodes characters not allowed within html/xml tags, for use with nester xml. + * @param {String} input + * @return {String} + */ +export function EncodeXml(input: string): string; +/** + * Converts parentID to upnp cass + * @param {String} parentID The id of the parent + * @return {String} object.item.audioItem.musicTrack + */ +export function GetUpnpClass(parentID: string): string; +/** + * Generate custom metadata, to be used with the play and/or setAVTransportURI + * @param {String} streamUri The playback uri + * @param {String} itemId + * @param {String} duration The duration of the song, as 'hh:mm:ss' + * @param {String} title The title of the song + * @param {String} artist The artist of the sons + * @param {String} album the album of the song + * @param {String} coverUrl the coverUrl of the song + * @param {String} parentId the parentId of the song + */ +export function GenerateCustomMetadata(streamUrl: any, itemId: string, duration: string, title: string, artist: string, album: string, coverUrl: string, parentId: string): string; +/** + * Creates object with uri and metadata from playback uri + * @param {String} uri The playback uri + * @param {String} artUri Uri for art image + * @return {Object} { uri: uri, metadata: metadata } + */ +export function GenerateLocalMetadata(uri: string, artUri?: string): any; +/** + * Creates object with uri and metadata from playback uri + * @param {String} uri The playback uri (currently supports spotify, tunein) + * @param {String} title Sometimes the title is required. + * @param {String} region Spotify region is required for all spotify tracks, see `sonos.SpotifyRegion` + * @return {Object} options {uri: Spotify uri, metadata: metadata} + */ +export function GenerateMetadata(uri: string, title?: string, region?: string): any; +/** + * Parse DIDL into track structure + * @param {String} didl + * @param {String} host host ip + * @param {Number} port port numer + * @param {String} trackUri Track Uri + * @return {object} + */ +export function ParseDIDL(didl: string, host: string, port: number, trackUri: string): any; +export function dropIDNamespace(value: any): any; +export function ParseDIDLItem(item: any, host: any, port: any, trackUri: any): { + id: any; + parentID: any; + title: any; + artist: any; + album: any; + albumArtist: any; + albumArtURI: any; +}; +/** + * Convert a time string to seconds + * @param {String} time like `00:03:34` + * @returns {Number} number of seconds like 214 + */ +export function TimeToSeconds(time: string): number; +export function _ParseXml(input: any, callback: any): any; +/** + * Convert the playbackstate to a bit more readable + * @param {String} state Sonos playback state + */ +export function TranslateState(state: string): any; +/** + * Parse Xml to an object async + * @param {String} input The XML to be parsed + * @return {Promise} + */ +export function ParseXml(input: string): Promise; +/** + * Sanitizes Device Description XML async + * @param {String} input The XML to be sanitized + * @return {Promise} + */ +export function SanitizeDeviceDescriptionXml(input: string): Promise; diff --git a/types/lib/services/AVTransport.d.ts b/types/lib/services/AVTransport.d.ts new file mode 100644 index 00000000..f88de5fa --- /dev/null +++ b/types/lib/services/AVTransport.d.ts @@ -0,0 +1,153 @@ +export = AVTransport; +/** + * Create a new instance of AVTransport + * @class AVTransport + * @param {String} host The host param of one of your sonos speakers + * @param {Number} port The port of your sonos speaker, defaults to 1400 + */ +declare class AVTransport extends Service { + constructor(host: any, port: any); + /** + * Set the Transport URI + * @param {object} options Object with required options + * @param {number} options.InstanceID The instance you want to control is always `0` + * @param {string} options.CurrentURI The new URI you wish to set. + * @param {string} options.CurrentURIMetaData The metadata of the uri you wish to set. + * @returns {Promise} Parsed response data. + */ + SetAVTransportURI(options: { + InstanceID: number; + CurrentURI: string; + CurrentURIMetaData: string; + }): Promise; + /** + * Add an URI to the queue + * @param {object} options The the required properties + * @param {number} options.InstanceID The instance you want to control is always `0` + * @param {string} options.EnqueuedURI The URI of the track you want to add + * @param {string} options.EnqueuedURIMetaData The Metadata of the track you wish to add, see `Helpers.GenerateMetadata` + * @param {number} options.DesiredFirstTrackNumberEnqueued The position in the queue + * @param {number} options.EnqueueAsNext To Queue this item as the next item set to `1` + * @returns {Promise} Parsed response data. + */ + AddURIToQueue(options: { + InstanceID: number; + EnqueuedURI: string; + EnqueuedURIMetaData: string; + DesiredFirstTrackNumberEnqueued: number; + EnqueueAsNext: number; + }): Promise; + AddURIToSavedQueue(options: any): Promise; + AddMultipleURIsToQueue(options: any): Promise; + /** + * Reorder tracks in queue + * @param {object} options All the required options + * @param {number} options.InstanceID The instance you want to edit is always `0` + * @param {number} options.UpdateID The update id, not a clue what this means. Just specify `0` + * @param {number} options.StartingIndex The index of the first song you want to move. + * @param {number} options.NumberOfTracks How many tracks do you want to move? + * @param {number} options.InsertBefore Where should these tracks be inserted? + * @returns {Promise} Parsed response data. + */ + ReorderTracksInQueue(options: { + InstanceID: number; + UpdateID: number; + StartingIndex: number; + NumberOfTracks: number; + InsertBefore: number; + }): Promise; + ReorderTracksInSavedQueue(options: any): Promise; + /** + * Remove a single track from the queue + * @param {object} options Object with required options + * @param {number} options.InstanceID The instance you want to control is always `0` + * @param {string} options.ObjectID The object to remove + * @param {string} options.UpdateID The update id, not a clue what this means. Just specify `0` + * @returns {Promise} Parsed response data. + */ + RemoveTrackFromQueue(options: { + InstanceID: number; + ObjectID: string; + UpdateID: string; + }): Promise; + /** + * Remove a range of tracks from the queue + * @param {object} options Object with required options + * @param {number} options.InstanceID The instance you want to control is always `0` + * @param {number} options.UpdateID The update id, not a clue what this means. Just specify `0` + * @param {number} options.StartingIndex Index of the first song to remove + * @param {number} options.NumberOfTracks How many tracks to remove + * @returns {Promise} Parsed response data. + */ + RemoveTrackRangeFromQueue(options: { + InstanceID: number; + UpdateID: number; + StartingIndex: number; + NumberOfTracks: number; + }): Promise; + RemoveAllTracksFromQueue(): Promise; + SaveQueue(options: any): Promise; + CreateSavedQueue(title: any): Promise; + BackupQueue(options: any): Promise; + GetMediaInfo(): Promise; + GetTransportInfo(): Promise; + GetPositionInfo(): Promise; + GetDeviceCapabilities(): Promise; + GetTransportSettings(): Promise; + GetCrossfadeMode(): Promise; + Stop(): Promise; + Play(): Promise; + Pause(): Promise; + /** + * Skip to other track or time + * @param {object} options Object with required options + * @param {number} options.InstanceID The instance you want to control is always `0` + * @param {'TRACK_NR' | 'REL_TIME' | 'TIME_DELTA'} options.Unit One of these `TRACK_NR`, `REL_TIME`, `TIME_DELTA` + * @param {string | number} options.Target Skip to what track number, relative time as hh:mm:ss, or track number + */ + Seek(options: { + InstanceID: number; + Unit: 'TRACK_NR' | 'REL_TIME' | 'TIME_DELTA'; + Target: string | number; + }): Promise; + Next(): Promise; + NextProgrammedRadioTracks(): Promise; + Previous(): Promise; + NextSection(options: any): Promise; + PreviousSection(options: any): Promise; + /** + * Set the new playmode + * @param {string} playmode One of the following `NORMAL` `REPEAT_ALL` `SHUFFLE` `SHUFFLE_NOREPEAT` + * @returns {Promise} Parsed response data. + */ + SetPlayMode(playmode: string): Promise; + SetCrossfadeMode(options: any): Promise; + NotifyDeletedURI(options: any): Promise; + GetCurrentTransportActions(): Promise; + BecomeCoordinatorOfStandaloneGroup(): Promise; + DelegateGroupCoordinationTo(options: any): Promise; + BecomeGroupCoordinator(options: any): Promise; + BecomeGroupCoordinatorAndSource(options: any): Promise; + /** + * Configure a sleeptimer. + * @param {string} duration the duration as 'ISO8601Time', needs sample! + * @returns {Promise} Parsed response data. + */ + ConfigureSleepTimer(duration: string): Promise; + GetRemainingSleepTimerDuration(): Promise; + RunAlarm(options: any): Promise; + StartAutoplay(options: any): Promise; + GetRunningAlarmProperties(options: any): Promise; + /** + * Snooze the current running alarm for a number of minutes. + * @param {string} duration The duration, as 'ISO8601Time', needs sample! + * @returns {Promise} Parsed response data. + */ + SnoozeAlarm(duration: string): Promise; + /** + * Get information about the current track, parsed version of `GetPositionInfo()` + * @returns {Promise} The current playing track + */ + CurrentTrack(): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/AlarmClock.d.ts b/types/lib/services/AlarmClock.d.ts new file mode 100644 index 00000000..2f1bef55 --- /dev/null +++ b/types/lib/services/AlarmClock.d.ts @@ -0,0 +1,98 @@ +export = AlarmClock; +/** + * Create a new instance of AlarmClock + * @class AlarmClock + * @param {String} host The host param of one of your sonos speakers + * @param {Number} port The port of your sonos speaker, defaults to 1400 + */ +declare class AlarmClock extends Service { + constructor(host: any, port: any); + /** + * Create an alarm, but using the sonos app it advised (because you most likely cannot set the ProgramMetaData correctly) + * @param {Object} [options] An object with all the required settings + * @param {String} options.StartLocalTime Time string when you want the alarm to sound. + * @param {String} options.Duration How many minutes should the alarm sound. + * @param {String} options.Recurrance What should the recurrence be ['DAILY','ONCE','WEEKDAYS'] + * @param {String} options.Enabled Should the alarm be enabled ['1','0'] + * @param {String} options.RoomUUID The UUID of the room `RINCON_xxxxxxxxxxxx01400` + * @param {String} options.ProgramURI The programUri you want, this is the difficult part. `x-rincon-buzzer:0` for ringer + * @param {String} options.ProgramMetaData The metadata for the programURI, this is the hard part. + * @param {String} options.PlayMode The playmode ['??','SHUFFLE'] + * @param {String} options.Volume What should the volume be + * @param {String} options.IncludeLinkedZones Should linked zones be included? ['0', '1'] + * @returns {Promise} parsed response object + */ + CreateAlarm(options?: { + StartLocalTime: string; + Duration: string; + Recurrance: string; + Enabled: string; + RoomUUID: string; + ProgramURI: string; + ProgramMetaData: string; + PlayMode: string; + Volume: string; + IncludeLinkedZones: string; + }): Promise; + /** + * Delete an alarm + * @param {String} id the id of the alarm you want to delete + * @returns {Promise} parsed response object + */ + DestroyAlarm(id: string): Promise; + /** + * Get all the alarms known to sonos + * @return {Object} + */ + ListAlarms(): any; + /** + * Enable/disable an alarm + * @param {String} id the id of the alarm you want to set + * @param {Boolean} enabled Should the alarm be enabled or not + * @returns {Promise} parsed response object + */ + SetAlarm(id: string, enabled: boolean): Promise; + /** + * Update only some properties of an Alarm + * @param {String} id the id of the alarm you want to update + * @param {Object} [options] An object with the settings you wish to update + * @param {String?} options.StartLocalTime Time string when you want the alarm to sound. + * @param {String?} options.Duration How many minutes should the alarm sound. + * @param {String?} options.Recurrance What should the recurrence be ['DAILY','ONCE','WEEKDAYS'] + * @param {String?} options.Enabled Should the alarm be enabled ['1','0'] + * @param {String?} options.RoomUUID The UUID of the room `RINCON_xxxxxxxxxxxx01400` + * @param {String?} options.ProgramURI The programUri you want, this is the difficult part. `x-rincon-buzzer:0` for ringer + * @param {String?} options.ProgramMetaData The metadata for the programURI, this is the hard part. + * @param {String?} options.PlayMode The playmode ['??','SHUFFLE'] + * @param {String?} options.Volume What should the volume be + * @param {String?} options.IncludeLinkedZones Should linked zones be included? ['0', '1'] + * @returns {Promise} parsed response object + */ + PatchAlarm(id: string, options?: { + StartLocalTime: string | null; + Duration: string | null; + Recurrance: string | null; + Enabled: string | null; + RoomUUID: string | null; + ProgramURI: string | null; + ProgramMetaData: string | null; + PlayMode: string | null; + Volume: string | null; + IncludeLinkedZones: string | null; + }): Promise; + SetFormat(options: any): Promise; + GetFormat(options: any): Promise; + SetTimeZone(options: any): Promise; + GetTimeZone(options: any): Promise; + GetTimeZoneAndRule(options: any): Promise; + GetTimeZoneRule(options: any): Promise; + SetTimeServer(options: any): Promise; + GetTimeServer(options: any): Promise; + SetTimeNow(options: any): Promise; + GetHouseholdTimeAtStamp(options: any): Promise; + GetTimeNow(options: any): Promise; + UpdateAlarm(options: any): Promise; + SetDailyIndexRefreshTime(options: any): Promise; + GetDailyIndexRefreshTime(options: any): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/AudioIn.d.ts b/types/lib/services/AudioIn.d.ts new file mode 100644 index 00000000..93436914 --- /dev/null +++ b/types/lib/services/AudioIn.d.ts @@ -0,0 +1,18 @@ +export = AudioIn; +/** + * Create a new instance of AudioIn + * @class AudioIn + * @param {String} host The host param of one of your sonos speakers + * @param {Number} port The port of your sonos speaker, defaults to 1400 + */ +declare class AudioIn extends Service { + constructor(host: any, port: any); + StartTransmissionToGroup(options: any): Promise; + StopTransmissionToGroup(options: any): Promise; + SetAudioInputAttributes(options: any): Promise; + GetAudioInputAttributes(options: any): Promise; + SetLineInLevel(options: any): Promise; + GetLineInLevel(options: any): Promise; + SelectAudio(options: any): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/ContentDirectory.d.ts b/types/lib/services/ContentDirectory.d.ts new file mode 100644 index 00000000..23e1c320 --- /dev/null +++ b/types/lib/services/ContentDirectory.d.ts @@ -0,0 +1,43 @@ +export = ContentDirectory; +/** + * Create a new instance of ContentDirectory + * @class ContentDirectory + * @param {String} host The host param of one of your sonos speakers + * @param {Number} port The port of your sonos speaker, defaults to 1400 + */ +declare class ContentDirectory extends Service { + constructor(host: any, port: any); + _parseResult(input: any): Promise; + _enumItems(resultcontainer: any): any[]; + GetResult(options: any): Promise<{ + returned: any; + total: any; + updateID: any; + items: any[]; + }>; + Browse(options: any): Promise; + DestroyObject(options: any): Promise; + /** + * See: http://docs.python-soco.com/en/latest/api/soco.music_library.html#soco.music_library.MusicLibrary.album_artist_display_option + * + * Possible values are: + * 'WMP' - use Album Artists + * 'ITUNES' - use iTunes® Compilations + * 'NONE' - do not group compilations + */ + GetSearchCapabilities(): Promise; + GetSortCapabilities(): Promise; + GetSystemUpdateID(): Promise; + GetAlbumArtistDisplayOption(): Promise; + GetLastIndexChange(): Promise; + FindPrefix(ObjectID: any, Prefix: any): Promise; + GetAllPrefixLocations(ObjectID: any): Promise; + CreateObject(ContainerID: any, Elements: any): Promise; + UpdateObject(ObjectID: any, CurrentTagValue: any): Promise; + RefreshShareIndex(AlbumArtistDisplayOption?: string): Promise; + RequestResort(SortOrder: any): Promise; + GetShareIndexInProgress(): Promise; + GetBrowseable(): Promise; + SetBrowseable(Browseable: any): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/DeviceProperties.d.ts b/types/lib/services/DeviceProperties.d.ts new file mode 100644 index 00000000..b5229699 --- /dev/null +++ b/types/lib/services/DeviceProperties.d.ts @@ -0,0 +1,76 @@ +export = DeviceProperties; +/** + * Create a new instance of DeviceProperties + * @class DeviceProperties + * @param {String} host The host param of one of your sonos speakers + * @param {Number} port The port of your sonos speaker, defaults to 1400 + */ +declare class DeviceProperties extends Service { + constructor(host: any, port: any); + /** + * Enters config mode + * @param {string} Mode Use 'button-notify' to listen to then poll the button state via GetButtonState. This can be used to identify left or right of a pair + * @param {string} Options + */ + EnterConfigMode(Mode?: string, Options?: string): Promise; + /** + * Exits config mode + * @param {string} Options + */ + ExitConfigMode(Options?: string): Promise; + /** + * Gets button state + */ + GetButtonState(): Promise; + SetLEDState(state: any): Promise; + GetLEDState(): Promise; + SetInvisible(options: any): Promise; + GetInvisible(options: any): Promise; + /** + * Adds bonded zones + * @param {object} options Object with required parameters + * @param {string} options.ChannelMapSet i.e. to create a stereo pair, use `${left.UUID}:LF,LF;${right.UUID}:RF,RF` + */ + AddBondedZones(options: { + ChannelMapSet: string; + }): Promise; + /** + * Removes bonded zones + * @param {object} options Object with required parameters + * @param {string} options.ChannelMapSet can be empty string + * @param {Number} options.KeepGrouped 0 or 1 + */ + RemoveBondedZones(options: { + ChannelMapSet: string; + KeepGrouped: number; + }): Promise; + CreateStereoPair(options: any): Promise; + SeparateStereoPair(options: any): Promise; + /** + * Set the attributes of this speaker + * @param {object} options Object with required parameters + * @param {string} options.DesiredZoneName The name of the speaker + * @param {string} options.DesiredIcon The icon of the speaker + * @param {string} options.DesiredConfiguration The config of the speaker + */ + SetZoneAttributes(options: { + DesiredZoneName: string; + DesiredIcon: string; + DesiredConfiguration: string; + }): Promise; + GetZoneAttributes(): Promise; + GetHouseholdID(options: any): Promise; + GetZoneInfo(): Promise; + SetAutoplayLinkedZones(options: any): Promise; + GetAutoplayLinkedZones(options: any): Promise; + SetAutoplayRoomUUID(options: any): Promise; + GetAutoplayRoomUUID(options: any): Promise; + SetAutoplayVolume(options: any): Promise; + GetAutoplayVolume(options: any): Promise; + ImportSetting(options: any): Promise; + SetUseAutoplayVolume(options: any): Promise; + GetUseAutoplayVolume(options: any): Promise; + AddHTSatellite(options: any): Promise; + RemoveHTSatellite(options: any): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/GroupManagement.d.ts b/types/lib/services/GroupManagement.d.ts new file mode 100644 index 00000000..a2182a5a --- /dev/null +++ b/types/lib/services/GroupManagement.d.ts @@ -0,0 +1,14 @@ +export = GroupManagement; +/** + * Create a new instance of GroupManagement + * @class GroupManagement + * @param {String} host The host param of one of your sonos speakers + * @param {Number} port The port of your sonos speaker, defaults to 1400 + */ +declare class GroupManagement extends Service { + constructor(host: any, port: any); + AddMember(options: any): Promise; + RemoveMember(options: any): Promise; + ReportTrackBufferingResult(options: any): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/GroupRenderingControl.d.ts b/types/lib/services/GroupRenderingControl.d.ts new file mode 100644 index 00000000..80d000fa --- /dev/null +++ b/types/lib/services/GroupRenderingControl.d.ts @@ -0,0 +1,17 @@ +export = GroupRenderingControl; +/** + * Create a new instance of AlarmClock + * @class AlarmClock + * @param {String} host The host param of one of your sonos speakers + * @param {Number} port The port of your sonos speaker, defaults to 1400 + */ +declare class GroupRenderingControl extends Service { + constructor(host: any, port: any); + GetGroupMute(): Promise; + SetGroupMute(DesiredMute: any): Promise; + GetGroupVolume(): Promise; + SetGroupVolume(DesiredVolume: any): Promise; + SetRelativeGroupVolume(Adjustment: any): Promise; + SnapshotGroupVolume(): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/MusicServices.d.ts b/types/lib/services/MusicServices.d.ts new file mode 100644 index 00000000..1cbbe319 --- /dev/null +++ b/types/lib/services/MusicServices.d.ts @@ -0,0 +1,14 @@ +export = MusicServices; +/** + * Create a new instance of MusicServices + * @class MusicServices + * @param {String} host The host param of one of your sonos speakers + * @param {Number} port The port of your sonos speaker, defaults to 1400 + */ +declare class MusicServices extends Service { + constructor(host: any, port: any); + GetSessionId(options: any): Promise; + ListAvailableServices(options: any): Promise; + UpdateAvailableServices(options: any): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/RenderingControl.d.ts b/types/lib/services/RenderingControl.d.ts new file mode 100644 index 00000000..bef3b133 --- /dev/null +++ b/types/lib/services/RenderingControl.d.ts @@ -0,0 +1,77 @@ +export = RenderingControl; +/** + * Create a new instance of RenderingControl + * @class RenderingControl + * @param {String} host The host param of one of your sonos speakers + * @param {Number} port The port of your sonos speaker, defaults to 1400 + */ +declare class RenderingControl extends Service { + constructor(host: any, port: any); + /** + * Get the volume + * @param {string} channel Get to volume for this channel, `Master` is default. + */ + GetVolume(channel?: string): Promise; + /** + * Set the volume for a speaker. + * @param {number} volume The volume you want (0-100) + * @param {string} channel The channel you want to set `Master` is default + */ + SetVolume(volume: number, channel?: string): Promise; + /** + * Adjust volume with relative value + * @param {number} volumeAdjustment The volume adjustment + * @param {string} channel The channel you want to set. `Master` is default + */ + SetRelativeVolume(volumeAdjustment: number, channel?: string): Promise; + /** + * Check if the speaker is muted + * @param {string} channel What channel do you want to check? `Master` is default. + */ + GetMute(channel?: string): Promise; + /** + * (Un)mute the volume of a speaker. + * @param {boolean} mute Should it be muted or unmuted? + * @param {string} channel The channel you want to set. `Master` is default + */ + SetMute(mute: boolean, channel?: string): Promise; + /** + * Get loudness value of a speaker. + * @param {string} Channel What channel do you want to check? `Master` is default + */ + GetLoudness(Channel?: string): Promise; + /** + * (Un)set loudness of a speaker. + * @param {boolean} loudness Should it be with or without loudness? + * @param {string} Channel The channel you want to set. `Master` is default + */ + SetLoudness(loudness: boolean, Channel?: string): Promise; + /** + * Get bass value of a speaker. + */ + GetBass(): Promise; + /** + * Set bass of a speaker. + * @param {Number} bass desired level of bass, range from -10 to +10 + */ + SetBass(bass: number): Promise; + /** + * Get treble value of a speaker. + */ + GetTreble(): Promise; + /** + * Set treble of a speaker. + * @param {Number} treble desired level of treble, range from -10 to +10 + */ + SetTreble(treble: number): Promise; + /** + * Get room calibration status, response payload is { RoomCalibrationEnabled, RoomCalibrationAvailable } + */ + GetRoomCalibrationStatus(): Promise; + /** + * (Un)set room calibration status (TruePlay) of a speaker. + * @param {boolean} enabled Should it be with or without truePlay? + */ + SetRoomCalibrationStatus(enabled: boolean): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/Service.d.ts b/types/lib/services/Service.d.ts new file mode 100644 index 00000000..5c9fea3e --- /dev/null +++ b/types/lib/services/Service.d.ts @@ -0,0 +1,36 @@ +export = Service; +/** + * Create a new instance of Service + * @class Service + * @param {Object} [options] All the required options to use this class + * @param {String} options.host The host param of one of your sonos speakers + * @param {Number} options.port The port of your sonos speaker, defaults to 1400 + * @param {String} options.controlURL The control url used for the calls + * @param {String} options.eventURL The Event URL used for the calls + * @param {String} options.SCPDURL The SCPDURL (ask Ben) + */ +declare class Service { + constructor(options?: {}); + name: any; + host: any; + port: any; + controlURL: any; + eventSubURL: any; + SCPDURL: any; + debug: any; + /** + * Call the UPNP action + * @param {String} action The action you want to call + * @param {Object} variables If this endpoint requires options, put them in here. Otherwise `{ }` + * @returns {Object} The result of the request. + */ + _request(action: string, variables: any): any; + /** + * Parse a key from the response. + * @param {Object} input The complete response + * @param {String} key The key you want parsed + * @param {Function} callback (err, result) + * @return {void} + */ + _parseKey(input: any, key: string, callback: Function): void; +} diff --git a/types/lib/services/SystemProperties.d.ts b/types/lib/services/SystemProperties.d.ts new file mode 100644 index 00000000..89da87ba --- /dev/null +++ b/types/lib/services/SystemProperties.d.ts @@ -0,0 +1,28 @@ +export = SystemProperties; +/** + * Create a new instance of SystemProperties + * @class SystemProperties + * @param {String} host The host param of one of your sonos speakers + * @param {Number} port The port of your sonos speaker, defaults to 1400 + */ +declare class SystemProperties extends Service { + constructor(host: any, port: any); + SetString(options: any): Promise; + SetStringX(options: any): Promise; + GetString(options: any): Promise; + GetStringX(options: any): Promise; + Remove(options: any): Promise; + RemoveX(options: any): Promise; + GetWebCode(options: any): Promise; + ProvisionTrialAccount(options: any): Promise; + ProvisionCredentialedTrialAccountX(options: any): Promise; + MigrateTrialAccountX(options: any): Promise; + AddAccountX(options: any): Promise; + AddAccountWithCredentialsX(options: any): Promise; + RemoveAccount(options: any): Promise; + EditAccountPasswordX(options: any): Promise; + EditAccountMd(options: any): Promise; + DoPostUpdateTasks(options: any): Promise; + ResetThirdPartyCredentials(options: any): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/ZoneGroupTopology.d.ts b/types/lib/services/ZoneGroupTopology.d.ts new file mode 100644 index 00000000..d9e4f56e --- /dev/null +++ b/types/lib/services/ZoneGroupTopology.d.ts @@ -0,0 +1,28 @@ +export = ZoneGroupTopology; +/** + * Create a new instance of ZoneGroupTopology + * @class ZoneGroupTopology + * @param {String} host The host param of one of your sonos speakers + * @param {Number} port The port of your sonos speaker, defaults to 1400 + * Check http://[sonos_ip]:1400/xml/ZoneGroupTopology1.xml for all actions. + */ +declare class ZoneGroupTopology extends Service { + constructor(host: any, port: any); + CheckForUpdate(options: any): Promise; + BeginSoftwareUpdate(options: any): Promise; + ReportUnresponsiveDevice(options: any): Promise; + ReportAlarmStartedRunning(options: any): Promise; + SubmitDiagnostics(options: any): Promise; + RegisterMobileDevice(options: any): Promise; + GetZoneGroupAttributes(): Promise; + /** + * Get all the information about the ZoneGroups + * @returns {Promise} Object with one property, 'ZoneGroupState' + */ + GetZoneGroupState(): Promise; + /** + * Get all the ZoneGroups + */ + AllZoneGroups(): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/alarm-clock.service.d.ts b/types/lib/services/alarm-clock.service.d.ts new file mode 100644 index 00000000..4a275efe --- /dev/null +++ b/types/lib/services/alarm-clock.service.d.ts @@ -0,0 +1,202 @@ +export = AlarmClockService; +/** + * Sonos AlarmClockService + * + * Control the sonos alarms and times + * + * @author Stephan van Rooij - https://svrooij.io + * @remarks This file is generated, do not edit manually. https://svrooij.io/sonos-api-docs + * @export + * @class AlarmClockService + * @extends {Service} + */ +declare class AlarmClockService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ + constructor(host: string, port: number); + /** + * CreateAlarm - Create a single alarm, all properties are required + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.StartLocalTime - The start time as `hh:mm:ss` + * @param {string} options.Duration - The duration as `hh:mm:ss` + * @param {string} options.Recurrence - Repeat this alarm on [ 'ONCE' / 'WEEKDAYS' / 'WEEKENDS' / 'DAILY' ] + * @param {boolean} options.Enabled - Alarm enabled after creation + * @param {string} options.RoomUUID - The UUID of the speaker you want this alarm for + * @param {string} options.ProgramURI - The sound uri + * @param {string} options.ProgramMetaData - The sound metadata, can be empty string + * @param {string} options.PlayMode - Alarm play mode [ 'NORMAL' / 'REPEAT_ALL' / 'SHUFFLE_NOREPEAT' / 'SHUFFLE' ] + * @param {number} options.Volume - Volume between 0 and 100 + * @param {boolean} options.IncludeLinkedZones - Should grouped players also play the alarm? + * @returns {Promise} response object, with these properties `AssignedID` + */ + CreateAlarm(options?: { + StartLocalTime: string; + Duration: string; + Recurrence: string; + Enabled: boolean; + RoomUUID: string; + ProgramURI: string; + ProgramMetaData: string; + PlayMode: string; + Volume: number; + IncludeLinkedZones: boolean; + }): Promise; + /** + * DestroyAlarm - Delete an alarm + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.ID - The Alarm ID from ListAlarms + * @returns {Promise} request succeeded + */ + DestroyAlarm(options?: { + ID: number; + }): Promise; + /** + * GetDailyIndexRefreshTime + * @returns {Promise} response object, with these properties `CurrentDailyIndexRefreshTime` + */ + GetDailyIndexRefreshTime(): Promise; + /** + * GetFormat + * @returns {Promise} response object, with these properties `CurrentTimeFormat`, `CurrentDateFormat` + */ + GetFormat(): Promise; + /** + * GetHouseholdTimeAtStamp + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.TimeStamp + * @returns {Promise} response object, with these properties `HouseholdUTCTime` + */ + GetHouseholdTimeAtStamp(options?: { + TimeStamp: string; + }): Promise; + /** + * GetTimeNow + * @returns {Promise} response object, with these properties `CurrentUTCTime`, `CurrentLocalTime`, `CurrentTimeZone`, `CurrentTimeGeneration` + */ + GetTimeNow(): Promise; + /** + * GetTimeServer + * @returns {Promise} response object, with these properties `CurrentTimeServer` + */ + GetTimeServer(): Promise; + /** + * GetTimeZone + * @returns {Promise} response object, with these properties `Index`, `AutoAdjustDst` + */ + GetTimeZone(): Promise; + /** + * GetTimeZoneAndRule + * @returns {Promise} response object, with these properties `Index`, `AutoAdjustDst`, `CurrentTimeZone` + */ + GetTimeZoneAndRule(): Promise; + /** + * GetTimeZoneRule + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.Index + * @returns {Promise} response object, with these properties `TimeZone` + */ + GetTimeZoneRule(options?: { + Index: number; + }): Promise; + /** + * ListAlarms - Get the AlarmList as XML + * @remarks Some libraries also provide a ListAndParseAlarms where the alarm list xml is parsed + * @returns {Promise} response object, with these properties `CurrentAlarmList`, `CurrentAlarmListVersion` + */ + ListAlarms(): Promise; + /** + * SetDailyIndexRefreshTime + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.DesiredDailyIndexRefreshTime + * @returns {Promise} request succeeded + */ + SetDailyIndexRefreshTime(options?: { + DesiredDailyIndexRefreshTime: string; + }): Promise; + /** + * SetFormat + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.DesiredTimeFormat + * @param {string} options.DesiredDateFormat + * @returns {Promise} request succeeded + */ + SetFormat(options?: { + DesiredTimeFormat: string; + DesiredDateFormat: string; + }): Promise; + /** + * SetTimeNow + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.DesiredTime + * @param {string} options.TimeZoneForDesiredTime + * @returns {Promise} request succeeded + */ + SetTimeNow(options?: { + DesiredTime: string; + TimeZoneForDesiredTime: string; + }): Promise; + /** + * SetTimeServer + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.DesiredTimeServer + * @returns {Promise} request succeeded + */ + SetTimeServer(options?: { + DesiredTimeServer: string; + }): Promise; + /** + * SetTimeZone + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.Index + * @param {boolean} options.AutoAdjustDst + * @returns {Promise} request succeeded + */ + SetTimeZone(options?: { + Index: number; + AutoAdjustDst: boolean; + }): Promise; + /** + * UpdateAlarm - Update an alarm, all parameters are required. + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.ID - The ID of the alarm see ListAlarms + * @param {string} options.StartLocalTime - The start time as `hh:mm:ss` + * @param {string} options.Duration - The duration as `hh:mm:ss` + * @param {string} options.Recurrence - Repeat this alarm on [ 'ONCE' / 'WEEKDAYS' / 'WEEKENDS' / 'DAILY' ] + * @param {boolean} options.Enabled - Alarm enabled after creation + * @param {string} options.RoomUUID - The UUID of the speaker you want this alarm for + * @param {string} options.ProgramURI - The sound uri + * @param {string} options.ProgramMetaData - The sound metadata, can be empty string + * @param {string} options.PlayMode - Alarm play mode [ 'NORMAL' / 'REPEAT_ALL' / 'SHUFFLE_NOREPEAT' / 'SHUFFLE' ] + * @param {number} options.Volume - Volume between 0 and 100 + * @param {boolean} options.IncludeLinkedZones - Should grouped players also play the alarm? + * @remarks Some libraries support PatchAlarm where you can update a single parameter + * @returns {Promise} request succeeded + */ + UpdateAlarm(options?: { + ID: number; + StartLocalTime: string; + Duration: string; + Recurrence: string; + Enabled: boolean; + RoomUUID: string; + ProgramURI: string; + ProgramMetaData: string; + PlayMode: string; + Volume: number; + IncludeLinkedZones: boolean; + }): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/all-services.d.ts b/types/lib/services/all-services.d.ts new file mode 100644 index 00000000..7a788c40 --- /dev/null +++ b/types/lib/services/all-services.d.ts @@ -0,0 +1,148 @@ +/** + * Sonos AllServices + * + * A generated class to access all Sonos UPNP services. + * + * @remarks This file is generated, do not edit manually. https://svrooij.io/sonos-api-docs + * @exports + * @class AllServices + */ +export class AllServices { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ + constructor(host: string, port: number); + host: string; + port: number; + /** + * Get instance of AlarmClock service + * + * @returns {AlarmClockService} + */ + AlarmClockService(): AlarmClockService; + alarmclockservice: AlarmClockService; + /** + * Get instance of AudioIn service + * + * @returns {AudioInService} + */ + AudioInService(): AudioInService; + audioinservice: AudioInService; + /** + * Get instance of AVTransport service + * + * @returns {AVTransportService} + */ + AVTransportService(): AVTransportService; + avtransportservice: AVTransportService; + /** + * Get instance of ConnectionManager service + * + * @returns {ConnectionManagerService} + */ + ConnectionManagerService(): ConnectionManagerService; + connectionmanagerservice: ConnectionManagerService; + /** + * Get instance of ContentDirectory service + * + * @returns {ContentDirectoryService} + */ + ContentDirectoryService(): ContentDirectoryService; + contentdirectoryservice: ContentDirectoryService; + /** + * Get instance of DeviceProperties service + * + * @returns {DevicePropertiesService} + */ + DevicePropertiesService(): DevicePropertiesService; + devicepropertiesservice: DevicePropertiesService; + /** + * Get instance of GroupManagement service + * + * @returns {GroupManagementService} + */ + GroupManagementService(): GroupManagementService; + groupmanagementservice: GroupManagementService; + /** + * Get instance of GroupRenderingControl service + * + * @returns {GroupRenderingControlService} + */ + GroupRenderingControlService(): GroupRenderingControlService; + grouprenderingcontrolservice: GroupRenderingControlService; + /** + * Get instance of HTControl service + * + * @returns {HTControlService} + */ + HTControlService(): HTControlService; + htcontrolservice: HTControlService; + /** + * Get instance of MusicServices service + * + * @returns {MusicServicesService} + */ + MusicServicesService(): MusicServicesService; + musicservicesservice: MusicServicesService; + /** + * Get instance of QPlay service + * + * @returns {QPlayService} + */ + QPlayService(): QPlayService; + qplayservice: QPlayService; + /** + * Get instance of Queue service + * + * @returns {QueueService} + */ + QueueService(): QueueService; + queueservice: QueueService; + /** + * Get instance of RenderingControl service + * + * @returns {RenderingControlService} + */ + RenderingControlService(): RenderingControlService; + renderingcontrolservice: RenderingControlService; + /** + * Get instance of SystemProperties service + * + * @returns {SystemPropertiesService} + */ + SystemPropertiesService(): SystemPropertiesService; + systempropertiesservice: SystemPropertiesService; + /** + * Get instance of VirtualLineIn service + * + * @returns {VirtualLineInService} + */ + VirtualLineInService(): VirtualLineInService; + virtuallineinservice: VirtualLineInService; + /** + * Get instance of ZoneGroupTopology service + * + * @returns {ZoneGroupTopologyService} + */ + ZoneGroupTopologyService(): ZoneGroupTopologyService; + zonegrouptopologyservice: ZoneGroupTopologyService; +} +import AlarmClockService = require("./alarm-clock.service"); +import AudioInService = require("./audio-in.service"); +import AVTransportService = require("./av-transport.service"); +import ConnectionManagerService = require("./connection-manager.service"); +import ContentDirectoryService = require("./content-directory.service"); +import DevicePropertiesService = require("./device-properties.service"); +import GroupManagementService = require("./group-management.service"); +import GroupRenderingControlService = require("./group-rendering-control.service"); +import HTControlService = require("./ht-control.service"); +import MusicServicesService = require("./music-services.service"); +import QPlayService = require("./q-play.service"); +import QueueService = require("./queue.service"); +import RenderingControlService = require("./rendering-control.service"); +import SystemPropertiesService = require("./system-properties.service"); +import VirtualLineInService = require("./virtual-line-in.service"); +import ZoneGroupTopologyService = require("./zone-group-topology.service"); +export { AlarmClockService, AudioInService, AVTransportService, ConnectionManagerService, ContentDirectoryService, DevicePropertiesService, GroupManagementService, GroupRenderingControlService, HTControlService, MusicServicesService, QPlayService, QueueService, RenderingControlService, SystemPropertiesService, VirtualLineInService, ZoneGroupTopologyService }; diff --git a/types/lib/services/audio-in.service.d.ts b/types/lib/services/audio-in.service.d.ts new file mode 100644 index 00000000..83695df4 --- /dev/null +++ b/types/lib/services/audio-in.service.d.ts @@ -0,0 +1,85 @@ +export = AudioInService; +/** + * Sonos AudioInService + * + * Control line in + * + * @author Stephan van Rooij - https://svrooij.io + * @remarks This file is generated, do not edit manually. https://svrooij.io/sonos-api-docs + * @export + * @class AudioInService + * @extends {Service} + */ +declare class AudioInService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ + constructor(host: string, port: number); + /** + * GetAudioInputAttributes + * @returns {Promise} response object, with these properties `CurrentName`, `CurrentIcon` + */ + GetAudioInputAttributes(): Promise; + /** + * GetLineInLevel + * @returns {Promise} response object, with these properties `CurrentLeftLineInLevel`, `CurrentRightLineInLevel` + */ + GetLineInLevel(): Promise; + /** + * SelectAudio + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.ObjectID + * @returns {Promise} request succeeded + */ + SelectAudio(options?: { + ObjectID: string; + }): Promise; + /** + * SetAudioInputAttributes + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.DesiredName + * @param {string} options.DesiredIcon + * @returns {Promise} request succeeded + */ + SetAudioInputAttributes(options?: { + DesiredName: string; + DesiredIcon: string; + }): Promise; + /** + * SetLineInLevel + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.DesiredLeftLineInLevel + * @param {number} options.DesiredRightLineInLevel + * @returns {Promise} request succeeded + */ + SetLineInLevel(options?: { + DesiredLeftLineInLevel: number; + DesiredRightLineInLevel: number; + }): Promise; + /** + * StartTransmissionToGroup + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.CoordinatorID + * @returns {Promise} response object, with these properties `CurrentTransportSettings` + */ + StartTransmissionToGroup(options?: { + CoordinatorID: string; + }): Promise; + /** + * StopTransmissionToGroup + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.CoordinatorID + * @returns {Promise} request succeeded + */ + StopTransmissionToGroup(options?: { + CoordinatorID: string; + }): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/av-transport.service.d.ts b/types/lib/services/av-transport.service.d.ts new file mode 100644 index 00000000..8c7ca9b0 --- /dev/null +++ b/types/lib/services/av-transport.service.d.ts @@ -0,0 +1,639 @@ +export = AVTransportService; +/** + * Sonos AVTransportService + * + * Service that controls stuff related to transport (play/pause/next/special urls) + * + * @author Stephan van Rooij - https://svrooij.io + * @remarks This file is generated, do not edit manually. https://svrooij.io/sonos-api-docs + * @export + * @class AVTransportService + * @extends {Service} + */ +declare class AVTransportService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ + constructor(host: string, port: number); + /** + * AddMultipleURIsToQueue + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {number} options.UpdateID + * @param {number} options.NumberOfURIs + * @param {string} options.EnqueuedURIs + * @param {string} options.EnqueuedURIsMetaData + * @param {string} options.ContainerURI + * @param {string} options.ContainerMetaData + * @param {number} options.DesiredFirstTrackNumberEnqueued + * @param {boolean} options.EnqueueAsNext + * @returns {Promise} response object, with these properties `FirstTrackNumberEnqueued`, `NumTracksAdded`, `NewQueueLength`, `NewUpdateID` + */ + AddMultipleURIsToQueue(options?: { + InstanceID: number; + UpdateID: number; + NumberOfURIs: number; + EnqueuedURIs: string; + EnqueuedURIsMetaData: string; + ContainerURI: string; + ContainerMetaData: string; + DesiredFirstTrackNumberEnqueued: number; + EnqueueAsNext: boolean; + }): Promise; + /** + * AddURIToQueue - Adds songs to the SONOS queue + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.EnqueuedURI + * @param {string} options.EnqueuedURIMetaData + * @param {number} options.DesiredFirstTrackNumberEnqueued - use `0` to add at the end or `1` to insert at the beginning + * @param {boolean} options.EnqueueAsNext + * @remarks In NORMAL play mode the songs are added prior to the specified `DesiredFirstTrackNumberEnqueued`. + * @returns {Promise} response object, with these properties `FirstTrackNumberEnqueued`, `NumTracksAdded`, `NewQueueLength` + */ + AddURIToQueue(options?: { + InstanceID: number; + EnqueuedURI: string; + EnqueuedURIMetaData: string; + DesiredFirstTrackNumberEnqueued: number; + EnqueueAsNext: boolean; + }): Promise; + /** + * AddURIToSavedQueue + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.ObjectID + * @param {number} options.UpdateID + * @param {string} options.EnqueuedURI + * @param {string} options.EnqueuedURIMetaData + * @param {number} options.AddAtIndex + * @returns {Promise} response object, with these properties `NumTracksAdded`, `NewQueueLength`, `NewUpdateID` + */ + AddURIToSavedQueue(options?: { + InstanceID: number; + ObjectID: string; + UpdateID: number; + EnqueuedURI: string; + EnqueuedURIMetaData: string; + AddAtIndex: number; + }): Promise; + /** + * BackupQueue + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @returns {Promise} request succeeded + */ + BackupQueue(options?: { + InstanceID: number; + }): Promise; + /** + * BecomeCoordinatorOfStandaloneGroup - Leave the current group and revert to a single player. + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @returns {Promise} response object, with these properties `DelegatedGroupCoordinatorID`, `NewGroupID` + */ + BecomeCoordinatorOfStandaloneGroup(options?: { + InstanceID: number; + }): Promise; + /** + * BecomeGroupCoordinator + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.CurrentCoordinator + * @param {string} options.CurrentGroupID + * @param {string} options.OtherMembers + * @param {string} options.TransportSettings + * @param {string} options.CurrentURI + * @param {string} options.CurrentURIMetaData + * @param {string} options.SleepTimerState + * @param {string} options.AlarmState + * @param {string} options.StreamRestartState + * @param {string} options.CurrentQueueTrackList + * @param {string} options.CurrentVLIState + * @returns {Promise} request succeeded + */ + BecomeGroupCoordinator(options?: { + InstanceID: number; + CurrentCoordinator: string; + CurrentGroupID: string; + OtherMembers: string; + TransportSettings: string; + CurrentURI: string; + CurrentURIMetaData: string; + SleepTimerState: string; + AlarmState: string; + StreamRestartState: string; + CurrentQueueTrackList: string; + CurrentVLIState: string; + }): Promise; + /** + * BecomeGroupCoordinatorAndSource + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.CurrentCoordinator + * @param {string} options.CurrentGroupID + * @param {string} options.OtherMembers + * @param {string} options.CurrentURI + * @param {string} options.CurrentURIMetaData + * @param {string} options.SleepTimerState + * @param {string} options.AlarmState + * @param {string} options.StreamRestartState + * @param {string} options.CurrentAVTTrackList + * @param {string} options.CurrentQueueTrackList + * @param {string} options.CurrentSourceState + * @param {boolean} options.ResumePlayback + * @returns {Promise} request succeeded + */ + BecomeGroupCoordinatorAndSource(options?: { + InstanceID: number; + CurrentCoordinator: string; + CurrentGroupID: string; + OtherMembers: string; + CurrentURI: string; + CurrentURIMetaData: string; + SleepTimerState: string; + AlarmState: string; + StreamRestartState: string; + CurrentAVTTrackList: string; + CurrentQueueTrackList: string; + CurrentSourceState: string; + ResumePlayback: boolean; + }): Promise; + /** + * ChangeCoordinator + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.CurrentCoordinator + * @param {string} options.NewCoordinator + * @param {string} options.NewTransportSettings + * @param {string} options.CurrentAVTransportURI + * @returns {Promise} request succeeded + */ + ChangeCoordinator(options?: { + InstanceID: number; + CurrentCoordinator: string; + NewCoordinator: string; + NewTransportSettings: string; + CurrentAVTransportURI: string; + }): Promise; + /** + * ChangeTransportSettings + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.NewTransportSettings + * @param {string} options.CurrentAVTransportURI + * @returns {Promise} request succeeded + */ + ChangeTransportSettings(options?: { + InstanceID: number; + NewTransportSettings: string; + CurrentAVTransportURI: string; + }): Promise; + /** + * ConfigureSleepTimer - Stop playing after set sleep timer or cancel + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.NewSleepTimerDuration - Time to stop after, as `hh:mm:ss` or empty string to cancel + * @remarks Send to non-coordinator returns error code 800 + * @returns {Promise} request succeeded + */ + ConfigureSleepTimer(options?: { + InstanceID: number; + NewSleepTimerDuration: string; + }): Promise; + /** + * CreateSavedQueue + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.Title + * @param {string} options.EnqueuedURI + * @param {string} options.EnqueuedURIMetaData + * @returns {Promise} response object, with these properties `NumTracksAdded`, `NewQueueLength`, `AssignedObjectID`, `NewUpdateID` + */ + CreateSavedQueue(options?: { + InstanceID: number; + Title: string; + EnqueuedURI: string; + EnqueuedURIMetaData: string; + }): Promise; + /** + * DelegateGroupCoordinationTo - Delegates the coordinator role to another player in the same group + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.NewCoordinator - uuid of the new coordinator - must be in same group + * @param {boolean} options.RejoinGroup - Should former coordinator rejoin the group? + * @remarks Send to non-coordinator has no results - should be avoided. + * @returns {Promise} request succeeded + */ + DelegateGroupCoordinationTo(options?: { + InstanceID: number; + NewCoordinator: string; + RejoinGroup: boolean; + }): Promise; + /** + * EndDirectControlSession + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @returns {Promise} request succeeded + */ + EndDirectControlSession(options?: { + InstanceID: number; + }): Promise; + /** + * GetCrossfadeMode - Get crossfade mode + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @remarks Send to non-coordinator may return wrong value as only the coordinator value in a group + * @returns {Promise} response object, with these properties `CrossfadeMode` + */ + GetCrossfadeMode(options?: { + InstanceID: number; + }): Promise; + /** + * GetCurrentTransportActions - Get current transport actions such as Set, Stop, Pause, Play, X_DLNA_SeekTime, Next, X_DLNA_SeekTrackNr + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @remarks Send to non-coordinator returns only `Start` and `Stop` since it cannot control the stream. + * @returns {Promise} response object, with these properties `Actions` + */ + GetCurrentTransportActions(options?: { + InstanceID: number; + }): Promise; + /** + * GetDeviceCapabilities + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @returns {Promise} response object, with these properties `PlayMedia`, `RecMedia`, `RecQualityModes` + */ + GetDeviceCapabilities(options?: { + InstanceID: number; + }): Promise; + /** + * GetMediaInfo - Get information about the current playing media (queue) + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @returns {Promise} response object, with these properties `NrTracks`, `MediaDuration`, `CurrentURI`, `CurrentURIMetaData`, `NextURI`, `NextURIMetaData`, `PlayMedium`, `RecordMedium`, `WriteStatus` + */ + GetMediaInfo(options?: { + InstanceID: number; + }): Promise; + /** + * GetPositionInfo - Get information about current position (position in queue and time in current song) + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @returns {Promise} response object, with these properties `Track`, `TrackDuration`, `TrackMetaData`, `TrackURI`, `RelTime`, `AbsTime`, `RelCount`, `AbsCount` + */ + GetPositionInfo(options?: { + InstanceID: number; + }): Promise; + /** + * GetRemainingSleepTimerDuration - Get time left on sleeptimer. + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @remarks Send to non-coordinator returns error code 800 + * @returns {Promise} response object, with these properties `RemainingSleepTimerDuration`, `CurrentSleepTimerGeneration` + */ + GetRemainingSleepTimerDuration(options?: { + InstanceID: number; + }): Promise; + /** + * GetRunningAlarmProperties + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @returns {Promise} response object, with these properties `AlarmID`, `GroupID`, `LoggedStartTime` + */ + GetRunningAlarmProperties(options?: { + InstanceID: number; + }): Promise; + /** + * GetTransportInfo - Get current transport status, speed and state such as PLAYING, STOPPED, PLAYING, PAUSED_PLAYBACK, TRANSITIONING, NO_MEDIA_PRESENT + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @remarks Send to non-coordinator always returns PLAYING + * @returns {Promise} response object, with these properties `CurrentTransportState`, `CurrentTransportStatus`, `CurrentSpeed` + */ + GetTransportInfo(options?: { + InstanceID: number; + }): Promise; + /** + * GetTransportSettings - Get transport settings + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @remarks Send to non-coordinator returns the settings of it's queue + * @returns {Promise} response object, with these properties `PlayMode`, `RecQualityMode` + */ + GetTransportSettings(options?: { + InstanceID: number; + }): Promise; + /** + * Next - Go to next song + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @remarks Possibly not supported at the moment see GetCurrentTransportActions + * @returns {Promise} request succeeded + */ + Next(options?: { + InstanceID: number; + }): Promise; + /** + * NotifyDeletedURI + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.DeletedURI + * @returns {Promise} request succeeded + */ + NotifyDeletedURI(options?: { + InstanceID: number; + DeletedURI: string; + }): Promise; + /** + * Pause - Pause playback + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @returns {Promise} request succeeded + */ + Pause(options?: { + InstanceID: number; + }): Promise; + /** + * Play - Start playing the set TransportURI + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.Speed - Play speed usually 1, can be a fraction of 1 [ '1' ] + * @returns {Promise} request succeeded + */ + Play(options?: { + InstanceID: number; + Speed: string; + }): Promise; + /** + * Previous - Go to previous song + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @remarks Possibly not supported at the moment see GetCurrentTransportActions + * @returns {Promise} request succeeded + */ + Previous(options?: { + InstanceID: number; + }): Promise; + /** + * RemoveAllTracksFromQueue - Flushes the SONOS queue. + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @remarks If queue is already empty it throw error 804. Send to non-coordinator returns error code 800. + * @returns {Promise} request succeeded + */ + RemoveAllTracksFromQueue(options?: { + InstanceID: number; + }): Promise; + /** + * RemoveTrackFromQueue + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.ObjectID + * @param {number} options.UpdateID + * @returns {Promise} request succeeded + */ + RemoveTrackFromQueue(options?: { + InstanceID: number; + ObjectID: string; + UpdateID: number; + }): Promise; + /** + * RemoveTrackRangeFromQueue - Removes the specified range of songs from the SONOS queue. + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {number} options.UpdateID - Leave blank + * @param {number} options.StartingIndex - between 1 and queue-length + * @param {number} options.NumberOfTracks + * @returns {Promise} response object, with these properties `NewUpdateID` + */ + RemoveTrackRangeFromQueue(options?: { + InstanceID: number; + UpdateID: number; + StartingIndex: number; + NumberOfTracks: number; + }): Promise; + /** + * ReorderTracksInQueue + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {number} options.StartingIndex + * @param {number} options.NumberOfTracks + * @param {number} options.InsertBefore + * @param {number} options.UpdateID + * @returns {Promise} request succeeded + */ + ReorderTracksInQueue(options?: { + InstanceID: number; + StartingIndex: number; + NumberOfTracks: number; + InsertBefore: number; + UpdateID: number; + }): Promise; + /** + * ReorderTracksInSavedQueue + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.ObjectID + * @param {number} options.UpdateID + * @param {string} options.TrackList + * @param {string} options.NewPositionList + * @returns {Promise} response object, with these properties `QueueLengthChange`, `NewQueueLength`, `NewUpdateID` + */ + ReorderTracksInSavedQueue(options?: { + InstanceID: number; + ObjectID: string; + UpdateID: number; + TrackList: string; + NewPositionList: string; + }): Promise; + /** + * RunAlarm + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {number} options.AlarmID + * @param {string} options.LoggedStartTime + * @param {string} options.Duration + * @param {string} options.ProgramURI + * @param {string} options.ProgramMetaData + * @param {string} options.PlayMode [ 'NORMAL' / 'REPEAT_ALL' / 'REPEAT_ONE' / 'SHUFFLE_NOREPEAT' / 'SHUFFLE' / 'SHUFFLE_REPEAT_ONE' ] + * @param {number} options.Volume + * @param {boolean} options.IncludeLinkedZones + * @returns {Promise} request succeeded + */ + RunAlarm(options?: { + InstanceID: number; + AlarmID: number; + LoggedStartTime: string; + Duration: string; + ProgramURI: string; + ProgramMetaData: string; + PlayMode: string; + Volume: number; + IncludeLinkedZones: boolean; + }): Promise; + /** + * SaveQueue - Saves the current SONOS queue as a SONOS playlist and outputs objectID + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.Title - SONOS playlist title + * @param {string} options.ObjectID - Leave blank + * @remarks Send to non-coordinator returns error code 800 + * @returns {Promise} response object, with these properties `AssignedObjectID` + */ + SaveQueue(options?: { + InstanceID: number; + Title: string; + ObjectID: string; + }): Promise; + /** + * Seek - Seek track in queue, time delta or absolute time in song + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.Unit - What to seek [ 'TRACK_NR' / 'REL_TIME' / 'TIME_DELTA' ] + * @param {string} options.Target - Position of track in queue (start at 1) or `hh:mm:ss` for `REL_TIME` or `+/-hh:mm:ss` for `TIME_DELTA` + * @remarks Returns error code 701 in case that content does not support Seek or send to non-coordinator + * @returns {Promise} request succeeded + */ + Seek(options?: { + InstanceID: number; + Unit: string; + Target: string; + }): Promise; + /** + * SetAVTransportURI - Set the transport URI to a song, a stream, the queue, another player-rincon and a lot more + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.CurrentURI - The new TransportURI - its a special SONOS format + * @param {string} options.CurrentURIMetaData - Track Metadata, see MetadataHelper.GuessTrack to guess based on track uri + * @remarks If set to another player RINCON, the player is grouped with that one. + * @returns {Promise} request succeeded + */ + SetAVTransportURI(options?: { + InstanceID: number; + CurrentURI: string; + CurrentURIMetaData: string; + }): Promise; + /** + * SetCrossfadeMode - Set crossfade mode + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {boolean} options.CrossfadeMode + * @remarks Send to non-coordinator returns error code 800. Same for content, which does not support crossfade mode. + * @returns {Promise} request succeeded + */ + SetCrossfadeMode(options?: { + InstanceID: number; + CrossfadeMode: boolean; + }): Promise; + /** + * SetNextAVTransportURI + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.NextURI + * @param {string} options.NextURIMetaData + * @returns {Promise} request succeeded + */ + SetNextAVTransportURI(options?: { + InstanceID: number; + NextURI: string; + NextURIMetaData: string; + }): Promise; + /** + * SetPlayMode - Set the PlayMode + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.NewPlayMode - New playmode [ 'NORMAL' / 'REPEAT_ALL' / 'REPEAT_ONE' / 'SHUFFLE_NOREPEAT' / 'SHUFFLE' / 'SHUFFLE_REPEAT_ONE' ] + * @remarks Send to non-coordinator returns error code 712. If SONOS queue is not activated returns error code 712. + * @returns {Promise} request succeeded + */ + SetPlayMode(options?: { + InstanceID: number; + NewPlayMode: string; + }): Promise; + /** + * SnoozeAlarm - Snooze the current alarm for some time. + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.Duration - Snooze time as `hh:mm:ss`, 10 minutes = 00:10:00 + * @returns {Promise} request succeeded + */ + SnoozeAlarm(options?: { + InstanceID: number; + Duration: string; + }): Promise; + /** + * StartAutoplay + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.ProgramURI + * @param {string} options.ProgramMetaData + * @param {number} options.Volume + * @param {boolean} options.IncludeLinkedZones + * @param {boolean} options.ResetVolumeAfter + * @returns {Promise} request succeeded + */ + StartAutoplay(options?: { + InstanceID: number; + ProgramURI: string; + ProgramMetaData: string; + Volume: number; + IncludeLinkedZones: boolean; + ResetVolumeAfter: boolean; + }): Promise; + /** + * Stop - Stop playback + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @returns {Promise} request succeeded + */ + Stop(options?: { + InstanceID: number; + }): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/connection-manager.service.d.ts b/types/lib/services/connection-manager.service.d.ts new file mode 100644 index 00000000..d95cf06f --- /dev/null +++ b/types/lib/services/connection-manager.service.d.ts @@ -0,0 +1,41 @@ +export = ConnectionManagerService; +/** + * Sonos ConnectionManagerService + * + * Services related to connections and protocols + * + * @author Stephan van Rooij - https://svrooij.io + * @remarks This file is generated, do not edit manually. https://svrooij.io/sonos-api-docs + * @export + * @class ConnectionManagerService + * @extends {Service} + */ +declare class ConnectionManagerService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ + constructor(host: string, port: number); + /** + * GetCurrentConnectionIDs + * @returns {Promise} response object, with these properties `ConnectionIDs` + */ + GetCurrentConnectionIDs(): Promise; + /** + * GetCurrentConnectionInfo + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.ConnectionID + * @returns {Promise} response object, with these properties `RcsID`, `AVTransportID`, `ProtocolInfo`, `PeerConnectionManager`, `PeerConnectionID`, `Direction`, `Status` + */ + GetCurrentConnectionInfo(options?: { + ConnectionID: number; + }): Promise; + /** + * GetProtocolInfo + * @returns {Promise} response object, with these properties `Source`, `Sink` + */ + GetProtocolInfo(): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/content-directory.service.d.ts b/types/lib/services/content-directory.service.d.ts new file mode 100644 index 00000000..2ab40274 --- /dev/null +++ b/types/lib/services/content-directory.service.d.ts @@ -0,0 +1,165 @@ +export = ContentDirectoryService; +/** + * Sonos ContentDirectoryService + * + * Browse for local content + * + * @author Stephan van Rooij - https://svrooij.io + * @remarks This file is generated, do not edit manually. https://svrooij.io/sonos-api-docs + * @export + * @class ContentDirectoryService + * @extends {Service} + */ +declare class ContentDirectoryService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ + constructor(host: string, port: number); + /** + * Browse - Browse for content: Music library (A), share(S:), Sonos playlists(SQ:), Sonos favorites(FV:2), radio stations(R:0/0), radio shows(R:0/1). Recommendation: Send one request, check the `TotalMatches` and - if necessary - do additional requests with higher `StartingIndex`. In case of duplicates only the first is returned! Example: albums with same title, even if artists are different + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.ObjectID - The search query, (`A:ARTIST` / `A:ALBUMARTIST` / `A:ALBUM` / `A:GENRE` / `A:COMPOSER` / `A:TRACKS` / `A:PLAYLISTS` / `S:` / `SQ:` / `FV:2` / `R:0/0` / `R:0/1`) with optionally `:search+query` behind it. + * @param {string} options.BrowseFlag - How to browse [ 'BrowseMetadata' / 'BrowseDirectChildren' ] + * @param {string} options.Filter - Which fields should be returned `*` for all. + * @param {number} options.StartingIndex - Paging, where to start, usually 0 + * @param {number} options.RequestedCount - Paging, number of items, maximum is 1,000. This parameter does NOT restrict the number of items being searched (filter) but only the number being returned. + * @param {string} options.SortCriteria - Sort the results based on metadata fields. `+upnp:artist,+dc:title` for sorting on artist then on title. + * @remarks (1) If the title contains an apostrophe the returned uri will contain a `'`. (2) Some libraries support a BrowseAndParse, so you don't have to parse the xml. + * @returns {Promise} response object, with these properties `Result`, `NumberReturned`, `TotalMatches`, `UpdateID` + */ + Browse(options?: { + ObjectID: string; + BrowseFlag: string; + Filter: string; + StartingIndex: number; + RequestedCount: number; + SortCriteria: string; + }): Promise; + /** + * CreateObject + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.ContainerID + * @param {string} options.Elements + * @returns {Promise} response object, with these properties `ObjectID`, `Result` + */ + CreateObject(options?: { + ContainerID: string; + Elements: string; + }): Promise; + /** + * DestroyObject + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.ObjectID + * @returns {Promise} request succeeded + */ + DestroyObject(options?: { + ObjectID: string; + }): Promise; + /** + * FindPrefix + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.ObjectID + * @param {string} options.Prefix + * @returns {Promise} response object, with these properties `StartingIndex`, `UpdateID` + */ + FindPrefix(options?: { + ObjectID: string; + Prefix: string; + }): Promise; + /** + * GetAlbumArtistDisplayOption + * @returns {Promise} response object, with these properties `AlbumArtistDisplayOption` + */ + GetAlbumArtistDisplayOption(): Promise; + /** + * GetAllPrefixLocations + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.ObjectID + * @returns {Promise} response object, with these properties `TotalPrefixes`, `PrefixAndIndexCSV`, `UpdateID` + */ + GetAllPrefixLocations(options?: { + ObjectID: string; + }): Promise; + /** + * GetBrowseable + * @returns {Promise} response object, with these properties `IsBrowseable` + */ + GetBrowseable(): Promise; + /** + * GetLastIndexChange + * @returns {Promise} response object, with these properties `LastIndexChange` + */ + GetLastIndexChange(): Promise; + /** + * GetSearchCapabilities + * @returns {Promise} response object, with these properties `SearchCaps` + */ + GetSearchCapabilities(): Promise; + /** + * GetShareIndexInProgress + * @returns {Promise} response object, with these properties `IsIndexing` + */ + GetShareIndexInProgress(): Promise; + /** + * GetSortCapabilities + * @returns {Promise} response object, with these properties `SortCaps` + */ + GetSortCapabilities(): Promise; + /** + * GetSystemUpdateID + * @returns {Promise} response object, with these properties `Id` + */ + GetSystemUpdateID(): Promise; + /** + * RefreshShareIndex + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.AlbumArtistDisplayOption + * @returns {Promise} request succeeded + */ + RefreshShareIndex(options?: { + AlbumArtistDisplayOption: string; + }): Promise; + /** + * RequestResort + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.SortOrder + * @returns {Promise} request succeeded + */ + RequestResort(options?: { + SortOrder: string; + }): Promise; + /** + * SetBrowseable + * + * @param {Object} [options] - An object with the following properties + * @param {boolean} options.Browseable + * @returns {Promise} request succeeded + */ + SetBrowseable(options?: { + Browseable: boolean; + }): Promise; + /** + * UpdateObject + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.ObjectID + * @param {string} options.CurrentTagValue + * @param {string} options.NewTagValue + * @returns {Promise} request succeeded + */ + UpdateObject(options?: { + ObjectID: string; + CurrentTagValue: string; + NewTagValue: string; + }): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/device-properties.service.d.ts b/types/lib/services/device-properties.service.d.ts new file mode 100644 index 00000000..678c89f2 --- /dev/null +++ b/types/lib/services/device-properties.service.d.ts @@ -0,0 +1,281 @@ +export = DevicePropertiesService; +/** + * Sonos DevicePropertiesService + * + * Modify device properties, like LED status and stereo pairs + * + * @author Stephan van Rooij - https://svrooij.io + * @remarks This file is generated, do not edit manually. https://svrooij.io/sonos-api-docs + * @export + * @class DevicePropertiesService + * @extends {Service} + */ +declare class DevicePropertiesService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ + constructor(host: string, port: number); + /** + * AddBondedZones + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.ChannelMapSet + * @returns {Promise} request succeeded + */ + AddBondedZones(options?: { + ChannelMapSet: string; + }): Promise; + /** + * AddHTSatellite + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.HTSatChanMapSet + * @returns {Promise} request succeeded + */ + AddHTSatellite(options?: { + HTSatChanMapSet: string; + }): Promise; + /** + * CreateStereoPair - Create a stereo pair (left, right speakers), right one becomes hidden + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.ChannelMapSet - example: `RINCON_B8E9375831C001400:LF,LF;RINCON_000E58FE3AEA01400:RF,RF` + * @remarks No all speakers support StereoPairs + * @returns {Promise} request succeeded + */ + CreateStereoPair(options?: { + ChannelMapSet: string; + }): Promise; + /** + * EnterConfigMode + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.Mode + * @param {string} options.Options + * @returns {Promise} response object, with these properties `State` + */ + EnterConfigMode(options?: { + Mode: string; + Options: string; + }): Promise; + /** + * ExitConfigMode + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.Options + * @returns {Promise} request succeeded + */ + ExitConfigMode(options?: { + Options: string; + }): Promise; + /** + * GetAutoplayLinkedZones + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.Source + * @returns {Promise} response object, with these properties `IncludeLinkedZones` + */ + GetAutoplayLinkedZones(options?: { + Source: string; + }): Promise; + /** + * GetAutoplayRoomUUID + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.Source + * @returns {Promise} response object, with these properties `RoomUUID` + */ + GetAutoplayRoomUUID(options?: { + Source: string; + }): Promise; + /** + * GetAutoplayVolume + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.Source + * @returns {Promise} response object, with these properties `CurrentVolume` + */ + GetAutoplayVolume(options?: { + Source: string; + }): Promise; + /** + * GetButtonLockState - Get the current button lock state + * @returns {Promise} response object, with these properties `CurrentButtonLockState` + */ + GetButtonLockState(): Promise; + /** + * GetButtonState + * @returns {Promise} response object, with these properties `State` + */ + GetButtonState(): Promise; + /** + * GetHouseholdID + * @returns {Promise} response object, with these properties `CurrentHouseholdID` + */ + GetHouseholdID(): Promise; + /** + * GetLEDState - Get the current LED state + * @returns {Promise} response object, with these properties `CurrentLEDState` + */ + GetLEDState(): Promise; + /** + * GetUseAutoplayVolume + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.Source + * @returns {Promise} response object, with these properties `UseVolume` + */ + GetUseAutoplayVolume(options?: { + Source: string; + }): Promise; + /** + * GetZoneAttributes + * @returns {Promise} response object, with these properties `CurrentZoneName`, `CurrentIcon`, `CurrentConfiguration` + */ + GetZoneAttributes(): Promise; + /** + * GetZoneInfo - Get information about this specific speaker + * @returns {Promise} response object, with these properties `SerialNumber`, `SoftwareVersion`, `DisplaySoftwareVersion`, `HardwareVersion`, `IPAddress`, `MACAddress`, `CopyrightInfo`, `ExtraInfo`, `HTAudioIn`, `Flags` + */ + GetZoneInfo(): Promise; + /** + * RemoveBondedZones + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.ChannelMapSet + * @param {boolean} options.KeepGrouped + * @returns {Promise} request succeeded + */ + RemoveBondedZones(options?: { + ChannelMapSet: string; + KeepGrouped: boolean; + }): Promise; + /** + * RemoveHTSatellite + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.SatRoomUUID + * @returns {Promise} request succeeded + */ + RemoveHTSatellite(options?: { + SatRoomUUID: string; + }): Promise; + /** + * RoomDetectionStartChirping + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.Channel + * @param {number} options.DurationMilliseconds + * @returns {Promise} response object, with these properties `PlayId`, `ChirpIfPlayingSwappableAudio` + */ + RoomDetectionStartChirping(options?: { + Channel: number; + DurationMilliseconds: number; + }): Promise; + /** + * RoomDetectionStopChirping + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.PlayId + * @returns {Promise} request succeeded + */ + RoomDetectionStopChirping(options?: { + PlayId: number; + }): Promise; + /** + * SeparateStereoPair - Separate a stereo pair + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.ChannelMapSet - example: `RINCON_B8E9375831C001400:LF,LF;RINCON_000E58FE3AEA01400:RF,RF` + * @remarks No all speakers support StereoPairs + * @returns {Promise} request succeeded + */ + SeparateStereoPair(options?: { + ChannelMapSet: string; + }): Promise; + /** + * SetAutoplayLinkedZones + * + * @param {Object} [options] - An object with the following properties + * @param {boolean} options.IncludeLinkedZones + * @param {string} options.Source + * @returns {Promise} request succeeded + */ + SetAutoplayLinkedZones(options?: { + IncludeLinkedZones: boolean; + Source: string; + }): Promise; + /** + * SetAutoplayRoomUUID + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.RoomUUID + * @param {string} options.Source + * @returns {Promise} request succeeded + */ + SetAutoplayRoomUUID(options?: { + RoomUUID: string; + Source: string; + }): Promise; + /** + * SetAutoplayVolume + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.Volume + * @param {string} options.Source + * @returns {Promise} request succeeded + */ + SetAutoplayVolume(options?: { + Volume: number; + Source: string; + }): Promise; + /** + * SetButtonLockState - Set the button lock state + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.DesiredButtonLockState [ 'On' / 'Off' ] + * @returns {Promise} request succeeded + */ + SetButtonLockState(options?: { + DesiredButtonLockState: string; + }): Promise; + /** + * SetLEDState - Set the LED state + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.DesiredLEDState [ 'On' / 'Off' ] + * @returns {Promise} request succeeded + */ + SetLEDState(options?: { + DesiredLEDState: string; + }): Promise; + /** + * SetUseAutoplayVolume + * + * @param {Object} [options] - An object with the following properties + * @param {boolean} options.UseVolume + * @param {string} options.Source + * @returns {Promise} request succeeded + */ + SetUseAutoplayVolume(options?: { + UseVolume: boolean; + Source: string; + }): Promise; + /** + * SetZoneAttributes + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.DesiredZoneName + * @param {string} options.DesiredIcon + * @param {string} options.DesiredConfiguration + * @returns {Promise} request succeeded + */ + SetZoneAttributes(options?: { + DesiredZoneName: string; + DesiredIcon: string; + DesiredConfiguration: string; + }): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/group-management.service.d.ts b/types/lib/services/group-management.service.d.ts new file mode 100644 index 00000000..47b3231f --- /dev/null +++ b/types/lib/services/group-management.service.d.ts @@ -0,0 +1,65 @@ +export = GroupManagementService; +/** + * Sonos GroupManagementService + * + * Services related to groups + * + * @author Stephan van Rooij - https://svrooij.io + * @remarks This file is generated, do not edit manually. https://svrooij.io/sonos-api-docs + * @export + * @class GroupManagementService + * @extends {Service} + */ +declare class GroupManagementService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ + constructor(host: string, port: number); + /** + * AddMember + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.MemberID + * @param {number} options.BootSeq + * @returns {Promise} response object, with these properties `CurrentTransportSettings`, `CurrentURI`, `GroupUUIDJoined`, `ResetVolumeAfter`, `VolumeAVTransportURI` + */ + AddMember(options?: { + MemberID: string; + BootSeq: number; + }): Promise; + /** + * RemoveMember + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.MemberID + * @returns {Promise} request succeeded + */ + RemoveMember(options?: { + MemberID: string; + }): Promise; + /** + * ReportTrackBufferingResult + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.MemberID + * @param {number} options.ResultCode + * @returns {Promise} request succeeded + */ + ReportTrackBufferingResult(options?: { + MemberID: string; + ResultCode: number; + }): Promise; + /** + * SetSourceAreaIds + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.DesiredSourceAreaIds + * @returns {Promise} request succeeded + */ + SetSourceAreaIds(options?: { + DesiredSourceAreaIds: string; + }): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/group-rendering-control.service.d.ts b/types/lib/services/group-rendering-control.service.d.ts new file mode 100644 index 00000000..ac8d8103 --- /dev/null +++ b/types/lib/services/group-rendering-control.service.d.ts @@ -0,0 +1,93 @@ +export = GroupRenderingControlService; +/** + * Sonos GroupRenderingControlService + * + * Volume related controls for groups + * + * @author Stephan van Rooij - https://svrooij.io + * @remarks This file is generated, do not edit manually. https://svrooij.io/sonos-api-docs + * @export + * @class GroupRenderingControlService + * @extends {Service} + */ +declare class GroupRenderingControlService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ + constructor(host: string, port: number); + /** + * GetGroupMute - Get the group mute state. + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @remarks Should be send to coordinator only + * @returns {Promise} response object, with these properties `CurrentMute` + */ + GetGroupMute(options?: { + InstanceID: number; + }): Promise; + /** + * GetGroupVolume - Get the group volume. + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @remarks Should be send to coordinator only + * @returns {Promise} response object, with these properties `CurrentVolume` + */ + GetGroupVolume(options?: { + InstanceID: number; + }): Promise; + /** + * SetGroupMute - (Un-/)Mute the entire group + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {boolean} options.DesiredMute + * @remarks Should be send to coordinator only + * @returns {Promise} request succeeded + */ + SetGroupMute(options?: { + InstanceID: number; + DesiredMute: boolean; + }): Promise; + /** + * SetGroupVolume - Change group volume. Players volume will be changed proportionally based on last snapshot + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {number} options.DesiredVolume - New volume between 0 and 100 + * @remarks Should be send to coordinator only + * @returns {Promise} request succeeded + */ + SetGroupVolume(options?: { + InstanceID: number; + DesiredVolume: number; + }): Promise; + /** + * SetRelativeGroupVolume - Relatively change group volume - returns final group volume. Players volume will be changed proportionally based on last snapshot + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {number} options.Adjustment - Number between -100 and +100 + * @remarks Should be send to coordinator only + * @returns {Promise} response object, with these properties `NewVolume` + */ + SetRelativeGroupVolume(options?: { + InstanceID: number; + Adjustment: number; + }): Promise; + /** + * SnapshotGroupVolume - Creates a new group volume snapshot, the volume ratio between all players. It is used by SetGroupVolume and SetRelativeGroupVolume + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @remarks Should be send to coordinator only + * @returns {Promise} request succeeded + */ + SnapshotGroupVolume(options?: { + InstanceID: number; + }): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/ht-control.service.d.ts b/types/lib/services/ht-control.service.d.ts new file mode 100644 index 00000000..9d6bf1a3 --- /dev/null +++ b/types/lib/services/ht-control.service.d.ts @@ -0,0 +1,88 @@ +export = HTControlService; +/** + * Sonos HTControlService + * + * Service related to the TV remote control + * + * @author Stephan van Rooij - https://svrooij.io + * @remarks This file is generated, do not edit manually. https://svrooij.io/sonos-api-docs + * @export + * @class HTControlService + * @extends {Service} + */ +declare class HTControlService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ + constructor(host: string, port: number); + /** + * CommitLearnedIRCodes + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.Name + * @returns {Promise} request succeeded + */ + CommitLearnedIRCodes(options?: { + Name: string; + }): Promise; + /** + * GetIRRepeaterState + * @returns {Promise} response object, with these properties `CurrentIRRepeaterState` + */ + GetIRRepeaterState(): Promise; + /** + * GetLEDFeedbackState + * @returns {Promise} response object, with these properties `LEDFeedbackState` + */ + GetLEDFeedbackState(): Promise; + /** + * IdentifyIRRemote + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.Timeout + * @returns {Promise} request succeeded + */ + IdentifyIRRemote(options?: { + Timeout: number; + }): Promise; + /** + * IsRemoteConfigured + * @returns {Promise} response object, with these properties `RemoteConfigured` + */ + IsRemoteConfigured(): Promise; + /** + * LearnIRCode + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.IRCode + * @param {number} options.Timeout + * @returns {Promise} request succeeded + */ + LearnIRCode(options?: { + IRCode: string; + Timeout: number; + }): Promise; + /** + * SetIRRepeaterState + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.DesiredIRRepeaterState [ 'On' / 'Off' / 'Disabled' ] + * @returns {Promise} request succeeded + */ + SetIRRepeaterState(options?: { + DesiredIRRepeaterState: string; + }): Promise; + /** + * SetLEDFeedbackState + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.LEDFeedbackState [ 'On' / 'Off' ] + * @returns {Promise} request succeeded + */ + SetLEDFeedbackState(options?: { + LEDFeedbackState: string; + }): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/music-services.service.d.ts b/types/lib/services/music-services.service.d.ts new file mode 100644 index 00000000..70b5544c --- /dev/null +++ b/types/lib/services/music-services.service.d.ts @@ -0,0 +1,44 @@ +export = MusicServicesService; +/** + * Sonos MusicServicesService + * + * Access to external music services, like Spotify or Youtube Music + * + * @author Stephan van Rooij - https://svrooij.io + * @remarks This file is generated, do not edit manually. https://svrooij.io/sonos-api-docs + * @export + * @class MusicServicesService + * @extends {Service} + */ +declare class MusicServicesService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ + constructor(host: string, port: number); + /** + * GetSessionId + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.ServiceId + * @param {string} options.Username + * @returns {Promise} response object, with these properties `SessionId` + */ + GetSessionId(options?: { + ServiceId: number; + Username: string; + }): Promise; + /** + * ListAvailableServices - Load music service list as xml + * @remarks Some libraries also support ListAndParseAvailableServices + * @returns {Promise} response object, with these properties `AvailableServiceDescriptorList`, `AvailableServiceTypeList`, `AvailableServiceListVersion` + */ + ListAvailableServices(): Promise; + /** + * UpdateAvailableServices + * @returns {Promise} request succeeded + */ + UpdateAvailableServices(): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/q-play.service.d.ts b/types/lib/services/q-play.service.d.ts new file mode 100644 index 00000000..58c747aa --- /dev/null +++ b/types/lib/services/q-play.service.d.ts @@ -0,0 +1,31 @@ +export = QPlayService; +/** + * Sonos QPlayService + * + * Services related to Chinese Tencent Qplay service + * + * @author Stephan van Rooij - https://svrooij.io + * @remarks This file is generated, do not edit manually. https://svrooij.io/sonos-api-docs + * @export + * @class QPlayService + * @extends {Service} + */ +declare class QPlayService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ + constructor(host: string, port: number); + /** + * QPlayAuth + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.Seed + * @returns {Promise} response object, with these properties `Code`, `MID`, `DID` + */ + QPlayAuth(options?: { + Seed: string; + }): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/queue.service.d.ts b/types/lib/services/queue.service.d.ts new file mode 100644 index 00000000..7f16e9ba --- /dev/null +++ b/types/lib/services/queue.service.d.ts @@ -0,0 +1,192 @@ +export = QueueService; +/** + * Sonos QueueService + * + * Modify and browse queues + * + * @author Stephan van Rooij - https://svrooij.io + * @remarks This file is generated, do not edit manually. https://svrooij.io/sonos-api-docs + * @export + * @class QueueService + * @extends {Service} + */ +declare class QueueService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ + constructor(host: string, port: number); + /** + * AddMultipleURIs + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.QueueID + * @param {number} options.UpdateID + * @param {string} options.ContainerURI + * @param {string} options.ContainerMetaData + * @param {number} options.DesiredFirstTrackNumberEnqueued + * @param {boolean} options.EnqueueAsNext + * @param {number} options.NumberOfURIs + * @param {string} options.EnqueuedURIsAndMetaData + * @returns {Promise} response object, with these properties `FirstTrackNumberEnqueued`, `NumTracksAdded`, `NewQueueLength`, `NewUpdateID` + */ + AddMultipleURIs(options?: { + QueueID: number; + UpdateID: number; + ContainerURI: string; + ContainerMetaData: string; + DesiredFirstTrackNumberEnqueued: number; + EnqueueAsNext: boolean; + NumberOfURIs: number; + EnqueuedURIsAndMetaData: string; + }): Promise; + /** + * AddURI + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.QueueID + * @param {number} options.UpdateID + * @param {string} options.EnqueuedURI + * @param {string} options.EnqueuedURIMetaData + * @param {number} options.DesiredFirstTrackNumberEnqueued + * @param {boolean} options.EnqueueAsNext + * @returns {Promise} response object, with these properties `FirstTrackNumberEnqueued`, `NumTracksAdded`, `NewQueueLength`, `NewUpdateID` + */ + AddURI(options?: { + QueueID: number; + UpdateID: number; + EnqueuedURI: string; + EnqueuedURIMetaData: string; + DesiredFirstTrackNumberEnqueued: number; + EnqueueAsNext: boolean; + }): Promise; + /** + * AttachQueue + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.QueueOwnerID + * @returns {Promise} response object, with these properties `QueueID`, `QueueOwnerContext` + */ + AttachQueue(options?: { + QueueOwnerID: string; + }): Promise; + /** + * Backup + * @returns {Promise} request succeeded + */ + Backup(): Promise; + /** + * Browse + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.QueueID + * @param {number} options.StartingIndex + * @param {number} options.RequestedCount + * @returns {Promise} response object, with these properties `Result`, `NumberReturned`, `TotalMatches`, `UpdateID` + */ + Browse(options?: { + QueueID: number; + StartingIndex: number; + RequestedCount: number; + }): Promise; + /** + * CreateQueue + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.QueueOwnerID + * @param {string} options.QueueOwnerContext + * @param {string} options.QueuePolicy + * @returns {Promise} response object, with these properties `QueueID` + */ + CreateQueue(options?: { + QueueOwnerID: string; + QueueOwnerContext: string; + QueuePolicy: string; + }): Promise; + /** + * RemoveAllTracks + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.QueueID + * @param {number} options.UpdateID + * @returns {Promise} response object, with these properties `NewUpdateID` + */ + RemoveAllTracks(options?: { + QueueID: number; + UpdateID: number; + }): Promise; + /** + * RemoveTrackRange + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.QueueID + * @param {number} options.UpdateID + * @param {number} options.StartingIndex + * @param {number} options.NumberOfTracks + * @returns {Promise} response object, with these properties `NewUpdateID` + */ + RemoveTrackRange(options?: { + QueueID: number; + UpdateID: number; + StartingIndex: number; + NumberOfTracks: number; + }): Promise; + /** + * ReorderTracks + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.QueueID + * @param {number} options.StartingIndex + * @param {number} options.NumberOfTracks + * @param {number} options.InsertBefore + * @param {number} options.UpdateID + * @returns {Promise} response object, with these properties `NewUpdateID` + */ + ReorderTracks(options?: { + QueueID: number; + StartingIndex: number; + NumberOfTracks: number; + InsertBefore: number; + UpdateID: number; + }): Promise; + /** + * ReplaceAllTracks + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.QueueID + * @param {number} options.UpdateID + * @param {string} options.ContainerURI + * @param {string} options.ContainerMetaData + * @param {number} options.CurrentTrackIndex + * @param {string} options.NewCurrentTrackIndices + * @param {number} options.NumberOfURIs + * @param {string} options.EnqueuedURIsAndMetaData + * @returns {Promise} response object, with these properties `NewQueueLength`, `NewUpdateID` + */ + ReplaceAllTracks(options?: { + QueueID: number; + UpdateID: number; + ContainerURI: string; + ContainerMetaData: string; + CurrentTrackIndex: number; + NewCurrentTrackIndices: string; + NumberOfURIs: number; + EnqueuedURIsAndMetaData: string; + }): Promise; + /** + * SaveAsSonosPlaylist + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.QueueID + * @param {string} options.Title + * @param {string} options.ObjectID + * @returns {Promise} response object, with these properties `AssignedObjectID` + */ + SaveAsSonosPlaylist(options?: { + QueueID: number; + Title: string; + ObjectID: string; + }): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/rendering-control.service.d.ts b/types/lib/services/rendering-control.service.d.ts new file mode 100644 index 00000000..39db6ba1 --- /dev/null +++ b/types/lib/services/rendering-control.service.d.ts @@ -0,0 +1,369 @@ +export = RenderingControlService; +/** + * Sonos RenderingControlService + * + * Volume related controls + * + * @author Stephan van Rooij - https://svrooij.io + * @remarks This file is generated, do not edit manually. https://svrooij.io/sonos-api-docs + * @export + * @class RenderingControlService + * @extends {Service} + */ +declare class RenderingControlService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ + constructor(host: string, port: number); + /** + * GetBass - Get bass level between -10 and 10 + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @returns {Promise} response object, with these properties `CurrentBass` + */ + GetBass(options?: { + InstanceID: number; + }): Promise; + /** + * GetEQ - Get equalizer value + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.EQType - Allowed values `DialogLevel` (bool) / `MusicSurroundLevel` (-15/+15) / `NightMode` (bool) / `SubGain` (-10/+10) / `SurroundEnable` (bool) / `SurroundLevel` (-15/+15) / `SurroundMode` (0 = full, 1 = ambient) + * @remarks Not all EQ types are available on every speaker + * @returns {Promise} response object, with these properties `CurrentValue` + */ + GetEQ(options?: { + InstanceID: number; + EQType: string; + }): Promise; + /** + * GetHeadphoneConnected + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @returns {Promise} response object, with these properties `CurrentHeadphoneConnected` + */ + GetHeadphoneConnected(options?: { + InstanceID: number; + }): Promise; + /** + * GetLoudness - Whether or not Loudness is on + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] + * @returns {Promise} response object, with these properties `CurrentLoudness` + */ + GetLoudness(options?: { + InstanceID: number; + Channel: string; + }): Promise; + /** + * GetMute + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' / 'SpeakerOnly' ] + * @returns {Promise} response object, with these properties `CurrentMute` + */ + GetMute(options?: { + InstanceID: number; + Channel: string; + }): Promise; + /** + * GetOutputFixed + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @returns {Promise} response object, with these properties `CurrentFixed` + */ + GetOutputFixed(options?: { + InstanceID: number; + }): Promise; + /** + * GetRoomCalibrationStatus + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @returns {Promise} response object, with these properties `RoomCalibrationEnabled`, `RoomCalibrationAvailable` + */ + GetRoomCalibrationStatus(options?: { + InstanceID: number; + }): Promise; + /** + * GetSupportsOutputFixed + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @returns {Promise} response object, with these properties `CurrentSupportsFixed` + */ + GetSupportsOutputFixed(options?: { + InstanceID: number; + }): Promise; + /** + * GetTreble - Get treble + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @returns {Promise} response object, with these properties `CurrentTreble` + */ + GetTreble(options?: { + InstanceID: number; + }): Promise; + /** + * GetVolume - Get volume + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] + * @returns {Promise} response object, with these properties `CurrentVolume` + */ + GetVolume(options?: { + InstanceID: number; + Channel: string; + }): Promise; + /** + * GetVolumeDB + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] + * @returns {Promise} response object, with these properties `CurrentVolume` + */ + GetVolumeDB(options?: { + InstanceID: number; + Channel: string; + }): Promise; + /** + * GetVolumeDBRange + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] + * @returns {Promise} response object, with these properties `MinValue`, `MaxValue` + */ + GetVolumeDBRange(options?: { + InstanceID: number; + Channel: string; + }): Promise; + /** + * RampToVolume + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] + * @param {string} options.RampType [ 'SLEEP_TIMER_RAMP_TYPE' / 'ALARM_RAMP_TYPE' / 'AUTOPLAY_RAMP_TYPE' ] + * @param {number} options.DesiredVolume + * @param {boolean} options.ResetVolumeAfter + * @param {string} options.ProgramURI + * @returns {Promise} response object, with these properties `RampTime` + */ + RampToVolume(options?: { + InstanceID: number; + Channel: string; + RampType: string; + DesiredVolume: number; + ResetVolumeAfter: boolean; + ProgramURI: string; + }): Promise; + /** + * ResetBasicEQ + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @returns {Promise} response object, with these properties `Bass`, `Treble`, `Loudness`, `LeftVolume`, `RightVolume` + */ + ResetBasicEQ(options?: { + InstanceID: number; + }): Promise; + /** + * ResetExtEQ + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.EQType + * @returns {Promise} request succeeded + */ + ResetExtEQ(options?: { + InstanceID: number; + EQType: string; + }): Promise; + /** + * RestoreVolumePriorToRamp + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] + * @returns {Promise} request succeeded + */ + RestoreVolumePriorToRamp(options?: { + InstanceID: number; + Channel: string; + }): Promise; + /** + * SetBass - Set bass level, between -10 and 10 + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {number} options.DesiredBass + * @returns {Promise} request succeeded + */ + SetBass(options?: { + InstanceID: number; + DesiredBass: number; + }): Promise; + /** + * SetChannelMap + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.ChannelMap + * @returns {Promise} request succeeded + */ + SetChannelMap(options?: { + InstanceID: number; + ChannelMap: string; + }): Promise; + /** + * SetEQ - Set equalizer value for different types + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.EQType - Allowed values `DialogLevel` (bool) / `MusicSurroundLevel` (-15/+15) / `NightMode` (bool) / `SubGain` (-10/+10) / `SurroundEnable` (bool) / `SurroundLevel` (-15/+15) / `SurroundMode` (0 = full, 1 = ambient) + * @param {number} options.DesiredValue - Booleans required `1` for true or `0` for false, rest number as specified + * @remarks Not supported by all speakers, TV related + * @returns {Promise} request succeeded + */ + SetEQ(options?: { + InstanceID: number; + EQType: string; + DesiredValue: number; + }): Promise; + /** + * SetLoudness - Set loudness on / off + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] + * @param {boolean} options.DesiredLoudness + * @returns {Promise} request succeeded + */ + SetLoudness(options?: { + InstanceID: number; + Channel: string; + DesiredLoudness: boolean; + }): Promise; + /** + * SetMute + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' / 'SpeakerOnly' ] + * @param {boolean} options.DesiredMute + * @returns {Promise} request succeeded + */ + SetMute(options?: { + InstanceID: number; + Channel: string; + DesiredMute: boolean; + }): Promise; + /** + * SetOutputFixed + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {boolean} options.DesiredFixed + * @returns {Promise} request succeeded + */ + SetOutputFixed(options?: { + InstanceID: number; + DesiredFixed: boolean; + }): Promise; + /** + * SetRelativeVolume + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] + * @param {number} options.Adjustment + * @returns {Promise} response object, with these properties `NewVolume` + */ + SetRelativeVolume(options?: { + InstanceID: number; + Channel: string; + Adjustment: number; + }): Promise; + /** + * SetRoomCalibrationStatus + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {boolean} options.RoomCalibrationEnabled + * @returns {Promise} request succeeded + */ + SetRoomCalibrationStatus(options?: { + InstanceID: number; + RoomCalibrationEnabled: boolean; + }): Promise; + /** + * SetRoomCalibrationX + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.CalibrationID + * @param {string} options.Coefficients + * @param {string} options.CalibrationMode + * @returns {Promise} request succeeded + */ + SetRoomCalibrationX(options?: { + InstanceID: number; + CalibrationID: string; + Coefficients: string; + CalibrationMode: string; + }): Promise; + /** + * SetTreble - Set treble level + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {number} options.DesiredTreble - between -10 and 10 + * @returns {Promise} request succeeded + */ + SetTreble(options?: { + InstanceID: number; + DesiredTreble: number; + }): Promise; + /** + * SetVolume + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] + * @param {number} options.DesiredVolume + * @returns {Promise} request succeeded + */ + SetVolume(options?: { + InstanceID: number; + Channel: string; + DesiredVolume: number; + }): Promise; + /** + * SetVolumeDB + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID - InstanceID should always be `0` + * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] + * @param {number} options.DesiredVolume + * @returns {Promise} request succeeded + */ + SetVolumeDB(options?: { + InstanceID: number; + Channel: string; + DesiredVolume: number; + }): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/system-properties.service.d.ts b/types/lib/services/system-properties.service.d.ts new file mode 100644 index 00000000..e634c8b8 --- /dev/null +++ b/types/lib/services/system-properties.service.d.ts @@ -0,0 +1,231 @@ +export = SystemPropertiesService; +/** + * Sonos SystemPropertiesService + * + * Manage system-wide settings, mainly account stuff + * + * @author Stephan van Rooij - https://svrooij.io + * @remarks This file is generated, do not edit manually. https://svrooij.io/sonos-api-docs + * @export + * @class SystemPropertiesService + * @extends {Service} + */ +declare class SystemPropertiesService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ + constructor(host: string, port: number); + /** + * AddAccountX + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.AccountType + * @param {string} options.AccountID + * @param {string} options.AccountPassword + * @returns {Promise} response object, with these properties `AccountUDN` + */ + AddAccountX(options?: { + AccountType: number; + AccountID: string; + AccountPassword: string; + }): Promise; + /** + * AddOAuthAccountX + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.AccountType + * @param {string} options.AccountToken + * @param {string} options.AccountKey + * @param {string} options.OAuthDeviceID + * @param {string} options.AuthorizationCode + * @param {string} options.RedirectURI + * @param {string} options.UserIdHashCode + * @param {number} options.AccountTier + * @returns {Promise} response object, with these properties `AccountUDN`, `AccountNickname` + */ + AddOAuthAccountX(options?: { + AccountType: number; + AccountToken: string; + AccountKey: string; + OAuthDeviceID: string; + AuthorizationCode: string; + RedirectURI: string; + UserIdHashCode: string; + AccountTier: number; + }): Promise; + /** + * DoPostUpdateTasks + * @returns {Promise} request succeeded + */ + DoPostUpdateTasks(): Promise; + /** + * EditAccountMd + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.AccountType + * @param {string} options.AccountID + * @param {string} options.NewAccountMd + * @returns {Promise} request succeeded + */ + EditAccountMd(options?: { + AccountType: number; + AccountID: string; + NewAccountMd: string; + }): Promise; + /** + * EditAccountPasswordX + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.AccountType + * @param {string} options.AccountID + * @param {string} options.NewAccountPassword + * @returns {Promise} request succeeded + */ + EditAccountPasswordX(options?: { + AccountType: number; + AccountID: string; + NewAccountPassword: string; + }): Promise; + /** + * EnableRDM + * + * @param {Object} [options] - An object with the following properties + * @param {boolean} options.RDMValue + * @returns {Promise} request succeeded + */ + EnableRDM(options?: { + RDMValue: boolean; + }): Promise; + /** + * GetRDM + * @returns {Promise} response object, with these properties `RDMValue` + */ + GetRDM(): Promise; + /** + * GetString - Get a saved string. + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.VariableName - The key for this variable + * @remarks Strings are saved in the system with SetString, every speaker should return the same data. Will error when not existing + * @returns {Promise} response object, with these properties `StringValue` + */ + GetString(options?: { + VariableName: string; + }): Promise; + /** + * GetWebCode + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.AccountType + * @returns {Promise} response object, with these properties `WebCode` + */ + GetWebCode(options?: { + AccountType: number; + }): Promise; + /** + * ProvisionCredentialedTrialAccountX + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.AccountType + * @param {string} options.AccountID + * @param {string} options.AccountPassword + * @returns {Promise} response object, with these properties `IsExpired`, `AccountUDN` + */ + ProvisionCredentialedTrialAccountX(options?: { + AccountType: number; + AccountID: string; + AccountPassword: string; + }): Promise; + /** + * RefreshAccountCredentialsX + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.AccountType + * @param {number} options.AccountUID + * @param {string} options.AccountToken + * @param {string} options.AccountKey + * @returns {Promise} request succeeded + */ + RefreshAccountCredentialsX(options?: { + AccountType: number; + AccountUID: number; + AccountToken: string; + AccountKey: string; + }): Promise; + /** + * Remove - Remove a saved string + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.VariableName - The key for this variable + * @remarks Not sure what happens if you call this with a VariableName that doesn't exists. + * @returns {Promise} request succeeded + */ + Remove(options?: { + VariableName: string; + }): Promise; + /** + * RemoveAccount + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.AccountType + * @param {string} options.AccountID + * @returns {Promise} request succeeded + */ + RemoveAccount(options?: { + AccountType: number; + AccountID: string; + }): Promise; + /** + * ReplaceAccountX + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.AccountUDN + * @param {string} options.NewAccountID + * @param {string} options.NewAccountPassword + * @param {string} options.AccountToken + * @param {string} options.AccountKey + * @param {string} options.OAuthDeviceID + * @returns {Promise} response object, with these properties `NewAccountUDN` + */ + ReplaceAccountX(options?: { + AccountUDN: string; + NewAccountID: string; + NewAccountPassword: string; + AccountToken: string; + AccountKey: string; + OAuthDeviceID: string; + }): Promise; + /** + * ResetThirdPartyCredentials + * @returns {Promise} request succeeded + */ + ResetThirdPartyCredentials(): Promise; + /** + * SetAccountNicknameX + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.AccountUDN + * @param {string} options.AccountNickname + * @returns {Promise} request succeeded + */ + SetAccountNicknameX(options?: { + AccountUDN: string; + AccountNickname: string; + }): Promise; + /** + * SetString - Save a string in the system + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.VariableName - The key for this variable, use something unique + * @param {string} options.StringValue + * @remarks Strings are saved in the system, retrieve values with GetString. + * @returns {Promise} request succeeded + */ + SetString(options?: { + VariableName: string; + StringValue: string; + }): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/virtual-line-in.service.d.ts b/types/lib/services/virtual-line-in.service.d.ts new file mode 100644 index 00000000..79bf896f --- /dev/null +++ b/types/lib/services/virtual-line-in.service.d.ts @@ -0,0 +1,107 @@ +export = VirtualLineInService; +/** + * Sonos VirtualLineInService + * + * @author Stephan van Rooij - https://svrooij.io + * @remarks This file is generated, do not edit manually. https://svrooij.io/sonos-api-docs + * @export + * @class VirtualLineInService + * @extends {Service} + */ +declare class VirtualLineInService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ + constructor(host: string, port: number); + /** + * Next + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID + * @returns {Promise} request succeeded + */ + Next(options?: { + InstanceID: number; + }): Promise; + /** + * Pause + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID + * @returns {Promise} request succeeded + */ + Pause(options?: { + InstanceID: number; + }): Promise; + /** + * Play + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID + * @param {string} options.Speed + * @returns {Promise} request succeeded + */ + Play(options?: { + InstanceID: number; + Speed: string; + }): Promise; + /** + * Previous + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID + * @returns {Promise} request succeeded + */ + Previous(options?: { + InstanceID: number; + }): Promise; + /** + * SetVolume + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID + * @param {number} options.DesiredVolume + * @returns {Promise} request succeeded + */ + SetVolume(options?: { + InstanceID: number; + DesiredVolume: number; + }): Promise; + /** + * StartTransmission + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID + * @param {string} options.CoordinatorID + * @returns {Promise} response object, with these properties `CurrentTransportSettings` + */ + StartTransmission(options?: { + InstanceID: number; + CoordinatorID: string; + }): Promise; + /** + * Stop + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID + * @returns {Promise} request succeeded + */ + Stop(options?: { + InstanceID: number; + }): Promise; + /** + * StopTransmission + * + * @param {Object} [options] - An object with the following properties + * @param {number} options.InstanceID + * @param {string} options.CoordinatorID + * @returns {Promise} request succeeded + */ + StopTransmission(options?: { + InstanceID: number; + CoordinatorID: string; + }): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/services/zone-group-topology.service.d.ts b/types/lib/services/zone-group-topology.service.d.ts new file mode 100644 index 00000000..3dc55d44 --- /dev/null +++ b/types/lib/services/zone-group-topology.service.d.ts @@ -0,0 +1,103 @@ +export = ZoneGroupTopologyService; +/** + * Sonos ZoneGroupTopologyService + * + * Zone config stuff, eg getting all the configured sonos zones + * + * @author Stephan van Rooij - https://svrooij.io + * @remarks This file is generated, do not edit manually. https://svrooij.io/sonos-api-docs + * @export + * @class ZoneGroupTopologyService + * @extends {Service} + */ +declare class ZoneGroupTopologyService extends Service { + /** + * + * @param {string} host Sonos host + * @param {number} port Sonos port, default `1400` + */ + constructor(host: string, port: number); + /** + * BeginSoftwareUpdate + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.UpdateURL + * @param {number} options.Flags + * @param {string} options.ExtraOptions + * @returns {Promise} request succeeded + */ + BeginSoftwareUpdate(options?: { + UpdateURL: string; + Flags: number; + ExtraOptions: string; + }): Promise; + /** + * CheckForUpdate + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.UpdateType [ 'All' / 'Software' ] + * @param {boolean} options.CachedOnly + * @param {string} options.Version + * @returns {Promise} response object, with these properties `UpdateItem` + */ + CheckForUpdate(options?: { + UpdateType: string; + CachedOnly: boolean; + Version: string; + }): Promise; + /** + * GetZoneGroupAttributes - Get information about the current Zone + * @returns {Promise} response object, with these properties `CurrentZoneGroupName`, `CurrentZoneGroupID`, `CurrentZonePlayerUUIDsInGroup`, `CurrentMuseHouseholdId` + */ + GetZoneGroupAttributes(): Promise; + /** + * GetZoneGroupState - Get all the Sonos groups, (as XML) + * @remarks Some libraries also support GetParsedZoneGroupState that parses the xml for you. + * @returns {Promise} response object, with these properties `ZoneGroupState` + */ + GetZoneGroupState(): Promise; + /** + * RegisterMobileDevice + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.MobileDeviceName + * @param {string} options.MobileDeviceUDN + * @param {string} options.MobileIPAndPort + * @returns {Promise} request succeeded + */ + RegisterMobileDevice(options?: { + MobileDeviceName: string; + MobileDeviceUDN: string; + MobileIPAndPort: string; + }): Promise; + /** + * ReportAlarmStartedRunning + * @returns {Promise} request succeeded + */ + ReportAlarmStartedRunning(): Promise; + /** + * ReportUnresponsiveDevice + * + * @param {Object} [options] - An object with the following properties + * @param {string} options.DeviceUUID + * @param {string} options.DesiredAction [ 'Remove' / 'TopologyMonitorProbe' / 'VerifyThenRemoveSystemwide' ] + * @returns {Promise} request succeeded + */ + ReportUnresponsiveDevice(options?: { + DeviceUUID: string; + DesiredAction: string; + }): Promise; + /** + * SubmitDiagnostics + * + * @param {Object} [options] - An object with the following properties + * @param {boolean} options.IncludeControllers + * @param {string} options.Type + * @returns {Promise} response object, with these properties `DiagnosticID` + */ + SubmitDiagnostics(options?: { + IncludeControllers: boolean; + Type: string; + }): Promise; +} +import Service = require("./Service"); diff --git a/types/lib/sonos.d.ts b/types/lib/sonos.d.ts new file mode 100644 index 00000000..2d426de6 --- /dev/null +++ b/types/lib/sonos.d.ts @@ -0,0 +1,393 @@ +/** + * Create an instance of Sonos + * @class Sonos + * @param {String} host IP/DNS + * @param {Number} port port, defaults to `1400` + * @returns {Sonos} + */ +export class Sonos extends EventEmitter { + constructor(host: any, port: any, options: any); + host: any; + port: any; + options: any; + _isSubscribed: any; + _state: any; + _mute: any; + _volume: any; + /** + * Get Music Library Information + * @param {String} searchType Choice - artists, albumArtists, albums, genres, composers, tracks, playlists, share + * @param {Object} options Optional - default {start: 0, total: 100} + * @returns {Promise} {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]} + */ + getMusicLibrary(searchType: string, options: any): Promise; + /** + * Get Music Library Information + * @param {String} searchType Choice - artists, albumArtists, albums, genres, composers, tracks, playlists, share + * @param {String} searchTerm Optional - search term to search for + * @param {Object} requestOptions Optional - default {start: 0, total: 100} + * @param {String} separator Optional - default is colon. `:` or `/` + * @returns {Promise} {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]} + */ + searchMusicLibrary(searchType: string, searchTerm: string, requestOptions?: any, separator?: string): Promise; + /** + * Get Sonos Playlist + * @param {String} playlistId Sonos id of the playlist + * @param {Object} requestOptions Optional - default {start: 0, total: 100} + * @returns {Promise} {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]} + */ + getPlaylist(playlistId: string, requestOptions?: any): Promise; + /** + * Create a new sonos playlist + * @param {String} title Name of the playlist + * @returns {Promise} { NumTracksAdded: 0, NewQueueLength: 0, NewUpdateID: 0, AssignedObjectID: 'SQ:3' } + */ + createPlaylist(title: string): Promise; + /** + * Delete sonos playlist + * @param {Number} playlistId Sonos id of the playlist + * @returns {Promise} Playlist deleted + */ + deletePlaylist(playlistId: number): Promise; + /** + * Add uri to sonos playlist + * @param {String} playlistId Sonos id of the playlist + * @param {String} uri Uri to add to the playlist + * @returns {Promise} { NumTracksAdded: 1, NewQueueLength: 2, NewUpdateID: 2 } + */ + addToPlaylist(playlistId: string, uri: string): Promise; + /** + * Remove track from playlist + * @param {String} playlistId Sonos id of the playlist + * @param {String} index Index of song to remove + * @returns {Promise} { QueueLengthChange: -1, NewQueueLength: 2, NewUpdateID: 2 } + */ + removeFromPlaylist(playlistId: string, index: string): Promise; + /** + * Get Sonos Favorites + * @returns {Promise} {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]} + */ + getFavorites(): Promise; + /** + * Get Current Track + * @returns {Promise} All the info of the current track + */ + currentTrack(): Promise; + /** + * Get Current Volume + * @returns {Promise} The current volume + */ + getVolume(): Promise; + /** + * Get Current Muted + * @returns {Promise} + */ + getMuted(): Promise; + /** + * Resumes Queue or Plays Provided URI + * @param {String|Object} options Optional - URI to a Audio Stream or Object with play options + * @returns {Promise} Started playing? + */ + play(options: string | any): Promise; + /** + * Plays a uri directly (the queue stays the same) + * @param {String|Object} options URI to a Audio Stream or Object with play options see `Helpers.GenerateMetadata` + * @returns {Promise} + */ + setAVTransportURI(options: string | any): Promise; + /** + * Stop What's Playing + * @returns {Promise} + */ + stop(): Promise; + /** + * Get all the groups, replaces some functionality of 'getTopology()' + */ + getAllGroups(): Promise; + /** + * Become Coordinator of Standalone Group + * @returns {Promise} + */ + becomeCoordinatorOfStandaloneGroup(): Promise; + /** + * Leave the group (shortcut to becomeCoordinatorOfStandaloneGroup) + * @returns {Promise} + */ + leaveGroup(): Promise; + /** + * Join an other device by name + * @param {String} otherDeviceName The name of de device you want to join, doesn't matter if that isn't the coordinator + * @returns {Promise} + */ + joinGroup(otherDeviceName: string): Promise; + /** + * Pause Current Queue + * @returns {Promise} + */ + pause(): Promise; + /** + * Seek in the current track + * @param {Number} seconds jump to x seconds. + * @returns {Promise} + */ + seek(seconds: number): Promise; + /** + * Select specific track in queue + * @param {Number} trackNr Number of track in queue (optional, indexed from 1) + * @returns {Promise} + */ + selectTrack(trackNr: number): Promise; + /** + * Play next in queue + * @returns {Promise} + */ + next(): Promise; + /** + * Play previous in queue + * @returns {Promise} + */ + previous(): Promise; + /** + * Select Queue. Mostly required after turning on the speakers otherwise play, setPlaymode and other commands will fail. + * @returns {Promise} success + */ + selectQueue(): Promise; + /** + * Plays tunein based on radio station id + * @param {String} stationId tunein radio station id + * @returns {Promise} + */ + playTuneinRadio(stationId: string, stationTitle: any): Promise; + /** + * Plays Spotify radio based on artist uri + * @param {String} artistId Spotify artist id + * @returns {Promise} + */ + playSpotifyRadio(artistId: string, artistName: any): Promise; + /** + * Add a song to the queue. + * @param {String|Object} options Uri with audio stream of object with `uri` and `metadata` + * @param {Number} positionInQueue Position in queue at which to add song (optional, indexed from 1, + * defaults to end of queue, 0 to explicitly set end of queue) + * @returns {Promise} Some info about the last queued file. + */ + queue(options: string | any, positionInQueue?: number): Promise; + /** + * Remove a range of tracks from the queue. + * @param {number} startIndex Where to start removing the tracks, 1 for first item! + * @param {number} numberOfTracks How many tracks to remove. + */ + removeTracksFromQueue(startIndex: number, numberOfTracks?: number): Promise; + /** + * Flush queue + * @returns {Promise} + */ + flush(): Promise; + /** + * Get the LED State + * @returns {Promise} state is a string, "On" or "Off" + */ + getLEDState(): Promise; + /** + * Set the LED State + * @param {String} newState "On"/"Off" + * @returns {Promise} + */ + setLEDState(newState: string): Promise; + /** + * Get Zone Info + * @returns {Promise} + */ + getZoneInfo(): Promise; + /** + * Get Zone Attributes + * @returns {Promise} + */ + getZoneAttrs(): Promise; + /** + * Get Information provided by /xml/device_description.xml + * @returns {Promise} + */ + deviceDescription(): Promise; + /** + * Set Name + * @param {String} name + * @returns {Promise} + */ + setName(name: string): Promise; + /** + * Get the CurrentZoneName + * @returns {Promise} + */ + getName(): Promise; + /** + * Get Play Mode + * @returns {Promise} + */ + getPlayMode(): Promise; + /** + * Set Play Mode + * @param {String} playmode + * @returns {Promise} + */ + setPlayMode(playmode: string): Promise; + /** + * Set Volume + * @param {number} volume 0..100 + * @param {string} channel What channel to change, `Master` is default. + * @returns {Promise} + */ + setVolume(volume: number, channel?: string): Promise; + /** + * Adjust volume + * @param {number} volumeAdjustment The relative volume adjustment + * @param {string} channel The channel you want to set, `Master` is default. + */ + adjustVolume(volumeAdjustment: number, channel?: string): Promise; + /** + * Configure Sleep Timer + * @param {String} sleepTimerDuration + * @returns {Promise} + */ + configureSleepTimer(sleepTimerDuration: string): Promise; + /** + * Set Muted + * @param {Boolean} muted + * @param {string} channel What channel to change, `Master` is default. + * @returns {Promise} + */ + setMuted(muted: boolean, channel?: string): Promise; + /** + * Get device balance as number from -100 (full left) to +100 (full right), where 0 is left and right equal + * @returns {Promise} + */ + getBalance(): Promise; + /** + * Set device balance + * @param {Number} balance from -100 (full left) to +100 (full right), where 0 is left and right equal + * @returns {Promise} + */ + setBalance(balance: number): Promise; + /** + * Get Zones in contact with current Zone with Group Data + * @deprecated Doesn't work if you upgraded your system to Sonos v9.1 + * @returns {Promise} + */ + getTopology(): Promise; + /** + * Get Current Playback State + * @returns {Promise} the current playback state + */ + getCurrentState(): Promise; + /** + * Toggle the current playback, like the button. Currently only works for state `playing` or `paused` + * @returns {Promise} + */ + togglePlayback(): Promise; + /** + * Get Favorites Radio Stations + * @param {Object} options Optional - default {start: 0, total: 100} + * @returns {Promise} {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]} + */ + getFavoritesRadioStations(options: any): Promise; + /** + * Get Favorites Radio Shows + * @param {Object} options Optional - default {start: 0, total: 100} + * @returns {Promise} {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]} + */ + getFavoritesRadioShows(options: any): Promise; + /** + * Get Favorites Radio for a given radio type + * @param {String} favoriteRadioType Choice - stations, shows + * @param {Object} requestOptions Optional - default {start: 0, total: 100} + * @returns {Promise} {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]} + */ + getFavoritesRadio(favoriteRadioType: string, requestOptions?: any): Promise; + setSpotifyRegion(region: any): void; + /** + * Get the current queue + * @returns {Promise} {returned: {String}, total: {String}, items:[{title:{String}, uri: {String}}]} + */ + getQueue(): Promise; + /** + * Play uri and restore last state + * @param {Object} options URI to a Audio Stream or Object with play options see `Helpers.GenerateMetadata` + * @param {String} options.uri The URI of the stream + * @param {String} options.metadata The metadata of the stream see `Helpers.GenerateMetadata` + * @param {Boolean} options.onlyWhenPlaying Only play this notification on players currently 'playing' + * @param {Number} options.volume The volume used for the notification. + * @returns {Promise} Did the notification play? Only returns when finished reverting to old play settings. + */ + playNotification(options: { + uri: string; + metadata: string; + onlyWhenPlaying: boolean; + volume: number; + }): Promise; + /** + * Reorder tracks in queue. + * @param {number} startingIndex Index of the first track to be moved + * @param {number} numberOfTracks How many tracks do we want to move + * @param {number} insertBefore Index of place where the tracks should be moved to + * @param {number} updateId Not sure what this means, just leave it at `0` + * @returns {Promise} + */ + reorderTracksInQueue(startingIndex: number, numberOfTracks: number, insertBefore: number, updateId?: number): Promise; + /** + * Get SpotifyConnect info, will error when no premium account is present + * @returns {Promise} + */ + getSpotifyConnectInfo(): Promise; + /** + * Get device spicific ZPInfo, will return empty object if failed for some reason + * This is useful for extracting the HouseholdControlID, Mac Address, serial number etc + * @returns {Promise} + */ + getZPInfo(): Promise; + alarmClockService(): import("./services/AlarmClock"); + avTransportService(): import("./services/AVTransport"); + contentDirectoryService(): import("./services/ContentDirectory"); + devicePropertiesService(): import("./services/DeviceProperties"); + groupRenderingControlService(): import("./services/GroupRenderingControl"); + renderingControlService(): import("./services/RenderingControl"); + zoneGroupTopologyService(): import("./services/ZoneGroupTopology"); + musicServices(): import("./services/MusicServices"); + /** + * Get all services available to sonos. + */ + get generatedServices(): GeneratedServices.AllServices; +} +import deviceDiscovery = require("./deviceDiscovery"); +import asyncDeviceDiscovery = require("./asyncDeviceDiscovery"); +import Helpers = require("./helpers"); +export namespace Services { + const AlarmClock_1: typeof import("./services/AlarmClock"); + export { AlarmClock_1 as AlarmClock }; + export const AudioIn: typeof import("./services/AudioIn"); + const AVTransport_1: typeof import("./services/AVTransport"); + export { AVTransport_1 as AVTransport }; + const ContentDirectory_1: typeof import("./services/ContentDirectory"); + export { ContentDirectory_1 as ContentDirectory }; + const DeviceProperties_1: typeof import("./services/DeviceProperties"); + export { DeviceProperties_1 as DeviceProperties }; + export const GroupManagement: typeof import("./services/GroupManagement"); + const GroupRenderingControl_1: typeof import("./services/GroupRenderingControl"); + export { GroupRenderingControl_1 as GroupRenderingControl }; + const MusicServices_1: typeof import("./services/MusicServices"); + export { MusicServices_1 as MusicServices }; + const RenderingControl_1: typeof import("./services/RenderingControl"); + export { RenderingControl_1 as RenderingControl }; + export const Service: typeof import("./services/Service"); + export const SystemProperties: typeof import("./services/SystemProperties"); + const ZoneGroupTopology_1: typeof import("./services/ZoneGroupTopology"); + export { ZoneGroupTopology_1 as ZoneGroupTopology }; +} +import GeneratedServices = require("./services/all-services"); +import Listener = require("./events/adv-listener"); +export namespace SpotifyRegion { + const EU: string; + const US: string; +} +import EventEmitter_1 = require("events"); +import EventEmitter = EventEmitter_1.EventEmitter; +export { deviceDiscovery as DeviceDiscovery, deviceDiscovery as Search, asyncDeviceDiscovery as AsyncDeviceDiscovery, Helpers, GeneratedServices, Listener }; diff --git a/types/lib/sonosGroup.d.ts b/types/lib/sonosGroup.d.ts new file mode 100644 index 00000000..48e39117 --- /dev/null +++ b/types/lib/sonosGroup.d.ts @@ -0,0 +1,11 @@ +export = SonosGroup; +declare class SonosGroup { + constructor(zoneGroup: any); + CoordinatorID: any; + Members: any[]; + Name: any; + Coordinator: { + host: string; + port: string; + }; +} From 4b62c2415d1caa2c31df52ad86fa66ad63ed397b Mon Sep 17 00:00:00 2001 From: Stephan van Rooij <1292510+svrooij@users.noreply.github.com> Date: Sun, 3 Oct 2021 14:57:48 +0200 Subject: [PATCH 5/6] fix: Types improved --- examples/deviceDiscovery.js | 31 +- lib/asyncDeviceDiscovery.js | 15 +- lib/deviceDiscovery.js | 4 +- lib/events/adv-listener.js | 37 +- lib/helpers.js | 560 ++++++++++++++-------------- lib/services/AlarmClock.js | 2 +- lib/sonosGroup.js | 10 +- types/lib/asyncDeviceDiscovery.d.ts | 20 +- types/lib/deviceDiscovery.d.ts | 6 +- types/lib/events/adv-listener.d.ts | 4 +- types/lib/events/eventParser.d.ts | 3 +- types/lib/helpers.d.ts | 186 ++++----- types/lib/services/AlarmClock.d.ts | 4 +- types/lib/sonosGroup.d.ts | 14 +- 14 files changed, 488 insertions(+), 408 deletions(-) diff --git a/examples/deviceDiscovery.js b/examples/deviceDiscovery.js index e17b1ec9..1093fe6a 100644 --- a/examples/deviceDiscovery.js +++ b/examples/deviceDiscovery.js @@ -4,21 +4,26 @@ console.log('Searching for Sonos devices for 10 seconds...') const discovery = new Sonos.AsyncDeviceDiscovery() -discovery.discover({ port: 50333, timeout: 10000 }).then((device, model) => { - console.log('Found one sonos device %s getting all groups', device.host) - return device.getAllGroups().then((groups) => { - console.log('Groups %s', JSON.stringify(groups, null, 2)) - return groups[0].CoordinatorDevice().togglePlayback() +// discovery.discover({ port: 50333, timeout: 10000 }).then((device, model) => { +// console.log('Found one sonos device %s getting all groups', device.host) +// return device.getAllGroups().then((groups) => { +// console.log('Groups %s', JSON.stringify(groups, null, 2)) +// //return groups[0].CoordinatorDevice().togglePlayback() +// }) +// }).catch(e => { +// console.warn(' Error in discovery %o', e) +// }) + +discovery.discoverMultiple({ port: 50333, timeout: 10000 }).then((devices) => { + console.log('Found %d sonos devices', devices.length) + devices.forEach(device => { + console.log('Device IP: %s', device.host) }) }).catch(e => { - console.warn(' Error in discovery %o', e) + console.warn(' Error in discovery %j', e) }) -// discovery.discoverMultiple({ port: 50333, timeout: 10000 }).then((devices) => { -// console.log('Found %d sonos devices', devices.length) -// devices.forEach(device => { -// console.log('Device IP: %s', device.host) -// }) -// }).catch(e => { -// console.warn(' Error in discovery %j', e) +// const discovery = new Sonos.DeviceDiscovery({}, (device, model) => { +// console.log('Found one sonos device %s', device.host) +// process.exit(0); // }) diff --git a/lib/asyncDeviceDiscovery.js b/lib/asyncDeviceDiscovery.js index b9cb2175..92733149 100644 --- a/lib/asyncDeviceDiscovery.js +++ b/lib/asyncDeviceDiscovery.js @@ -1,11 +1,18 @@ +const { Sonos } = require('..') const DeviceDiscovery = require('./deviceDiscovery') class AsyncDeviceDiscovery { + /** + * Discover one device, will return first device found + * @param {object} options + * @param {number} options.timeout Milliseconds to timeout + * @returns {Promise<{device: Sonos, model: string}>} + */ async discover (options = { timeout: 5000 }) { return new Promise((resolve, reject) => { const discovery = DeviceDiscovery(options) discovery.once('DeviceAvailable', (device, model) => { discovery.destroy() - resolve(device, model) + resolve({device, model}) }) discovery.once('timeout', () => { @@ -14,6 +21,12 @@ class AsyncDeviceDiscovery { }) } + /** + * Discover multiple devices, will return after timeout + * @param {object} options + * @param {number} options.timeout Milliseconds to timeout + * @returns {Promise} + */ async discoverMultiple (options = { timeout: 5000 }) { return new Promise((resolve, reject) => { const discovery = DeviceDiscovery(options) diff --git a/lib/deviceDiscovery.js b/lib/deviceDiscovery.js index 052ac0e2..209853b3 100644 --- a/lib/deviceDiscovery.js +++ b/lib/deviceDiscovery.js @@ -111,10 +111,10 @@ class DeviceDiscovery extends EventEmitter { * (in milliseconds). * Set 'port' to use a specific inbound UDP port, * rather than a randomly assigned one - * @param {Function} listener Optional 'DeviceAvailable' listener (sonos) + * @param {(device: Sonos, model: string) => void | undefined} listener Optional 'DeviceAvailable' listener (sonos) * @return {DeviceDiscovery} */ -const deviceDiscovery = function (options, listener) { +const deviceDiscovery = function (options, listener = undefined) { if (typeof options === 'function') { listener = options options = null diff --git a/lib/events/adv-listener.js b/lib/events/adv-listener.js index a05a9e12..ca8ad298 100644 --- a/lib/events/adv-listener.js +++ b/lib/events/adv-listener.js @@ -94,7 +94,7 @@ class SonosListener extends EventEmitter { /** * Subscribe to all events for this device. - * @param {Sonos} device Pass in the Sonos device, it will be the eventemitter + * @param {import("../sonos").Sonos} device Pass in the Sonos device, it will be the eventemitter */ async subscribeTo (device) { return new Promise((resolve, reject) => { @@ -190,7 +190,7 @@ module.exports = defaultListener class DeviceSubscription { /** * Create new subscription - * @param {Sonos} device Pass in the sonos device + * @param {import("../sonos").Sonos} device Pass in the sonos device */ constructor (device) { this.subscriptions = [] @@ -199,7 +199,7 @@ class DeviceSubscription { /** * Subscribe to specefic endpoint for this device - * @param {String} endpoint What endpoint do we need to subscribe to? + * @param {string} endpoint What endpoint do we need to subscribe to? */ async addSubscription (endpoint) { const opt = { @@ -258,7 +258,7 @@ class DeviceSubscription { /** * Renew a single subscription - * @param {String} sid Subscription id you want to renew + * @param {string} sid Subscription id you want to renew */ async renewSubscription (sid) { return new Promise((resolve, reject) => { @@ -290,7 +290,7 @@ class DeviceSubscription { /** * Does this deivce have a subscription with a specific sid - * @param {String} sid Subscription id + * @param {string} sid Subscription id */ hasSubscription (sid) { return (this.subscriptions[sid] !== undefined) @@ -298,8 +298,8 @@ class DeviceSubscription { /** * This will be called by the SonosListener for device specific devices - * @param {String} endpoint The endpoint used for the subscription - * @param {String} body The body of the event + * @param {string} endpoint The endpoint used for the subscription + * @param {string} body The body of the event */ async handleNotification (endpoint, body) { // debug('Incoming message on %s %s %j', this.device.host, endpoint, body) @@ -309,7 +309,7 @@ class DeviceSubscription { } /** - * Cancel all the subscriptions for this device. Important to stop the notifications from returing. + * Cancel all the subscriptions for this device. Important to stop the notifications from returning. */ async cancelAllSubscriptions () { const self = this @@ -322,7 +322,7 @@ class DeviceSubscription { /** * Cancel a single subscribtion - * @param {String} sid Subscription id + * @param {string} sid Subscription id */ async cancelSubscription (sid) { return request({ @@ -339,14 +339,25 @@ class DeviceSubscription { /** * Convert the Timeout header to datetime (legacy code...) - * @param {String | Number} timeout TimeOut header + * @param {string | number} timeout TimeOut header + * @returns {number} */ headerToDateTime (timeout) { let seconds - if ((!!timeout) && (timeout.indexOf('Second-') === 0)) timeout = timeout.substr(7) - seconds = (((!!timeout) && (!isNaN(timeout))) ? parseInt(timeout, 10) : 3600) - 15 - if (seconds < 0) seconds = 15; else if (seconds > 1200) seconds = 1200 + if (timeout) { + if (typeof timeout === 'string') { + seconds = parseInt(((timeout.indexOf('Second-') === 0) ? timeout = timeout.substr(7) : timeout), 10) + } else { + seconds = timeout; + if (timeout < 15) { + seconds = 15 + } else if (timeout > 1200) { + seconds = 1200 + } + + } + } return (new Date().getTime() + (seconds * 1000)) } diff --git a/lib/helpers.js b/lib/helpers.js index 6df1fd32..0757edac 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -8,58 +8,53 @@ const debug = require('debug')('sonos:helpers') const parseString = require('xml2js').parseString -/** - * Helper class - * @class Helpers - */ -const Helpers = {} - +class Helpers { /** * Wrap in UPnP Envelope * @param {String} body The SOAP body. * @return {String} */ -Helpers.CreateSoapEnvelop = function (body) { - return [// '', - '', - '' + body + '', - ''].join('') -} + static CreateSoapEnvelop (body) { + return [// '', + '', + '' + body + '', + ''].join('') + } -/** + /** * Encodes characters not allowed within html/xml tags, for use with nester xml. * @param {String} input * @return {String} */ -Helpers.EncodeXml = function (input) { - return String(input).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"') -} + static EncodeXml (input) { + return String(input).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"') + } -/** + /** * Converts parentID to upnp cass * @param {String} parentID The id of the parent * @return {String} object.item.audioItem.musicTrack */ -Helpers.GetUpnpClass = function (parentID) { - switch (parentID) { - case 'A:ALBUMS': - return 'object.item.audioItem.musicAlbum' - case 'A:TRACKS': - return 'object.item.audioItem.musicTrack' - case 'A:ALBUMARTIST': - return 'object.item.audioItem.musicArtist' - case 'A:GENRE': - return 'object.container.genre.musicGenre' - case 'A:COMPOSER': - return 'object.container.person.composer' - default: - return '' + static GetUpnpClass (parentID) { + switch (parentID) { + case 'A:ALBUMS': + return 'object.item.audioItem.musicAlbum' + case 'A:TRACKS': + return 'object.item.audioItem.musicTrack' + case 'A:ALBUMARTIST': + return 'object.item.audioItem.musicArtist' + case 'A:GENRE': + return 'object.container.genre.musicGenre' + case 'A:COMPOSER': + return 'object.container.person.composer' + default: + return '' + } } -} -/** + /** * Generate custom metadata, to be used with the play and/or setAVTransportURI - * @param {String} streamUri The playback uri + * @param {String} streamUrl The playback uri * @param {String} itemId * @param {String} duration The duration of the song, as 'hh:mm:ss' * @param {String} title The title of the song @@ -68,309 +63,318 @@ Helpers.GetUpnpClass = function (parentID) { * @param {String} coverUrl the coverUrl of the song * @param {String} parentId the parentId of the song */ -Helpers.GenerateCustomMetadata = function (streamUrl, itemId, duration = '00:00:00', title, artist, album, coverUrl, parentId) { - let metadata = '' - metadata += `` : '>' - metadata += `${streamUrl}` - if (coverUrl) metadata += `${coverUrl}` - if (title) metadata += `${title}` - if (artist) metadata += `${artist}` - if (album) metadata += `${album}` - metadata += '' - return metadata -} + static GenerateCustomMetadata (streamUrl, itemId, duration = '00:00:00', title, artist, album, coverUrl, parentId) { + let metadata = '' + metadata += `` : '>' + metadata += `${streamUrl}` + if (coverUrl) metadata += `${coverUrl}` + if (title) metadata += `${title}` + if (artist) metadata += `${artist}` + if (album) metadata += `${album}` + metadata += '' + return metadata + } -/** + /** * Creates object with uri and metadata from playback uri * @param {String} uri The playback uri * @param {String} artUri Uri for art image * @return {Object} { uri: uri, metadata: metadata } */ -Helpers.GenerateLocalMetadata = function (uri, artUri = '') { - let title = '' - const match = /.*\/(.*)$/g.exec(uri.replace(/\.[a-zA-Z0-9]{3}$/, '')) - if (match) { - title = match[1] - } - const meta = '##RESOURCETITLE####UPNPCLASS####ARTURI####REGION##' - if (uri.startsWith('x-file-cifs')) { - return { - uri: uri, - metadata: meta.replace('##ITEMID##', uri.replace('x-file-cifs', 'S').replace(/\s/g, '%20')) - .replace('##RESOURCETITLE##', title.replace('%20', ' ')) - .replace('##UPNPCLASS##', Helpers.GetUpnpClass('A:TRACKS')) - .replace('##PARENTID##', 'A:TRACKS') - .replace('##ARTURI##', artUri.replace(/\s/g, '%20')) - .replace('##REGION##', 'RINCON_AssociatedZPUDN') + static GenerateLocalMetadata (uri, artUri = '') { + let title = '' + const match = /.*\/(.*)$/g.exec(uri.replace(/\.[a-zA-Z0-9]{3}$/, '')) + if (match) { + title = match[1] } - } - if (uri.startsWith('x-rincon-playlist')) { - const parentMatch = /.*#(.*)\/.*/g.exec(uri) - const parentID = parentMatch[1] + const meta = '##RESOURCETITLE####UPNPCLASS####ARTURI####REGION##' + if (uri.startsWith('x-file-cifs')) { + return { + uri: uri, + metadata: meta.replace('##ITEMID##', uri.replace('x-file-cifs', 'S').replace(/\s/g, '%20')) + .replace('##RESOURCETITLE##', title.replace('%20', ' ')) + .replace('##UPNPCLASS##', Helpers.GetUpnpClass('A:TRACKS')) + .replace('##PARENTID##', 'A:TRACKS') + .replace('##ARTURI##', artUri.replace(/\s/g, '%20')) + .replace('##REGION##', 'RINCON_AssociatedZPUDN') + } + } + if (uri.startsWith('x-rincon-playlist')) { + const parentMatch = /.*#(.*)\/.*/g.exec(uri) + const parentID = parentMatch[1] - return { - uri: uri, - metadata: meta.replace('##ITEMID##', `${parentID}/${title.replace(/\s/g, '%20')}`) - .replace('##RESOURCETITLE##', title.replace('%20', ' ')) - .replace('##UPNPCLASS##', Helpers.GetUpnpClass(parentID)) - .replace('##PARENTID##', parentID) - .replace('##ARTURI##', artUri.replace(/\s/g, '%20')) - .replace('##REGION##', 'RINCON_AssociatedZPUDN') + return { + uri: uri, + metadata: meta.replace('##ITEMID##', `${parentID}/${title.replace(/\s/g, '%20')}`) + .replace('##RESOURCETITLE##', title.replace('%20', ' ')) + .replace('##UPNPCLASS##', Helpers.GetUpnpClass(parentID)) + .replace('##PARENTID##', parentID) + .replace('##ARTURI##', artUri.replace(/\s/g, '%20')) + .replace('##REGION##', 'RINCON_AssociatedZPUDN') + } } + return { uri: uri, metadata: '' } } - return { uri: uri, metadata: '' } -} -/** + /** * Creates object with uri and metadata from playback uri * @param {String} uri The playback uri (currently supports spotify, tunein) * @param {String} title Sometimes the title is required. * @param {String} region Spotify region is required for all spotify tracks, see `sonos.SpotifyRegion` * @return {Object} options {uri: Spotify uri, metadata: metadata} */ -Helpers.GenerateMetadata = function (uri, title = '', region = '3079') { - let meta = '##RESOURCETITLE####SPOTIFYTYPE####REGION##' + static GenerateMetadata (uri, title = '', region = '3079') { + let meta = '##RESOURCETITLE####SPOTIFYTYPE####REGION##' - // Soundcloud track - const match = uri.match(/x-sonos-http:track:(\d+).mp3\?sid=160&flags=8224&sn=4/) - if (match) { - return { - uri, - metadata: meta.replace('##SPOTIFYURI##', '10032020track%3a' + match[1]) - .replace('##RESOURCETITLE##', title || 'Soundcloud Track') - .replace('##SPOTIFYTYPE##', 'object.item.audioItem.musicTrack') - .replace('##PARENTID##', '') - .replace('##REGION##', 'SA_RINCON40967_X_#Svc40967-0-Token') + // Soundcloud track + const match = uri.match(/x-sonos-http:track:(\d+).mp3\?sid=160&flags=8224&sn=4/) + if (match) { + return { + uri, + metadata: meta.replace('##SPOTIFYURI##', '10032020track%3a' + match[1]) + .replace('##RESOURCETITLE##', title || 'Soundcloud Track') + .replace('##SPOTIFYTYPE##', 'object.item.audioItem.musicTrack') + .replace('##PARENTID##', '') + .replace('##REGION##', 'SA_RINCON40967_X_#Svc40967-0-Token') + } } - } - const parts = uri.split(':') - if (!((parts.length === 2 && (parts[0] === 'radio' || parts[0] === 'x-sonosapi-stream' || parts[0] === 'x-rincon-cpcontainer')) || (parts.length >= 3 && parts[0] === 'spotify'))) { - debug('Returning string because it isn\'t recognized') - return Helpers.GenerateLocalMetadata(uri) - } + const parts = uri.split(':') + if (!((parts.length === 2 && (parts[0] === 'radio' || parts[0] === 'x-sonosapi-stream' || parts[0] === 'x-rincon-cpcontainer')) || (parts.length >= 3 && parts[0] === 'spotify'))) { + debug('Returning string because it isn\'t recognized') + return Helpers.GenerateLocalMetadata(uri) + } - if (parts[0] === 'radio' || parts[0] === 'x-sonosapi-stream') { - const radioTitle = title || 'TuneIn Radio' - if (parts[0] === 'radio') { - return { - uri: 'x-sonosapi-stream:' + parts[1] + '?sid=254&flags=8224&sn=0', - metadata: meta.replace('##SPOTIFYURI##', 'F00092020' + parts[1]) - .replace('##RESOURCETITLE##', Helpers.EncodeXml(radioTitle)) - .replace('##SPOTIFYTYPE##', 'object.item.audioItem.audioBroadcast') - .replace('##PARENTID##', 'parentID="L" ') - .replace('##REGION##', 'SA_RINCON65031_') + if (parts[0] === 'radio' || parts[0] === 'x-sonosapi-stream') { + const radioTitle = title || 'TuneIn Radio' + if (parts[0] === 'radio') { + return { + uri: 'x-sonosapi-stream:' + parts[1] + '?sid=254&flags=8224&sn=0', + metadata: meta.replace('##SPOTIFYURI##', 'F00092020' + parts[1]) + .replace('##RESOURCETITLE##', Helpers.EncodeXml(radioTitle)) + .replace('##SPOTIFYTYPE##', 'object.item.audioItem.audioBroadcast') + .replace('##PARENTID##', 'parentID="L" ') + .replace('##REGION##', 'SA_RINCON65031_') + } + } else { + const itemId = parts[1].split('?')[0] + return { + uri: uri, + metadata: meta.replace('##SPOTIFYURI##', 'F00092020' + itemId) + .replace('##RESOURCETITLE##', radioTitle) + .replace('##SPOTIFYTYPE##', 'object.item.audioItem.audioBroadcast') + .replace('##PARENTID##', 'parentID="R:0/0" ') + .replace('##REGION##', 'SA_RINCON65031_') + } } } else { - const itemId = parts[1].split('?')[0] - return { - uri: uri, - metadata: meta.replace('##SPOTIFYURI##', 'F00092020' + itemId) - .replace('##RESOURCETITLE##', radioTitle) - .replace('##SPOTIFYTYPE##', 'object.item.audioItem.audioBroadcast') - .replace('##PARENTID##', 'parentID="R:0/0" ') - .replace('##REGION##', 'SA_RINCON65031_') - } + meta = meta.replace('##REGION##', 'SA_RINCON' + region + '_X_#Svc' + region + '-0-Token') } - } else { - meta = meta.replace('##REGION##', 'SA_RINCON' + region + '_X_#Svc' + region + '-0-Token') - } - const spotifyUri = uri.replace(/:/g, '%3a') + const spotifyUri = uri.replace(/:/g, '%3a') - if (uri.startsWith('spotify:track:')) { // Just one track - return { - uri: 'x-sonos-spotify:' + spotifyUri, - metadata: meta.replace('##SPOTIFYURI##', '00032020' + spotifyUri) - .replace('##RESOURCETITLE##', '') - .replace('##SPOTIFYTYPE##', 'object.item.audioItem.musicTrack') - .replace('##PARENTID##', '') - } - } else if (uri.startsWith('spotify:album:')) { // Album - return { - uri: 'x-rincon-cpcontainer:0004206c' + spotifyUri, - metadata: meta.replace('##SPOTIFYURI##', '0004206c' + spotifyUri) - .replace('##RESOURCETITLE##', '') - .replace('##SPOTIFYTYPE##', 'object.container.album.musicAlbum') - .replace('##PARENTID##', '') - } - } else if (uri.startsWith('spotify:artistTopTracks:')) { // Artist top tracks - return { - uri: 'x-rincon-cpcontainer:000e206c' + spotifyUri, - metadata: meta.replace('##SPOTIFYURI##', '000e206c' + spotifyUri) - .replace('##RESOURCETITLE##', '') - .replace('##SPOTIFYTYPE##', 'object.container.playlistContainer') - .replace('##PARENTID##', '') - } - } else if (uri.startsWith('spotify:playlist:')) { // Playlist - return { - uri: 'x-rincon-cpcontainer:1006206c' + spotifyUri, - metadata: meta.replace('##SPOTIFYURI##', '1006206c' + spotifyUri) - .replace('##RESOURCETITLE##', '') - .replace('##SPOTIFYTYPE##', 'object.container.album.playlistContainer') - .replace('##PARENTID##', '') - } - } else if (uri.startsWith('spotify:user:')) { - return { - uri: 'x-rincon-cpcontainer:10062a6c' + spotifyUri + '?sid=9&flags=10860&sn=7', - metadata: meta.replace('##SPOTIFYURI##', '10062a6c' + spotifyUri) - .replace('##RESOURCETITLE##', 'User playlist') - .replace('##SPOTIFYTYPE##', 'object.container.playlistContainer') - .replace('##PARENTID##', 'parentID="10082664playlists" ') - } - } else if (uri.startsWith('spotify:artistRadio:')) { // Artist radio - const spotifyTitle = title || 'Artist Radio' - const parentId = spotifyUri.replace('artistRadio', 'artist') - return { - uri: 'x-sonosapi-radio:' + spotifyUri + '?sid=12&flags=8300&sn=5', - metadata: meta.replace('##SPOTIFYURI##', '100c206c' + spotifyUri) - .replace('##RESOURCETITLE##', spotifyTitle) - .replace('##SPOTIFYTYPE##', 'object.item.audioItem.audioBroadcast.#artistRadio') - .replace('##PARENTID##', 'parentID="10052064' + parentId + '" ') - } - } else if (uri.startsWith('x-rincon-cpcontainer:1006206ccatalog')) { // Amazon prime container - const [id] = uri.match(/^x-rincon-cpcontainer:(.*)\?.*/).splice(1) + if (uri.startsWith('spotify:track:')) { // Just one track + return { + uri: 'x-sonos-spotify:' + spotifyUri, + metadata: meta.replace('##SPOTIFYURI##', '00032020' + spotifyUri) + .replace('##RESOURCETITLE##', '') + .replace('##SPOTIFYTYPE##', 'object.item.audioItem.musicTrack') + .replace('##PARENTID##', '') + } + } else if (uri.startsWith('spotify:album:')) { // Album + return { + uri: 'x-rincon-cpcontainer:0004206c' + spotifyUri, + metadata: meta.replace('##SPOTIFYURI##', '0004206c' + spotifyUri) + .replace('##RESOURCETITLE##', '') + .replace('##SPOTIFYTYPE##', 'object.container.album.musicAlbum') + .replace('##PARENTID##', '') + } + } else if (uri.startsWith('spotify:artistTopTracks:')) { // Artist top tracks + return { + uri: 'x-rincon-cpcontainer:000e206c' + spotifyUri, + metadata: meta.replace('##SPOTIFYURI##', '000e206c' + spotifyUri) + .replace('##RESOURCETITLE##', '') + .replace('##SPOTIFYTYPE##', 'object.container.playlistContainer') + .replace('##PARENTID##', '') + } + } else if (uri.startsWith('spotify:playlist:')) { // Playlist + return { + uri: 'x-rincon-cpcontainer:1006206c' + spotifyUri, + metadata: meta.replace('##SPOTIFYURI##', '1006206c' + spotifyUri) + .replace('##RESOURCETITLE##', '') + .replace('##SPOTIFYTYPE##', 'object.container.album.playlistContainer') + .replace('##PARENTID##', '') + } + } else if (uri.startsWith('spotify:user:')) { + return { + uri: 'x-rincon-cpcontainer:10062a6c' + spotifyUri + '?sid=9&flags=10860&sn=7', + metadata: meta.replace('##SPOTIFYURI##', '10062a6c' + spotifyUri) + .replace('##RESOURCETITLE##', 'User playlist') + .replace('##SPOTIFYTYPE##', 'object.container.playlistContainer') + .replace('##PARENTID##', 'parentID="10082664playlists" ') + } + } else if (uri.startsWith('spotify:artistRadio:')) { // Artist radio + const spotifyTitle = title || 'Artist Radio' + const parentId = spotifyUri.replace('artistRadio', 'artist') + return { + uri: 'x-sonosapi-radio:' + spotifyUri + '?sid=12&flags=8300&sn=5', + metadata: meta.replace('##SPOTIFYURI##', '100c206c' + spotifyUri) + .replace('##RESOURCETITLE##', spotifyTitle) + .replace('##SPOTIFYTYPE##', 'object.item.audioItem.audioBroadcast.#artistRadio') + .replace('##PARENTID##', 'parentID="10052064' + parentId + '" ') + } + } else if (uri.startsWith('x-rincon-cpcontainer:1006206ccatalog')) { // Amazon prime container + const [id] = uri.match(/^x-rincon-cpcontainer:(.*)\?.*/).splice(1) - return { - uri: String(uri).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'), - metadata: meta.replace('##SPOTIFYURI##', id) - .replace('##RESOURCETITLE##', title) - .replace('##SPOTIFYTYPE##', 'object.container.playlistContainer') - .replace('##PARENTID##', '') - } - } else if (uri.startsWith('x-rincon-cpcontainer:100d206cuser-fav')) { // Sound Cloud likes - const id = uri.replace('x-rincon-cpcontainer:', '') - return { - uri: uri, - metadata: meta.replace('##SPOTIFYURI##', id) - .replace('##RESOURCETITLE##', title || 'Sound Cloud Likes') - .replace('##SPOTIFYTYPE##', 'object.container.albumList') - .replace('##PARENTID##', '') - .replace(`SA_RINCON${region}_X_#Svc${region}-0-Token`, 'SA_RINCON40967_X_#Svc40967-0-Token') - } - } else if (uri.startsWith('x-rincon-cpcontainer:100f206cuser-tracks')) { // Sound Cloud user - const [id] = uri.replace('x-rincon-cpcontainer:', '').split('?') - return { - uri: uri, - metadata: meta.replace('##SPOTIFYURI##', id) - .replace('##RESOURCETITLE##', title || 'Sound Cloud User') - .replace('##SPOTIFYTYPE##', 'object.container.playlistContainer.sameArtist') - .replace('##PARENTID##', '') - .replace(`SA_RINCON${region}_X_#Svc${region}-0-Token`, 'SA_RINCON40967_X_#Svc40967-0-Token') - } - } else if (uri.startsWith('x-rincon-cpcontainer:1006206cplaylist')) { // Sound Cloud playlists - const [id] = uri.replace('x-rincon-cpcontainer:', '').split('?') - return { - uri: uri, - metadata: meta.replace('##SPOTIFYURI##', id) - .replace('##RESOURCETITLE##', title || 'Sound Cloud Playlist') - .replace('##SPOTIFYTYPE##', 'object.container.playlistContainer') - .replace('##PARENTID##', '') - .replace(`SA_RINCON${region}_X_#Svc${region}-0-Token`, 'SA_RINCON40967_X_#Svc40967-0-Token') + return { + uri: String(uri).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'), + metadata: meta.replace('##SPOTIFYURI##', id) + .replace('##RESOURCETITLE##', title) + .replace('##SPOTIFYTYPE##', 'object.container.playlistContainer') + .replace('##PARENTID##', '') + } + } else if (uri.startsWith('x-rincon-cpcontainer:100d206cuser-fav')) { // Sound Cloud likes + const id = uri.replace('x-rincon-cpcontainer:', '') + return { + uri: uri, + metadata: meta.replace('##SPOTIFYURI##', id) + .replace('##RESOURCETITLE##', title || 'Sound Cloud Likes') + .replace('##SPOTIFYTYPE##', 'object.container.albumList') + .replace('##PARENTID##', '') + .replace(`SA_RINCON${region}_X_#Svc${region}-0-Token`, 'SA_RINCON40967_X_#Svc40967-0-Token') + } + } else if (uri.startsWith('x-rincon-cpcontainer:100f206cuser-tracks')) { // Sound Cloud user + const [id] = uri.replace('x-rincon-cpcontainer:', '').split('?') + return { + uri: uri, + metadata: meta.replace('##SPOTIFYURI##', id) + .replace('##RESOURCETITLE##', title || 'Sound Cloud User') + .replace('##SPOTIFYTYPE##', 'object.container.playlistContainer.sameArtist') + .replace('##PARENTID##', '') + .replace(`SA_RINCON${region}_X_#Svc${region}-0-Token`, 'SA_RINCON40967_X_#Svc40967-0-Token') + } + } else if (uri.startsWith('x-rincon-cpcontainer:1006206cplaylist')) { // Sound Cloud playlists + const [id] = uri.replace('x-rincon-cpcontainer:', '').split('?') + return { + uri: uri, + metadata: meta.replace('##SPOTIFYURI##', id) + .replace('##RESOURCETITLE##', title || 'Sound Cloud Playlist') + .replace('##SPOTIFYTYPE##', 'object.container.playlistContainer') + .replace('##PARENTID##', '') + .replace(`SA_RINCON${region}_X_#Svc${region}-0-Token`, 'SA_RINCON40967_X_#Svc40967-0-Token') + } + } else { + return { uri: uri, metadata: '' } } - } else { - return { uri: uri, metadata: '' } } -} -/** + /** * Parse DIDL into track structure - * @param {String} didl - * @param {String} host host ip + * @param {string} didl + * @param {string} host host ip * @param {Number} port port numer - * @param {String} trackUri Track Uri + * @param {string | undefined} trackUri Track Uri * @return {object} */ -Helpers.ParseDIDL = function (didl, host, port, trackUri) { - debug('ParseDIDL %j %s %d', didl, host, port) - if ((!didl) || (!didl['DIDL-Lite'])) return {} - const item = didl['DIDL-Lite'].item - return Helpers.ParseDIDLItem(item, host, port, trackUri) -} - -Helpers.dropIDNamespace = function (value) { - if (!value) { - return null - } - const ret = value.split(':', 2)[1] - if (!ret || ret.length === 0) { - return null + static ParseDIDL (didl, host = undefined, port = undefined, trackUri = undefined) { + debug('ParseDIDL %j %s %d', didl, host, port) + if ((!didl) || (!didl['DIDL-Lite'])) return {} + const item = didl['DIDL-Lite'].item + return Helpers.ParseDIDLItem(item, host, port, trackUri) } - return ret -} -Helpers.ParseDIDLItem = function (item, host, port, trackUri) { - let albumArtURI = item['upnp:albumArtURI'] || null - if (albumArtURI && Array.isArray(albumArtURI)) { - albumArtURI = albumArtURI.length > 0 ? albumArtURI[0] : null - } - const track = { - id: Helpers.dropIDNamespace(item.id), - parentID: Helpers.dropIDNamespace(item.parentID), - title: item['r:streamContent'] || item['dc:title'] || null, - artist: item['dc:creator'] || null, - album: item['upnp:album'] || null, - albumArtist: item['r:albumArtist'] || null, - albumArtURI + static dropIDNamespace (value) { + if (!value) { + return null + } + const ret = value.split(':', 2)[1] + if (!ret || ret.length === 0) { + return null + } + return ret } - if (trackUri) track.uri = trackUri - if (host && port && track.albumArtURI && !/^\bhttp[s]*:\/\//.test(track.albumArtURI)) { - track.albumArtURI = 'http://' + host + ':' + port + track.albumArtURI + + static ParseDIDLItem (item, host= undefined, port = undefined, trackUri = undefined) { + let albumArtURI = item['upnp:albumArtURI'] || null + if (albumArtURI && Array.isArray(albumArtURI)) { + albumArtURI = albumArtURI.length > 0 ? albumArtURI[0] : null + } + const track = { + id: Helpers.dropIDNamespace(item.id), + parentID: Helpers.dropIDNamespace(item.parentID), + title: item['r:streamContent'] || item['dc:title'] || null, + artist: item['dc:creator'] || null, + album: item['upnp:album'] || null, + albumArtist: item['r:albumArtist'] || null, + albumArtURI + } + if (trackUri) track.uri = trackUri + if (host && port && track.albumArtURI && !/^\bhttp[s]*:\/\//.test(track.albumArtURI)) { + track.albumArtURI = 'http://' + host + ':' + port + track.albumArtURI + } + return track } - return track -} -/** + /** * Convert a time string to seconds * @param {String} time like `00:03:34` * @returns {Number} number of seconds like 214 */ -Helpers.TimeToSeconds = function (time) { - const timeSplit = time.split(':') - return (parseInt(timeSplit[0], 10) * 60 * 60) + + static TimeToSeconds (time) { + const timeSplit = time.split(':') + return (parseInt(timeSplit[0], 10) * 60 * 60) + (parseInt(timeSplit[1], 10) * 60) + parseInt(timeSplit[2], 10) -} + } -Helpers._ParseXml = function (input, callback) { - return parseString(input, { mergeAttrs: true, explicitArray: false }, callback) -} + /** + * + * @param {string} input + * @param {function} callback + * @returns {Object} + */ + static _ParseXml (input, callback) { + return parseString(input, { mergeAttrs: true, explicitArray: false }, callback) + } -const playbackStates = { STOPPED: 'stopped', PLAYING: 'playing', PAUSED_PLAYBACK: 'paused', TRANSITIONING: 'transitioning', NO_MEDIA_PRESENT: 'no_media' } -/** + /** * Convert the playbackstate to a bit more readable - * @param {String} state Sonos playback state + * @param {string} state Sonos playback state + * @returns {string} */ -Helpers.TranslateState = function (state) { - return playbackStates[state] || state -} + static TranslateState (state) { + const playbackStates = { STOPPED: 'stopped', PLAYING: 'playing', PAUSED_PLAYBACK: 'paused', TRANSITIONING: 'transitioning', NO_MEDIA_PRESENT: 'no_media' } -/** + return playbackStates[state] || state + } + + /** * Parse Xml to an object async * @param {String} input The XML to be parsed * @return {Promise} */ -Helpers.ParseXml = async function (input) { - debug('Helpers.ParseXml %j', input) - return new Promise((resolve, reject) => { - Helpers._ParseXml(input, (err, data) => { - if (err) { - reject(err) - } else { - resolve(data) - } + static async ParseXml (input) { + debug('Helpers.ParseXml %j', input) + return new Promise((resolve, reject) => { + Helpers._ParseXml(input, (err, data) => { + if (err) { + reject(err) + } else { + resolve(data) + } + }) }) - }) -} + } -/** + /** * Sanitizes Device Description XML async * @param {String} input The XML to be sanitized - * @return {Promise} + * @return {string} */ -Helpers.SanitizeDeviceDescriptionXml = async function (input) { + static SanitizeDeviceDescriptionXml (input) { // This is to fix malformed xml in description see https://github.com/bencevans/node-sonos/issues/465 - debug('Helpers.SanitizeDeviceDescriptionXml %j', input) - return input.replace(/#([\w]+)#/gm, '') + debug('Helpers.SanitizeDeviceDescriptionXml %j', input) + return input.replace(/#([\w]+)#/gm, '') + } } module.exports = Helpers diff --git a/lib/services/AlarmClock.js b/lib/services/AlarmClock.js index b704140b..0ee9f330 100644 --- a/lib/services/AlarmClock.js +++ b/lib/services/AlarmClock.js @@ -57,7 +57,7 @@ class AlarmClock extends Service { /** * Get all the alarms known to sonos - * @return {Object} + * @return {Promise} */ async ListAlarms () { return this._request('ListAlarms', {}) diff --git a/lib/sonosGroup.js b/lib/sonosGroup.js index 8736713e..439bf03e 100644 --- a/lib/sonosGroup.js +++ b/lib/sonosGroup.js @@ -1,10 +1,18 @@ const debug = require('debug')('sonos-group') const URL = require('url').URL + + class SonosGroup { constructor (zoneGroup) { debug('ZoneGroup %j', zoneGroup) + /** + * @type {string} + */ this.CoordinatorID = zoneGroup.Coordinator + /** + * @type {Array<{ host: string, port: number | string, name: string}>} + */ this.Members = [] if (!Array.isArray(zoneGroup.ZoneGroupMember)) { zoneGroup.ZoneGroupMember = [zoneGroup.ZoneGroupMember] @@ -21,7 +29,7 @@ class SonosGroup { const url = new URL(coordinator.Location) this.Coordinator = { host: url.hostname, port: url.port } } else { - this.Name = this.Members.length > 0 ? this.Members.name : '' + this.Name = this.Members.length > 0 ? this.Members[0].name : '' } if (this.Members.length > 1) this.Name += ' + ' + (this.Members.length - 1).toString() } diff --git a/types/lib/asyncDeviceDiscovery.d.ts b/types/lib/asyncDeviceDiscovery.d.ts index c6fd5ebb..fa25b026 100644 --- a/types/lib/asyncDeviceDiscovery.d.ts +++ b/types/lib/asyncDeviceDiscovery.d.ts @@ -1,9 +1,25 @@ export = AsyncDeviceDiscovery; declare class AsyncDeviceDiscovery { + /** + * Discover one device, will return first device found + * @param {object} options + * @param {number} options.timeout Milliseconds to timeout + * @returns {Promise<{device: Sonos, model: string}>} + */ discover(options?: { timeout: number; - }): Promise; + }): Promise<{ + device: Sonos; + model: string; + }>; + /** + * Discover multiple devices, will return after timeout + * @param {object} options + * @param {number} options.timeout Milliseconds to timeout + * @returns {Promise} + */ discoverMultiple(options?: { timeout: number; - }): Promise; + }): Promise; } +import { Sonos } from "./sonos"; diff --git a/types/lib/deviceDiscovery.d.ts b/types/lib/deviceDiscovery.d.ts index 3bb2d5ba..ca1aaa36 100644 --- a/types/lib/deviceDiscovery.d.ts +++ b/types/lib/deviceDiscovery.d.ts @@ -7,10 +7,12 @@ export = deviceDiscovery; * (in milliseconds). * Set 'port' to use a specific inbound UDP port, * rather than a randomly assigned one - * @param {Function} listener Optional 'DeviceAvailable' listener (sonos) + * @param {(device: Sonos, model: string) => void | undefined} listener Optional 'DeviceAvailable' listener (sonos) * @return {DeviceDiscovery} */ -declare function deviceDiscovery(options: any, listener: Function): DeviceDiscovery; +declare function deviceDiscovery(options: any, listener?: (device: Sonos, model: string) => void | undefined): DeviceDiscovery; +import Sonos_1 = require("./sonos"); +import Sonos = Sonos_1.Sonos; /** * Create a new instance of DeviceDiscovery * @class DeviceDiscovery diff --git a/types/lib/events/adv-listener.d.ts b/types/lib/events/adv-listener.d.ts index bba36007..ba7d1a8c 100644 --- a/types/lib/events/adv-listener.d.ts +++ b/types/lib/events/adv-listener.d.ts @@ -27,9 +27,9 @@ declare class SonosListener extends EventEmitter { isListening(): boolean; /** * Subscribe to all events for this device. - * @param {Sonos} device Pass in the Sonos device, it will be the eventemitter + * @param {import("../sonos").Sonos} device Pass in the Sonos device, it will be the eventemitter */ - subscribeTo(device: any): Promise; + subscribeTo(device: import("../sonos").Sonos): Promise; _handleMessage(req: any, resp: any, body: any): void; _handleGlobalNotification(endpoint: any, body: any): Promise; } diff --git a/types/lib/events/eventParser.d.ts b/types/lib/events/eventParser.d.ts index b6990149..713b41e5 100644 --- a/types/lib/events/eventParser.d.ts +++ b/types/lib/events/eventParser.d.ts @@ -1,3 +1,4 @@ +import SonosGroup = require("../sonosGroup"); export function ParseAndEmitEvents(endpoint: any, body: any, device: any): Promise<{ name: string; eventBody: any; @@ -26,7 +27,7 @@ export function _parseAlarmEvent(body: any, device: any): { export function _parseZoneGroupTopologyEvent(body: any, device: any): Promise<{ name: string; eventBody: { - Zones: any; + Zones: SonosGroup[]; }; }>; export function _parseGroupRenderingControlEvent(body: any, device: any): { diff --git a/types/lib/helpers.d.ts b/types/lib/helpers.d.ts index 7dfbeef5..80451a38 100644 --- a/types/lib/helpers.d.ts +++ b/types/lib/helpers.d.ts @@ -1,88 +1,98 @@ -/** - * Wrap in UPnP Envelope - * @param {String} body The SOAP body. - * @return {String} - */ -export function CreateSoapEnvelop(body: string): string; -/** - * Encodes characters not allowed within html/xml tags, for use with nester xml. - * @param {String} input - * @return {String} - */ -export function EncodeXml(input: string): string; -/** - * Converts parentID to upnp cass - * @param {String} parentID The id of the parent - * @return {String} object.item.audioItem.musicTrack - */ -export function GetUpnpClass(parentID: string): string; -/** - * Generate custom metadata, to be used with the play and/or setAVTransportURI - * @param {String} streamUri The playback uri - * @param {String} itemId - * @param {String} duration The duration of the song, as 'hh:mm:ss' - * @param {String} title The title of the song - * @param {String} artist The artist of the sons - * @param {String} album the album of the song - * @param {String} coverUrl the coverUrl of the song - * @param {String} parentId the parentId of the song - */ -export function GenerateCustomMetadata(streamUrl: any, itemId: string, duration: string, title: string, artist: string, album: string, coverUrl: string, parentId: string): string; -/** - * Creates object with uri and metadata from playback uri - * @param {String} uri The playback uri - * @param {String} artUri Uri for art image - * @return {Object} { uri: uri, metadata: metadata } - */ -export function GenerateLocalMetadata(uri: string, artUri?: string): any; -/** - * Creates object with uri and metadata from playback uri - * @param {String} uri The playback uri (currently supports spotify, tunein) - * @param {String} title Sometimes the title is required. - * @param {String} region Spotify region is required for all spotify tracks, see `sonos.SpotifyRegion` - * @return {Object} options {uri: Spotify uri, metadata: metadata} - */ -export function GenerateMetadata(uri: string, title?: string, region?: string): any; -/** - * Parse DIDL into track structure - * @param {String} didl - * @param {String} host host ip - * @param {Number} port port numer - * @param {String} trackUri Track Uri - * @return {object} - */ -export function ParseDIDL(didl: string, host: string, port: number, trackUri: string): any; -export function dropIDNamespace(value: any): any; -export function ParseDIDLItem(item: any, host: any, port: any, trackUri: any): { - id: any; - parentID: any; - title: any; - artist: any; - album: any; - albumArtist: any; - albumArtURI: any; -}; -/** - * Convert a time string to seconds - * @param {String} time like `00:03:34` - * @returns {Number} number of seconds like 214 - */ -export function TimeToSeconds(time: string): number; -export function _ParseXml(input: any, callback: any): any; -/** - * Convert the playbackstate to a bit more readable - * @param {String} state Sonos playback state - */ -export function TranslateState(state: string): any; -/** - * Parse Xml to an object async - * @param {String} input The XML to be parsed - * @return {Promise} - */ -export function ParseXml(input: string): Promise; -/** - * Sanitizes Device Description XML async - * @param {String} input The XML to be sanitized - * @return {Promise} - */ -export function SanitizeDeviceDescriptionXml(input: string): Promise; +export = Helpers; +declare class Helpers { + /** + * Wrap in UPnP Envelope + * @param {String} body The SOAP body. + * @return {String} + */ + static CreateSoapEnvelop(body: string): string; + /** + * Encodes characters not allowed within html/xml tags, for use with nester xml. + * @param {String} input + * @return {String} + */ + static EncodeXml(input: string): string; + /** + * Converts parentID to upnp cass + * @param {String} parentID The id of the parent + * @return {String} object.item.audioItem.musicTrack + */ + static GetUpnpClass(parentID: string): string; + /** + * Generate custom metadata, to be used with the play and/or setAVTransportURI + * @param {String} streamUrl The playback uri + * @param {String} itemId + * @param {String} duration The duration of the song, as 'hh:mm:ss' + * @param {String} title The title of the song + * @param {String} artist The artist of the sons + * @param {String} album the album of the song + * @param {String} coverUrl the coverUrl of the song + * @param {String} parentId the parentId of the song + */ + static GenerateCustomMetadata(streamUrl: string, itemId: string, duration: string, title: string, artist: string, album: string, coverUrl: string, parentId: string): string; + /** + * Creates object with uri and metadata from playback uri + * @param {String} uri The playback uri + * @param {String} artUri Uri for art image + * @return {Object} { uri: uri, metadata: metadata } + */ + static GenerateLocalMetadata(uri: string, artUri?: string): any; + /** + * Creates object with uri and metadata from playback uri + * @param {String} uri The playback uri (currently supports spotify, tunein) + * @param {String} title Sometimes the title is required. + * @param {String} region Spotify region is required for all spotify tracks, see `sonos.SpotifyRegion` + * @return {Object} options {uri: Spotify uri, metadata: metadata} + */ + static GenerateMetadata(uri: string, title?: string, region?: string): any; + /** + * Parse DIDL into track structure + * @param {string} didl + * @param {string} host host ip + * @param {Number} port port numer + * @param {string | undefined} trackUri Track Uri + * @return {object} + */ + static ParseDIDL(didl: string, host?: string, port?: number, trackUri?: string | undefined): object; + static dropIDNamespace(value: any): any; + static ParseDIDLItem(item: any, host?: any, port?: any, trackUri?: any): { + id: any; + parentID: any; + title: any; + artist: any; + album: any; + albumArtist: any; + albumArtURI: any; + }; + /** + * Convert a time string to seconds + * @param {String} time like `00:03:34` + * @returns {Number} number of seconds like 214 + */ + static TimeToSeconds(time: string): number; + /** + * + * @param {string} input + * @param {function} callback + * @returns {Object} + */ + static _ParseXml(input: string, callback: Function): any; + /** + * Convert the playbackstate to a bit more readable + * @param {string} state Sonos playback state + * @returns {string} + */ + static TranslateState(state: string): string; + /** + * Parse Xml to an object async + * @param {String} input The XML to be parsed + * @return {Promise} + */ + static ParseXml(input: string): Promise; + /** + * Sanitizes Device Description XML async + * @param {String} input The XML to be sanitized + * @return {string} + */ + static SanitizeDeviceDescriptionXml(input: string): string; +} diff --git a/types/lib/services/AlarmClock.d.ts b/types/lib/services/AlarmClock.d.ts index 2f1bef55..66ab3bb7 100644 --- a/types/lib/services/AlarmClock.d.ts +++ b/types/lib/services/AlarmClock.d.ts @@ -42,9 +42,9 @@ declare class AlarmClock extends Service { DestroyAlarm(id: string): Promise; /** * Get all the alarms known to sonos - * @return {Object} + * @return {Promise} */ - ListAlarms(): any; + ListAlarms(): Promise; /** * Enable/disable an alarm * @param {String} id the id of the alarm you want to set diff --git a/types/lib/sonosGroup.d.ts b/types/lib/sonosGroup.d.ts index 48e39117..5dcb1c8a 100644 --- a/types/lib/sonosGroup.d.ts +++ b/types/lib/sonosGroup.d.ts @@ -1,8 +1,18 @@ export = SonosGroup; declare class SonosGroup { constructor(zoneGroup: any); - CoordinatorID: any; - Members: any[]; + /** + * @type {string} + */ + CoordinatorID: string; + /** + * @type {Array<{ host: string, port: number | string, name: string}>} + */ + Members: { + host: string; + port: number | string; + name: string; + }[]; Name: any; Coordinator: { host: string; From 9a87007e3aa81886fca274ed301a64f3bb7ff2ab Mon Sep 17 00:00:00 2001 From: Stephan van Rooij <1292510+svrooij@users.noreply.github.com> Date: Sun, 3 Oct 2021 15:26:43 +0200 Subject: [PATCH 6/6] fix: Types for generated services Related to: #512 --- .generator/node/service.hbs | 2 +- lib/asyncDeviceDiscovery.js | 11 +- lib/deviceDiscovery.js | 10 +- lib/events/adv-listener.js | 3 +- lib/helpers.js | 2 +- lib/services/alarm-clock.service.js | 20 +-- lib/services/audio-in.service.js | 6 +- lib/services/av-transport.service.js | 34 ++--- lib/services/connection-manager.service.js | 6 +- lib/services/content-directory.service.js | 22 +-- lib/services/device-properties.service.js | 24 +-- lib/services/group-management.service.js | 2 +- .../group-rendering-control.service.js | 6 +- lib/services/ht-control.service.js | 6 +- lib/services/music-services.service.js | 4 +- lib/services/q-play.service.js | 2 +- lib/services/queue.service.js | 20 +-- lib/services/rendering-control.service.js | 30 ++-- lib/services/system-properties.service.js | 14 +- lib/services/virtual-line-in.service.js | 2 +- lib/services/zone-group-topology.service.js | 8 +- lib/sonos.js | 4 +- lib/sonosGroup.js | 2 - test/sonos.test.js | 6 +- types/lib/asyncDeviceDiscovery.d.ts | 9 +- types/lib/events/eventParser.d.ts | 3 +- types/lib/services/alarm-clock.service.d.ts | 68 ++++++--- types/lib/services/audio-in.service.d.ts | 20 ++- types/lib/services/av-transport.service.d.ts | 138 +++++++++++++----- .../services/connection-manager.service.d.ts | 25 +++- .../services/content-directory.service.d.ts | 73 ++++++--- .../services/device-properties.service.d.ts | 84 ++++++++--- .../services/group-management.service.d.ts | 10 +- .../group-rendering-control.service.d.ts | 18 ++- types/lib/services/ht-control.service.d.ts | 18 ++- .../lib/services/music-services.service.d.ts | 14 +- types/lib/services/q-play.service.d.ts | 8 +- types/lib/services/queue.service.d.ts | 71 ++++++--- .../services/rendering-control.service.d.ts | 96 ++++++++---- .../services/system-properties.service.d.ts | 44 ++++-- .../lib/services/virtual-line-in.service.d.ts | 6 +- .../services/zone-group-topology.service.d.ts | 27 +++- 42 files changed, 640 insertions(+), 338 deletions(-) diff --git a/.generator/node/service.hbs b/.generator/node/service.hbs index 6d3871da..9b354d66 100644 --- a/.generator/node/service.hbs +++ b/.generator/node/service.hbs @@ -43,7 +43,7 @@ class {{serviceName}} extends Service { * @remarks {{{remarks}}} {{/if}} {{#if outputs}} - * @returns {Promise} response object, with these properties {{#each outputs}}`{{name}}`{{#unless @last}}, {{/unless}}{{/each}} + * @returns {Promise<{ {{#each outputs}}{{name}}: {{relatedStateVariable.dataType}}{{#unless @last}}, {{/unless}}{{/each ~}} }>} response object. {{else}} * @returns {Promise} request succeeded {{/if}} diff --git a/lib/asyncDeviceDiscovery.js b/lib/asyncDeviceDiscovery.js index 92733149..c060c735 100644 --- a/lib/asyncDeviceDiscovery.js +++ b/lib/asyncDeviceDiscovery.js @@ -1,18 +1,17 @@ -const { Sonos } = require('..') const DeviceDiscovery = require('./deviceDiscovery') class AsyncDeviceDiscovery { /** * Discover one device, will return first device found - * @param {object} options + * @param {object} options * @param {number} options.timeout Milliseconds to timeout - * @returns {Promise<{device: Sonos, model: string}>} + * @returns {Promise<{device: import("./sonos").Sonos, model: string}>} */ async discover (options = { timeout: 5000 }) { return new Promise((resolve, reject) => { const discovery = DeviceDiscovery(options) discovery.once('DeviceAvailable', (device, model) => { discovery.destroy() - resolve({device, model}) + resolve({ device, model }) }) discovery.once('timeout', () => { @@ -23,9 +22,9 @@ class AsyncDeviceDiscovery { /** * Discover multiple devices, will return after timeout - * @param {object} options + * @param {object} options * @param {number} options.timeout Milliseconds to timeout - * @returns {Promise} + * @returns {Promise} */ async discoverMultiple (options = { timeout: 5000 }) { return new Promise((resolve, reject) => { diff --git a/lib/deviceDiscovery.js b/lib/deviceDiscovery.js index 209853b3..5051a13b 100644 --- a/lib/deviceDiscovery.js +++ b/lib/deviceDiscovery.js @@ -53,14 +53,14 @@ class DeviceDiscovery extends EventEmitter { }) this.socket.on('listening', () => { - console.log('UDP port %d opened for discovery', this.socket.address().port) + // console.log('UDP port %d opened for discovery', this.socket.address().port) this.socket.setBroadcast(true) this.sendDiscover() }) this.socket.bind(options.port) - if (options.timeout) { + if (options && options.timeout) { this.searchTimer = setTimeout(() => { this.socket.close() this.emit('timeout') @@ -117,12 +117,12 @@ class DeviceDiscovery extends EventEmitter { const deviceDiscovery = function (options, listener = undefined) { if (typeof options === 'function') { listener = options - options = null + options = undefined } options = options || {} - listener = listener || null + listener = listener || undefined const search = new DeviceDiscovery(options) - if (listener !== null) { + if (listener !== undefined) { search.on('DeviceAvailable', listener) } return search diff --git a/lib/events/adv-listener.js b/lib/events/adv-listener.js index ca8ad298..45907603 100644 --- a/lib/events/adv-listener.js +++ b/lib/events/adv-listener.js @@ -349,13 +349,12 @@ class DeviceSubscription { if (typeof timeout === 'string') { seconds = parseInt(((timeout.indexOf('Second-') === 0) ? timeout = timeout.substr(7) : timeout), 10) } else { - seconds = timeout; + seconds = timeout if (timeout < 15) { seconds = 15 } else if (timeout > 1200) { seconds = 1200 } - } } diff --git a/lib/helpers.js b/lib/helpers.js index 0757edac..7ba1c6bc 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -293,7 +293,7 @@ class Helpers { return ret } - static ParseDIDLItem (item, host= undefined, port = undefined, trackUri = undefined) { + static ParseDIDLItem (item, host = undefined, port = undefined, trackUri = undefined) { let albumArtURI = item['upnp:albumArtURI'] || null if (albumArtURI && Array.isArray(albumArtURI)) { albumArtURI = albumArtURI.length > 0 ? albumArtURI[0] : null diff --git a/lib/services/alarm-clock.service.js b/lib/services/alarm-clock.service.js index 50c3424f..c0583ff4 100644 --- a/lib/services/alarm-clock.service.js +++ b/lib/services/alarm-clock.service.js @@ -41,7 +41,7 @@ class AlarmClockService extends Service { * @param {string} options.PlayMode - Alarm play mode [ 'NORMAL' / 'REPEAT_ALL' / 'SHUFFLE_NOREPEAT' / 'SHUFFLE' ] * @param {number} options.Volume - Volume between 0 and 100 * @param {boolean} options.IncludeLinkedZones - Should grouped players also play the alarm? - * @returns {Promise} response object, with these properties `AssignedID` + * @returns {Promise<{ AssignedID: number}>} response object. */ async CreateAlarm (options) { return this._request('CreateAlarm', options) } @@ -56,13 +56,13 @@ class AlarmClockService extends Service { /** * GetDailyIndexRefreshTime - * @returns {Promise} response object, with these properties `CurrentDailyIndexRefreshTime` + * @returns {Promise<{ CurrentDailyIndexRefreshTime: string}>} response object. */ async GetDailyIndexRefreshTime () { return this._request('GetDailyIndexRefreshTime') } /** * GetFormat - * @returns {Promise} response object, with these properties `CurrentTimeFormat`, `CurrentDateFormat` + * @returns {Promise<{ CurrentTimeFormat: string, CurrentDateFormat: string}>} response object. */ async GetFormat () { return this._request('GetFormat') } @@ -71,31 +71,31 @@ class AlarmClockService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.TimeStamp - * @returns {Promise} response object, with these properties `HouseholdUTCTime` + * @returns {Promise<{ HouseholdUTCTime: string}>} response object. */ async GetHouseholdTimeAtStamp (options) { return this._request('GetHouseholdTimeAtStamp', options) } /** * GetTimeNow - * @returns {Promise} response object, with these properties `CurrentUTCTime`, `CurrentLocalTime`, `CurrentTimeZone`, `CurrentTimeGeneration` + * @returns {Promise<{ CurrentUTCTime: string, CurrentLocalTime: string, CurrentTimeZone: string, CurrentTimeGeneration: number}>} response object. */ async GetTimeNow () { return this._request('GetTimeNow') } /** * GetTimeServer - * @returns {Promise} response object, with these properties `CurrentTimeServer` + * @returns {Promise<{ CurrentTimeServer: string}>} response object. */ async GetTimeServer () { return this._request('GetTimeServer') } /** * GetTimeZone - * @returns {Promise} response object, with these properties `Index`, `AutoAdjustDst` + * @returns {Promise<{ Index: number, AutoAdjustDst: boolean}>} response object. */ async GetTimeZone () { return this._request('GetTimeZone') } /** * GetTimeZoneAndRule - * @returns {Promise} response object, with these properties `Index`, `AutoAdjustDst`, `CurrentTimeZone` + * @returns {Promise<{ Index: number, AutoAdjustDst: boolean, CurrentTimeZone: string}>} response object. */ async GetTimeZoneAndRule () { return this._request('GetTimeZoneAndRule') } @@ -104,14 +104,14 @@ class AlarmClockService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.Index - * @returns {Promise} response object, with these properties `TimeZone` + * @returns {Promise<{ TimeZone: string}>} response object. */ async GetTimeZoneRule (options) { return this._request('GetTimeZoneRule', options) } /** * ListAlarms - Get the AlarmList as XML * @remarks Some libraries also provide a ListAndParseAlarms where the alarm list xml is parsed - * @returns {Promise} response object, with these properties `CurrentAlarmList`, `CurrentAlarmListVersion` + * @returns {Promise<{ CurrentAlarmList: string, CurrentAlarmListVersion: string}>} response object. */ async ListAlarms () { return this._request('ListAlarms') } diff --git a/lib/services/audio-in.service.js b/lib/services/audio-in.service.js index 091074f9..8289141f 100644 --- a/lib/services/audio-in.service.js +++ b/lib/services/audio-in.service.js @@ -29,13 +29,13 @@ class AudioInService extends Service { // #region actions /** * GetAudioInputAttributes - * @returns {Promise} response object, with these properties `CurrentName`, `CurrentIcon` + * @returns {Promise<{ CurrentName: string, CurrentIcon: string}>} response object. */ async GetAudioInputAttributes () { return this._request('GetAudioInputAttributes') } /** * GetLineInLevel - * @returns {Promise} response object, with these properties `CurrentLeftLineInLevel`, `CurrentRightLineInLevel` + * @returns {Promise<{ CurrentLeftLineInLevel: number, CurrentRightLineInLevel: number}>} response object. */ async GetLineInLevel () { return this._request('GetLineInLevel') } @@ -73,7 +73,7 @@ class AudioInService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.CoordinatorID - * @returns {Promise} response object, with these properties `CurrentTransportSettings` + * @returns {Promise<{ CurrentTransportSettings: string}>} response object. */ async StartTransmissionToGroup (options) { return this._request('StartTransmissionToGroup', options) } diff --git a/lib/services/av-transport.service.js b/lib/services/av-transport.service.js index 119a71bf..82e2d8c6 100644 --- a/lib/services/av-transport.service.js +++ b/lib/services/av-transport.service.js @@ -40,7 +40,7 @@ class AVTransportService extends Service { * @param {string} options.ContainerMetaData * @param {number} options.DesiredFirstTrackNumberEnqueued * @param {boolean} options.EnqueueAsNext - * @returns {Promise} response object, with these properties `FirstTrackNumberEnqueued`, `NumTracksAdded`, `NewQueueLength`, `NewUpdateID` + * @returns {Promise<{ FirstTrackNumberEnqueued: number, NumTracksAdded: number, NewQueueLength: number, NewUpdateID: number}>} response object. */ async AddMultipleURIsToQueue (options) { return this._request('AddMultipleURIsToQueue', options) } @@ -54,7 +54,7 @@ class AVTransportService extends Service { * @param {number} options.DesiredFirstTrackNumberEnqueued - use `0` to add at the end or `1` to insert at the beginning * @param {boolean} options.EnqueueAsNext * @remarks In NORMAL play mode the songs are added prior to the specified `DesiredFirstTrackNumberEnqueued`. - * @returns {Promise} response object, with these properties `FirstTrackNumberEnqueued`, `NumTracksAdded`, `NewQueueLength` + * @returns {Promise<{ FirstTrackNumberEnqueued: number, NumTracksAdded: number, NewQueueLength: number}>} response object. */ async AddURIToQueue (options) { return this._request('AddURIToQueue', options) } @@ -68,7 +68,7 @@ class AVTransportService extends Service { * @param {string} options.EnqueuedURI * @param {string} options.EnqueuedURIMetaData * @param {number} options.AddAtIndex - * @returns {Promise} response object, with these properties `NumTracksAdded`, `NewQueueLength`, `NewUpdateID` + * @returns {Promise<{ NumTracksAdded: number, NewQueueLength: number, NewUpdateID: number}>} response object. */ async AddURIToSavedQueue (options) { return this._request('AddURIToSavedQueue', options) } @@ -86,7 +86,7 @@ class AVTransportService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Promise} response object, with these properties `DelegatedGroupCoordinatorID`, `NewGroupID` + * @returns {Promise<{ DelegatedGroupCoordinatorID: string, NewGroupID: string}>} response object. */ async BecomeCoordinatorOfStandaloneGroup (options = { InstanceID: 0 }) { return this._request('BecomeCoordinatorOfStandaloneGroup', options) } @@ -174,7 +174,7 @@ class AVTransportService extends Service { * @param {string} options.Title * @param {string} options.EnqueuedURI * @param {string} options.EnqueuedURIMetaData - * @returns {Promise} response object, with these properties `NumTracksAdded`, `NewQueueLength`, `AssignedObjectID`, `NewUpdateID` + * @returns {Promise<{ NumTracksAdded: number, NewQueueLength: number, AssignedObjectID: string, NewUpdateID: number}>} response object. */ async CreateSavedQueue (options) { return this._request('CreateSavedQueue', options) } @@ -205,7 +205,7 @@ class AVTransportService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @remarks Send to non-coordinator may return wrong value as only the coordinator value in a group - * @returns {Promise} response object, with these properties `CrossfadeMode` + * @returns {Promise<{ CrossfadeMode: boolean}>} response object. */ async GetCrossfadeMode (options = { InstanceID: 0 }) { return this._request('GetCrossfadeMode', options) } @@ -215,7 +215,7 @@ class AVTransportService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @remarks Send to non-coordinator returns only `Start` and `Stop` since it cannot control the stream. - * @returns {Promise} response object, with these properties `Actions` + * @returns {Promise<{ Actions: string}>} response object. */ async GetCurrentTransportActions (options = { InstanceID: 0 }) { return this._request('GetCurrentTransportActions', options) } @@ -224,7 +224,7 @@ class AVTransportService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Promise} response object, with these properties `PlayMedia`, `RecMedia`, `RecQualityModes` + * @returns {Promise<{ PlayMedia: string, RecMedia: string, RecQualityModes: string}>} response object. */ async GetDeviceCapabilities (options = { InstanceID: 0 }) { return this._request('GetDeviceCapabilities', options) } @@ -233,7 +233,7 @@ class AVTransportService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Promise} response object, with these properties `NrTracks`, `MediaDuration`, `CurrentURI`, `CurrentURIMetaData`, `NextURI`, `NextURIMetaData`, `PlayMedium`, `RecordMedium`, `WriteStatus` + * @returns {Promise<{ NrTracks: number, MediaDuration: string, CurrentURI: string, CurrentURIMetaData: string, NextURI: string, NextURIMetaData: string, PlayMedium: string, RecordMedium: string, WriteStatus: string}>} response object. */ async GetMediaInfo (options = { InstanceID: 0 }) { return this._request('GetMediaInfo', options) } @@ -242,7 +242,7 @@ class AVTransportService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Promise} response object, with these properties `Track`, `TrackDuration`, `TrackMetaData`, `TrackURI`, `RelTime`, `AbsTime`, `RelCount`, `AbsCount` + * @returns {Promise<{ Track: number, TrackDuration: string, TrackMetaData: string, TrackURI: string, RelTime: string, AbsTime: string, RelCount: number, AbsCount: number}>} response object. */ async GetPositionInfo (options = { InstanceID: 0 }) { return this._request('GetPositionInfo', options) } @@ -252,7 +252,7 @@ class AVTransportService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @remarks Send to non-coordinator returns error code 800 - * @returns {Promise} response object, with these properties `RemainingSleepTimerDuration`, `CurrentSleepTimerGeneration` + * @returns {Promise<{ RemainingSleepTimerDuration: string, CurrentSleepTimerGeneration: number}>} response object. */ async GetRemainingSleepTimerDuration (options = { InstanceID: 0 }) { return this._request('GetRemainingSleepTimerDuration', options) } @@ -261,7 +261,7 @@ class AVTransportService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Promise} response object, with these properties `AlarmID`, `GroupID`, `LoggedStartTime` + * @returns {Promise<{ AlarmID: number, GroupID: string, LoggedStartTime: string}>} response object. */ async GetRunningAlarmProperties (options = { InstanceID: 0 }) { return this._request('GetRunningAlarmProperties', options) } @@ -271,7 +271,7 @@ class AVTransportService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @remarks Send to non-coordinator always returns PLAYING - * @returns {Promise} response object, with these properties `CurrentTransportState`, `CurrentTransportStatus`, `CurrentSpeed` + * @returns {Promise<{ CurrentTransportState: string, CurrentTransportStatus: string, CurrentSpeed: string}>} response object. */ async GetTransportInfo (options = { InstanceID: 0 }) { return this._request('GetTransportInfo', options) } @@ -281,7 +281,7 @@ class AVTransportService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @remarks Send to non-coordinator returns the settings of it's queue - * @returns {Promise} response object, with these properties `PlayMode`, `RecQualityMode` + * @returns {Promise<{ PlayMode: string, RecQualityMode: string}>} response object. */ async GetTransportSettings (options = { InstanceID: 0 }) { return this._request('GetTransportSettings', options) } @@ -363,7 +363,7 @@ class AVTransportService extends Service { * @param {number} options.UpdateID - Leave blank * @param {number} options.StartingIndex - between 1 and queue-length * @param {number} options.NumberOfTracks - * @returns {Promise} response object, with these properties `NewUpdateID` + * @returns {Promise<{ NewUpdateID: number}>} response object. */ async RemoveTrackRangeFromQueue (options) { return this._request('RemoveTrackRangeFromQueue', options) } @@ -389,7 +389,7 @@ class AVTransportService extends Service { * @param {number} options.UpdateID * @param {string} options.TrackList * @param {string} options.NewPositionList - * @returns {Promise} response object, with these properties `QueueLengthChange`, `NewQueueLength`, `NewUpdateID` + * @returns {Promise<{ QueueLengthChange: number, NewQueueLength: number, NewUpdateID: number}>} response object. */ async ReorderTracksInSavedQueue (options) { return this._request('ReorderTracksInSavedQueue', options) } @@ -418,7 +418,7 @@ class AVTransportService extends Service { * @param {string} options.Title - SONOS playlist title * @param {string} options.ObjectID - Leave blank * @remarks Send to non-coordinator returns error code 800 - * @returns {Promise} response object, with these properties `AssignedObjectID` + * @returns {Promise<{ AssignedObjectID: string}>} response object. */ async SaveQueue (options) { return this._request('SaveQueue', options) } diff --git a/lib/services/connection-manager.service.js b/lib/services/connection-manager.service.js index 3da63dbc..9fbcbbe6 100644 --- a/lib/services/connection-manager.service.js +++ b/lib/services/connection-manager.service.js @@ -29,7 +29,7 @@ class ConnectionManagerService extends Service { // #region actions /** * GetCurrentConnectionIDs - * @returns {Promise} response object, with these properties `ConnectionIDs` + * @returns {Promise<{ ConnectionIDs: string}>} response object. */ async GetCurrentConnectionIDs () { return this._request('GetCurrentConnectionIDs') } @@ -38,13 +38,13 @@ class ConnectionManagerService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.ConnectionID - * @returns {Promise} response object, with these properties `RcsID`, `AVTransportID`, `ProtocolInfo`, `PeerConnectionManager`, `PeerConnectionID`, `Direction`, `Status` + * @returns {Promise<{ RcsID: number, AVTransportID: number, ProtocolInfo: string, PeerConnectionManager: string, PeerConnectionID: number, Direction: string, Status: string}>} response object. */ async GetCurrentConnectionInfo (options) { return this._request('GetCurrentConnectionInfo', options) } /** * GetProtocolInfo - * @returns {Promise} response object, with these properties `Source`, `Sink` + * @returns {Promise<{ Source: string, Sink: string}>} response object. */ async GetProtocolInfo () { return this._request('GetProtocolInfo') } // #endregion diff --git a/lib/services/content-directory.service.js b/lib/services/content-directory.service.js index abae5dd8..745a364d 100644 --- a/lib/services/content-directory.service.js +++ b/lib/services/content-directory.service.js @@ -38,7 +38,7 @@ class ContentDirectoryService extends Service { * @param {number} options.RequestedCount - Paging, number of items, maximum is 1,000. This parameter does NOT restrict the number of items being searched (filter) but only the number being returned. * @param {string} options.SortCriteria - Sort the results based on metadata fields. `+upnp:artist,+dc:title` for sorting on artist then on title. * @remarks (1) If the title contains an apostrophe the returned uri will contain a `'`. (2) Some libraries support a BrowseAndParse, so you don't have to parse the xml. - * @returns {Promise} response object, with these properties `Result`, `NumberReturned`, `TotalMatches`, `UpdateID` + * @returns {Promise<{ Result: string, NumberReturned: number, TotalMatches: number, UpdateID: number}>} response object. */ async Browse (options) { return this._request('Browse', options) } @@ -48,7 +48,7 @@ class ContentDirectoryService extends Service { * @param {Object} [options] - An object with the following properties * @param {string} options.ContainerID * @param {string} options.Elements - * @returns {Promise} response object, with these properties `ObjectID`, `Result` + * @returns {Promise<{ ObjectID: string, Result: string}>} response object. */ async CreateObject (options) { return this._request('CreateObject', options) } @@ -67,13 +67,13 @@ class ContentDirectoryService extends Service { * @param {Object} [options] - An object with the following properties * @param {string} options.ObjectID * @param {string} options.Prefix - * @returns {Promise} response object, with these properties `StartingIndex`, `UpdateID` + * @returns {Promise<{ StartingIndex: number, UpdateID: number}>} response object. */ async FindPrefix (options) { return this._request('FindPrefix', options) } /** * GetAlbumArtistDisplayOption - * @returns {Promise} response object, with these properties `AlbumArtistDisplayOption` + * @returns {Promise<{ AlbumArtistDisplayOption: string}>} response object. */ async GetAlbumArtistDisplayOption () { return this._request('GetAlbumArtistDisplayOption') } @@ -82,43 +82,43 @@ class ContentDirectoryService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.ObjectID - * @returns {Promise} response object, with these properties `TotalPrefixes`, `PrefixAndIndexCSV`, `UpdateID` + * @returns {Promise<{ TotalPrefixes: number, PrefixAndIndexCSV: string, UpdateID: number}>} response object. */ async GetAllPrefixLocations (options) { return this._request('GetAllPrefixLocations', options) } /** * GetBrowseable - * @returns {Promise} response object, with these properties `IsBrowseable` + * @returns {Promise<{ IsBrowseable: boolean}>} response object. */ async GetBrowseable () { return this._request('GetBrowseable') } /** * GetLastIndexChange - * @returns {Promise} response object, with these properties `LastIndexChange` + * @returns {Promise<{ LastIndexChange: string}>} response object. */ async GetLastIndexChange () { return this._request('GetLastIndexChange') } /** * GetSearchCapabilities - * @returns {Promise} response object, with these properties `SearchCaps` + * @returns {Promise<{ SearchCaps: string}>} response object. */ async GetSearchCapabilities () { return this._request('GetSearchCapabilities') } /** * GetShareIndexInProgress - * @returns {Promise} response object, with these properties `IsIndexing` + * @returns {Promise<{ IsIndexing: boolean}>} response object. */ async GetShareIndexInProgress () { return this._request('GetShareIndexInProgress') } /** * GetSortCapabilities - * @returns {Promise} response object, with these properties `SortCaps` + * @returns {Promise<{ SortCaps: string}>} response object. */ async GetSortCapabilities () { return this._request('GetSortCapabilities') } /** * GetSystemUpdateID - * @returns {Promise} response object, with these properties `Id` + * @returns {Promise<{ Id: number}>} response object. */ async GetSystemUpdateID () { return this._request('GetSystemUpdateID') } diff --git a/lib/services/device-properties.service.js b/lib/services/device-properties.service.js index 8eb7465f..20fbc331 100644 --- a/lib/services/device-properties.service.js +++ b/lib/services/device-properties.service.js @@ -61,7 +61,7 @@ class DevicePropertiesService extends Service { * @param {Object} [options] - An object with the following properties * @param {string} options.Mode * @param {string} options.Options - * @returns {Promise} response object, with these properties `State` + * @returns {Promise<{ State: string}>} response object. */ async EnterConfigMode (options) { return this._request('EnterConfigMode', options) } @@ -79,7 +79,7 @@ class DevicePropertiesService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.Source - * @returns {Promise} response object, with these properties `IncludeLinkedZones` + * @returns {Promise<{ IncludeLinkedZones: boolean}>} response object. */ async GetAutoplayLinkedZones (options) { return this._request('GetAutoplayLinkedZones', options) } @@ -88,7 +88,7 @@ class DevicePropertiesService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.Source - * @returns {Promise} response object, with these properties `RoomUUID` + * @returns {Promise<{ RoomUUID: string}>} response object. */ async GetAutoplayRoomUUID (options) { return this._request('GetAutoplayRoomUUID', options) } @@ -97,31 +97,31 @@ class DevicePropertiesService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.Source - * @returns {Promise} response object, with these properties `CurrentVolume` + * @returns {Promise<{ CurrentVolume: number}>} response object. */ async GetAutoplayVolume (options) { return this._request('GetAutoplayVolume', options) } /** * GetButtonLockState - Get the current button lock state - * @returns {Promise} response object, with these properties `CurrentButtonLockState` + * @returns {Promise<{ CurrentButtonLockState: string}>} response object. */ async GetButtonLockState () { return this._request('GetButtonLockState') } /** * GetButtonState - * @returns {Promise} response object, with these properties `State` + * @returns {Promise<{ State: string}>} response object. */ async GetButtonState () { return this._request('GetButtonState') } /** * GetHouseholdID - * @returns {Promise} response object, with these properties `CurrentHouseholdID` + * @returns {Promise<{ CurrentHouseholdID: string}>} response object. */ async GetHouseholdID () { return this._request('GetHouseholdID') } /** * GetLEDState - Get the current LED state - * @returns {Promise} response object, with these properties `CurrentLEDState` + * @returns {Promise<{ CurrentLEDState: string}>} response object. */ async GetLEDState () { return this._request('GetLEDState') } @@ -130,19 +130,19 @@ class DevicePropertiesService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.Source - * @returns {Promise} response object, with these properties `UseVolume` + * @returns {Promise<{ UseVolume: boolean}>} response object. */ async GetUseAutoplayVolume (options) { return this._request('GetUseAutoplayVolume', options) } /** * GetZoneAttributes - * @returns {Promise} response object, with these properties `CurrentZoneName`, `CurrentIcon`, `CurrentConfiguration` + * @returns {Promise<{ CurrentZoneName: string, CurrentIcon: string, CurrentConfiguration: string}>} response object. */ async GetZoneAttributes () { return this._request('GetZoneAttributes') } /** * GetZoneInfo - Get information about this specific speaker - * @returns {Promise} response object, with these properties `SerialNumber`, `SoftwareVersion`, `DisplaySoftwareVersion`, `HardwareVersion`, `IPAddress`, `MACAddress`, `CopyrightInfo`, `ExtraInfo`, `HTAudioIn`, `Flags` + * @returns {Promise<{ SerialNumber: string, SoftwareVersion: string, DisplaySoftwareVersion: string, HardwareVersion: string, IPAddress: string, MACAddress: string, CopyrightInfo: string, ExtraInfo: string, HTAudioIn: number, Flags: number}>} response object. */ async GetZoneInfo () { return this._request('GetZoneInfo') } @@ -171,7 +171,7 @@ class DevicePropertiesService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.Channel * @param {number} options.DurationMilliseconds - * @returns {Promise} response object, with these properties `PlayId`, `ChirpIfPlayingSwappableAudio` + * @returns {Promise<{ PlayId: number, ChirpIfPlayingSwappableAudio: boolean}>} response object. */ async RoomDetectionStartChirping (options) { return this._request('RoomDetectionStartChirping', options) } diff --git a/lib/services/group-management.service.js b/lib/services/group-management.service.js index 301bf915..80334006 100644 --- a/lib/services/group-management.service.js +++ b/lib/services/group-management.service.js @@ -33,7 +33,7 @@ class GroupManagementService extends Service { * @param {Object} [options] - An object with the following properties * @param {string} options.MemberID * @param {number} options.BootSeq - * @returns {Promise} response object, with these properties `CurrentTransportSettings`, `CurrentURI`, `GroupUUIDJoined`, `ResetVolumeAfter`, `VolumeAVTransportURI` + * @returns {Promise<{ CurrentTransportSettings: string, CurrentURI: string, GroupUUIDJoined: string, ResetVolumeAfter: boolean, VolumeAVTransportURI: string}>} response object. */ async AddMember (options) { return this._request('AddMember', options) } diff --git a/lib/services/group-rendering-control.service.js b/lib/services/group-rendering-control.service.js index 6e2aeaa3..3ed9f672 100644 --- a/lib/services/group-rendering-control.service.js +++ b/lib/services/group-rendering-control.service.js @@ -33,7 +33,7 @@ class GroupRenderingControlService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @remarks Should be send to coordinator only - * @returns {Promise} response object, with these properties `CurrentMute` + * @returns {Promise<{ CurrentMute: boolean}>} response object. */ async GetGroupMute (options = { InstanceID: 0 }) { return this._request('GetGroupMute', options) } @@ -43,7 +43,7 @@ class GroupRenderingControlService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @remarks Should be send to coordinator only - * @returns {Promise} response object, with these properties `CurrentVolume` + * @returns {Promise<{ CurrentVolume: number}>} response object. */ async GetGroupVolume (options = { InstanceID: 0 }) { return this._request('GetGroupVolume', options) } @@ -76,7 +76,7 @@ class GroupRenderingControlService extends Service { * @param {number} options.InstanceID - InstanceID should always be `0` * @param {number} options.Adjustment - Number between -100 and +100 * @remarks Should be send to coordinator only - * @returns {Promise} response object, with these properties `NewVolume` + * @returns {Promise<{ NewVolume: number}>} response object. */ async SetRelativeGroupVolume (options) { return this._request('SetRelativeGroupVolume', options) } diff --git a/lib/services/ht-control.service.js b/lib/services/ht-control.service.js index e222f79e..393027f5 100644 --- a/lib/services/ht-control.service.js +++ b/lib/services/ht-control.service.js @@ -38,13 +38,13 @@ class HTControlService extends Service { /** * GetIRRepeaterState - * @returns {Promise} response object, with these properties `CurrentIRRepeaterState` + * @returns {Promise<{ CurrentIRRepeaterState: string}>} response object. */ async GetIRRepeaterState () { return this._request('GetIRRepeaterState') } /** * GetLEDFeedbackState - * @returns {Promise} response object, with these properties `LEDFeedbackState` + * @returns {Promise<{ LEDFeedbackState: string}>} response object. */ async GetLEDFeedbackState () { return this._request('GetLEDFeedbackState') } @@ -59,7 +59,7 @@ class HTControlService extends Service { /** * IsRemoteConfigured - * @returns {Promise} response object, with these properties `RemoteConfigured` + * @returns {Promise<{ RemoteConfigured: boolean}>} response object. */ async IsRemoteConfigured () { return this._request('IsRemoteConfigured') } diff --git a/lib/services/music-services.service.js b/lib/services/music-services.service.js index 24d39552..102241d7 100644 --- a/lib/services/music-services.service.js +++ b/lib/services/music-services.service.js @@ -33,14 +33,14 @@ class MusicServicesService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.ServiceId * @param {string} options.Username - * @returns {Promise} response object, with these properties `SessionId` + * @returns {Promise<{ SessionId: string}>} response object. */ async GetSessionId (options) { return this._request('GetSessionId', options) } /** * ListAvailableServices - Load music service list as xml * @remarks Some libraries also support ListAndParseAvailableServices - * @returns {Promise} response object, with these properties `AvailableServiceDescriptorList`, `AvailableServiceTypeList`, `AvailableServiceListVersion` + * @returns {Promise<{ AvailableServiceDescriptorList: string, AvailableServiceTypeList: string, AvailableServiceListVersion: string}>} response object. */ async ListAvailableServices () { return this._request('ListAvailableServices') } diff --git a/lib/services/q-play.service.js b/lib/services/q-play.service.js index 7033c3ef..5ad802c1 100644 --- a/lib/services/q-play.service.js +++ b/lib/services/q-play.service.js @@ -32,7 +32,7 @@ class QPlayService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.Seed - * @returns {Promise} response object, with these properties `Code`, `MID`, `DID` + * @returns {Promise<{ Code: string, MID: string, DID: string}>} response object. */ async QPlayAuth (options) { return this._request('QPlayAuth', options) } // #endregion diff --git a/lib/services/queue.service.js b/lib/services/queue.service.js index ad4e8da9..a542f4c9 100644 --- a/lib/services/queue.service.js +++ b/lib/services/queue.service.js @@ -39,7 +39,7 @@ class QueueService extends Service { * @param {boolean} options.EnqueueAsNext * @param {number} options.NumberOfURIs * @param {string} options.EnqueuedURIsAndMetaData - * @returns {Promise} response object, with these properties `FirstTrackNumberEnqueued`, `NumTracksAdded`, `NewQueueLength`, `NewUpdateID` + * @returns {Promise<{ FirstTrackNumberEnqueued: number, NumTracksAdded: number, NewQueueLength: number, NewUpdateID: number}>} response object. */ async AddMultipleURIs (options) { return this._request('AddMultipleURIs', options) } @@ -53,7 +53,7 @@ class QueueService extends Service { * @param {string} options.EnqueuedURIMetaData * @param {number} options.DesiredFirstTrackNumberEnqueued * @param {boolean} options.EnqueueAsNext - * @returns {Promise} response object, with these properties `FirstTrackNumberEnqueued`, `NumTracksAdded`, `NewQueueLength`, `NewUpdateID` + * @returns {Promise<{ FirstTrackNumberEnqueued: number, NumTracksAdded: number, NewQueueLength: number, NewUpdateID: number}>} response object. */ async AddURI (options) { return this._request('AddURI', options) } @@ -62,7 +62,7 @@ class QueueService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.QueueOwnerID - * @returns {Promise} response object, with these properties `QueueID`, `QueueOwnerContext` + * @returns {Promise<{ QueueID: number, QueueOwnerContext: string}>} response object. */ async AttachQueue (options) { return this._request('AttachQueue', options) } @@ -79,7 +79,7 @@ class QueueService extends Service { * @param {number} options.QueueID * @param {number} options.StartingIndex * @param {number} options.RequestedCount - * @returns {Promise} response object, with these properties `Result`, `NumberReturned`, `TotalMatches`, `UpdateID` + * @returns {Promise<{ Result: string, NumberReturned: number, TotalMatches: number, UpdateID: number}>} response object. */ async Browse (options) { return this._request('Browse', options) } @@ -90,7 +90,7 @@ class QueueService extends Service { * @param {string} options.QueueOwnerID * @param {string} options.QueueOwnerContext * @param {string} options.QueuePolicy - * @returns {Promise} response object, with these properties `QueueID` + * @returns {Promise<{ QueueID: number}>} response object. */ async CreateQueue (options) { return this._request('CreateQueue', options) } @@ -100,7 +100,7 @@ class QueueService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.QueueID * @param {number} options.UpdateID - * @returns {Promise} response object, with these properties `NewUpdateID` + * @returns {Promise<{ NewUpdateID: number}>} response object. */ async RemoveAllTracks (options) { return this._request('RemoveAllTracks', options) } @@ -112,7 +112,7 @@ class QueueService extends Service { * @param {number} options.UpdateID * @param {number} options.StartingIndex * @param {number} options.NumberOfTracks - * @returns {Promise} response object, with these properties `NewUpdateID` + * @returns {Promise<{ NewUpdateID: number}>} response object. */ async RemoveTrackRange (options) { return this._request('RemoveTrackRange', options) } @@ -125,7 +125,7 @@ class QueueService extends Service { * @param {number} options.NumberOfTracks * @param {number} options.InsertBefore * @param {number} options.UpdateID - * @returns {Promise} response object, with these properties `NewUpdateID` + * @returns {Promise<{ NewUpdateID: number}>} response object. */ async ReorderTracks (options) { return this._request('ReorderTracks', options) } @@ -141,7 +141,7 @@ class QueueService extends Service { * @param {string} options.NewCurrentTrackIndices * @param {number} options.NumberOfURIs * @param {string} options.EnqueuedURIsAndMetaData - * @returns {Promise} response object, with these properties `NewQueueLength`, `NewUpdateID` + * @returns {Promise<{ NewQueueLength: number, NewUpdateID: number}>} response object. */ async ReplaceAllTracks (options) { return this._request('ReplaceAllTracks', options) } @@ -152,7 +152,7 @@ class QueueService extends Service { * @param {number} options.QueueID * @param {string} options.Title * @param {string} options.ObjectID - * @returns {Promise} response object, with these properties `AssignedObjectID` + * @returns {Promise<{ AssignedObjectID: string}>} response object. */ async SaveAsSonosPlaylist (options) { return this._request('SaveAsSonosPlaylist', options) } // #endregion diff --git a/lib/services/rendering-control.service.js b/lib/services/rendering-control.service.js index 728baf32..91f3092e 100644 --- a/lib/services/rendering-control.service.js +++ b/lib/services/rendering-control.service.js @@ -32,7 +32,7 @@ class RenderingControlService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Promise} response object, with these properties `CurrentBass` + * @returns {Promise<{ CurrentBass: number}>} response object. */ async GetBass (options = { InstanceID: 0 }) { return this._request('GetBass', options) } @@ -43,7 +43,7 @@ class RenderingControlService extends Service { * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.EQType - Allowed values `DialogLevel` (bool) / `MusicSurroundLevel` (-15/+15) / `NightMode` (bool) / `SubGain` (-10/+10) / `SurroundEnable` (bool) / `SurroundLevel` (-15/+15) / `SurroundMode` (0 = full, 1 = ambient) * @remarks Not all EQ types are available on every speaker - * @returns {Promise} response object, with these properties `CurrentValue` + * @returns {Promise<{ CurrentValue: number}>} response object. */ async GetEQ (options) { return this._request('GetEQ', options) } @@ -52,7 +52,7 @@ class RenderingControlService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Promise} response object, with these properties `CurrentHeadphoneConnected` + * @returns {Promise<{ CurrentHeadphoneConnected: boolean}>} response object. */ async GetHeadphoneConnected (options = { InstanceID: 0 }) { return this._request('GetHeadphoneConnected', options) } @@ -62,7 +62,7 @@ class RenderingControlService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] - * @returns {Promise} response object, with these properties `CurrentLoudness` + * @returns {Promise<{ CurrentLoudness: boolean}>} response object. */ async GetLoudness (options) { return this._request('GetLoudness', options) } @@ -72,7 +72,7 @@ class RenderingControlService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' / 'SpeakerOnly' ] - * @returns {Promise} response object, with these properties `CurrentMute` + * @returns {Promise<{ CurrentMute: boolean}>} response object. */ async GetMute (options) { return this._request('GetMute', options) } @@ -81,7 +81,7 @@ class RenderingControlService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Promise} response object, with these properties `CurrentFixed` + * @returns {Promise<{ CurrentFixed: boolean}>} response object. */ async GetOutputFixed (options = { InstanceID: 0 }) { return this._request('GetOutputFixed', options) } @@ -90,7 +90,7 @@ class RenderingControlService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Promise} response object, with these properties `RoomCalibrationEnabled`, `RoomCalibrationAvailable` + * @returns {Promise<{ RoomCalibrationEnabled: boolean, RoomCalibrationAvailable: boolean}>} response object. */ async GetRoomCalibrationStatus (options = { InstanceID: 0 }) { return this._request('GetRoomCalibrationStatus', options) } @@ -99,7 +99,7 @@ class RenderingControlService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Promise} response object, with these properties `CurrentSupportsFixed` + * @returns {Promise<{ CurrentSupportsFixed: boolean}>} response object. */ async GetSupportsOutputFixed (options = { InstanceID: 0 }) { return this._request('GetSupportsOutputFixed', options) } @@ -108,7 +108,7 @@ class RenderingControlService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Promise} response object, with these properties `CurrentTreble` + * @returns {Promise<{ CurrentTreble: number}>} response object. */ async GetTreble (options = { InstanceID: 0 }) { return this._request('GetTreble', options) } @@ -118,7 +118,7 @@ class RenderingControlService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] - * @returns {Promise} response object, with these properties `CurrentVolume` + * @returns {Promise<{ CurrentVolume: number}>} response object. */ async GetVolume (options) { return this._request('GetVolume', options) } @@ -128,7 +128,7 @@ class RenderingControlService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] - * @returns {Promise} response object, with these properties `CurrentVolume` + * @returns {Promise<{ CurrentVolume: number}>} response object. */ async GetVolumeDB (options) { return this._request('GetVolumeDB', options) } @@ -138,7 +138,7 @@ class RenderingControlService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] - * @returns {Promise} response object, with these properties `MinValue`, `MaxValue` + * @returns {Promise<{ MinValue: number, MaxValue: number}>} response object. */ async GetVolumeDBRange (options) { return this._request('GetVolumeDBRange', options) } @@ -152,7 +152,7 @@ class RenderingControlService extends Service { * @param {number} options.DesiredVolume * @param {boolean} options.ResetVolumeAfter * @param {string} options.ProgramURI - * @returns {Promise} response object, with these properties `RampTime` + * @returns {Promise<{ RampTime: number}>} response object. */ async RampToVolume (options) { return this._request('RampToVolume', options) } @@ -161,7 +161,7 @@ class RenderingControlService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Promise} response object, with these properties `Bass`, `Treble`, `Loudness`, `LeftVolume`, `RightVolume` + * @returns {Promise<{ Bass: number, Treble: number, Loudness: boolean, LeftVolume: number, RightVolume: number}>} response object. */ async ResetBasicEQ (options = { InstanceID: 0 }) { return this._request('ResetBasicEQ', options) } @@ -256,7 +256,7 @@ class RenderingControlService extends Service { * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] * @param {number} options.Adjustment - * @returns {Promise} response object, with these properties `NewVolume` + * @returns {Promise<{ NewVolume: number}>} response object. */ async SetRelativeVolume (options) { return this._request('SetRelativeVolume', options) } diff --git a/lib/services/system-properties.service.js b/lib/services/system-properties.service.js index 031f3f69..a12d6fb7 100644 --- a/lib/services/system-properties.service.js +++ b/lib/services/system-properties.service.js @@ -34,7 +34,7 @@ class SystemPropertiesService extends Service { * @param {number} options.AccountType * @param {string} options.AccountID * @param {string} options.AccountPassword - * @returns {Promise} response object, with these properties `AccountUDN` + * @returns {Promise<{ AccountUDN: string}>} response object. */ async AddAccountX (options) { return this._request('AddAccountX', options) } @@ -50,7 +50,7 @@ class SystemPropertiesService extends Service { * @param {string} options.RedirectURI * @param {string} options.UserIdHashCode * @param {number} options.AccountTier - * @returns {Promise} response object, with these properties `AccountUDN`, `AccountNickname` + * @returns {Promise<{ AccountUDN: string, AccountNickname: string}>} response object. */ async AddOAuthAccountX (options) { return this._request('AddOAuthAccountX', options) } @@ -93,7 +93,7 @@ class SystemPropertiesService extends Service { /** * GetRDM - * @returns {Promise} response object, with these properties `RDMValue` + * @returns {Promise<{ RDMValue: boolean}>} response object. */ async GetRDM () { return this._request('GetRDM') } @@ -103,7 +103,7 @@ class SystemPropertiesService extends Service { * @param {Object} [options] - An object with the following properties * @param {string} options.VariableName - The key for this variable * @remarks Strings are saved in the system with SetString, every speaker should return the same data. Will error when not existing - * @returns {Promise} response object, with these properties `StringValue` + * @returns {Promise<{ StringValue: string}>} response object. */ async GetString (options) { return this._request('GetString', options) } @@ -112,7 +112,7 @@ class SystemPropertiesService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.AccountType - * @returns {Promise} response object, with these properties `WebCode` + * @returns {Promise<{ WebCode: string}>} response object. */ async GetWebCode (options) { return this._request('GetWebCode', options) } @@ -123,7 +123,7 @@ class SystemPropertiesService extends Service { * @param {number} options.AccountType * @param {string} options.AccountID * @param {string} options.AccountPassword - * @returns {Promise} response object, with these properties `IsExpired`, `AccountUDN` + * @returns {Promise<{ IsExpired: boolean, AccountUDN: string}>} response object. */ async ProvisionCredentialedTrialAccountX (options) { return this._request('ProvisionCredentialedTrialAccountX', options) } @@ -169,7 +169,7 @@ class SystemPropertiesService extends Service { * @param {string} options.AccountToken * @param {string} options.AccountKey * @param {string} options.OAuthDeviceID - * @returns {Promise} response object, with these properties `NewAccountUDN` + * @returns {Promise<{ NewAccountUDN: string}>} response object. */ async ReplaceAccountX (options) { return this._request('ReplaceAccountX', options) } diff --git a/lib/services/virtual-line-in.service.js b/lib/services/virtual-line-in.service.js index bf29d74e..8dbb7824 100644 --- a/lib/services/virtual-line-in.service.js +++ b/lib/services/virtual-line-in.service.js @@ -78,7 +78,7 @@ class VirtualLineInService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID * @param {string} options.CoordinatorID - * @returns {Promise} response object, with these properties `CurrentTransportSettings` + * @returns {Promise<{ CurrentTransportSettings: string}>} response object. */ async StartTransmission (options) { return this._request('StartTransmission', options) } diff --git a/lib/services/zone-group-topology.service.js b/lib/services/zone-group-topology.service.js index 61854ce5..bd547afb 100644 --- a/lib/services/zone-group-topology.service.js +++ b/lib/services/zone-group-topology.service.js @@ -45,20 +45,20 @@ class ZoneGroupTopologyService extends Service { * @param {string} options.UpdateType [ 'All' / 'Software' ] * @param {boolean} options.CachedOnly * @param {string} options.Version - * @returns {Promise} response object, with these properties `UpdateItem` + * @returns {Promise<{ UpdateItem: string}>} response object. */ async CheckForUpdate (options) { return this._request('CheckForUpdate', options) } /** * GetZoneGroupAttributes - Get information about the current Zone - * @returns {Promise} response object, with these properties `CurrentZoneGroupName`, `CurrentZoneGroupID`, `CurrentZonePlayerUUIDsInGroup`, `CurrentMuseHouseholdId` + * @returns {Promise<{ CurrentZoneGroupName: string, CurrentZoneGroupID: string, CurrentZonePlayerUUIDsInGroup: string, CurrentMuseHouseholdId: string}>} response object. */ async GetZoneGroupAttributes () { return this._request('GetZoneGroupAttributes') } /** * GetZoneGroupState - Get all the Sonos groups, (as XML) * @remarks Some libraries also support GetParsedZoneGroupState that parses the xml for you. - * @returns {Promise} response object, with these properties `ZoneGroupState` + * @returns {Promise<{ ZoneGroupState: string}>} response object. */ async GetZoneGroupState () { return this._request('GetZoneGroupState') } @@ -95,7 +95,7 @@ class ZoneGroupTopologyService extends Service { * @param {Object} [options] - An object with the following properties * @param {boolean} options.IncludeControllers * @param {string} options.Type - * @returns {Promise} response object, with these properties `DiagnosticID` + * @returns {Promise<{ DiagnosticID: number}>} response object. */ async SubmitDiagnostics (options) { return this._request('SubmitDiagnostics', options) } // #endregion diff --git a/lib/sonos.js b/lib/sonos.js index f7b0027d..57ad39a9 100644 --- a/lib/sonos.js +++ b/lib/sonos.js @@ -946,14 +946,14 @@ class Sonos extends EventEmitter { if (positionInfo.Track && positionInfo.Track > 1 && mediaInfo.NrTracks > 1) { debug('Selecting track %j', positionInfo.Track) await self.selectTrack(positionInfo.Track).catch(reason => { - debug('Reverting back track failed, happens for some muic services.') + debug('Reverting back track failed, happens for some music services.') }) } if (positionInfo.RelTime && positionInfo.TrackDuration !== '0:00:00') { debug('Setting back time to %j', positionInfo.RelTime) await self.avTransportService().Seek({ InstanceID: 0, Unit: 'REL_TIME', Target: positionInfo.RelTime }).catch(reason => { - debug('Reverting back track time failed, happens for some muic services (radio or stream).') + debug('Reverting back track time failed, happens for some music services (radio or stream).') }) } diff --git a/lib/sonosGroup.js b/lib/sonosGroup.js index 439bf03e..0d0093f2 100644 --- a/lib/sonosGroup.js +++ b/lib/sonosGroup.js @@ -1,8 +1,6 @@ const debug = require('debug')('sonos-group') const URL = require('url').URL - - class SonosGroup { constructor (zoneGroup) { debug('ZoneGroup %j', zoneGroup) diff --git a/test/sonos.test.js b/test/sonos.test.js index 8fa93b95..feb56ca4 100644 --- a/test/sonos.test.js +++ b/test/sonos.test.js @@ -493,7 +493,7 @@ describe('DeviceDiscovery', function () { }) it('should not emit a timeout event when no timeout option is passed in', function (done) { - setTimeout(function () { + setTimeout(() => { assert(true) done() }, 10) @@ -506,8 +506,8 @@ describe('DeviceDiscovery', function () { }) }) - it('should not emit a timeout event after search is stopped', function (done) { - const search = SONOS.DeviceDiscovery({ timeout: 10 }, function (device, model) {}) + it.skip('should not emit a timeout event after search is stopped', function (done) { + const search = SONOS.DeviceDiscovery({ timeout: 100 }, function (device, model) {}) search.on('timeout', function () { assert(false, 'Timeout event should never fire') diff --git a/types/lib/asyncDeviceDiscovery.d.ts b/types/lib/asyncDeviceDiscovery.d.ts index fa25b026..eda2daaf 100644 --- a/types/lib/asyncDeviceDiscovery.d.ts +++ b/types/lib/asyncDeviceDiscovery.d.ts @@ -4,22 +4,21 @@ declare class AsyncDeviceDiscovery { * Discover one device, will return first device found * @param {object} options * @param {number} options.timeout Milliseconds to timeout - * @returns {Promise<{device: Sonos, model: string}>} + * @returns {Promise<{device: import("./sonos").Sonos, model: string}>} */ discover(options?: { timeout: number; }): Promise<{ - device: Sonos; + device: import("./sonos").Sonos; model: string; }>; /** * Discover multiple devices, will return after timeout * @param {object} options * @param {number} options.timeout Milliseconds to timeout - * @returns {Promise} + * @returns {Promise} */ discoverMultiple(options?: { timeout: number; - }): Promise; + }): Promise; } -import { Sonos } from "./sonos"; diff --git a/types/lib/events/eventParser.d.ts b/types/lib/events/eventParser.d.ts index 713b41e5..b6990149 100644 --- a/types/lib/events/eventParser.d.ts +++ b/types/lib/events/eventParser.d.ts @@ -1,4 +1,3 @@ -import SonosGroup = require("../sonosGroup"); export function ParseAndEmitEvents(endpoint: any, body: any, device: any): Promise<{ name: string; eventBody: any; @@ -27,7 +26,7 @@ export function _parseAlarmEvent(body: any, device: any): { export function _parseZoneGroupTopologyEvent(body: any, device: any): Promise<{ name: string; eventBody: { - Zones: SonosGroup[]; + Zones: any; }; }>; export function _parseGroupRenderingControlEvent(body: any, device: any): { diff --git a/types/lib/services/alarm-clock.service.d.ts b/types/lib/services/alarm-clock.service.d.ts index 4a275efe..9498bdb2 100644 --- a/types/lib/services/alarm-clock.service.d.ts +++ b/types/lib/services/alarm-clock.service.d.ts @@ -31,7 +31,7 @@ declare class AlarmClockService extends Service { * @param {string} options.PlayMode - Alarm play mode [ 'NORMAL' / 'REPEAT_ALL' / 'SHUFFLE_NOREPEAT' / 'SHUFFLE' ] * @param {number} options.Volume - Volume between 0 and 100 * @param {boolean} options.IncludeLinkedZones - Should grouped players also play the alarm? - * @returns {Promise} response object, with these properties `AssignedID` + * @returns {Promise<{ AssignedID: number}>} response object. */ CreateAlarm(options?: { StartLocalTime: string; @@ -44,7 +44,9 @@ declare class AlarmClockService extends Service { PlayMode: string; Volume: number; IncludeLinkedZones: boolean; - }): Promise; + }): Promise<{ + AssignedID: number; + }>; /** * DestroyAlarm - Delete an alarm * @@ -57,60 +59,86 @@ declare class AlarmClockService extends Service { }): Promise; /** * GetDailyIndexRefreshTime - * @returns {Promise} response object, with these properties `CurrentDailyIndexRefreshTime` + * @returns {Promise<{ CurrentDailyIndexRefreshTime: string}>} response object. */ - GetDailyIndexRefreshTime(): Promise; + GetDailyIndexRefreshTime(): Promise<{ + CurrentDailyIndexRefreshTime: string; + }>; /** * GetFormat - * @returns {Promise} response object, with these properties `CurrentTimeFormat`, `CurrentDateFormat` + * @returns {Promise<{ CurrentTimeFormat: string, CurrentDateFormat: string}>} response object. */ - GetFormat(): Promise; + GetFormat(): Promise<{ + CurrentTimeFormat: string; + CurrentDateFormat: string; + }>; /** * GetHouseholdTimeAtStamp * * @param {Object} [options] - An object with the following properties * @param {string} options.TimeStamp - * @returns {Promise} response object, with these properties `HouseholdUTCTime` + * @returns {Promise<{ HouseholdUTCTime: string}>} response object. */ GetHouseholdTimeAtStamp(options?: { TimeStamp: string; - }): Promise; + }): Promise<{ + HouseholdUTCTime: string; + }>; /** * GetTimeNow - * @returns {Promise} response object, with these properties `CurrentUTCTime`, `CurrentLocalTime`, `CurrentTimeZone`, `CurrentTimeGeneration` + * @returns {Promise<{ CurrentUTCTime: string, CurrentLocalTime: string, CurrentTimeZone: string, CurrentTimeGeneration: number}>} response object. */ - GetTimeNow(): Promise; + GetTimeNow(): Promise<{ + CurrentUTCTime: string; + CurrentLocalTime: string; + CurrentTimeZone: string; + CurrentTimeGeneration: number; + }>; /** * GetTimeServer - * @returns {Promise} response object, with these properties `CurrentTimeServer` + * @returns {Promise<{ CurrentTimeServer: string}>} response object. */ - GetTimeServer(): Promise; + GetTimeServer(): Promise<{ + CurrentTimeServer: string; + }>; /** * GetTimeZone - * @returns {Promise} response object, with these properties `Index`, `AutoAdjustDst` + * @returns {Promise<{ Index: number, AutoAdjustDst: boolean}>} response object. */ - GetTimeZone(): Promise; + GetTimeZone(): Promise<{ + Index: number; + AutoAdjustDst: boolean; + }>; /** * GetTimeZoneAndRule - * @returns {Promise} response object, with these properties `Index`, `AutoAdjustDst`, `CurrentTimeZone` + * @returns {Promise<{ Index: number, AutoAdjustDst: boolean, CurrentTimeZone: string}>} response object. */ - GetTimeZoneAndRule(): Promise; + GetTimeZoneAndRule(): Promise<{ + Index: number; + AutoAdjustDst: boolean; + CurrentTimeZone: string; + }>; /** * GetTimeZoneRule * * @param {Object} [options] - An object with the following properties * @param {number} options.Index - * @returns {Promise} response object, with these properties `TimeZone` + * @returns {Promise<{ TimeZone: string}>} response object. */ GetTimeZoneRule(options?: { Index: number; - }): Promise; + }): Promise<{ + TimeZone: string; + }>; /** * ListAlarms - Get the AlarmList as XML * @remarks Some libraries also provide a ListAndParseAlarms where the alarm list xml is parsed - * @returns {Promise} response object, with these properties `CurrentAlarmList`, `CurrentAlarmListVersion` + * @returns {Promise<{ CurrentAlarmList: string, CurrentAlarmListVersion: string}>} response object. */ - ListAlarms(): Promise; + ListAlarms(): Promise<{ + CurrentAlarmList: string; + CurrentAlarmListVersion: string; + }>; /** * SetDailyIndexRefreshTime * diff --git a/types/lib/services/audio-in.service.d.ts b/types/lib/services/audio-in.service.d.ts index 83695df4..0a278fa0 100644 --- a/types/lib/services/audio-in.service.d.ts +++ b/types/lib/services/audio-in.service.d.ts @@ -19,14 +19,20 @@ declare class AudioInService extends Service { constructor(host: string, port: number); /** * GetAudioInputAttributes - * @returns {Promise} response object, with these properties `CurrentName`, `CurrentIcon` + * @returns {Promise<{ CurrentName: string, CurrentIcon: string}>} response object. */ - GetAudioInputAttributes(): Promise; + GetAudioInputAttributes(): Promise<{ + CurrentName: string; + CurrentIcon: string; + }>; /** * GetLineInLevel - * @returns {Promise} response object, with these properties `CurrentLeftLineInLevel`, `CurrentRightLineInLevel` + * @returns {Promise<{ CurrentLeftLineInLevel: number, CurrentRightLineInLevel: number}>} response object. */ - GetLineInLevel(): Promise; + GetLineInLevel(): Promise<{ + CurrentLeftLineInLevel: number; + CurrentRightLineInLevel: number; + }>; /** * SelectAudio * @@ -66,11 +72,13 @@ declare class AudioInService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.CoordinatorID - * @returns {Promise} response object, with these properties `CurrentTransportSettings` + * @returns {Promise<{ CurrentTransportSettings: string}>} response object. */ StartTransmissionToGroup(options?: { CoordinatorID: string; - }): Promise; + }): Promise<{ + CurrentTransportSettings: string; + }>; /** * StopTransmissionToGroup * diff --git a/types/lib/services/av-transport.service.d.ts b/types/lib/services/av-transport.service.d.ts index 8c7ca9b0..7a808f0f 100644 --- a/types/lib/services/av-transport.service.d.ts +++ b/types/lib/services/av-transport.service.d.ts @@ -30,7 +30,7 @@ declare class AVTransportService extends Service { * @param {string} options.ContainerMetaData * @param {number} options.DesiredFirstTrackNumberEnqueued * @param {boolean} options.EnqueueAsNext - * @returns {Promise} response object, with these properties `FirstTrackNumberEnqueued`, `NumTracksAdded`, `NewQueueLength`, `NewUpdateID` + * @returns {Promise<{ FirstTrackNumberEnqueued: number, NumTracksAdded: number, NewQueueLength: number, NewUpdateID: number}>} response object. */ AddMultipleURIsToQueue(options?: { InstanceID: number; @@ -42,7 +42,12 @@ declare class AVTransportService extends Service { ContainerMetaData: string; DesiredFirstTrackNumberEnqueued: number; EnqueueAsNext: boolean; - }): Promise; + }): Promise<{ + FirstTrackNumberEnqueued: number; + NumTracksAdded: number; + NewQueueLength: number; + NewUpdateID: number; + }>; /** * AddURIToQueue - Adds songs to the SONOS queue * @@ -53,7 +58,7 @@ declare class AVTransportService extends Service { * @param {number} options.DesiredFirstTrackNumberEnqueued - use `0` to add at the end or `1` to insert at the beginning * @param {boolean} options.EnqueueAsNext * @remarks In NORMAL play mode the songs are added prior to the specified `DesiredFirstTrackNumberEnqueued`. - * @returns {Promise} response object, with these properties `FirstTrackNumberEnqueued`, `NumTracksAdded`, `NewQueueLength` + * @returns {Promise<{ FirstTrackNumberEnqueued: number, NumTracksAdded: number, NewQueueLength: number}>} response object. */ AddURIToQueue(options?: { InstanceID: number; @@ -61,7 +66,11 @@ declare class AVTransportService extends Service { EnqueuedURIMetaData: string; DesiredFirstTrackNumberEnqueued: number; EnqueueAsNext: boolean; - }): Promise; + }): Promise<{ + FirstTrackNumberEnqueued: number; + NumTracksAdded: number; + NewQueueLength: number; + }>; /** * AddURIToSavedQueue * @@ -72,7 +81,7 @@ declare class AVTransportService extends Service { * @param {string} options.EnqueuedURI * @param {string} options.EnqueuedURIMetaData * @param {number} options.AddAtIndex - * @returns {Promise} response object, with these properties `NumTracksAdded`, `NewQueueLength`, `NewUpdateID` + * @returns {Promise<{ NumTracksAdded: number, NewQueueLength: number, NewUpdateID: number}>} response object. */ AddURIToSavedQueue(options?: { InstanceID: number; @@ -81,7 +90,11 @@ declare class AVTransportService extends Service { EnqueuedURI: string; EnqueuedURIMetaData: string; AddAtIndex: number; - }): Promise; + }): Promise<{ + NumTracksAdded: number; + NewQueueLength: number; + NewUpdateID: number; + }>; /** * BackupQueue * @@ -97,11 +110,14 @@ declare class AVTransportService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Promise} response object, with these properties `DelegatedGroupCoordinatorID`, `NewGroupID` + * @returns {Promise<{ DelegatedGroupCoordinatorID: string, NewGroupID: string}>} response object. */ BecomeCoordinatorOfStandaloneGroup(options?: { InstanceID: number; - }): Promise; + }): Promise<{ + DelegatedGroupCoordinatorID: string; + NewGroupID: string; + }>; /** * BecomeGroupCoordinator * @@ -221,14 +237,19 @@ declare class AVTransportService extends Service { * @param {string} options.Title * @param {string} options.EnqueuedURI * @param {string} options.EnqueuedURIMetaData - * @returns {Promise} response object, with these properties `NumTracksAdded`, `NewQueueLength`, `AssignedObjectID`, `NewUpdateID` + * @returns {Promise<{ NumTracksAdded: number, NewQueueLength: number, AssignedObjectID: string, NewUpdateID: number}>} response object. */ CreateSavedQueue(options?: { InstanceID: number; Title: string; EnqueuedURI: string; EnqueuedURIMetaData: string; - }): Promise; + }): Promise<{ + NumTracksAdded: number; + NewQueueLength: number; + AssignedObjectID: string; + NewUpdateID: number; + }>; /** * DelegateGroupCoordinationTo - Delegates the coordinator role to another player in the same group * @@ -260,95 +281,136 @@ declare class AVTransportService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @remarks Send to non-coordinator may return wrong value as only the coordinator value in a group - * @returns {Promise} response object, with these properties `CrossfadeMode` + * @returns {Promise<{ CrossfadeMode: boolean}>} response object. */ GetCrossfadeMode(options?: { InstanceID: number; - }): Promise; + }): Promise<{ + CrossfadeMode: boolean; + }>; /** * GetCurrentTransportActions - Get current transport actions such as Set, Stop, Pause, Play, X_DLNA_SeekTime, Next, X_DLNA_SeekTrackNr * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @remarks Send to non-coordinator returns only `Start` and `Stop` since it cannot control the stream. - * @returns {Promise} response object, with these properties `Actions` + * @returns {Promise<{ Actions: string}>} response object. */ GetCurrentTransportActions(options?: { InstanceID: number; - }): Promise; + }): Promise<{ + Actions: string; + }>; /** * GetDeviceCapabilities * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Promise} response object, with these properties `PlayMedia`, `RecMedia`, `RecQualityModes` + * @returns {Promise<{ PlayMedia: string, RecMedia: string, RecQualityModes: string}>} response object. */ GetDeviceCapabilities(options?: { InstanceID: number; - }): Promise; + }): Promise<{ + PlayMedia: string; + RecMedia: string; + RecQualityModes: string; + }>; /** * GetMediaInfo - Get information about the current playing media (queue) * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Promise} response object, with these properties `NrTracks`, `MediaDuration`, `CurrentURI`, `CurrentURIMetaData`, `NextURI`, `NextURIMetaData`, `PlayMedium`, `RecordMedium`, `WriteStatus` + * @returns {Promise<{ NrTracks: number, MediaDuration: string, CurrentURI: string, CurrentURIMetaData: string, NextURI: string, NextURIMetaData: string, PlayMedium: string, RecordMedium: string, WriteStatus: string}>} response object. */ GetMediaInfo(options?: { InstanceID: number; - }): Promise; + }): Promise<{ + NrTracks: number; + MediaDuration: string; + CurrentURI: string; + CurrentURIMetaData: string; + NextURI: string; + NextURIMetaData: string; + PlayMedium: string; + RecordMedium: string; + WriteStatus: string; + }>; /** * GetPositionInfo - Get information about current position (position in queue and time in current song) * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Promise} response object, with these properties `Track`, `TrackDuration`, `TrackMetaData`, `TrackURI`, `RelTime`, `AbsTime`, `RelCount`, `AbsCount` + * @returns {Promise<{ Track: number, TrackDuration: string, TrackMetaData: string, TrackURI: string, RelTime: string, AbsTime: string, RelCount: number, AbsCount: number}>} response object. */ GetPositionInfo(options?: { InstanceID: number; - }): Promise; + }): Promise<{ + Track: number; + TrackDuration: string; + TrackMetaData: string; + TrackURI: string; + RelTime: string; + AbsTime: string; + RelCount: number; + AbsCount: number; + }>; /** * GetRemainingSleepTimerDuration - Get time left on sleeptimer. * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @remarks Send to non-coordinator returns error code 800 - * @returns {Promise} response object, with these properties `RemainingSleepTimerDuration`, `CurrentSleepTimerGeneration` + * @returns {Promise<{ RemainingSleepTimerDuration: string, CurrentSleepTimerGeneration: number}>} response object. */ GetRemainingSleepTimerDuration(options?: { InstanceID: number; - }): Promise; + }): Promise<{ + RemainingSleepTimerDuration: string; + CurrentSleepTimerGeneration: number; + }>; /** * GetRunningAlarmProperties * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Promise} response object, with these properties `AlarmID`, `GroupID`, `LoggedStartTime` + * @returns {Promise<{ AlarmID: number, GroupID: string, LoggedStartTime: string}>} response object. */ GetRunningAlarmProperties(options?: { InstanceID: number; - }): Promise; + }): Promise<{ + AlarmID: number; + GroupID: string; + LoggedStartTime: string; + }>; /** * GetTransportInfo - Get current transport status, speed and state such as PLAYING, STOPPED, PLAYING, PAUSED_PLAYBACK, TRANSITIONING, NO_MEDIA_PRESENT * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @remarks Send to non-coordinator always returns PLAYING - * @returns {Promise} response object, with these properties `CurrentTransportState`, `CurrentTransportStatus`, `CurrentSpeed` + * @returns {Promise<{ CurrentTransportState: string, CurrentTransportStatus: string, CurrentSpeed: string}>} response object. */ GetTransportInfo(options?: { InstanceID: number; - }): Promise; + }): Promise<{ + CurrentTransportState: string; + CurrentTransportStatus: string; + CurrentSpeed: string; + }>; /** * GetTransportSettings - Get transport settings * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @remarks Send to non-coordinator returns the settings of it's queue - * @returns {Promise} response object, with these properties `PlayMode`, `RecQualityMode` + * @returns {Promise<{ PlayMode: string, RecQualityMode: string}>} response object. */ GetTransportSettings(options?: { InstanceID: number; - }): Promise; + }): Promise<{ + PlayMode: string; + RecQualityMode: string; + }>; /** * Next - Go to next song * @@ -438,14 +500,16 @@ declare class AVTransportService extends Service { * @param {number} options.UpdateID - Leave blank * @param {number} options.StartingIndex - between 1 and queue-length * @param {number} options.NumberOfTracks - * @returns {Promise} response object, with these properties `NewUpdateID` + * @returns {Promise<{ NewUpdateID: number}>} response object. */ RemoveTrackRangeFromQueue(options?: { InstanceID: number; UpdateID: number; StartingIndex: number; NumberOfTracks: number; - }): Promise; + }): Promise<{ + NewUpdateID: number; + }>; /** * ReorderTracksInQueue * @@ -473,7 +537,7 @@ declare class AVTransportService extends Service { * @param {number} options.UpdateID * @param {string} options.TrackList * @param {string} options.NewPositionList - * @returns {Promise} response object, with these properties `QueueLengthChange`, `NewQueueLength`, `NewUpdateID` + * @returns {Promise<{ QueueLengthChange: number, NewQueueLength: number, NewUpdateID: number}>} response object. */ ReorderTracksInSavedQueue(options?: { InstanceID: number; @@ -481,7 +545,11 @@ declare class AVTransportService extends Service { UpdateID: number; TrackList: string; NewPositionList: string; - }): Promise; + }): Promise<{ + QueueLengthChange: number; + NewQueueLength: number; + NewUpdateID: number; + }>; /** * RunAlarm * @@ -516,13 +584,15 @@ declare class AVTransportService extends Service { * @param {string} options.Title - SONOS playlist title * @param {string} options.ObjectID - Leave blank * @remarks Send to non-coordinator returns error code 800 - * @returns {Promise} response object, with these properties `AssignedObjectID` + * @returns {Promise<{ AssignedObjectID: string}>} response object. */ SaveQueue(options?: { InstanceID: number; Title: string; ObjectID: string; - }): Promise; + }): Promise<{ + AssignedObjectID: string; + }>; /** * Seek - Seek track in queue, time delta or absolute time in song * diff --git a/types/lib/services/connection-manager.service.d.ts b/types/lib/services/connection-manager.service.d.ts index d95cf06f..9387238d 100644 --- a/types/lib/services/connection-manager.service.d.ts +++ b/types/lib/services/connection-manager.service.d.ts @@ -19,23 +19,36 @@ declare class ConnectionManagerService extends Service { constructor(host: string, port: number); /** * GetCurrentConnectionIDs - * @returns {Promise} response object, with these properties `ConnectionIDs` + * @returns {Promise<{ ConnectionIDs: string}>} response object. */ - GetCurrentConnectionIDs(): Promise; + GetCurrentConnectionIDs(): Promise<{ + ConnectionIDs: string; + }>; /** * GetCurrentConnectionInfo * * @param {Object} [options] - An object with the following properties * @param {number} options.ConnectionID - * @returns {Promise} response object, with these properties `RcsID`, `AVTransportID`, `ProtocolInfo`, `PeerConnectionManager`, `PeerConnectionID`, `Direction`, `Status` + * @returns {Promise<{ RcsID: number, AVTransportID: number, ProtocolInfo: string, PeerConnectionManager: string, PeerConnectionID: number, Direction: string, Status: string}>} response object. */ GetCurrentConnectionInfo(options?: { ConnectionID: number; - }): Promise; + }): Promise<{ + RcsID: number; + AVTransportID: number; + ProtocolInfo: string; + PeerConnectionManager: string; + PeerConnectionID: number; + Direction: string; + Status: string; + }>; /** * GetProtocolInfo - * @returns {Promise} response object, with these properties `Source`, `Sink` + * @returns {Promise<{ Source: string, Sink: string}>} response object. */ - GetProtocolInfo(): Promise; + GetProtocolInfo(): Promise<{ + Source: string; + Sink: string; + }>; } import Service = require("./Service"); diff --git a/types/lib/services/content-directory.service.d.ts b/types/lib/services/content-directory.service.d.ts index 2ab40274..d4b3df0e 100644 --- a/types/lib/services/content-directory.service.d.ts +++ b/types/lib/services/content-directory.service.d.ts @@ -28,7 +28,7 @@ declare class ContentDirectoryService extends Service { * @param {number} options.RequestedCount - Paging, number of items, maximum is 1,000. This parameter does NOT restrict the number of items being searched (filter) but only the number being returned. * @param {string} options.SortCriteria - Sort the results based on metadata fields. `+upnp:artist,+dc:title` for sorting on artist then on title. * @remarks (1) If the title contains an apostrophe the returned uri will contain a `'`. (2) Some libraries support a BrowseAndParse, so you don't have to parse the xml. - * @returns {Promise} response object, with these properties `Result`, `NumberReturned`, `TotalMatches`, `UpdateID` + * @returns {Promise<{ Result: string, NumberReturned: number, TotalMatches: number, UpdateID: number}>} response object. */ Browse(options?: { ObjectID: string; @@ -37,19 +37,27 @@ declare class ContentDirectoryService extends Service { StartingIndex: number; RequestedCount: number; SortCriteria: string; - }): Promise; + }): Promise<{ + Result: string; + NumberReturned: number; + TotalMatches: number; + UpdateID: number; + }>; /** * CreateObject * * @param {Object} [options] - An object with the following properties * @param {string} options.ContainerID * @param {string} options.Elements - * @returns {Promise} response object, with these properties `ObjectID`, `Result` + * @returns {Promise<{ ObjectID: string, Result: string}>} response object. */ CreateObject(options?: { ContainerID: string; Elements: string; - }): Promise; + }): Promise<{ + ObjectID: string; + Result: string; + }>; /** * DestroyObject * @@ -66,57 +74,78 @@ declare class ContentDirectoryService extends Service { * @param {Object} [options] - An object with the following properties * @param {string} options.ObjectID * @param {string} options.Prefix - * @returns {Promise} response object, with these properties `StartingIndex`, `UpdateID` + * @returns {Promise<{ StartingIndex: number, UpdateID: number}>} response object. */ FindPrefix(options?: { ObjectID: string; Prefix: string; - }): Promise; + }): Promise<{ + StartingIndex: number; + UpdateID: number; + }>; /** * GetAlbumArtistDisplayOption - * @returns {Promise} response object, with these properties `AlbumArtistDisplayOption` + * @returns {Promise<{ AlbumArtistDisplayOption: string}>} response object. */ - GetAlbumArtistDisplayOption(): Promise; + GetAlbumArtistDisplayOption(): Promise<{ + AlbumArtistDisplayOption: string; + }>; /** * GetAllPrefixLocations * * @param {Object} [options] - An object with the following properties * @param {string} options.ObjectID - * @returns {Promise} response object, with these properties `TotalPrefixes`, `PrefixAndIndexCSV`, `UpdateID` + * @returns {Promise<{ TotalPrefixes: number, PrefixAndIndexCSV: string, UpdateID: number}>} response object. */ GetAllPrefixLocations(options?: { ObjectID: string; - }): Promise; + }): Promise<{ + TotalPrefixes: number; + PrefixAndIndexCSV: string; + UpdateID: number; + }>; /** * GetBrowseable - * @returns {Promise} response object, with these properties `IsBrowseable` + * @returns {Promise<{ IsBrowseable: boolean}>} response object. */ - GetBrowseable(): Promise; + GetBrowseable(): Promise<{ + IsBrowseable: boolean; + }>; /** * GetLastIndexChange - * @returns {Promise} response object, with these properties `LastIndexChange` + * @returns {Promise<{ LastIndexChange: string}>} response object. */ - GetLastIndexChange(): Promise; + GetLastIndexChange(): Promise<{ + LastIndexChange: string; + }>; /** * GetSearchCapabilities - * @returns {Promise} response object, with these properties `SearchCaps` + * @returns {Promise<{ SearchCaps: string}>} response object. */ - GetSearchCapabilities(): Promise; + GetSearchCapabilities(): Promise<{ + SearchCaps: string; + }>; /** * GetShareIndexInProgress - * @returns {Promise} response object, with these properties `IsIndexing` + * @returns {Promise<{ IsIndexing: boolean}>} response object. */ - GetShareIndexInProgress(): Promise; + GetShareIndexInProgress(): Promise<{ + IsIndexing: boolean; + }>; /** * GetSortCapabilities - * @returns {Promise} response object, with these properties `SortCaps` + * @returns {Promise<{ SortCaps: string}>} response object. */ - GetSortCapabilities(): Promise; + GetSortCapabilities(): Promise<{ + SortCaps: string; + }>; /** * GetSystemUpdateID - * @returns {Promise} response object, with these properties `Id` + * @returns {Promise<{ Id: number}>} response object. */ - GetSystemUpdateID(): Promise; + GetSystemUpdateID(): Promise<{ + Id: number; + }>; /** * RefreshShareIndex * diff --git a/types/lib/services/device-properties.service.d.ts b/types/lib/services/device-properties.service.d.ts index 678c89f2..1ec55917 100644 --- a/types/lib/services/device-properties.service.d.ts +++ b/types/lib/services/device-properties.service.d.ts @@ -54,12 +54,14 @@ declare class DevicePropertiesService extends Service { * @param {Object} [options] - An object with the following properties * @param {string} options.Mode * @param {string} options.Options - * @returns {Promise} response object, with these properties `State` + * @returns {Promise<{ State: string}>} response object. */ EnterConfigMode(options?: { Mode: string; Options: string; - }): Promise; + }): Promise<{ + State: string; + }>; /** * ExitConfigMode * @@ -75,71 +77,102 @@ declare class DevicePropertiesService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.Source - * @returns {Promise} response object, with these properties `IncludeLinkedZones` + * @returns {Promise<{ IncludeLinkedZones: boolean}>} response object. */ GetAutoplayLinkedZones(options?: { Source: string; - }): Promise; + }): Promise<{ + IncludeLinkedZones: boolean; + }>; /** * GetAutoplayRoomUUID * * @param {Object} [options] - An object with the following properties * @param {string} options.Source - * @returns {Promise} response object, with these properties `RoomUUID` + * @returns {Promise<{ RoomUUID: string}>} response object. */ GetAutoplayRoomUUID(options?: { Source: string; - }): Promise; + }): Promise<{ + RoomUUID: string; + }>; /** * GetAutoplayVolume * * @param {Object} [options] - An object with the following properties * @param {string} options.Source - * @returns {Promise} response object, with these properties `CurrentVolume` + * @returns {Promise<{ CurrentVolume: number}>} response object. */ GetAutoplayVolume(options?: { Source: string; - }): Promise; + }): Promise<{ + CurrentVolume: number; + }>; /** * GetButtonLockState - Get the current button lock state - * @returns {Promise} response object, with these properties `CurrentButtonLockState` + * @returns {Promise<{ CurrentButtonLockState: string}>} response object. */ - GetButtonLockState(): Promise; + GetButtonLockState(): Promise<{ + CurrentButtonLockState: string; + }>; /** * GetButtonState - * @returns {Promise} response object, with these properties `State` + * @returns {Promise<{ State: string}>} response object. */ - GetButtonState(): Promise; + GetButtonState(): Promise<{ + State: string; + }>; /** * GetHouseholdID - * @returns {Promise} response object, with these properties `CurrentHouseholdID` + * @returns {Promise<{ CurrentHouseholdID: string}>} response object. */ - GetHouseholdID(): Promise; + GetHouseholdID(): Promise<{ + CurrentHouseholdID: string; + }>; /** * GetLEDState - Get the current LED state - * @returns {Promise} response object, with these properties `CurrentLEDState` + * @returns {Promise<{ CurrentLEDState: string}>} response object. */ - GetLEDState(): Promise; + GetLEDState(): Promise<{ + CurrentLEDState: string; + }>; /** * GetUseAutoplayVolume * * @param {Object} [options] - An object with the following properties * @param {string} options.Source - * @returns {Promise} response object, with these properties `UseVolume` + * @returns {Promise<{ UseVolume: boolean}>} response object. */ GetUseAutoplayVolume(options?: { Source: string; - }): Promise; + }): Promise<{ + UseVolume: boolean; + }>; /** * GetZoneAttributes - * @returns {Promise} response object, with these properties `CurrentZoneName`, `CurrentIcon`, `CurrentConfiguration` + * @returns {Promise<{ CurrentZoneName: string, CurrentIcon: string, CurrentConfiguration: string}>} response object. */ - GetZoneAttributes(): Promise; + GetZoneAttributes(): Promise<{ + CurrentZoneName: string; + CurrentIcon: string; + CurrentConfiguration: string; + }>; /** * GetZoneInfo - Get information about this specific speaker - * @returns {Promise} response object, with these properties `SerialNumber`, `SoftwareVersion`, `DisplaySoftwareVersion`, `HardwareVersion`, `IPAddress`, `MACAddress`, `CopyrightInfo`, `ExtraInfo`, `HTAudioIn`, `Flags` + * @returns {Promise<{ SerialNumber: string, SoftwareVersion: string, DisplaySoftwareVersion: string, HardwareVersion: string, IPAddress: string, MACAddress: string, CopyrightInfo: string, ExtraInfo: string, HTAudioIn: number, Flags: number}>} response object. */ - GetZoneInfo(): Promise; + GetZoneInfo(): Promise<{ + SerialNumber: string; + SoftwareVersion: string; + DisplaySoftwareVersion: string; + HardwareVersion: string; + IPAddress: string; + MACAddress: string; + CopyrightInfo: string; + ExtraInfo: string; + HTAudioIn: number; + Flags: number; + }>; /** * RemoveBondedZones * @@ -168,12 +201,15 @@ declare class DevicePropertiesService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.Channel * @param {number} options.DurationMilliseconds - * @returns {Promise} response object, with these properties `PlayId`, `ChirpIfPlayingSwappableAudio` + * @returns {Promise<{ PlayId: number, ChirpIfPlayingSwappableAudio: boolean}>} response object. */ RoomDetectionStartChirping(options?: { Channel: number; DurationMilliseconds: number; - }): Promise; + }): Promise<{ + PlayId: number; + ChirpIfPlayingSwappableAudio: boolean; + }>; /** * RoomDetectionStopChirping * diff --git a/types/lib/services/group-management.service.d.ts b/types/lib/services/group-management.service.d.ts index 47b3231f..dc7f892f 100644 --- a/types/lib/services/group-management.service.d.ts +++ b/types/lib/services/group-management.service.d.ts @@ -23,12 +23,18 @@ declare class GroupManagementService extends Service { * @param {Object} [options] - An object with the following properties * @param {string} options.MemberID * @param {number} options.BootSeq - * @returns {Promise} response object, with these properties `CurrentTransportSettings`, `CurrentURI`, `GroupUUIDJoined`, `ResetVolumeAfter`, `VolumeAVTransportURI` + * @returns {Promise<{ CurrentTransportSettings: string, CurrentURI: string, GroupUUIDJoined: string, ResetVolumeAfter: boolean, VolumeAVTransportURI: string}>} response object. */ AddMember(options?: { MemberID: string; BootSeq: number; - }): Promise; + }): Promise<{ + CurrentTransportSettings: string; + CurrentURI: string; + GroupUUIDJoined: string; + ResetVolumeAfter: boolean; + VolumeAVTransportURI: string; + }>; /** * RemoveMember * diff --git a/types/lib/services/group-rendering-control.service.d.ts b/types/lib/services/group-rendering-control.service.d.ts index ac8d8103..6f86435a 100644 --- a/types/lib/services/group-rendering-control.service.d.ts +++ b/types/lib/services/group-rendering-control.service.d.ts @@ -23,22 +23,26 @@ declare class GroupRenderingControlService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @remarks Should be send to coordinator only - * @returns {Promise} response object, with these properties `CurrentMute` + * @returns {Promise<{ CurrentMute: boolean}>} response object. */ GetGroupMute(options?: { InstanceID: number; - }): Promise; + }): Promise<{ + CurrentMute: boolean; + }>; /** * GetGroupVolume - Get the group volume. * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @remarks Should be send to coordinator only - * @returns {Promise} response object, with these properties `CurrentVolume` + * @returns {Promise<{ CurrentVolume: number}>} response object. */ GetGroupVolume(options?: { InstanceID: number; - }): Promise; + }): Promise<{ + CurrentVolume: number; + }>; /** * SetGroupMute - (Un-/)Mute the entire group * @@ -72,12 +76,14 @@ declare class GroupRenderingControlService extends Service { * @param {number} options.InstanceID - InstanceID should always be `0` * @param {number} options.Adjustment - Number between -100 and +100 * @remarks Should be send to coordinator only - * @returns {Promise} response object, with these properties `NewVolume` + * @returns {Promise<{ NewVolume: number}>} response object. */ SetRelativeGroupVolume(options?: { InstanceID: number; Adjustment: number; - }): Promise; + }): Promise<{ + NewVolume: number; + }>; /** * SnapshotGroupVolume - Creates a new group volume snapshot, the volume ratio between all players. It is used by SetGroupVolume and SetRelativeGroupVolume * diff --git a/types/lib/services/ht-control.service.d.ts b/types/lib/services/ht-control.service.d.ts index 9d6bf1a3..d84b8e87 100644 --- a/types/lib/services/ht-control.service.d.ts +++ b/types/lib/services/ht-control.service.d.ts @@ -29,14 +29,18 @@ declare class HTControlService extends Service { }): Promise; /** * GetIRRepeaterState - * @returns {Promise} response object, with these properties `CurrentIRRepeaterState` + * @returns {Promise<{ CurrentIRRepeaterState: string}>} response object. */ - GetIRRepeaterState(): Promise; + GetIRRepeaterState(): Promise<{ + CurrentIRRepeaterState: string; + }>; /** * GetLEDFeedbackState - * @returns {Promise} response object, with these properties `LEDFeedbackState` + * @returns {Promise<{ LEDFeedbackState: string}>} response object. */ - GetLEDFeedbackState(): Promise; + GetLEDFeedbackState(): Promise<{ + LEDFeedbackState: string; + }>; /** * IdentifyIRRemote * @@ -49,9 +53,11 @@ declare class HTControlService extends Service { }): Promise; /** * IsRemoteConfigured - * @returns {Promise} response object, with these properties `RemoteConfigured` + * @returns {Promise<{ RemoteConfigured: boolean}>} response object. */ - IsRemoteConfigured(): Promise; + IsRemoteConfigured(): Promise<{ + RemoteConfigured: boolean; + }>; /** * LearnIRCode * diff --git a/types/lib/services/music-services.service.d.ts b/types/lib/services/music-services.service.d.ts index 70b5544c..11438a2e 100644 --- a/types/lib/services/music-services.service.d.ts +++ b/types/lib/services/music-services.service.d.ts @@ -23,18 +23,24 @@ declare class MusicServicesService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.ServiceId * @param {string} options.Username - * @returns {Promise} response object, with these properties `SessionId` + * @returns {Promise<{ SessionId: string}>} response object. */ GetSessionId(options?: { ServiceId: number; Username: string; - }): Promise; + }): Promise<{ + SessionId: string; + }>; /** * ListAvailableServices - Load music service list as xml * @remarks Some libraries also support ListAndParseAvailableServices - * @returns {Promise} response object, with these properties `AvailableServiceDescriptorList`, `AvailableServiceTypeList`, `AvailableServiceListVersion` + * @returns {Promise<{ AvailableServiceDescriptorList: string, AvailableServiceTypeList: string, AvailableServiceListVersion: string}>} response object. */ - ListAvailableServices(): Promise; + ListAvailableServices(): Promise<{ + AvailableServiceDescriptorList: string; + AvailableServiceTypeList: string; + AvailableServiceListVersion: string; + }>; /** * UpdateAvailableServices * @returns {Promise} request succeeded diff --git a/types/lib/services/q-play.service.d.ts b/types/lib/services/q-play.service.d.ts index 58c747aa..f08ec314 100644 --- a/types/lib/services/q-play.service.d.ts +++ b/types/lib/services/q-play.service.d.ts @@ -22,10 +22,14 @@ declare class QPlayService extends Service { * * @param {Object} [options] - An object with the following properties * @param {string} options.Seed - * @returns {Promise} response object, with these properties `Code`, `MID`, `DID` + * @returns {Promise<{ Code: string, MID: string, DID: string}>} response object. */ QPlayAuth(options?: { Seed: string; - }): Promise; + }): Promise<{ + Code: string; + MID: string; + DID: string; + }>; } import Service = require("./Service"); diff --git a/types/lib/services/queue.service.d.ts b/types/lib/services/queue.service.d.ts index 7f16e9ba..9d31c981 100644 --- a/types/lib/services/queue.service.d.ts +++ b/types/lib/services/queue.service.d.ts @@ -29,7 +29,7 @@ declare class QueueService extends Service { * @param {boolean} options.EnqueueAsNext * @param {number} options.NumberOfURIs * @param {string} options.EnqueuedURIsAndMetaData - * @returns {Promise} response object, with these properties `FirstTrackNumberEnqueued`, `NumTracksAdded`, `NewQueueLength`, `NewUpdateID` + * @returns {Promise<{ FirstTrackNumberEnqueued: number, NumTracksAdded: number, NewQueueLength: number, NewUpdateID: number}>} response object. */ AddMultipleURIs(options?: { QueueID: number; @@ -40,7 +40,12 @@ declare class QueueService extends Service { EnqueueAsNext: boolean; NumberOfURIs: number; EnqueuedURIsAndMetaData: string; - }): Promise; + }): Promise<{ + FirstTrackNumberEnqueued: number; + NumTracksAdded: number; + NewQueueLength: number; + NewUpdateID: number; + }>; /** * AddURI * @@ -51,7 +56,7 @@ declare class QueueService extends Service { * @param {string} options.EnqueuedURIMetaData * @param {number} options.DesiredFirstTrackNumberEnqueued * @param {boolean} options.EnqueueAsNext - * @returns {Promise} response object, with these properties `FirstTrackNumberEnqueued`, `NumTracksAdded`, `NewQueueLength`, `NewUpdateID` + * @returns {Promise<{ FirstTrackNumberEnqueued: number, NumTracksAdded: number, NewQueueLength: number, NewUpdateID: number}>} response object. */ AddURI(options?: { QueueID: number; @@ -60,17 +65,25 @@ declare class QueueService extends Service { EnqueuedURIMetaData: string; DesiredFirstTrackNumberEnqueued: number; EnqueueAsNext: boolean; - }): Promise; + }): Promise<{ + FirstTrackNumberEnqueued: number; + NumTracksAdded: number; + NewQueueLength: number; + NewUpdateID: number; + }>; /** * AttachQueue * * @param {Object} [options] - An object with the following properties * @param {string} options.QueueOwnerID - * @returns {Promise} response object, with these properties `QueueID`, `QueueOwnerContext` + * @returns {Promise<{ QueueID: number, QueueOwnerContext: string}>} response object. */ AttachQueue(options?: { QueueOwnerID: string; - }): Promise; + }): Promise<{ + QueueID: number; + QueueOwnerContext: string; + }>; /** * Backup * @returns {Promise} request succeeded @@ -83,13 +96,18 @@ declare class QueueService extends Service { * @param {number} options.QueueID * @param {number} options.StartingIndex * @param {number} options.RequestedCount - * @returns {Promise} response object, with these properties `Result`, `NumberReturned`, `TotalMatches`, `UpdateID` + * @returns {Promise<{ Result: string, NumberReturned: number, TotalMatches: number, UpdateID: number}>} response object. */ Browse(options?: { QueueID: number; StartingIndex: number; RequestedCount: number; - }): Promise; + }): Promise<{ + Result: string; + NumberReturned: number; + TotalMatches: number; + UpdateID: number; + }>; /** * CreateQueue * @@ -97,25 +115,29 @@ declare class QueueService extends Service { * @param {string} options.QueueOwnerID * @param {string} options.QueueOwnerContext * @param {string} options.QueuePolicy - * @returns {Promise} response object, with these properties `QueueID` + * @returns {Promise<{ QueueID: number}>} response object. */ CreateQueue(options?: { QueueOwnerID: string; QueueOwnerContext: string; QueuePolicy: string; - }): Promise; + }): Promise<{ + QueueID: number; + }>; /** * RemoveAllTracks * * @param {Object} [options] - An object with the following properties * @param {number} options.QueueID * @param {number} options.UpdateID - * @returns {Promise} response object, with these properties `NewUpdateID` + * @returns {Promise<{ NewUpdateID: number}>} response object. */ RemoveAllTracks(options?: { QueueID: number; UpdateID: number; - }): Promise; + }): Promise<{ + NewUpdateID: number; + }>; /** * RemoveTrackRange * @@ -124,14 +146,16 @@ declare class QueueService extends Service { * @param {number} options.UpdateID * @param {number} options.StartingIndex * @param {number} options.NumberOfTracks - * @returns {Promise} response object, with these properties `NewUpdateID` + * @returns {Promise<{ NewUpdateID: number}>} response object. */ RemoveTrackRange(options?: { QueueID: number; UpdateID: number; StartingIndex: number; NumberOfTracks: number; - }): Promise; + }): Promise<{ + NewUpdateID: number; + }>; /** * ReorderTracks * @@ -141,7 +165,7 @@ declare class QueueService extends Service { * @param {number} options.NumberOfTracks * @param {number} options.InsertBefore * @param {number} options.UpdateID - * @returns {Promise} response object, with these properties `NewUpdateID` + * @returns {Promise<{ NewUpdateID: number}>} response object. */ ReorderTracks(options?: { QueueID: number; @@ -149,7 +173,9 @@ declare class QueueService extends Service { NumberOfTracks: number; InsertBefore: number; UpdateID: number; - }): Promise; + }): Promise<{ + NewUpdateID: number; + }>; /** * ReplaceAllTracks * @@ -162,7 +188,7 @@ declare class QueueService extends Service { * @param {string} options.NewCurrentTrackIndices * @param {number} options.NumberOfURIs * @param {string} options.EnqueuedURIsAndMetaData - * @returns {Promise} response object, with these properties `NewQueueLength`, `NewUpdateID` + * @returns {Promise<{ NewQueueLength: number, NewUpdateID: number}>} response object. */ ReplaceAllTracks(options?: { QueueID: number; @@ -173,7 +199,10 @@ declare class QueueService extends Service { NewCurrentTrackIndices: string; NumberOfURIs: number; EnqueuedURIsAndMetaData: string; - }): Promise; + }): Promise<{ + NewQueueLength: number; + NewUpdateID: number; + }>; /** * SaveAsSonosPlaylist * @@ -181,12 +210,14 @@ declare class QueueService extends Service { * @param {number} options.QueueID * @param {string} options.Title * @param {string} options.ObjectID - * @returns {Promise} response object, with these properties `AssignedObjectID` + * @returns {Promise<{ AssignedObjectID: string}>} response object. */ SaveAsSonosPlaylist(options?: { QueueID: number; Title: string; ObjectID: string; - }): Promise; + }): Promise<{ + AssignedObjectID: string; + }>; } import Service = require("./Service"); diff --git a/types/lib/services/rendering-control.service.d.ts b/types/lib/services/rendering-control.service.d.ts index 39db6ba1..2e76d051 100644 --- a/types/lib/services/rendering-control.service.d.ts +++ b/types/lib/services/rendering-control.service.d.ts @@ -22,11 +22,13 @@ declare class RenderingControlService extends Service { * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Promise} response object, with these properties `CurrentBass` + * @returns {Promise<{ CurrentBass: number}>} response object. */ GetBass(options?: { InstanceID: number; - }): Promise; + }): Promise<{ + CurrentBass: number; + }>; /** * GetEQ - Get equalizer value * @@ -34,122 +36,146 @@ declare class RenderingControlService extends Service { * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.EQType - Allowed values `DialogLevel` (bool) / `MusicSurroundLevel` (-15/+15) / `NightMode` (bool) / `SubGain` (-10/+10) / `SurroundEnable` (bool) / `SurroundLevel` (-15/+15) / `SurroundMode` (0 = full, 1 = ambient) * @remarks Not all EQ types are available on every speaker - * @returns {Promise} response object, with these properties `CurrentValue` + * @returns {Promise<{ CurrentValue: number}>} response object. */ GetEQ(options?: { InstanceID: number; EQType: string; - }): Promise; + }): Promise<{ + CurrentValue: number; + }>; /** * GetHeadphoneConnected * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Promise} response object, with these properties `CurrentHeadphoneConnected` + * @returns {Promise<{ CurrentHeadphoneConnected: boolean}>} response object. */ GetHeadphoneConnected(options?: { InstanceID: number; - }): Promise; + }): Promise<{ + CurrentHeadphoneConnected: boolean; + }>; /** * GetLoudness - Whether or not Loudness is on * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] - * @returns {Promise} response object, with these properties `CurrentLoudness` + * @returns {Promise<{ CurrentLoudness: boolean}>} response object. */ GetLoudness(options?: { InstanceID: number; Channel: string; - }): Promise; + }): Promise<{ + CurrentLoudness: boolean; + }>; /** * GetMute * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' / 'SpeakerOnly' ] - * @returns {Promise} response object, with these properties `CurrentMute` + * @returns {Promise<{ CurrentMute: boolean}>} response object. */ GetMute(options?: { InstanceID: number; Channel: string; - }): Promise; + }): Promise<{ + CurrentMute: boolean; + }>; /** * GetOutputFixed * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Promise} response object, with these properties `CurrentFixed` + * @returns {Promise<{ CurrentFixed: boolean}>} response object. */ GetOutputFixed(options?: { InstanceID: number; - }): Promise; + }): Promise<{ + CurrentFixed: boolean; + }>; /** * GetRoomCalibrationStatus * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Promise} response object, with these properties `RoomCalibrationEnabled`, `RoomCalibrationAvailable` + * @returns {Promise<{ RoomCalibrationEnabled: boolean, RoomCalibrationAvailable: boolean}>} response object. */ GetRoomCalibrationStatus(options?: { InstanceID: number; - }): Promise; + }): Promise<{ + RoomCalibrationEnabled: boolean; + RoomCalibrationAvailable: boolean; + }>; /** * GetSupportsOutputFixed * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Promise} response object, with these properties `CurrentSupportsFixed` + * @returns {Promise<{ CurrentSupportsFixed: boolean}>} response object. */ GetSupportsOutputFixed(options?: { InstanceID: number; - }): Promise; + }): Promise<{ + CurrentSupportsFixed: boolean; + }>; /** * GetTreble - Get treble * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Promise} response object, with these properties `CurrentTreble` + * @returns {Promise<{ CurrentTreble: number}>} response object. */ GetTreble(options?: { InstanceID: number; - }): Promise; + }): Promise<{ + CurrentTreble: number; + }>; /** * GetVolume - Get volume * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] - * @returns {Promise} response object, with these properties `CurrentVolume` + * @returns {Promise<{ CurrentVolume: number}>} response object. */ GetVolume(options?: { InstanceID: number; Channel: string; - }): Promise; + }): Promise<{ + CurrentVolume: number; + }>; /** * GetVolumeDB * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] - * @returns {Promise} response object, with these properties `CurrentVolume` + * @returns {Promise<{ CurrentVolume: number}>} response object. */ GetVolumeDB(options?: { InstanceID: number; Channel: string; - }): Promise; + }): Promise<{ + CurrentVolume: number; + }>; /** * GetVolumeDBRange * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] - * @returns {Promise} response object, with these properties `MinValue`, `MaxValue` + * @returns {Promise<{ MinValue: number, MaxValue: number}>} response object. */ GetVolumeDBRange(options?: { InstanceID: number; Channel: string; - }): Promise; + }): Promise<{ + MinValue: number; + MaxValue: number; + }>; /** * RampToVolume * @@ -160,7 +186,7 @@ declare class RenderingControlService extends Service { * @param {number} options.DesiredVolume * @param {boolean} options.ResetVolumeAfter * @param {string} options.ProgramURI - * @returns {Promise} response object, with these properties `RampTime` + * @returns {Promise<{ RampTime: number}>} response object. */ RampToVolume(options?: { InstanceID: number; @@ -169,17 +195,25 @@ declare class RenderingControlService extends Service { DesiredVolume: number; ResetVolumeAfter: boolean; ProgramURI: string; - }): Promise; + }): Promise<{ + RampTime: number; + }>; /** * ResetBasicEQ * * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID - InstanceID should always be `0` - * @returns {Promise} response object, with these properties `Bass`, `Treble`, `Loudness`, `LeftVolume`, `RightVolume` + * @returns {Promise<{ Bass: number, Treble: number, Loudness: boolean, LeftVolume: number, RightVolume: number}>} response object. */ ResetBasicEQ(options?: { InstanceID: number; - }): Promise; + }): Promise<{ + Bass: number; + Treble: number; + Loudness: boolean; + LeftVolume: number; + RightVolume: number; + }>; /** * ResetExtEQ * @@ -290,13 +324,15 @@ declare class RenderingControlService extends Service { * @param {number} options.InstanceID - InstanceID should always be `0` * @param {string} options.Channel [ 'Master' / 'LF' / 'RF' ] * @param {number} options.Adjustment - * @returns {Promise} response object, with these properties `NewVolume` + * @returns {Promise<{ NewVolume: number}>} response object. */ SetRelativeVolume(options?: { InstanceID: number; Channel: string; Adjustment: number; - }): Promise; + }): Promise<{ + NewVolume: number; + }>; /** * SetRoomCalibrationStatus * diff --git a/types/lib/services/system-properties.service.d.ts b/types/lib/services/system-properties.service.d.ts index e634c8b8..295ebf23 100644 --- a/types/lib/services/system-properties.service.d.ts +++ b/types/lib/services/system-properties.service.d.ts @@ -24,13 +24,15 @@ declare class SystemPropertiesService extends Service { * @param {number} options.AccountType * @param {string} options.AccountID * @param {string} options.AccountPassword - * @returns {Promise} response object, with these properties `AccountUDN` + * @returns {Promise<{ AccountUDN: string}>} response object. */ AddAccountX(options?: { AccountType: number; AccountID: string; AccountPassword: string; - }): Promise; + }): Promise<{ + AccountUDN: string; + }>; /** * AddOAuthAccountX * @@ -43,7 +45,7 @@ declare class SystemPropertiesService extends Service { * @param {string} options.RedirectURI * @param {string} options.UserIdHashCode * @param {number} options.AccountTier - * @returns {Promise} response object, with these properties `AccountUDN`, `AccountNickname` + * @returns {Promise<{ AccountUDN: string, AccountNickname: string}>} response object. */ AddOAuthAccountX(options?: { AccountType: number; @@ -54,7 +56,10 @@ declare class SystemPropertiesService extends Service { RedirectURI: string; UserIdHashCode: string; AccountTier: number; - }): Promise; + }): Promise<{ + AccountUDN: string; + AccountNickname: string; + }>; /** * DoPostUpdateTasks * @returns {Promise} request succeeded @@ -100,30 +105,36 @@ declare class SystemPropertiesService extends Service { }): Promise; /** * GetRDM - * @returns {Promise} response object, with these properties `RDMValue` + * @returns {Promise<{ RDMValue: boolean}>} response object. */ - GetRDM(): Promise; + GetRDM(): Promise<{ + RDMValue: boolean; + }>; /** * GetString - Get a saved string. * * @param {Object} [options] - An object with the following properties * @param {string} options.VariableName - The key for this variable * @remarks Strings are saved in the system with SetString, every speaker should return the same data. Will error when not existing - * @returns {Promise} response object, with these properties `StringValue` + * @returns {Promise<{ StringValue: string}>} response object. */ GetString(options?: { VariableName: string; - }): Promise; + }): Promise<{ + StringValue: string; + }>; /** * GetWebCode * * @param {Object} [options] - An object with the following properties * @param {number} options.AccountType - * @returns {Promise} response object, with these properties `WebCode` + * @returns {Promise<{ WebCode: string}>} response object. */ GetWebCode(options?: { AccountType: number; - }): Promise; + }): Promise<{ + WebCode: string; + }>; /** * ProvisionCredentialedTrialAccountX * @@ -131,13 +142,16 @@ declare class SystemPropertiesService extends Service { * @param {number} options.AccountType * @param {string} options.AccountID * @param {string} options.AccountPassword - * @returns {Promise} response object, with these properties `IsExpired`, `AccountUDN` + * @returns {Promise<{ IsExpired: boolean, AccountUDN: string}>} response object. */ ProvisionCredentialedTrialAccountX(options?: { AccountType: number; AccountID: string; AccountPassword: string; - }): Promise; + }): Promise<{ + IsExpired: boolean; + AccountUDN: string; + }>; /** * RefreshAccountCredentialsX * @@ -187,7 +201,7 @@ declare class SystemPropertiesService extends Service { * @param {string} options.AccountToken * @param {string} options.AccountKey * @param {string} options.OAuthDeviceID - * @returns {Promise} response object, with these properties `NewAccountUDN` + * @returns {Promise<{ NewAccountUDN: string}>} response object. */ ReplaceAccountX(options?: { AccountUDN: string; @@ -196,7 +210,9 @@ declare class SystemPropertiesService extends Service { AccountToken: string; AccountKey: string; OAuthDeviceID: string; - }): Promise; + }): Promise<{ + NewAccountUDN: string; + }>; /** * ResetThirdPartyCredentials * @returns {Promise} request succeeded diff --git a/types/lib/services/virtual-line-in.service.d.ts b/types/lib/services/virtual-line-in.service.d.ts index 79bf896f..9c49dca2 100644 --- a/types/lib/services/virtual-line-in.service.d.ts +++ b/types/lib/services/virtual-line-in.service.d.ts @@ -75,12 +75,14 @@ declare class VirtualLineInService extends Service { * @param {Object} [options] - An object with the following properties * @param {number} options.InstanceID * @param {string} options.CoordinatorID - * @returns {Promise} response object, with these properties `CurrentTransportSettings` + * @returns {Promise<{ CurrentTransportSettings: string}>} response object. */ StartTransmission(options?: { InstanceID: number; CoordinatorID: string; - }): Promise; + }): Promise<{ + CurrentTransportSettings: string; + }>; /** * Stop * diff --git a/types/lib/services/zone-group-topology.service.d.ts b/types/lib/services/zone-group-topology.service.d.ts index 3dc55d44..15de028e 100644 --- a/types/lib/services/zone-group-topology.service.d.ts +++ b/types/lib/services/zone-group-topology.service.d.ts @@ -38,24 +38,33 @@ declare class ZoneGroupTopologyService extends Service { * @param {string} options.UpdateType [ 'All' / 'Software' ] * @param {boolean} options.CachedOnly * @param {string} options.Version - * @returns {Promise} response object, with these properties `UpdateItem` + * @returns {Promise<{ UpdateItem: string}>} response object. */ CheckForUpdate(options?: { UpdateType: string; CachedOnly: boolean; Version: string; - }): Promise; + }): Promise<{ + UpdateItem: string; + }>; /** * GetZoneGroupAttributes - Get information about the current Zone - * @returns {Promise} response object, with these properties `CurrentZoneGroupName`, `CurrentZoneGroupID`, `CurrentZonePlayerUUIDsInGroup`, `CurrentMuseHouseholdId` + * @returns {Promise<{ CurrentZoneGroupName: string, CurrentZoneGroupID: string, CurrentZonePlayerUUIDsInGroup: string, CurrentMuseHouseholdId: string}>} response object. */ - GetZoneGroupAttributes(): Promise; + GetZoneGroupAttributes(): Promise<{ + CurrentZoneGroupName: string; + CurrentZoneGroupID: string; + CurrentZonePlayerUUIDsInGroup: string; + CurrentMuseHouseholdId: string; + }>; /** * GetZoneGroupState - Get all the Sonos groups, (as XML) * @remarks Some libraries also support GetParsedZoneGroupState that parses the xml for you. - * @returns {Promise} response object, with these properties `ZoneGroupState` + * @returns {Promise<{ ZoneGroupState: string}>} response object. */ - GetZoneGroupState(): Promise; + GetZoneGroupState(): Promise<{ + ZoneGroupState: string; + }>; /** * RegisterMobileDevice * @@ -93,11 +102,13 @@ declare class ZoneGroupTopologyService extends Service { * @param {Object} [options] - An object with the following properties * @param {boolean} options.IncludeControllers * @param {string} options.Type - * @returns {Promise} response object, with these properties `DiagnosticID` + * @returns {Promise<{ DiagnosticID: number}>} response object. */ SubmitDiagnostics(options?: { IncludeControllers: boolean; Type: string; - }): Promise; + }): Promise<{ + DiagnosticID: number; + }>; } import Service = require("./Service");