Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions lib/sonos.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,27 @@ Sonos.prototype.getMuted = async function () {
return this.renderingControlService().GetMute()
}

/**
* Get Current Group Volume
* @returns {Number} The current volume
*/
Sonos.prototype.getGroupVolume = async function () {
debug('Sonos.getGroupVolume()')
if (this._isSubscribed && this._volume) return this._volume
return this.groupRenderingControlService().GetGroupVolume()
}

/**
* Get Current Group Muted
* @returns {Boolean}
*/
Sonos.prototype.getGroupMuted = async function () {
debug('Sonos.getGroupMuted()')
if (this._isSubscribed && this._mute) return this._mute
return this.groupRenderingControlService().GetGroupMute()
}


/**
* Resumes Queue or Plays Provided URI
* @param {String|Object} options Optional - URI to a Audio Stream or Object with play options
Expand Down Expand Up @@ -682,6 +703,27 @@ Sonos.prototype.adjustVolume = async function (volumeAdjustment, channel = 'Mast
return this.renderingControlService().SetRelativeVolume(volumeAdjustment, channel)
}

/**
* Set Group Volume
* @param {number} volume 0..100
* @param {string} channel What channel to change, `Master` is default.
* @returns {Object}
*/
Sonos.prototype.setGroupVolume = async function (volume, channel = 'Master') {
debug('Sonos.setGroupVolume(%j)', volume)
return this.groupRenderingControlService().SetGroupVolume(volume, channel)
}

/**
* Adjust Group volume
* @param {number} volumeAdjustment The relative volume adjustment
* @param {string} channel The channel you want to set, `Master` is default.
*/
Sonos.prototype.adjustGroupVolume = async function (volumeAdjustment, channel = 'Master') {
debug('Sonos.adjustGroupVolume(%j)', volumeAdjustment)
return this.groupRenderingControlService().SetRelativeGroupVolume(volumeAdjustment, channel)
}

/**
* Configure Sleep Timer
* @param {String} sleepTimerDuration
Expand All @@ -704,6 +746,18 @@ Sonos.prototype.setMuted = async function (muted, channel = 'Master') {
return this.renderingControlService().SetMute(muted, channel)
}

/**
* Set Group Muted
* @param {Boolean} muted
* @param {string} channel What channel to change, `Master` is default.
* @returns {Object}
*/
Sonos.prototype.setGroupMuted = async function (muted, channel = 'Master') {
debug('Sonos.setGroupMuted(%j)', muted)
if (typeof muted === 'string') muted = !!parseInt(muted, 10)
return this.groupRenderingControlService().SetGroupMute(muted, channel)
}

/**
* Get device balance as number from -100 (full left) to +100 (full right), where 0 is left and right equal
* @returns {Promise}
Expand Down Expand Up @@ -1003,6 +1057,10 @@ Sonos.prototype.renderingControlService = function () {
return new Services.RenderingControl(this.host, this.port)
}

Sonos.prototype.groupRenderingControlService = function () {
return new Services.GroupRenderingControl(this.host, this.port)
}

Sonos.prototype.zoneGroupTopologyService = function () {
return new Services.ZoneGroupTopology(this.host, this.port)
}
Expand Down