Play a random Spotify playlist on Squeezebox

For people coming back to this. As of April 2017, the random filter has been broken in HA. You’ll get a random playlist the first time this runs, but subsequent commands load the same randomly-chosen playlist. Reboot HA and you’ll get a new random choice, but you’re stuck with that choice till you reboot.

@7h30n3 discovered that the problem only seemed to occur with lists. So here’s a work-around that I’ve been using to restore randomness:

data_template:
         media_content_id: >
          {%- set plists = ["spotify:user:ih8gates:playlist:3C4vzY7mOqylGLmGRlPplf", 
            "spotify:user:ih8gates:playlist:32kolpL0K7jto6GQZE2skl", 
            "spotify:user:ih8gates:playlist:0TRYnIGISaQV3l2va1dPCp", 
            "spotify:user:ih8gates:playlist:6PDDqtno9XiHU0YbmysQEp", 
            "spotify:user:ih8gates:playlist:0MHHBF5wsI3zweHaYBp1t8",            
            "spotify:user:ih8gates:playlist:0RFECUW6B7mGZlQPwytJgd",            
            "spotify:user:ih8gates:playlist:7I3IZTkHbX5z5nyIbiQ84P", 
            "spotify:user:ih8gates:playlist:3aVhoe60krjCtm0owZGwu8", 
            "spotify:user:ih8gates:playlist:0EddcASHBaRuWQFnlw852q",            
            "spotify:user:ih8gates:playlist:3v4uykRhSasEaS8ApIM7Sp",
            "spotify:user:ih8gates:playlist:7vPmKlFOMMdY1Uw1ZQNMIn",
            "spotify:user:frankspin:playlist:2Lzb461rpLNb9dVYN3uC7i",
            "spotify:user:spotify:playlist:37i9dQZEVXcSBzBguZEMX8"
            ] -%}
            {% set pindex =  (range(0, (plists | length - 1 ) )|random) -%}
            {{ plists[pindex] }}

Just fill that plists array with the URIs for your playlists.

1 Like