Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
e9693435ce | |||
a8fddae8c5 | |||
3759d91d1f |
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "homebridge-harmony-control",
|
||||
"version": "1.0.4",
|
||||
"version": "1.0.5",
|
||||
"description": "Homebridge platform to control smart home equipment by room.",
|
||||
"main": "bin/index.js",
|
||||
"scripts": {
|
||||
|
@ -86,8 +86,8 @@ export class DeviceButton implements IAccessory {
|
||||
* Handler for switch set event
|
||||
* @param callback The callback function to call when complete
|
||||
*/
|
||||
private onSwitchSet = async (activeState: boolean, callback: (error?: Error | null | undefined) => void) => {
|
||||
if (!this._buttonInfo.IsStateful && activeState === this._buttonState) {
|
||||
private onSwitchSet = async (newState: boolean, callback: (error?: Error | null | undefined) => void) => {
|
||||
if (!this._buttonInfo.IsStateful && newState === this._buttonState) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
@ -101,12 +101,12 @@ export class DeviceButton implements IAccessory {
|
||||
|
||||
//Execute command
|
||||
if (this._deviceCommand) {
|
||||
await this._dataProvider.sendCommand(this._deviceCommand);
|
||||
|
||||
//change state if stateful
|
||||
if (this._buttonInfo.IsStateful) {
|
||||
this._buttonState = !this._buttonState
|
||||
} else {
|
||||
if (this._buttonInfo.IsStateful && this._buttonState != newState) {
|
||||
this._buttonState = newState
|
||||
await this._dataProvider.sendCommand(this._deviceCommand);
|
||||
} else if (!this._buttonInfo.IsStateful) {
|
||||
await this._dataProvider.sendCommand(this._deviceCommand);
|
||||
this._switchService.getCharacteristic(Characteristic.On).updateValue(false);
|
||||
return callback(new Error("Normal Response"));
|
||||
}
|
||||
|
Reference in New Issue
Block a user