From 66752b04f946d42039c9343990fe1847bcd831a6 Mon Sep 17 00:00:00 2001 From: Johann Richard <189003+johannrichard@users.noreply.github.com> Date: Tue, 8 Dec 2020 13:41:03 +0100 Subject: [PATCH] fix(dingz): changes to button action handling - set button values instead of update - only get updated state once button events have been handled --- src/dingzAccessory.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/dingzAccessory.ts b/src/dingzAccessory.ts index 27ace2b..a859dd7 100644 --- a/src/dingzAccessory.ts +++ b/src/dingzAccessory.ts @@ -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(); } } },