What I currently have is a script that, when called, picks a playlist randomly from a list of playlists (called by name) and plays this playlist on our Sonos.
What I’d like is to extend this so that it cycles through the list of playlists and resets.
So it selects a random playlist from the list of playlists, removes it from that list so that next time it can’t pick it anymore, until the list is empty and then it resets the list to the original contents minus the just selected playlist.
My code thus far is as follows:
In configuration.yaml
input_text:
playlist_chosen_random_source:
name: Playlist Chosen Random Source
initial: Haven't picked a playlist
then test to see which option is selected and create a new options list without the last option used in the list. eventually you will get to the point that you have removed all options and then you can test the list of options again for being 0 and reload the input selects to reset the input select to the original set of options.
I know it sounds kind of confusing. but start here:
and if you need additional help I (or some other smarter person than me ) could try to cobble something together. But since you seem ok with using templates give it a try first to see what you can come up with.
But this already throws a lot of errors :-/
After this I was thinking of doing the check for 1, filter or reset through set_options and the playlist_options_filtered. But again, already stuck.
Also, as an FYI, unless you click the reply button in my post opr you tag me by using @ then my username I don’t see your reply to me unless I check my unread topic list. Which I do less often than if I get a notification.
Some progress but now I’m working on the filtering of the playlist_options_filtered.
So I made an automation that triggers whenever the input_text.playlist_chosen_random_source is changed.
I first check if the playlist_options_filtered (an input_select) is empty, if so, I set its options to playlist_options_full (an input_select)
Otherwise, I’d like to set its options to ( playlist_options_filtered - input_text.playlist_chosen_random_source) but this step is the thing I’m unsure about.
Any chance you could help? This is jinja right? I’ll look into templating a bit more.