diff --git a/src/Accessories/ControlUnit.ts b/src/Accessories/ControlUnit.ts index 1bde09d..f12919e 100644 --- a/src/Accessories/ControlUnit.ts +++ b/src/Accessories/ControlUnit.ts @@ -1,5 +1,4 @@ -import { IActivity } from '../Models/Config/IActivity'; -import { IMatrix } from '../Models/Config/IMatrix'; +import * as Config from "../Models/Config" import { IAccessory } from './IAccessory'; import callbackify from '../Util/Callbackify'; import HarmonyDataProvider from '../DataProviders/HarmonyDataProvider'; @@ -31,7 +30,7 @@ export enum RemoteKey { export interface IControlUnitProps { dataProvider: HarmonyDataProvider, displayName: string, - activities: Array, + activities: Array, api: any, log: any, homebridge: any, @@ -55,7 +54,7 @@ export class ControlUnit implements IAccessory { private inputServices: Array = []; //Harmony fields - private activities: Array = []; + private activities: Array = []; private dataProvider: HarmonyDataProvider; public platformAccessory: any; @@ -180,7 +179,7 @@ export class ControlUnit implements IAccessory { * Event handler for GET active identifier characteristic */ private onGetActiveIdentifier = async () => { - let currentActivity: IActivity = this.dataProvider.getIsActive(this.name)!; + let currentActivity: Config.IActivity = this.dataProvider.getIsActive(this.name)!; let identifier: number = 0; if (currentActivity) { identifier = this.activities.findIndex(e => e.DisplayName === currentActivity.DisplayName); @@ -240,7 +239,7 @@ export class ControlUnit implements IAccessory { */ private configureInputSourceService(): void { let inputs: Array = []; - this.activities.forEach((activity: IActivity, index: number) => { + this.activities.forEach((activity: Config.IActivity, index: number) => { let inputService = new Service.InputSource(activity.DisplayName, 'activity' + activity.DisplayName); inputService .setCharacteristic(Characteristic.Identifier, index) diff --git a/src/Accessories/DeviceButton.ts b/src/Accessories/DeviceButton.ts index edb8b8f..ce5f5e0 100644 --- a/src/Accessories/DeviceButton.ts +++ b/src/Accessories/DeviceButton.ts @@ -1,8 +1,7 @@ import HarmonyDataProvider from "../DataProviders/HarmonyDataProvider"; -import { IDeviceButton } from "../Models/Config/IDeviceButton"; +import { IDeviceButton } from "../Models/Config"; import { IAccessory } from "./IAccessory"; -import { sleep } from "../Util/Sleep"; -import { ICommand } from "../Models/IDevice"; +import { ICommand } from "../Models"; let Service: HAPNodeJS.Service; let Characteristic: HAPNodeJS.Characteristic; diff --git a/src/Accessories/index.ts b/src/Accessories/index.ts new file mode 100644 index 0000000..f908585 --- /dev/null +++ b/src/Accessories/index.ts @@ -0,0 +1,3 @@ +export { ControlUnit } from './ControlUnit'; +export { DeviceButton } from './DeviceButton'; +export { IAccessory } from './IAccessory'; \ No newline at end of file diff --git a/src/Models/Config/index.ts b/src/Models/Config/index.ts new file mode 100644 index 0000000..5bd6c00 --- /dev/null +++ b/src/Models/Config/index.ts @@ -0,0 +1,5 @@ +export * from './IActivity'; +export * from './IConfig'; +export * from './IDeviceButton'; +export * from './IDeviceSetupItem'; +export * from './IMatrix'; \ No newline at end of file diff --git a/src/Models/index.ts b/src/Models/index.ts new file mode 100644 index 0000000..a37e649 --- /dev/null +++ b/src/Models/index.ts @@ -0,0 +1 @@ +export * from './IDevice'; \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 188951d..2526c17 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,13 +1,7 @@ -import { ControlUnit } from "./Accessories/ControlUnit"; -import { DeviceButton } from './Accessories/DeviceButton'; -import { IActivity } from "./Models/Config/IActivity"; -import { IDeviceSetupItem } from "./Models/Config/IDeviceSetupItem"; -import { IInput, IOutput, IMatrix } from "./Models/Config/IMatrix"; +import * as Accessories from "./Accessories"; import HarmonyDataProvider from "./DataProviders/HarmonyDataProvider"; -import { IConfig, IControlUnit } from "./Models/Config/IConfig"; -import { IDeviceButton } from "./Models/Config/IDeviceButton"; -import { IAccessory } from "./Accessories/IAccessory"; -import { IDevice, ICommand } from "./Models/IDevice"; +import * as Config from "./Models/Config"; +import { IDevice } from "./Models"; let Accessory: any; let Homebridge: any; @@ -29,10 +23,10 @@ export default function (homebridge: any) { class HarmonyMatrixPlatform { log: any = {}; - config: IConfig; + config: Config.IConfig; api: any; dataProvider: HarmonyDataProvider | null; - accessoryList: Array = []; + accessoryList: Array = []; constructor(log: any, config: any, api: any) { this.log = log; @@ -74,8 +68,8 @@ class HarmonyMatrixPlatform { this.log(`Publishing external accessories`); //This is required in order to have multiple tv remotes on one platform - this.accessoryList.forEach((accessory: IAccessory) => { - if (accessory instanceof ControlUnit) { + this.accessoryList.forEach((accessory: Accessories.IAccessory) => { + if (accessory instanceof Accessories.ControlUnit) { this.api.publishExternalAccessories("HarmonyMatrixPlatform", [accessory.platformAccessory]); } }) @@ -85,11 +79,11 @@ class HarmonyMatrixPlatform { * Called by homebridge to gather accessories. * @param callback */ - accessories(callback: (accessories: Array) => void) { + accessories(callback: (accessories: Array) => void) { //Add control units - this.config.ControlUnits.forEach((unit: IControlUnit) => { - this.accessoryList.push(new ControlUnit({ + this.config.ControlUnits.forEach((unit: Config.IControlUnit) => { + this.accessoryList.push(new Accessories.ControlUnit({ dataProvider: this.dataProvider!, displayName: unit.DisplayName, api: this.api, @@ -100,8 +94,8 @@ class HarmonyMatrixPlatform { }); //Add device buttons - this.config.DeviceButtons.forEach((button: IDeviceButton) => { - this.accessoryList.push(new DeviceButton({ + this.config.DeviceButtons.forEach((button: Config.IDeviceButton) => { + this.accessoryList.push(new Accessories.DeviceButton({ dataProvider: this.dataProvider!, buttonName: button.ButtonName, displayName: button.DisplayName,