From 8494a0e3babe77cd388116cb8779c857fc79fe00 Mon Sep 17 00:00:00 2001 From: J-N-K Date: Fri, 29 Jan 2021 09:59:20 +0100 Subject: [PATCH] [http] Fix duplicate commands on PlayerItemConverter (#9981) Fixes #9957 Signed-off-by: Jan N. Klug --- .../http/internal/converter/PlayerItemConverter.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bundles/org.openhab.binding.http/src/main/java/org/openhab/binding/http/internal/converter/PlayerItemConverter.java b/bundles/org.openhab.binding.http/src/main/java/org/openhab/binding/http/internal/converter/PlayerItemConverter.java index 6ef676257..eb2ad57b3 100644 --- a/bundles/org.openhab.binding.http/src/main/java/org/openhab/binding/http/internal/converter/PlayerItemConverter.java +++ b/bundles/org.openhab.binding.http/src/main/java/org/openhab/binding/http/internal/converter/PlayerItemConverter.java @@ -35,6 +35,7 @@ import org.openhab.core.types.UnDefType; @NonNullByDefault public class PlayerItemConverter extends AbstractTransformingItemConverter { private final HttpChannelConfig channelConfig; + private @Nullable String lastCommand; // store last command to prevent duplicate commands public PlayerItemConverter(Consumer updateState, Consumer postCommand, @Nullable Consumer sendHttpValue, ValueTransformation stateTransformations, @@ -55,6 +56,12 @@ public class PlayerItemConverter extends AbstractTransformingItemConverter { @Override protected @Nullable Command toCommand(String string) { + if (string.equals(lastCommand)) { + // only send commands once + return null; + } + lastCommand = string; + if (string.equals(channelConfig.playValue)) { return PlayPauseType.PLAY; } else if (string.equals(channelConfig.pauseValue)) {