Using TS types. Not building
This commit is contained in:
30
src/index.ts
30
src/index.ts
@@ -1,40 +1,39 @@
|
||||
import * as Accessories from "./Accessories";
|
||||
import HarmonyDataProvider from "./DataProviders/HarmonyDataProvider";
|
||||
import * as Config from "./Models/Config";
|
||||
import { IDevice } from "./Models";
|
||||
import { HarmonyDevice } from "./Models/HarmonyDevice";
|
||||
import { HarmonyHub } from "./Models/HarmonyHub";
|
||||
import { API, Logging, StaticPlatformPlugin, AccessoryPlugin } from "homebridge";
|
||||
|
||||
let Accessory: any;
|
||||
let Homebridge: any;
|
||||
let Homebridge: API;
|
||||
|
||||
/**
|
||||
* Main entry.
|
||||
* @param homebridge
|
||||
*/
|
||||
export default function (homebridge: any) {
|
||||
export default function (homebridge: API) {
|
||||
Homebridge = homebridge;
|
||||
Accessory = homebridge.platformAccessory;
|
||||
homebridge.registerPlatform(
|
||||
'homebridge-harmony-watson',
|
||||
'HarmonyHubMatrix',
|
||||
HarmonyMatrixPlatform,
|
||||
true
|
||||
);
|
||||
};
|
||||
|
||||
class HarmonyMatrixPlatform {
|
||||
log: any = {};
|
||||
class HarmonyMatrixPlatform implements StaticPlatformPlugin {
|
||||
log: Logging;
|
||||
config: Config.IConfig;
|
||||
api: any;
|
||||
api: API;
|
||||
dataProvider: HarmonyDataProvider | null;
|
||||
accessoryList: Array<Accessories.IAccessory> = [];
|
||||
accessoryList: Array<AccessoryPlugin> = [];
|
||||
|
||||
constructor(log: any, config: any, api: any) {
|
||||
this.log = log;
|
||||
constructor(logger: Logging, config: any, api: API) {
|
||||
this.log = logger;
|
||||
this.config = config;
|
||||
this.api = api;
|
||||
this.log('INFO - Registering Harmony Matrix Platform');
|
||||
this.log.info('INFO - Registering Harmony Matrix Platform');
|
||||
this.api.on('didFinishLaunching', this.didFinishLaunching.bind(this));
|
||||
|
||||
this.dataProvider = null;
|
||||
@@ -79,7 +78,7 @@ class HarmonyMatrixPlatform {
|
||||
this.log(`Publishing external accessories`);
|
||||
|
||||
//This is required in order to have multiple tv remotes on one platform
|
||||
this.accessoryList.forEach((accessory: Accessories.IAccessory) => {
|
||||
this.accessoryList.forEach((accessory: AccessoryPlugin) => {
|
||||
if (accessory instanceof Accessories.ControlUnit) {
|
||||
this.api.publishExternalAccessories("HarmonyMatrixPlatform", [accessory.platformAccessory]);
|
||||
}
|
||||
@@ -90,7 +89,7 @@ class HarmonyMatrixPlatform {
|
||||
* Called by homebridge to gather accessories.
|
||||
* @param callback
|
||||
*/
|
||||
accessories(callback: (accessories: Array<Accessories.IAccessory>) => void) {
|
||||
accessories(callback: (accessories: Array<AccessoryPlugin>) => void) {
|
||||
|
||||
//Add control units
|
||||
this.config.ControlUnits.forEach((unit: Config.IControlUnit) => {
|
||||
@@ -100,7 +99,6 @@ class HarmonyMatrixPlatform {
|
||||
api: this.api,
|
||||
log: this.log,
|
||||
activities: unit.Activities,
|
||||
homebridge: Homebridge,
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -112,9 +110,7 @@ class HarmonyMatrixPlatform {
|
||||
displayName: button.DisplayName,
|
||||
deviceInfo: button,
|
||||
api: this.api,
|
||||
log: this.log,
|
||||
homebridge: Homebridge,
|
||||
|
||||
log: this.log
|
||||
}))
|
||||
});
|
||||
callback(this.accessoryList);
|
||||
|
||||
Reference in New Issue
Block a user