Added a delay between commands. Fixed issue where inputs were not being set correctly.
This commit is contained in:
parent
8bb65b5b3c
commit
0ea4188487
@ -2,6 +2,7 @@ import { Activity } from "../Models/Activity";
|
|||||||
import { DeviceSetupItem } from "../Models/DeviceSetupItem";
|
import { DeviceSetupItem } from "../Models/DeviceSetupItem";
|
||||||
import { Input, Matrix, Output } from "../Models/Matrix";
|
import { Input, Matrix, Output } from "../Models/Matrix";
|
||||||
import { RemoteKey } from '../Accessories/ControlUnit';
|
import { RemoteKey } from '../Accessories/ControlUnit';
|
||||||
|
import { sleep } from '../Util/Sleep';
|
||||||
|
|
||||||
let Characteristic: HAPNodeJS.Characteristic;
|
let Characteristic: HAPNodeJS.Characteristic;
|
||||||
|
|
||||||
@ -122,8 +123,8 @@ class HarmonyDataProvider {
|
|||||||
activity.deviceSetupItems.map(async (value: DeviceSetupItem) => {
|
activity.deviceSetupItems.map(async (value: DeviceSetupItem) => {
|
||||||
let device: IDevice = this.getDeviceFromName(value.deviceName);
|
let device: IDevice = this.getDeviceFromName(value.deviceName);
|
||||||
|
|
||||||
if (device && device.supportsCommand(`Input${value.input}`)) {
|
if (device && device.supportsCommand(`Input ${value.input}`)) {
|
||||||
let command: string = device.getCommand(`Input${value.input}`);
|
let command: string = device.getCommand(`Input ${value.input}`);
|
||||||
await this.sendCommand(command);
|
await this.sendCommand(command);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -389,8 +390,11 @@ class HarmonyDataProvider {
|
|||||||
*/
|
*/
|
||||||
private sendCommand = async (command: string) => {
|
private sendCommand = async (command: string) => {
|
||||||
try {
|
try {
|
||||||
|
//Execute command
|
||||||
let response = await this.harmony.sendCommand(JSON.stringify(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) {
|
} catch (err) {
|
||||||
this.log(`ERROR - error sending command to harmony: ${err}`);
|
this.log(`ERROR - error sending command to harmony: ${err}`);
|
||||||
}
|
}
|
||||||
|
3
src/Util/Sleep.ts
Normal file
3
src/Util/Sleep.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export function sleep(ms: number) {
|
||||||
|
return new Promise(resolve => setTimeout(resolve, ms));
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user