Skip to content

Commit

Permalink
Standard code style
Browse files Browse the repository at this point in the history
  • Loading branch information
ebaauw committed Mar 18, 2018
1 parent f906d89 commit bddbf1d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 20 deletions.
48 changes: 32 additions & 16 deletions lib/ZPAccessory.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,32 +142,42 @@ ZPAccessory.prototype.copyCoordinator = function () {
coordinator.becomePlatformCoordinator()
this.log.debug('%s: copy group characteristics from %s', this.name, coordinator.name)
if (this.state.group.on !== coordinator.state.group.on) {
this.log.debug('%s: set member power (play/pause) from %s to %s', this.name,
this.state.group.on, coordinator.state.group.on)
this.log.debug(
'%s: set member power (play/pause) from %s to %s', this.name,
this.state.group.on, coordinator.state.group.on
)
this.state.group.on = coordinator.state.group.on
this.groupService.setCharacteristic(Characteristic.On, this.state.group.on)
}
if (this.state.group.volume !== coordinator.state.group.volume) {
this.log.debug('%s: set member group volume from %s to %s', this.name,
this.state.group.volume, coordinator.state.group.volume)
this.log.debug(
'%s: set member group volume from %s to %s', this.name,
this.state.group.volume, coordinator.state.group.volume
)
this.state.group.volume = coordinator.state.group.volume
this.groupService.setCharacteristic(this.platform.VolumeCharacteristic, this.state.group.volume)
}
if (this.state.group.mute !== coordinator.state.group.mute) {
this.log.debug('%s: set member group mute from %s to %s', this.name,
this.state.group.mute, coordinator.state.group.mute)
this.log.debug(
'%s: set member group mute from %s to %s', this.name,
this.state.group.mute, coordinator.state.group.mute
)
this.state.group.mute = coordinator.state.group.mute
this.groupService.setCharacteristic(Characteristic.Mute, this.state.group.mute)
}
if (this.state.group.track !== coordinator.state.group.track) {
this.log.debug('%s: set member track from %s to %s', this.name,
this.state.group.track, coordinator.state.group.track)
this.log.debug(
'%s: set member track from %s to %s', this.name,
this.state.group.track, coordinator.state.group.track
)
this.state.group.track = coordinator.state.group.track
this.groupService.setCharacteristic(Characteristic.CurrentTrack, this.state.group.track)
}
if (this.state.group.name !== coordinator.state.group.name) {
this.log.debug('%s: set member sonos group from %s to %s', this.name,
this.state.group.name, coordinator.state.group.name)
this.log.debug(
'%s: set member sonos group from %s to %s', this.name,
this.state.group.name, coordinator.state.group.name
)
this.state.group.name = coordinator.state.group.name
this.groupService.setCharacteristic(Characteristic.SonosGroup, this.state.group.name)
}
Expand Down Expand Up @@ -339,8 +349,10 @@ ZPAccessory.prototype.handleAVTransportEvent = function (data) {
}
if (track !== this.state.group.track &&
track !== 'ZPSTR_CONNECTING' && track !== 'ZPSTR_BUFFERING') {
this.log.info('%s: current track changed from %s to %s', this.name,
this.state.group.track, track)
this.log.info(
'%s: current track changed from %s to %s', this.name,
this.state.group.track, track
)
this.state.group.track = track
this.groupService.setCharacteristic(Characteristic.CurrentTrack, this.state.group.track)
for (const member of this.members()) {
Expand Down Expand Up @@ -778,8 +790,10 @@ ZPAccessory.prototype.resubscribe = function (sid, device, service) {
}.bind(this))
return
}
this.log.debug('%s: renewed %s subscription %s (timeout %s)', this.name,
service, response.headers.sid, response.headers.timeout)
this.log.debug(
'%s: renewed %s subscription %s (timeout %s)', this.name,
service, response.headers.sid, response.headers.timeout
)
setTimeout(function () {
this.resubscribe(response.headers.sid, device, service)
}.bind(this), (this.platform.subscriptionTimeout - 60) * 1000)
Expand All @@ -796,8 +810,10 @@ ZPAccessory.prototype.request = function (opt, callback) {
return callback(err)
}
if (response.statusCode !== 200) {
this.log.error('%s: cannot %s %s (%d - %s)', this.name, opt.method, opt.url,
response.statusCode, response.statusMessage)
this.log.error(
'%s: cannot %s %s (%d - %s)', this.name, opt.method, opt.url,
response.statusCode, response.statusMessage
)
return callback(response.statusCode)
}
return callback(null, response)
Expand Down
8 changes: 4 additions & 4 deletions lib/ZPPlatform.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ function ZPPlatform (log, config) {
}
this.speakers = config.speakers || false
this.alarms = config.alarms || false
this.searchTimeout = config.searchTimeout || 5 // seconds
this.searchTimeout *= 1000 // milliseconds
this.subscriptionTimeout = config.subscriptionTimeout || 30 // minutes
this.subscriptionTimeout *= 60 // seconds
this.searchTimeout = config.searchTimeout || 5 // seconds
this.searchTimeout *= 1000 // milliseconds
this.subscriptionTimeout = config.subscriptionTimeout || 30 // minutes
this.subscriptionTimeout *= 60 // seconds

this.players = []
this.zpAccessories = {}
Expand Down

0 comments on commit bddbf1d

Please sign in to comment.