diff --git a/fhem/FHEM/37_Spotify.pm b/fhem/FHEM/37_Spotify.pm index 52006ef04..57cf7a8d5 100644 --- a/fhem/FHEM/37_Spotify.pm +++ b/fhem/FHEM/37_Spotify.pm @@ -420,7 +420,7 @@ sub Spotify_playContextByURI($$$$) { # play a context (playlist, album or artist my ($hash, $uri, $position, $device_id) = @_; my $name = $hash->{NAME}; return 'wrong syntax: set playContextByURI [ ] [ ]' if(!defined $uri); - $device_id = $position if(defined $position && $position !~ /^[0-9]+$/ && !defined $device_id); + $device_id = $position . (defined $device_id ? " ". $device_id : "") if(defined $position && $position !~ /^[0-9]+$/); $position = 1 if(!defined $position || $position !~ /^[0-9]+$/); return Spotify_play($hash, undef, $uri, $position, $device_id); @@ -518,7 +518,7 @@ sub Spotify_playSavedTracks($$$) { # play users saved tracks my ($hash, $first, $device_id) = @_; my $name = $hash->{NAME}; - $device_id = $first if($first !~ /^[0-9]+$/); + $device_id = $first . (defined $device_id ? " " . $device_id : "") if(defined $first && $first !~ /^[0-9]+$/); $first = 1 if(!defined $first || !$first !~ /^[0-9]+$/); Spotify_apiRequest($hash, 'me/tracks?limit=50'. ($first > 50 ? '&offset='. int($first/50)-1 : ''), undef, 'GET', 1); # getting saved tracks @@ -542,7 +542,7 @@ sub Spotify_playRandomTrackFromPlaylistByURI($$$$) { # select a random track fro my ($user_id, $playlist_id) = $uri =~ m/user:(.*):playlist:(.*)/; return 'invalid playlist_uri' if(!defined $user_id || !defined $playlist_id); - $device_id = $limit if(!defined $device_id && $limit !~ /^[0-9]+$/); + $device_id = $limit . (defined $device_id ? " " . $device_id : "") if(defined $limit && $limit !~ /^[0-9]+$/); $limit = undef if($limit !~ /^[0-9]+$/); Spotify_apiRequest($hash, "users/$user_id/playlists/$playlist_id/tracks?fields=items(track(name,uri))". (defined $limit ? "&limit=$limit" : ""), undef, 'GET', 1); @@ -585,7 +585,7 @@ sub Spotify_volumeFade($$$$$) { # fade the volume of a device return 'wrong syntax: set volumeFade [ ] [ ]' if(!defined $targetVolume); Spotify_updateDevices($hash, 1); # make sure devices are up to date (a valid start volume is required) - $device_id = $duration if(defined $duration && $duration !~ /^[0-9]+$/); + $device_id = $duration . (defined $device_id ? " " . $device_id : "") if(defined $duration && $duration !~ /^[0-9]+$/); my $startVolume = $hash->{helper}{device_active}{volume_percent}; return 'could not get start volume of active device' if(!defined $startVolume); $step = 5 if(!defined $step); # fall back to default step if not specified @@ -828,7 +828,7 @@ sub Spotify_dispatch($$$) { $hash->{STATE} = 'connected' if(!defined $json->{device}); } - if($json->{is_playing} ne 'false') { + if($hash->{helper}{is_playing}) { if(!defined $hash->{helper}{updatePlaybackTimer_next} || $hash->{helper}{updatePlaybackTimer_next} <= gettimeofday()) { # start refresh timer if not already started my $updateIntervalWhilePlaying = $attr{updateIntervalWhilePlaying}; $updateIntervalWhilePlaying = 10 if(!defined $updateIntervalWhilePlaying); @@ -983,7 +983,7 @@ sub Spotify_isDisabled($) { plays an artist using its name (uses search)
  • - playContextByURI <context_uri> [ <device_id / device_name> ]
    + playContextByURI <context_uri> [ <nr_of_start_track> ] [ <device_id / device_name> ]
    plays a context (playlist, album or artist) using a Spotify URI
  • @@ -991,11 +991,11 @@ sub Spotify_isDisabled($) { plays any playlist by providing a name (uses search)
  • - playRandomTrackFromPlaylistByURI <track_uri> [ <limit> ] [ <device_id> ]
    + playRandomTrackFromPlaylistByURI <track_uri> [ <limit> ] [ <device_id / device_name> ]
    plays a random track from a playlist (only considering the first <limit> songs)
  • - playSavedTracks [ <nr_of_start_track> ] [ <device_id> ]
    + playSavedTracks [ <nr_of_start_track> ] [ <device_id / device_name> ]
    plays the saved tracks (beginning with track <nr_of_start_track>)
  • @@ -1138,7 +1138,7 @@ sub Spotify_isDisabled($) { sucht einen Künstler und spielt dessen Tracks ab
  • - playContextByURI <context_uri> [ <device_id / device_name> ]
    + playContextByURI <context_uri> [ <nr_of_start_track> ] [ <device_id / device_name> ]
    spielt einen Context (Playlist, Album oder Künstler) durch Angabe der URI ab
  • @@ -1146,11 +1146,11 @@ sub Spotify_isDisabled($) { sucht eine Playlist und spielt diese ab
  • - playRandomTrackFromPlaylistByURI <track_uri> [ <limit> ] [ <device_id> ]
    + playRandomTrackFromPlaylistByURI <track_uri> [ <limit> ] [ <device_id / device_name> ]
    spielt einen zufälligen Track aus einer Playlist ab (berücksichtigt nur die ersten <limit> Tracks der Playlist)
  • - playSavedTracks [ <nr_of_start_track> ] [ <device_id> ]
    + playSavedTracks [ <nr_of_start_track> ] [ <device_id / device_name> ]
    spielt die gespeicherten Tracks ab (beginnend mit Track Nummer <nr_of_start_track>)