Skip to content

Commit

Permalink
[2.8.5] Added support for receiver and some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Martvvliet committed Jun 24, 2020
1 parent 494a376 commit d34ee57
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
46 changes: 22 additions & 24 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const discover = require('./lib/discover');

const pluginName = 'homebridge-denon-heos';
const platformName = 'DenonAVR';
const pluginVersion = '2.8.4';
const pluginVersion = '2.8.5';

const defaultPollingInterval = 3;
const infoRetDelay = 250;
Expand Down Expand Up @@ -128,7 +128,6 @@ class denonClient {
logDebug('DEBUG: configureAccessory');
//logDebug(platformAccessory);

platformAccessory.reachable = true;
cachedAccessories.push(platformAccessory);
}
removeAccessory(platformAccessory){
Expand Down Expand Up @@ -811,6 +810,8 @@ class tvClient {
logDebug('DEBUG: setupTvService zone: ' + this.zone + ': ' + this.name);

this.tvAccesory = new Accessory(this.name, UUIDGen.generate(this.ip+this.name+"tvService"));
this.tvAccesory.category = this.api.hap.Categories.AUDIO_RECEIVER;


this.tvService = new Service.Television(this.name, 'tvService');
this.tvService
Expand Down Expand Up @@ -1365,14 +1366,13 @@ class legacyClient {
/* Delay to wait for retrieve device info */
this.uuid = UUIDGen.generate(this.name+this.ip+toString(this.zone)+"switch");

this.accessory = new Accessory(this.name, this.uuid);

this.accessory.reachable = true;


let isCached = this.testCachedAccessories();

if (!isCached) {
g_log("New switch configured: " + this.name);

this.accessory = new Accessory(this.name, this.uuid);

this.switchService = new Service.Switch(this.name, 'legacyInput');
this.switchService
.getCharacteristic(Characteristic.On)
Expand Down Expand Up @@ -1400,6 +1400,8 @@ class legacyClient {
.getCharacteristic(Characteristic.On)
.on('get', this.getPowerStateLegacy.bind(this))
.on('set', this.setPowerStateLegacy.bind(this));

// this.api.updatePlatformAccessories([this.accessory]);
}
}

Expand Down Expand Up @@ -1659,12 +1661,10 @@ class legacyClient {
}

testCachedAccessories() {
for (let i in cachedAccessories) {
if (this.uuid == cachedAccessories[i].UUID) {
this.accessory = cachedAccessories[i];
cachedAccessories.splice(i,1);
return true;
}
this.accessory = cachedAccessories.find(cachedAccessories => cachedAccessories.UUID === this.uuid);
if (this.accessory) {
cachedAccessories.splice(cachedAccessories.indexOf(this.accessory),1);
return true;
}
return false;
}
Expand Down Expand Up @@ -1719,13 +1719,11 @@ class volumeClient {

/* Delay to wait for retrieve device info */
this.uuid = UUIDGen.generate(this.name+this.ip+toString(this.zone)+this.volumeAsFan+"volumeControl");

this.accessory = new Accessory(this.name, this.uuid);

this.accessory.reachable = true;

let isCached = this.testCachedAccessories();

if (!isCached) {
this.accessory = new Accessory(this.name, this.uuid);

g_log("New volumeControl configured: " + this.name);
if (this.volumeAsFan){
this.volumeService = new Service.Fanv2(this.name, 'volumeInput');
Expand Down Expand Up @@ -1788,6 +1786,7 @@ class volumeClient {
.on('get', this.getVolume.bind(this))
.on('set', this.setVolume.bind(this));
}
// this.api.updatePlatformAccessories([this.accessory]);
}
}

Expand Down Expand Up @@ -1968,19 +1967,18 @@ class volumeClient {
}

testCachedAccessories() {
for (let i in cachedAccessories) {
if (this.uuid == cachedAccessories[i].UUID) {
this.accessory = cachedAccessories[i];
cachedAccessories.splice(i,1);
return true;
}
this.accessory = cachedAccessories.find(cachedAccessories => cachedAccessories.UUID === this.uuid);
if (this.accessory) {
cachedAccessories.splice(cachedAccessories.indexOf(this.accessory),1);
return true;
}
return false;
}

getName() {
return this.name;
}

/*****************************************
* Volume service
****************************************/
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "homebridge-denon-heos",
"version": "2.8.4",
"version": "2.8.5",
"description": "Denon and possibly Marantz (some are tested with positive results) AVR support for Homebridge: https://github.com/nfarina/homebridge with support for newer version of receiver. This plugin uses the http commands to control the receivers. It is also possible to add a receiver as a tv to your homekit. This way, you can control the receiver with the remote. Set the volume with the remote and change the input, all in one block.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit d34ee57

Please sign in to comment.