External devices (remote control support) building blocks added.
This commit is contained in:
35
src/index.ts
35
src/index.ts
@@ -4,7 +4,12 @@ import { DeviceSetupItem } from "./Models/DeviceSetupItem";
|
||||
import { Input, Output, Matrix } from "./Models/Matrix";
|
||||
import HarmonyDataProvider from "./DataProviders/HarmonyDataProvider";
|
||||
|
||||
let Accessory: any;
|
||||
let Homebridge: any;
|
||||
|
||||
export default function (homebridge: any) {
|
||||
Homebridge = homebridge;
|
||||
Accessory = homebridge.platformAccessory;
|
||||
homebridge.registerPlatform(
|
||||
'homebridge-harmony-watson',
|
||||
'HarmonyHubMatrix',
|
||||
@@ -17,12 +22,23 @@ class HarmonyMatrixPlatform {
|
||||
log: any = {};
|
||||
config: any = {};
|
||||
api: any;
|
||||
externalAccessories: Array<any> = [];
|
||||
|
||||
constructor(log: any, config: any, api: any) {
|
||||
this.log = log;
|
||||
this.config = config;
|
||||
this.api = api;
|
||||
this.log('INFO - Registering Harmony Matrix Platform');
|
||||
this.api.on('didFinishLaunching', this.didFinishLaunching.bind(this));
|
||||
}
|
||||
|
||||
didFinishLaunching() {
|
||||
this.log(`Publishing external accessories`);
|
||||
|
||||
this.externalAccessories.forEach((accessory: ControlUnit) => {
|
||||
this.api.publishExternalAccessories("HarmonyMatrixPlatform", [accessory.platformAccessory]);
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,7 +91,7 @@ class HarmonyMatrixPlatform {
|
||||
let dataProvider = new HarmonyDataProvider({
|
||||
hubAddress: hubIp,
|
||||
matrix: matrix,
|
||||
log: this.log,
|
||||
log: this.log
|
||||
});
|
||||
|
||||
//Parse control units
|
||||
@@ -110,16 +126,27 @@ class HarmonyMatrixPlatform {
|
||||
this.log(`INFO - Added activity '${configActivity["DisplayName"]}'`);
|
||||
});
|
||||
|
||||
//Add control unit
|
||||
controlUnits.push(new ControlUnit({
|
||||
// let accessory = new Accessory(configControlUnit["DisplayName"],
|
||||
// Homebridge.hap.uuid.generate(configControlUnit["DisplayName"], Homebridge.hap.Accessory.Categories.TELEVISION));
|
||||
|
||||
let controlUnit: ControlUnit = new ControlUnit({
|
||||
dataProvider: dataProvider,
|
||||
displayName: configControlUnit["DisplayName"],
|
||||
api: this.api,
|
||||
log: this.log,
|
||||
activities: activities,
|
||||
}));
|
||||
homebridge: Homebridge
|
||||
});
|
||||
|
||||
//@ts-ignore
|
||||
let accessory = controlUnit as homebridge.platformAccessory;
|
||||
|
||||
//Add control unit
|
||||
controlUnits.push(accessory);
|
||||
|
||||
this.log(`INFO - Added ControlUnit`);
|
||||
});
|
||||
this.externalAccessories = controlUnits;
|
||||
callback(controlUnits);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user