4 Commits
1.0.1 ... 1.0.2

Author SHA1 Message Date
fb260c5532 Bump rev 2019-08-15 16:02:29 -04:00
f903c40f9c Getting rid of externalAccessories.
Rolling back external accessories specifically for remote because this was causing an unpredictable crash. (Likely an unhandled exception within either apple framework or HAPNodeJS
2019-08-13 21:02:40 -04:00
5c69e7b11f Cleaned up unused code. Corrected issue with getActive 2019-08-09 17:25:24 -04:00
a67674b3d3 deploy script now builds 2019-08-09 17:25:03 -04:00
4 changed files with 24 additions and 73 deletions

View File

@ -4,9 +4,10 @@ remote_server="192.168.1.31"
deploy_location="/home/bmw/homebridge-harmony-control"
homebridge_location="/var/lib/homebridge/"
#build
tsc --build
#copy files to remote machine
scp -r bin $remote_user@$remote_server:$deploy_location
scp -r src $remote_user@$remote_server:$deploy_location
scp package.json $remote_user@$remote_server:$deploy_location
#install package

View File

@ -1,6 +1,6 @@
{
"name": "homebridge-harmony-control",
"version": "1.0.0",
"version": "1.0.2",
"description": "Homebridge platform to control smart home equipment by room.",
"main": "bin/index.js",
"scripts": {

View File

@ -35,7 +35,6 @@ export interface IControlUnitProps {
api: any,
log: any,
homebridge: any,
isExternal: boolean,
}
/**
@ -48,7 +47,6 @@ export class ControlUnit implements IAccessory {
//fields
private log: any = {};
private displayName: string = "";
private isExternal: boolean = false;
//Service fields
private televisionService: HAPNodeJS.Service | undefined;
@ -73,8 +71,7 @@ export class ControlUnit implements IAccessory {
Service = props.api.hap.Service;
Characteristic = props.api.hap.Characteristic;
this.name = props.displayName;
this.displayName = props.isExternal ? `${props.displayName}-Remote` : props.displayName;
this.isExternal = props.isExternal;
this.displayName = props.displayName;
this.activities = props.activities;
@ -134,11 +131,10 @@ export class ControlUnit implements IAccessory {
.on("get", callbackify(this.onGetAccessoryActive));
//Set remote characteristics if is external
if (this.isExternal) {
this.televisionService.getCharacteristic(Characteristic.RemoteKey)
//@ts-ignore
.on("set", callbackify(this.onSetRemoteKey));
}
this.televisionService.getCharacteristic(Characteristic.ActiveIdentifier)
//@ts-ignore
@ -151,48 +147,34 @@ export class ControlUnit implements IAccessory {
* Event handler for SET active characteristic
*/
private onSetAccessoryActive = async (value: any) => {
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;
}
}
}
/**
* Event handler for GET active characteristic
*/
private onGetAccessoryActive = async () => {
//@ts-ignore
return this.dataProvider.getIsActive() ? Characteristic.Active.Active : Characteristic.Active.Inactive
return this.dataProvider.getIsActive(this.name) ? Characteristic.Active.Active : Characteristic.Active.Inactive
}
/**
* Event handler for SET remote key
*/
private onSetRemoteKey = async (key: any) => {
if (this.isExternal) {
//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);
}
}
/**
* Event handler for SET active identifier characteristic
*/
private onSetActiveIdentifier = async (identifier: any) => {
if (!this.isExternal) {
this.dataProvider.startActivity(this.name, this.activities[identifier]);
}
}
/**
* Event handler for GET active identifier characteristic
@ -241,29 +223,11 @@ export class ControlUnit implements IAccessory {
* Event handler for SET volume characteristic
*/
private onSetVolumeSelector = async (value: any) => {
if (this.isExternal) {
switch (value) {
case 0: this.dataProvider.volumeUp(this.name); break;
case 1: this.dataProvider.volumeDown(this.name); break;
}
}
}
/*********************
*
* Information Service
*
********************/
/**
* Configure information service
*/
private configureAccessoryInformation(): void {
this.informationService = new Service.AccessoryInformation(this.displayName, 'information');
this.informationService
.setCharacteristic(Characteristic.Manufacturer, 'Loftux Carwings')
.setCharacteristic(Characteristic.Model, 'Heater-Cooler')
}
/*****************
*

View File

@ -26,8 +26,8 @@ class HarmonyMatrixPlatform {
log: any = {};
config: any = {};
api: any;
externalAccessories: Array<any> = [];
dataProvider: HarmonyDataProvider | null;
controlUnits: Array<ControlUnit> = [];
constructor(log: any, config: any, api: any) {
this.log = log;
@ -48,7 +48,7 @@ class HarmonyMatrixPlatform {
this.log(`Publishing external accessories`);
//This is required in order to have multiple tv remotes on one platform
this.externalAccessories.forEach((accessory: ControlUnit) => {
this.controlUnits.forEach((accessory: ControlUnit) => {
this.api.publishExternalAccessories("HarmonyMatrixPlatform", [accessory.platformAccessory]);
})
@ -109,7 +109,7 @@ class HarmonyMatrixPlatform {
//Parse control units
let configControlUnits: any = this.config["ControlUnits"];
let controlUnits: Array<ControlUnit> = [];
configControlUnits.forEach((configControlUnit: any) => {
//Parse activities list
let configActivities: any = configControlUnit["Activities"];
@ -146,31 +146,17 @@ class HarmonyMatrixPlatform {
log: this.log,
activities: activities,
homebridge: Homebridge,
isExternal: false
});
let controlUnitExternal: ControlUnit = new ControlUnit({
dataProvider: this.dataProvider!,
displayName: `${configControlUnit["DisplayName"]}`,
api: this.api,
log: this.log,
activities: activities,
homebridge: Homebridge,
isExternal: true
});
//@ts-ignore
let accessory = controlUnit as homebridge.platformAccessory;
//@ts-ignore
let externalAccessory = controlUnitExternal as homebridge.platformAccessory;
//Add control unit
controlUnits.push(accessory);
//Add to list of remotes
this.externalAccessories.push(externalAccessory);
this.controlUnits.push(accessory);
this.log(`INFO - Added ControlUnit`);
});
callback(controlUnits);
callback(this.controlUnits);
}
}