Fixed issue with Tv's turning on while using remote
This commit is contained in:
parent
7638644935
commit
04024d565d
@ -72,8 +72,8 @@ export class ControlUnit implements IAccessory {
|
|||||||
Api = props.api;
|
Api = props.api;
|
||||||
Service = props.api.hap.Service;
|
Service = props.api.hap.Service;
|
||||||
Characteristic = props.api.hap.Characteristic;
|
Characteristic = props.api.hap.Characteristic;
|
||||||
this.displayName = props.displayName;
|
this.name = props.displayName;
|
||||||
this.name = this.displayName;
|
this.displayName = props.isExternal ? `${props.displayName}-Remote` : props.displayName;
|
||||||
this.isExternal = props.isExternal;
|
this.isExternal = props.isExternal;
|
||||||
|
|
||||||
this.activities = props.activities;
|
this.activities = props.activities;
|
||||||
@ -81,7 +81,7 @@ export class ControlUnit implements IAccessory {
|
|||||||
this.dataProvider = props.dataProvider;
|
this.dataProvider = props.dataProvider;
|
||||||
homebridge = props.homebridge;
|
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
|
//Configure services
|
||||||
this.configureTvService();
|
this.configureTvService();
|
||||||
@ -166,6 +166,14 @@ export class ControlUnit implements IAccessory {
|
|||||||
* Event handler for SET remote key
|
* Event handler for SET remote key
|
||||||
*/
|
*/
|
||||||
private onSetRemoteKey = async (key: any) => {
|
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);
|
this.dataProvider.sendKeyPress(this.name, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +181,9 @@ export class ControlUnit implements IAccessory {
|
|||||||
* Event handler for SET active identifier characteristic
|
* Event handler for SET active identifier characteristic
|
||||||
*/
|
*/
|
||||||
private onSetActiveIdentifier = async (identifier: any) => {
|
private onSetActiveIdentifier = async (identifier: any) => {
|
||||||
this.dataProvider.startActivity(this.name, this.activities[identifier]);
|
if (!this.isExternal) {
|
||||||
|
this.dataProvider.startActivity(this.name, this.activities[identifier]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -222,11 +222,6 @@ class HarmonyDataProvider {
|
|||||||
if (this.states[controlUnitName]) {
|
if (this.states[controlUnitName]) {
|
||||||
let commandName: string = "";
|
let commandName: string = "";
|
||||||
|
|
||||||
//Ignore commands unless the tv is already on
|
|
||||||
if (!this.states[controlUnitName]!.currentActivity) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let device: IDevice = this.getDeviceFromName(this.states[controlUnitName]!.currentActivity.controlDeviceId);
|
let device: IDevice = this.getDeviceFromName(this.states[controlUnitName]!.currentActivity.controlDeviceId);
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case RemoteKey.ARROW_UP: {
|
case RemoteKey.ARROW_UP: {
|
||||||
|
@ -37,6 +37,7 @@ class HarmonyMatrixPlatform {
|
|||||||
this.api.on('didFinishLaunching', this.didFinishLaunching.bind(this));
|
this.api.on('didFinishLaunching', this.didFinishLaunching.bind(this));
|
||||||
|
|
||||||
this.dataProvider = null;
|
this.dataProvider = null;
|
||||||
|
this.log("This is new");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,7 +151,7 @@ class HarmonyMatrixPlatform {
|
|||||||
|
|
||||||
let controlUnitExternal: ControlUnit = new ControlUnit({
|
let controlUnitExternal: ControlUnit = new ControlUnit({
|
||||||
dataProvider: this.dataProvider!,
|
dataProvider: this.dataProvider!,
|
||||||
displayName: `${configControlUnit["DisplayName"]}-Remote`,
|
displayName: `${configControlUnit["DisplayName"]}`,
|
||||||
api: this.api,
|
api: this.api,
|
||||||
log: this.log,
|
log: this.log,
|
||||||
activities: activities,
|
activities: activities,
|
||||||
|
Loading…
Reference in New Issue
Block a user