Skip to content

Commit

Permalink
fix(dingz): changes to button action handling
Browse files Browse the repository at this point in the history
- set button values instead of update
- only get updated state once button events have been handled
  • Loading branch information
johannrichard committed Dec 8, 2020
1 parent 074b315 commit 66752b0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/dingzAccessory.ts
Expand Up @@ -505,26 +505,26 @@ export class DingzAccessory extends DingzDaBaseAccessory {
`Button ${button} (${service?.displayName}) pressed -> ${action}`,
);

// Immediately update states after button pressed
this.getDeviceStateUpdate();

switch (action) {
case ButtonAction.SINGLE_PRESS:
service
?.getCharacteristic(ProgrammableSwitchEvent)
.updateValue(ProgrammableSwitchEvent.SINGLE_PRESS);
.setValue(ProgrammableSwitchEvent.SINGLE_PRESS);
break;
case ButtonAction.DOUBLE_PRESS:
service
?.getCharacteristic(ProgrammableSwitchEvent)
.updateValue(ProgrammableSwitchEvent.DOUBLE_PRESS);
.setValue(ProgrammableSwitchEvent.DOUBLE_PRESS);
break;
case ButtonAction.LONG_PRESS:
service
?.getCharacteristic(ProgrammableSwitchEvent)
.updateValue(ProgrammableSwitchEvent.LONG_PRESS);
.setValue(ProgrammableSwitchEvent.LONG_PRESS);
break;
}

// Immediately update states after button pressed
this.getDeviceStateUpdate();
}
}
},
Expand Down

0 comments on commit 66752b0

Please sign in to comment.