mirror of
https://github.com/danieldemus/openhab-addons
synced 2026-07-31 13:34:22 +02:00
[homematic] Fix HM-IP long press button handling (#18570)
When starting a long press right after a short press, the short press wrongly was emitted twice. Reported in the forum: https://community.openhab.org/t/homematic-ip-wired-virtual-datapoints-of-buttons-long-press-fires-short-pressed-command/163673 Signed-off-by: Danny Baumann <dannybaumann@web.de>
This commit is contained in:
+3
-3
@@ -80,10 +80,10 @@ public class ButtonVirtualDatapointHandler extends AbstractVirtualDatapointHandl
|
|||||||
}
|
}
|
||||||
case "LONG":
|
case "LONG":
|
||||||
if (usesLongStart) {
|
if (usesLongStart) {
|
||||||
// HM-IP devices do long press repetitions via LONG instead of CONT events,
|
// HM-IP devices do long press repetitions via LONG instead of CONT events;
|
||||||
// so clear previous value to force re-triggering of event
|
// besides that the logic is the same as in the CONT handling below
|
||||||
|
vdp.setValue(null);
|
||||||
if (isLongPressActive) {
|
if (isLongPressActive) {
|
||||||
vdp.setValue(null);
|
|
||||||
vdp.setValue(LONG_REPEATED_EVENT);
|
vdp.setValue(LONG_REPEATED_EVENT);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+12
@@ -80,6 +80,12 @@ public class ButtonDatapointTest extends JavaTest {
|
|||||||
HmDatapoint releaseDp = createPressDatapointFrom(longPressDp, "PRESS_LONG_RELEASE", Boolean.TRUE);
|
HmDatapoint releaseDp = createPressDatapointFrom(longPressDp, "PRESS_LONG_RELEASE", Boolean.TRUE);
|
||||||
mockEventReceiver.eventReceived(releaseDp);
|
mockEventReceiver.eventReceived(releaseDp);
|
||||||
assertThat(buttonVirtualDatapoint.getValue(), is("LONG_RELEASED"));
|
assertThat(buttonVirtualDatapoint.getValue(), is("LONG_RELEASED"));
|
||||||
|
|
||||||
|
// A CONT event right after a SHORT event should not trigger another SHORT_PRESSED event
|
||||||
|
HmDatapoint shortPressDp = createPressDatapointFrom(longPressDp, "PRESS_SHORT", Boolean.TRUE);
|
||||||
|
mockEventReceiver.eventReceived(shortPressDp);
|
||||||
|
mockEventReceiver.eventReceived(contPressDp);
|
||||||
|
assertThat(buttonVirtualDatapoint.getValue(), nullValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -98,6 +104,12 @@ public class ButtonDatapointTest extends JavaTest {
|
|||||||
HmDatapoint releaseDp = createPressDatapointFrom(longPressDp, "PRESS_LONG_RELEASE", Boolean.TRUE);
|
HmDatapoint releaseDp = createPressDatapointFrom(longPressDp, "PRESS_LONG_RELEASE", Boolean.TRUE);
|
||||||
mockEventReceiver.eventReceived(releaseDp);
|
mockEventReceiver.eventReceived(releaseDp);
|
||||||
assertThat(buttonVirtualDatapoint.getValue(), is("LONG_RELEASED"));
|
assertThat(buttonVirtualDatapoint.getValue(), is("LONG_RELEASED"));
|
||||||
|
|
||||||
|
// A LONG event right after a SHORT event should not trigger another SHORT_PRESSED event
|
||||||
|
HmDatapoint shortPressDp = createPressDatapointFrom(longPressDp, "PRESS_SHORT", Boolean.TRUE);
|
||||||
|
mockEventReceiver.eventReceived(shortPressDp);
|
||||||
|
mockEventReceiver.eventReceived(contPressDp);
|
||||||
|
assertThat(buttonVirtualDatapoint.getValue(), nullValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user