Play a Spotify Playlist on a Google Nest

Heyy I’m new to the party, so please have a bit understanding :wink:

I’m trying to start a Spotify Playlist with a button. It should play on the device “schlafzimmer”. I made following code but it won’t work. Any advice ? Thx in advance!!

type: button
name: Spotify on Nest
show_state: true
tap_action:
  action: call-service
  service: media_player.play_media
  target:
    entity_id: media_player.spotify
  data:
    media_content_id: "https://open.spotify.com/playlist/5xddIVAtLrZKtt4YGLM1SQ?si=YcvRqaKNTxOi043Qn4LYkg"
    media_content_type: playlist
  target:
    entity_id: media_player.schlafzimmer

Hi, just a few little mods to apply:

replace ‘data’ with ‘service_data’
unindent ‘entity_id: media_player.spotify’ and remove ‘_id’
replace ‘playlist’ by ‘spotify://playlist’
replace Spotify URL by URI (find URL in spotify and hold Ctrl key before copying link)

type: button
name: Spotify on Nest
entity: media_player.spotify
show_state: true
tap_action:
  action: call-service
  service: media_player.play_media
  service_data:
    media_content_id: spotify:playlist:5xddIVAtLrZKtt4YGLM1SQ
    media_content_type: spotify://playlist
  target:
    entity_id: media_player.schlafzimmer

Hope it will work

Thx for the reply!

So I got no errors thx for this!
But it isn’t doing enything…

Maybe I’m wrong but I noticed that this service works best with “Google Cast Group” media models instead of others like ‘Nest Hub’ or ‘Nest Audio’ ones

So, open your Google Home app on your mobile, create a Group (let’s call it ‘Bedroom’) even with a single device : your google nest.

Then, on Home Assistant, go to ‘Settings/Integration/Google Cast’ and you’ll see a ‘Bedroom’ device with ‘Google Cast Group’ as model and ‘media_player.bedroom’ as entity_id

replace ‘media_player.schlafzimmer’ with ‘media_player.bedroom’ in your yaml button card code

does this work ?

The Google Nest makes a start noise, but sadly it wont play anything.

I think there is a problem with playing the Spotify Playlist. But i can’t see the error.
Home Assistant Spotify

So, you got a starting sound with a Google Cast Group ? Perfect, you’re on the right way.

The playlist is fine but there must be a problem with your Spotify API.

I guess you correctly configured the spotify integration into “config.yaml”

spotify:
  client_id: YOUR_CLIENT_ID
  client_secret: YOUR_CLIENT_SECRET

But maybe you didn’t refer your local_ip as a “Redirect URIs” into the corresponding Spotify Developer App ?

If not, go to : My Dashboard | Spotify for Developers

Open your App, then click on “Edit Settings”

Add “http://your_local_ip:8123/auth/external/callback” in “Redirect URIs”

(don’t put “homeassistant.local” as “your_local_ip”)

I think the API can’t be the problem, but i did it again with the IP-Adress version of the Redirect URI:

image

I can contol (start and pause )the spotify music with the “media-control” panel, even on my google nest (Cast Group).

I made the spotify integration into the “/config/configuration.yaml” file this is correct isnt it?

But sadly after all this nothing plays when i push the “Spotify on Nest” button.

Install spotcast Custom component and link the button to a script:

- service: spotcast.start
    data_template:
      device_name: 'Living Room Speaker'
      uri: 'spotify:playlist:Enter_your_uri_Playlist'
      random_song: true
      shuffle: true