diff --git a/CHANGED b/CHANGED index af5574d7d..4e05a06d9 100644 --- a/CHANGED +++ b/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - feature: 37_Spotify: resume on target - feature: 93_DbRep: V5.1.0, create dumps of MySQL on client- or serverside, column UNIT is added to the result of fetchrows-command - feature: ESPEasy: command reference revised diff --git a/FHEM/37_Spotify.pm b/FHEM/37_Spotify.pm index 1b708b008..e498014d7 100644 --- a/FHEM/37_Spotify.pm +++ b/FHEM/37_Spotify.pm @@ -105,7 +105,7 @@ sub Spotify_Set($$@) { return Spotify_update($hash, 1) if($cmd eq 'update'); return Spotify_pausePlayback($hash) if($cmd eq 'pause'); - return Spotify_resumePlayback($hash) if($cmd eq 'resume'); + return Spotify_resumePlayback($hash, @args > 0 ? join(' ', @args) : undef) if($cmd eq 'resume'); return Spotify_setVolume($hash, 1, $args[0], defined $args[1] ? join(' ', @args[1..$#args]) : undef) if ($cmd eq 'volume'); return Spotify_skipToNext($hash) if ($cmd eq 'skipToNext' || $cmd eq 'skip' || $cmd eq 'next'); return Spotify_skipToPrevious($hash) if ($cmd eq 'skipToPrevious' || $cmd eq 'previous' || $cmd eq 'prev'); @@ -330,12 +330,13 @@ sub Spotify_pausePlayback($) { # pause playback return undef; } -sub Spotify_resumePlayback($) { # resume playback - my ($hash) = @_; +sub Spotify_resumePlayback($$) { # resume playback + my ($hash, $device_id) = @_; my $name = $hash->{NAME}; + $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', undef, 'PUT', 0); + Spotify_apiRequest($hash, 'me/player/play' . (defined $device_id ? "?device_id=$device_id" : ''), undef, 'PUT', 0); Log3 $name, 4, "$name: resume"; return undef; } @@ -623,7 +624,7 @@ sub Spotify_togglePlayback($) { # toggle playback (pause if active, resume other if($hash->{helper}{is_playing}) { Spotify_pausePlayback($hash); } else { - Spotify_resumePlayback($hash); + Spotify_resumePlayback($hash, undef); } return undef; @@ -1049,8 +1050,8 @@ sub Spotify_isDisabled($) { sets the repeat mode: either one, all (meaning playlist or album) or off