Modifying to publish new external accessory to fix remote problem (untested)
This commit is contained in:
26
src/index.ts
26
src/index.ts
@@ -27,6 +27,7 @@ class HarmonyMatrixPlatform {
|
||||
config: any = {};
|
||||
api: any;
|
||||
externalAccessories: Array<any> = [];
|
||||
dataProvider: HarmonyDataProvider | null;
|
||||
|
||||
constructor(log: any, config: any, api: any) {
|
||||
this.log = log;
|
||||
@@ -34,10 +35,13 @@ class HarmonyMatrixPlatform {
|
||||
this.api = api;
|
||||
this.log('INFO - Registering Harmony Matrix Platform');
|
||||
this.api.on('didFinishLaunching', this.didFinishLaunching.bind(this));
|
||||
|
||||
this.dataProvider = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for didFinishLaunching
|
||||
* Happens after constructor
|
||||
*/
|
||||
didFinishLaunching() {
|
||||
this.log(`Publishing external accessories`);
|
||||
@@ -96,7 +100,7 @@ class HarmonyMatrixPlatform {
|
||||
});
|
||||
|
||||
//construct data provider
|
||||
let dataProvider = new HarmonyDataProvider({
|
||||
this.dataProvider = new HarmonyDataProvider({
|
||||
hubAddress: hubIp,
|
||||
matrix: matrix,
|
||||
log: this.log
|
||||
@@ -135,23 +139,37 @@ class HarmonyMatrixPlatform {
|
||||
});
|
||||
|
||||
let controlUnit: ControlUnit = new ControlUnit({
|
||||
dataProvider: dataProvider,
|
||||
dataProvider: this.dataProvider!,
|
||||
displayName: configControlUnit["DisplayName"],
|
||||
api: this.api,
|
||||
log: this.log,
|
||||
activities: activities,
|
||||
homebridge: Homebridge
|
||||
homebridge: Homebridge,
|
||||
isExternal: false
|
||||
});
|
||||
|
||||
let controlUnitExternal: ControlUnit = new ControlUnit({
|
||||
dataProvider: this.dataProvider!,
|
||||
displayName: `${configControlUnit["DisplayName"]}-Remote`,
|
||||
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.log(`INFO - Added ControlUnit`);
|
||||
});
|
||||
this.externalAccessories = controlUnits;
|
||||
callback(controlUnits);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user