From 8a4b87e04e96c008882585a9adf26e9ffd270d54 Mon Sep 17 00:00:00 2001 From: Stefan Roellin Date: Wed, 17 Feb 2021 21:06:34 +0100 Subject: [PATCH] [mpd] fix invalid volume (#10166) Fixes #10142. Signed-off-by: Stefan Roellin Also-by: Jan N. Klug --- .../openhab/binding/mpd/internal/handler/MPDHandler.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.mpd/src/main/java/org/openhab/binding/mpd/internal/handler/MPDHandler.java b/bundles/org.openhab.binding.mpd/src/main/java/org/openhab/binding/mpd/internal/handler/MPDHandler.java index eecdf8eb2ff..21ddbf2fcae 100644 --- a/bundles/org.openhab.binding.mpd/src/main/java/org/openhab/binding/mpd/internal/handler/MPDHandler.java +++ b/bundles/org.openhab.binding.mpd/src/main/java/org/openhab/binding/mpd/internal/handler/MPDHandler.java @@ -254,7 +254,11 @@ public class MPDHandler extends BaseThingHandler implements MPDEventListener { @Override public void updateMPDStatus(MPDStatus status) { volume = status.getVolume(); - updateChannel(CHANNEL_VOLUME, new PercentType(status.getVolume())); + if (volume < 0 || volume > 100) { + updateChannel(CHANNEL_VOLUME, UnDefType.UNDEF); + } else { + updateChannel(CHANNEL_VOLUME, new PercentType(volume)); + } State newControlState = UnDefType.UNDEF; switch (status.getState()) {