[mpd] fix invalid volume (#10166)

Fixes #10142.

Signed-off-by: Stefan Roellin <stefan@roellin-baumann.ch>
Also-by: Jan N. Klug <jan.n.klug@rub.de>
This commit is contained in:
Stefan Roellin 2021-02-17 21:06:34 +01:00 committed by GitHub
parent c0cec8028c
commit 8a4b87e04e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()) {