diff --git a/src/DataProviders/HarmonyDataProvider.ts b/src/DataProviders/HarmonyDataProvider.ts index 66db933..75b1012 100644 --- a/src/DataProviders/HarmonyDataProvider.ts +++ b/src/DataProviders/HarmonyDataProvider.ts @@ -2,6 +2,7 @@ import { Activity } from "../Models/Activity"; import { DeviceSetupItem } from "../Models/DeviceSetupItem"; import { Input, Matrix, Output } from "../Models/Matrix"; import { RemoteKey } from '../Accessories/ControlUnit'; +import { sleep } from '../Util/Sleep'; let Characteristic: HAPNodeJS.Characteristic; @@ -122,8 +123,8 @@ class HarmonyDataProvider { activity.deviceSetupItems.map(async (value: DeviceSetupItem) => { let device: IDevice = this.getDeviceFromName(value.deviceName); - if (device && device.supportsCommand(`Input${value.input}`)) { - let command: string = device.getCommand(`Input${value.input}`); + if (device && device.supportsCommand(`Input ${value.input}`)) { + let command: string = device.getCommand(`Input ${value.input}`); await this.sendCommand(command); } }) @@ -389,8 +390,11 @@ class HarmonyDataProvider { */ private sendCommand = async (command: string) => { try { + //Execute command let response = await this.harmony.sendCommand(JSON.stringify(command)); - // this.log(`Sent command: ${JSON.stringify(command)} response: ${JSON.stringify(response)}`); + + //Sleep + await sleep(800); } catch (err) { this.log(`ERROR - error sending command to harmony: ${err}`); } diff --git a/src/Util/Sleep.ts b/src/Util/Sleep.ts new file mode 100644 index 0000000..9721cc4 --- /dev/null +++ b/src/Util/Sleep.ts @@ -0,0 +1,3 @@ +export function sleep(ms: number) { + return new Promise(resolve => setTimeout(resolve, ms)); +} \ No newline at end of file