Fixed issue with Tv's turning on while using remote

This commit is contained in:
watsonb8
2019-07-26 15:44:26 -04:00
parent 7638644935
commit 04024d565d
3 changed files with 16 additions and 10 deletions

View File

@ -72,8 +72,8 @@ export class ControlUnit implements IAccessory {
Api = props.api;
Service = props.api.hap.Service;
Characteristic = props.api.hap.Characteristic;
this.displayName = props.displayName;
this.name = this.displayName;
this.name = props.displayName;
this.displayName = props.isExternal ? `${props.displayName}-Remote` : props.displayName;
this.isExternal = props.isExternal;
this.activities = props.activities;
@ -81,7 +81,7 @@ export class ControlUnit implements IAccessory {
this.dataProvider = props.dataProvider;
homebridge = props.homebridge;
this.platformAccessory = new homebridge.platformAccessory(this.name, this.generateUUID(), homebridge.hap.Accessory.Categories.TELEVISION);
this.platformAccessory = new homebridge.platformAccessory(this.displayName, this.generateUUID(), homebridge.hap.Accessory.Categories.TELEVISION);
//Configure services
this.configureTvService();
@ -166,6 +166,14 @@ export class ControlUnit implements IAccessory {
* Event handler for SET remote key
*/
private onSetRemoteKey = async (key: any) => {
//Set the active identifier with every key press
let currentActivity: Activity = this.dataProvider.getIsActive(this.name)!;
let identifier: number = 0;
if (currentActivity) {
identifier = this.activities.findIndex(e => e.displayName === currentActivity.displayName);
}
this.televisionService!.setCharacteristic(Characteristic.ActiveIdentifier, identifier);
this.dataProvider.sendKeyPress(this.name, key);
}
@ -173,7 +181,9 @@ export class ControlUnit implements IAccessory {
* Event handler for SET active identifier characteristic
*/
private onSetActiveIdentifier = async (identifier: any) => {
this.dataProvider.startActivity(this.name, this.activities[identifier]);
if (!this.isExternal) {
this.dataProvider.startActivity(this.name, this.activities[identifier]);
}
}
/**