Progress commit
This commit is contained in:
@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user