diff --git a/src/Accessories/DeviceButton.ts b/src/Accessories/DeviceButton.ts index 9ed159f..cf02bf4 100644 --- a/src/Accessories/DeviceButton.ts +++ b/src/Accessories/DeviceButton.ts @@ -75,23 +75,28 @@ export class DeviceButton { } //Execute command - if (this._device) { - //change state if stateful - if (this._deviceInfo.IsStateful && this._buttonState != newState) { - this._buttonState = newState; - await this._device.sendCommand(this._deviceInfo.ButtonName); - } else if (!this._deviceInfo.IsStateful) { - //Send the number of configured key presses - for (let i = 0; i < this._deviceInfo.NumberOfKeyPresses; i++) { - await this._device.sendCommand(this._deviceInfo.ButtonName); - } - this._switchService - .getCharacteristic(this._platform.Characteristic.On) - .updateValue(false); - return callback(new Error("Normal Response")); - } + if (!this._device) { + return callback(); + } + + //change state if stateful + if (this._deviceInfo.IsStateful && this._buttonState != newState) { + this._buttonState = newState; + await this._device.sendCommand(this._deviceInfo.ButtonName); + return callback(); + } else if (!this._deviceInfo.IsStateful) { + //Send the number of configured key presses + for (let i = 0; i < this._deviceInfo.NumberOfKeyPresses; i++) { + await this._device.sendCommand(this._deviceInfo.ButtonName); + } + + this._switchService + .getCharacteristic(this._platform.Characteristic.On) + .updateValue(false); + + this._buttonState = false; + return callback(); } - return callback(); }; /**