Skip to content

Commit

Permalink
Detection of zoneplayer configuration and setup
Browse files Browse the repository at this point in the history
Using `DeviceProperties` event, see #74.
  • Loading branch information
ebaauw committed May 30, 2019
1 parent 475a040 commit e3acd71
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
26 changes: 22 additions & 4 deletions lib/ZpAccessory.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function setHomebridge (Homebridge) {
const tvModels = [
'ZPS9', // PlayBar.
'ZPS11', // Playbase, see #58.
'ZPS14', // Beam, see #74.
'ZPS16' // Amp, see #8.
]

Expand Down Expand Up @@ -77,9 +78,6 @@ function ZpAccessory (platform, zp) {
}
this.log = this.platform.log
this.parser = new xml2js.Parser()
if (this.tv !== this.zp.tv) {
this.log.warn('%s: warning: TV detection fails for %s: tv: %j, zp.tv: %j', this.name, this.zp.model, this.tv, this.zp.tv)
}

this.infoService = new Service.AccessoryInformation()
this.infoService
Expand Down Expand Up @@ -460,7 +458,27 @@ ZpAccessory.prototype.handleGroupManagementEvent = function (data) {
}

ZpAccessory.prototype.handleDevicePropertiesEvent = function (data) {
this.log('%s: DeviceProperties event: %j', this.name, data)
this.log.debug('%s: DeviceProperties event: %j', this.name, data)
if (this.capabilities == null) {
const caps = {
airPlay: data.AirPlayEnabled != null && data.AirPlayEnabled !== '0',
audioIn: data.SupportsAudioIn != null && data.SupportsAudioIn !== '0',
tvIn: data.HTFreq != null,
homeTheatreSetup: data.HTSatChanMapSet != null && data.HTSatChanMapSet !== '',
stereoPair: data.ChannelMapSet != null && data.ChannelMapSet !== ''
}
this.log.warn(
'%s: detected %s capabilities (please report if wrong): ' +
'AirPlay: %j, audio input: %j, TV input: %j',
this.name, this.zp.model, caps.airPlay, caps.audioIn, caps.tvIn
)
this.log.warn(
'%s: detected setup (please report if wrong): ' +
'Home Theatre: %j, Stereo Pair: %j',
this.name, caps.homeTheatreSetup, caps.stereoPair
)
this.capabities = caps
}
}

ZpAccessory.prototype.handleAVTransportEvent = function (data) {
Expand Down
3 changes: 1 addition & 2 deletions lib/ZpPlatform.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,10 @@ ZpPlatform.prototype.findPlayers = function () {
if (err) {
this.log.error('%s: error %s', zp.zone, err)
} else {
this.log('%s: info %j', zp.zone, info)
// this.log.debug('%s: info %j', zp.zone, info)
zp.id = 'RINCON_' + info.MACAddress.replace(/:/g, '') +
('00000' + zp.port).substr(-5, 5)
zp.version = info.DisplaySoftwareVersion
zp.tv = Number(info.HTAudioIn) > 0
zoneGroupTopology.GetZoneGroupAttributes({}, (err, attrs) => {
if (err) {
this.log.error('%s: error %s', zp.zone, err)
Expand Down

0 comments on commit e3acd71

Please sign in to comment.