Modifying to publish new external accessory to fix remote problem (untested)

This commit is contained in:
watsonb8
2019-07-26 13:07:50 -04:00
parent f0eb57e4dc
commit 7638644935
2 changed files with 32 additions and 9 deletions

View File

@@ -35,6 +35,7 @@ export interface IControlUnitProps {
api: any,
log: any,
homebridge: any,
isExternal: boolean,
}
/**
@@ -47,6 +48,7 @@ export class ControlUnit implements IAccessory {
//fields
private log: any = {};
private displayName: string = "";
private isExternal: boolean = false;
//Service fields
private televisionService: HAPNodeJS.Service | undefined;
@@ -72,6 +74,7 @@ export class ControlUnit implements IAccessory {
Characteristic = props.api.hap.Characteristic;
this.displayName = props.displayName;
this.name = this.displayName;
this.isExternal = props.isExternal;
this.activities = props.activities;
@@ -142,10 +145,12 @@ export class ControlUnit implements IAccessory {
* Event handler for SET active characteristic
*/
private onSetAccessoryActive = async (value: any) => {
switch (value) {
case 0: this.dataProvider.powerOff(this.name); break;
//Turn on with first activity
case 1: this.dataProvider.powerOn(this.name, this.activities[0]); break;
if (!this.isExternal) {
switch (value) {
case 0: this.dataProvider.powerOff(this.name); break;
//Turn on with first activity
case 1: this.dataProvider.powerOn(this.name, this.activities[0]); break;
}
}
}
@@ -154,7 +159,7 @@ export class ControlUnit implements IAccessory {
*/
private onGetAccessoryActive = async () => {
//@ts-ignore
return this.dataProvider.getIsActive ? Characteristic.Active.Active : Characteristic.Active.Inactive
return this.dataProvider.getIsActive() ? Characteristic.Active.Active : Characteristic.Active.Inactive
}
/**