A fuller script to do this follows
#
# in the following array SqueezePlayLists
# you must replace any URL Encoding strings by the actual characters they represent
# for exampe %2b is + and %2f is /
#
# the string dplstaticpl_PGPBtJ1Dd6Co5RDdrt9%2F%2FJKp1d8
# has to become dplstaticpl_PGPBtJ1Dd6Co5RDdrt9//JKp1d8
#
lms_dynamic_play:
alias: Lms Dynamic
mode: single
icon: mdi:music
sequence:
- variables:
SqueezePlayLists:
Dinner: 'dplstaticpl_PGPBtJ1Dd6Co5RDdrt9//JKp1d8'
Karen: 'dplstaticpl_xXMhdJQR/Up59ZgBx+j4ypsz55k'
Speaker-Test: 'dplstaticpl_maRsj0ELIYXNTbXiYejkTvghpek'
Guitars: 'dplccustom_guitars'
Heavy: 'dplccustom_heavy'
Long_Songs: 'dplccustom_long_songs'
My_Folk: 'dplccustom_my_folk'
My_Jazz: 'dplccustom_my_jazz'
My_Prog: 'dplccustom_my_prog'
RockSteady: 'dplccustom_rocksteady'
Short_Songs: 'dplccustom_short_songs'
1950s: 'dplccustom_1950s'
1960s: 'dplccustom_1960s'
1970s: 'dplccustom_1970s'
1980s: 'dplccustom_1980s'
'1969': 'dplccustom_1969'
'1975': 'dplccustom_1975'
Item: "{{ SqueezePlayLists[ states('input_select.lmsplaylist_select') ] }}"
- service: squeezebox.call_method
data:
command: dynamicplaylist
# parameters: "{{ ['playlist', 'play', item] }}"
parameters:
- playlist
- play
- "{{ Item }}"
target:
entity_id: media_player.{{ states('input_select.lms_instance') }}
The only way i have found to obtain the DYNAMICPLAYLIST_ID for a static playlists is by moving the mouse pointer over the play link for a static playlist in
Home > Dynamic Playlists > Static Playlists Menu
and by then copying the link and extracting the DYNAMICPLAYLIST_ID from it
note you must replace any URL Encoding strings by the actual characters they represent
for example %2b is + and %2f is /
the DYNAMICPLAYLIST_ID dplstaticpl_PGPBtJ1Dd6Co5RDdrt9%2F%2FJKp1d8
has to become dplstaticpl_PGPBtJ1Dd6Co5RDdrt9//JKp1d8
before you can use this in in any squeezebox_call_method parameters
Update !!!
Having heard from the creator of the LMS DynamicPlayList plugin how the url for static playlists is created
The specific part after dplstaticpl_
is the SHA1 digest of the playlist url as a base64 encoded string. As you have discovered, this ony applies to static playlists. All other dynamic playlists use the filename to create the playlist id
For Example:
Playlist url/path from the LMS database: file:///Users/af1/Music/LMS%20Playlists/Bookmarked%20Tracks.m3u
SHA1 digest of the playlist url as a base64 encoded string: jor13XtXjcbmjwFHTwGGp8xPK1k
Your playlist id for CLI commands: dplstaticpl_jor13XtXjcbmjwFHTwGGp8xPK1k
I have created a little perl script which you can run on your LMS server in the playlists folder, which will generate the correct playlist id for using in scripts
#!/usr/bin/perl
BEGIN {
push ( @INC,"/opt/logitechmediaserver/CPAN");
}
use Digest::SHA1 qw(sha1_base64);
$PLAYLIST = "/home/Playlists";
opendir(D, $PLAYLIST) || die "Can't open directory $PLAYLIST: $!\n";
@list = grep /m3u$/, readdir(D);
closedir(D);
foreach my $f (@list)
{
$string = "file://" . $PLAYLIST . "/" . $f;
my $playlistid = 'dplstaticpl_'.sha1_base64($string);
print "$string - $playlistid\n";
}
Hope it helps others