Progress commit

This commit is contained in:
watsonb8
2020-01-23 08:44:11 -05:00
parent e9693435ce
commit 5ddd1e1af0
9 changed files with 195 additions and 95 deletions

View File

@ -48,6 +48,15 @@ export class DeviceButton implements IAccessory {
this._buttonState = false;
if (this._buttonInfo.NumberOfKeyPresses && this._buttonInfo.IsStateful) {
throw new Error("A button cannot be stateful and be pressed more than once");
}
//Assign default number of key presses
if (!this._buttonInfo.NumberOfKeyPresses) {
this._buttonInfo.NumberOfKeyPresses = 1;
}
this.platformAccessory = new this._homebridge.platformAccessory(this.name, this.generateUUID(), this._homebridge.hap.Accessory.Categories.SWITCH);
//@ts-ignore
@ -106,11 +115,13 @@ export class DeviceButton implements IAccessory {
this._buttonState = newState
await this._dataProvider.sendCommand(this._deviceCommand);
} else if (!this._buttonInfo.IsStateful) {
await this._dataProvider.sendCommand(this._deviceCommand);
//Send the number of configured key presses
for (let i = 0; i < this._buttonInfo.NumberOfKeyPresses; i++) {
await this._dataProvider.sendCommand(this._deviceCommand);
}
this._switchService.getCharacteristic(Characteristic.On).updateValue(false);
return callback(new Error("Normal Response"));
}
}
return callback();
}