Fixing stateless device buttons to not error out when pressed
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
bc2208b5cb
commit
1121dbc52c
@ -75,23 +75,28 @@ export class DeviceButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Execute command
|
//Execute command
|
||||||
if (this._device) {
|
if (!this._device) {
|
||||||
//change state if stateful
|
return callback();
|
||||||
if (this._deviceInfo.IsStateful && this._buttonState != newState) {
|
}
|
||||||
this._buttonState = newState;
|
|
||||||
await this._device.sendCommand(this._deviceInfo.ButtonName);
|
//change state if stateful
|
||||||
} else if (!this._deviceInfo.IsStateful) {
|
if (this._deviceInfo.IsStateful && this._buttonState != newState) {
|
||||||
//Send the number of configured key presses
|
this._buttonState = newState;
|
||||||
for (let i = 0; i < this._deviceInfo.NumberOfKeyPresses; i++) {
|
await this._device.sendCommand(this._deviceInfo.ButtonName);
|
||||||
await this._device.sendCommand(this._deviceInfo.ButtonName);
|
return callback();
|
||||||
}
|
} else if (!this._deviceInfo.IsStateful) {
|
||||||
this._switchService
|
//Send the number of configured key presses
|
||||||
.getCharacteristic(this._platform.Characteristic.On)
|
for (let i = 0; i < this._deviceInfo.NumberOfKeyPresses; i++) {
|
||||||
.updateValue(false);
|
await this._device.sendCommand(this._deviceInfo.ButtonName);
|
||||||
return callback(new Error("Normal Response"));
|
}
|
||||||
}
|
|
||||||
|
this._switchService
|
||||||
|
.getCharacteristic(this._platform.Characteristic.On)
|
||||||
|
.updateValue(false);
|
||||||
|
|
||||||
|
this._buttonState = false;
|
||||||
|
return callback();
|
||||||
}
|
}
|
||||||
return callback();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user