Skip to content

Commit

Permalink
Merge pull request #235 from svrooij/master
Browse files Browse the repository at this point in the history
Data from listener is used
  • Loading branch information
svrooij authored Feb 12, 2018
2 parents 5a7c3d6 + 8c402ef commit 768c9d9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @requires 'xml2js
*/

const debug = require('debug')('sonos')
const debug = require('debug')('sonos:helpers')
const parseString = require('xml2js').parseString

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/services/Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

const request = require('request-promise-native')
const parseString = require('xml2js').parseString
const debug = require('debug')('sonos-service')
const debug = require('debug')('sonos:service')
const Helpers = require('../helpers')

/**
Expand Down
7 changes: 6 additions & 1 deletion lib/sonos.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const DEVICE_ENDPOINT = '/DeviceProperties/Control'
const util = require('util')
const EventEmitter = require('events').EventEmitter
const request = require('request-promise-native')
const debug = require('debug')('sonos')
const debug = require('debug')('sonos:main')
const Listener = require('./events/adv-listener')
const Helpers = require('./helpers')

Expand Down Expand Up @@ -162,6 +162,7 @@ Sonos.prototype.currentTrack = async function () {
*/
Sonos.prototype.getVolume = async function () {
debug('Sonos.getVolume()')
if (this._isSubscribed && this._volume) return this._volume
return this.renderingControlService().GetVolume()
}

Expand All @@ -171,6 +172,7 @@ Sonos.prototype.getVolume = async function () {
*/
Sonos.prototype.getMuted = async function () {
debug('Sonos.getMuted()')
if (this._isSubscribed && this._mute) return this._mute
return this.renderingControlService().GetMute()
}

Expand Down Expand Up @@ -558,6 +560,7 @@ Sonos.prototype.getTopology = async function () {
*/
Sonos.prototype.getCurrentState = function () {
debug('Sonos.currentState()')
if (this._isSubscribed && this._state) return this._state
return this.avTransportService().GetTransportInfo()
.then(result => {
return Helpers.TranslateState(result.CurrentTransportState)
Expand Down Expand Up @@ -641,7 +644,9 @@ Sonos.prototype.playNotification = async function (options) {
return new Promise(async (resolve, reject) => {
debug('sonos.playNotification(%j)', options)
const state = await this.getCurrentState()
debug('Current state %j', state)
const wasPlaying = (state === 'playing' || state === 'transitioning')
debug('Was playing %j', wasPlaying)
const wasListening = Listener.isListening()
let volume = 0
if (typeof options === 'object') {
Expand Down

0 comments on commit 768c9d9

Please sign in to comment.