From cbfcb76c2156e744901833b3fe5e8f9d579b9be5 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 4 Nov 2018 01:35:33 +0100 Subject: [PATCH] volup/voldown fix for mpd plugin --- platypush/plugins/music/mpd/__init__.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/platypush/plugins/music/mpd/__init__.py b/platypush/plugins/music/mpd/__init__.py index afa1ecf1..44b791b3 100644 --- a/platypush/plugins/music/mpd/__init__.py +++ b/platypush/plugins/music/mpd/__init__.py @@ -151,9 +151,8 @@ class MusicMpdPlugin(MusicPlugin): """ volume = int(self.status().output['volume']) - new_volume = volume+delta - if new_volume <= 100: - self.setvol(str(new_volume)) + new_volume = min(volume+delta, 100) + self.setvol(str(new_volume)) return self.status() @action @@ -166,9 +165,8 @@ class MusicMpdPlugin(MusicPlugin): """ volume = int(self.status().output['volume']) - new_volume = volume-delta - if new_volume >= 0: - self.setvol(str(new_volume)) + new_volume = max(volume-delta, 0) + self.setvol(str(new_volume)) return self.status() @action