diff --git a/fhem/FHEM/37_Spotify.pm b/fhem/FHEM/37_Spotify.pm index 2fa0d2f1a..ea7efe24f 100644 --- a/fhem/FHEM/37_Spotify.pm +++ b/fhem/FHEM/37_Spotify.pm @@ -327,7 +327,7 @@ sub Spotify_pausePlayback($) { # pause playback my $name = $hash->{NAME}; $hash->{helper}{is_playing} = 0; readingsSingleUpdate($hash, 'is_playing', 0, 1); - Spotify_apiRequest($hash, 'me/player/pause', undef, 'PUT', 0); + Spotify_apiRequest($hash, 'me/player/pause', {}, 'PUT', 0); Log3 $name, 4, "$name: pause"; return undef; } @@ -338,7 +338,7 @@ sub Spotify_resumePlayback($$) { # resume playback $device_id = Spotify_getTargetDeviceID($hash, $device_id, 0); # resolve target device id $hash->{helper}{is_playing} = 1; readingsSingleUpdate($hash, 'is_playing', 1, 1); - Spotify_apiRequest($hash, 'me/player/play' . (defined $device_id ? "?device_id=$device_id" : ''), undef, 'PUT', 0); + Spotify_apiRequest($hash, 'me/player/play' . (defined $device_id ? "?device_id=$device_id" : ''), {}, 'PUT', 0); Log3 $name, 4, "$name: resume"; return undef; } @@ -357,7 +357,7 @@ sub Spotify_setVolume($$$$) { # set the volume delete $hash->{helper}{fading} if($blocking && defined $hash->{helper}{fading}); # stop volumeFade if currently active (override) $device_id = Spotify_getTargetDeviceID($hash, $device_id, 0); # resolve target device id - Spotify_apiRequest($hash, "me/player/volume?volume_percent=$volume". (defined $device_id ? "&device_id=$device_id" : ''), undef, 'PUT', $blocking); + Spotify_apiRequest($hash, "me/player/volume?volume_percent=$volume". (defined $device_id ? "&device_id=$device_id" : ''), {}, 'PUT', $blocking); Log3 $name, 4, "$name: volume $volume" if(!defined $hash->{helper}{fading}); return undef; } @@ -365,7 +365,7 @@ sub Spotify_setVolume($$$$) { # set the volume sub Spotify_skipToNext($) { # skip to next track my ($hash) = @_; my $name = $hash->{NAME}; - Spotify_apiRequest($hash, 'me/player/next', undef, 'POST', 0); + Spotify_apiRequest($hash, 'me/player/next', encode_json {}, 'POST', 0); Log3 $name, 4, "$name: skipToNext"; return undef; } @@ -373,7 +373,7 @@ sub Spotify_skipToNext($) { # skip to next track sub Spotify_skipToPrevious($) { # skip to previous track my ($hash) = @_; my $name = $hash->{NAME}; - Spotify_apiRequest($hash, 'me/player/previous', undef, 'POST', 0); + Spotify_apiRequest($hash, 'me/player/previous', encode_json {}, 'POST', 0); Log3 $name, 4, "$name: skipToPrevious"; return undef; } @@ -384,7 +384,7 @@ sub Spotify_seekToPosition($$) { # seek to position in track my (undef, $minutes, $seconds) = $position =~ m/(([0-9]+):)?([0-9]+)/; return 'wrong syntax: set seekToPosition ' if(!defined $minutes && !defined $seconds); $position = ($minutes * 60 + $seconds) * 1000; - Spotify_apiRequest($hash, "me/player/seek?position_ms=$position", undef, 'PUT', 0); + Spotify_apiRequest($hash, "me/player/seek?position_ms=$position", {}, 'PUT', 0); return undef; } @@ -395,7 +395,7 @@ sub Spotify_setRepeat($$) { # set the repeat mode $mode = 'track' if($mode eq 'one'); $mode = 'context' if($mode eq 'all'); my $device_id = Spotify_getTargetDeviceID($hash, undef, 0); - Spotify_apiRequest($hash, "me/player/repeat?state=$mode". (defined $device_id ? "&device_id=$device_id" : ""), undef, 'PUT', 0); + Spotify_apiRequest($hash, "me/player/repeat?state=$mode". (defined $device_id ? "&device_id=$device_id" : ""), {}, 'PUT', 0); Log3 $name, 4, "$name: repeat $mode"; return undef; } @@ -406,7 +406,7 @@ sub Spotify_setShuffle($$) { # set the shuffle mode return 'wrong syntax: set shuffle ' if(!defined $mode || ($mode ne 'on' && $mode ne 'off')); $mode = $mode eq 'on' ? 'true' : 'false'; my $device_id = Spotify_getTargetDeviceID($hash, undef, 0); - Spotify_apiRequest($hash, "me/player/shuffle?state=$mode". (defined $device_id ? "&device_id=$device_id" : ""), undef, 'PUT', 0); + Spotify_apiRequest($hash, "me/player/shuffle?state=$mode". (defined $device_id ? "&device_id=$device_id" : ""), {}, 'PUT', 0); Log3 $name, 4, "$name: shuffle $mode"; return undef; } @@ -668,12 +668,12 @@ sub Spotify_volumeStep($$$$) { my @devices = @{$hash->{helper}{devices}}; foreach my $device (@devices) { if(defined $device->{id} && $device->{id} eq $device_id) { - $nextVolume = min(100, max(0, $device->{volume_percent} + $step * $direction)); + $nextVolume = $device->{volume_percent} + $step * $direction; $device->{volume_percent} = $nextVolume; } } } else { - $nextVolume = min(100, max(0, $hash->{helper}{device_active}{volume_percent} + $step * $direction)); + $nextVolume = $hash->{helper}{device_active}{volume_percent} + $step * $direction; $hash->{helper}{device_active}{volume_percent} = $nextVolume; }