Skip to content

Commit

Permalink
[http] Fix duplicate commands on PlayerItemConverter (openhab#9981)
Browse files Browse the repository at this point in the history
Fixes openhab#9957

Signed-off-by: Jan N. Klug <[email protected]>
  • Loading branch information
J-N-K authored Jan 29, 2021
1 parent 2127ac2 commit 8494a0e
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
@NonNullByDefault
public class PlayerItemConverter extends AbstractTransformingItemConverter {
private final HttpChannelConfig channelConfig;
private @Nullable String lastCommand; // store last command to prevent duplicate commands

public PlayerItemConverter(Consumer<State> updateState, Consumer<Command> postCommand,
@Nullable Consumer<String> sendHttpValue, ValueTransformation stateTransformations,
Expand All @@ -55,6 +56,12 @@ public String toString(Command command) {

@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)) {
Expand Down

0 comments on commit 8494a0e

Please sign in to comment.