Added missing logic
This commit is contained in:
parent
a8fddae8c5
commit
e9693435ce
@ -86,8 +86,8 @@ export class DeviceButton implements IAccessory {
|
|||||||
* Handler for switch set event
|
* Handler for switch set event
|
||||||
* @param callback The callback function to call when complete
|
* @param callback The callback function to call when complete
|
||||||
*/
|
*/
|
||||||
private onSwitchSet = async (activeState: boolean, callback: (error?: Error | null | undefined) => void) => {
|
private onSwitchSet = async (newState: boolean, callback: (error?: Error | null | undefined) => void) => {
|
||||||
if (!this._buttonInfo.IsStateful && activeState === this._buttonState) {
|
if (!this._buttonInfo.IsStateful && newState === this._buttonState) {
|
||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,12 +101,12 @@ export class DeviceButton implements IAccessory {
|
|||||||
|
|
||||||
//Execute command
|
//Execute command
|
||||||
if (this._deviceCommand) {
|
if (this._deviceCommand) {
|
||||||
await this._dataProvider.sendCommand(this._deviceCommand);
|
|
||||||
|
|
||||||
//change state if stateful
|
//change state if stateful
|
||||||
if (this._buttonInfo.IsStateful && this._buttonState != activeState) {
|
if (this._buttonInfo.IsStateful && this._buttonState != newState) {
|
||||||
this._buttonState = activeState
|
this._buttonState = newState
|
||||||
} else {
|
await this._dataProvider.sendCommand(this._deviceCommand);
|
||||||
|
} else if (!this._buttonInfo.IsStateful) {
|
||||||
|
await this._dataProvider.sendCommand(this._deviceCommand);
|
||||||
this._switchService.getCharacteristic(Characteristic.On).updateValue(false);
|
this._switchService.getCharacteristic(Characteristic.On).updateValue(false);
|
||||||
return callback(new Error("Normal Response"));
|
return callback(new Error("Normal Response"));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user