No bother at all. Lots of people helped me out when I got started (and even still!). I assumed you were a little farther along here. So I’ve eliminated everything but selecting and playing the playlist. You can build it up from here if you need to.
There are a couple parts to this. The select template stores your playlist names, which you will use to select the playlist you want to play in the UI. This needs to go in your config under a template section somewhere (depends on how you set up your configuration). I chose to make it a trigger template so the options will automatically update any time your Spotify playlists change (and only then). You’ll need something to trigger the play script also so I’ve also included a template button here to do that.
Spotify Templates
template:
- trigger:
- platform: state
entity_id: sensor.playlists_sensor
attribute: playlists
to: ~
- platform: state
entity_id: input_text.spotify_playlist
to: ~
- platform: homeassistant
event: start
- platform: event
event_type: event_template_reloaded
select:
- name: 'Spotify Playlist'
state: "{{ states('input_text.spotify_playlist') }}"
select_option:
- condition: template
value_template: '{{ option != none }}'
- service: input_text.set_value
target:
entity_id: input_text.spotify_playlist
data:
value: '{{ option }}'
options: >
{% set plist = namespace(value =[]) %}
{% set playlists = state_attr('sensor.playlists_sensor','playlists') %}
{% if playlists != none %}
{% for item in playlists %}
{% set plist.value = plist.value + [item.name] %}
{% endfor %}
{% endif %}
{{ plist.value }}
- button:
- name: 'Play Spotify'
press:
- service: script.play_spotify_playist
Along with this you need an input text to store your current playlist selection. We use this to reselect your selection after a restart or template reload. You can create input text in the Helpers page. The entity id must be input_text.spotify_playlist to work with the template.
Link to Helpers – My Home Assistant
Now you need a script which you call to use your selected playlist to start with spotcast.
Play Selected Spotify Playlist Script
script:
play_spotify_playist:
alias: 'Play Spotify Playlist'
description: 'Play selected Spotify playlist.'
sequence:
- service: spotcast.start
data:
device_name: Dining Room Hub # change to your device
uri: >
{% set playlists = state_attr('sensor.playlists_sensor','playlists') %}
{% if playlists != none %}
{% for item in playlists %}
{% if item.name == states('select.spotify_playlist') %}
{{ item.uri }}
{% endif %}
{% endfor %}
{% else %} {{ none }}
{% endif %}
Add these entities to a lovelace view, reload templates and scripts, and you should be ready to rock.
- type: entities
entities:
- select.spotify_playlist
- button.play_spotify