Play Music to Google Nest

Hi - I am brand new to HA so please be gentle! One automation that I am keen to get working (and was the only thing I could not manage to get off of Google Home and onto Smartthings before that app fell over). I would like to play music the Google Nest from 8pm to 12 pm from a specific Spotify playlist. I understand that I will need a second automation to “stop” the music. I can see the right media player and assume this should be simple but is just not working. Current YAML looks like this: alias: Sleep Music On
description: “”
triggers:

  • trigger: time
    at: “20:00:00”
    conditions:
    actions:
  • action: media_player.volume_set
    metadata: {}
    data:
    volume_level: 0.2
    target:
    device_id: 081dc5dfbe7c8635eef7255224ab8705
  • action: media_player.play_media
    metadata: {}
    data:
    media:
    media_content_id: >-
    Spotify
    media_content_type: Playlist
    metadata:
    navigateIds:
    - {}
    - media_content_type: “”
    media_content_id: MANUAL_ENTRY
    browse_entity_id: media_player.nest_bedroom
    target:
    device_id: 081dc5dfbe7c8635eef7255224ab8705
    mode: single

Hi & welcome to the community.

To help us help you, please take quick look at the guide for correctly formatting your yaml in a post.

That will make a world of difference with people being able to interpret this for you.

Otherwise, is it safe to presume that you have setup the Spotify integration correctly & can you get this working manually by using Developer Tools > Actions? This is a great way to get started with something like this. Once you have something working you can ‘go to yaml mode’ & use that yaml in your automation or script.

Cheers
Nick

1 Like

Hi Nick, thanks for your reply. I think best presume that I have fumbled my way around! I have Spotify Connect downloaded from Add Ons but not sure if this is what is required. Downside of being such a beginner is that I keep going down rabbit holes and not knowing whether I am doing what is necessary.
I have managed to set up a new dashboard and generate some scenes and automations but am just not sure what is required for the Nest/Spotify one

1 Like

@salwetherall
Author of the SpotifyPlus Integration here …

The Spotify Connect AddOn is used if your device that is running your Home Assistant server will be used to output Spotify audio to a speaker. An example of this would be a Raspberry Pi (3, 4, 5, etc) that has an audio cable running from it’s 3.5mm audio output jack (or even HDMI audio output) to an amplifier input (or amplified speaker input). For Google Nest devices, you don’t need this addon since the device itself already supports the Spotify Connect Zeroconf protocol and streams the Spotify audio directly to the Nest device.

Note that the HA Spotify Integration will not work for activating the Spotify App on the Google Nest device, though it can be used to control Spotify play on the device (e.g. pause, resume, volume adjust, etc) if the device is activated via the Spotify Mobile / Desktop / Web app.

For Google Nest devices, you will want to use either the SpotifyPlus integration or the SpotCast integration (v6, dev branch) - both of these integrations allow you to activate the Spotify App on the Google Nest (or other Chromecast) device.

As a quick example, you can use the following SpotifyPlus Player Media Play Context service call to transfer playback to a Google Nest device, and start playing the specified playlist.

service: spotifyplus.player_media_play_context
data:
  entity_id: media_player.spotifyplus_john_s
  context_uri: spotify:playlist:6M8n0Sp9895BXEE0MbGPde
  device_id: "Nest Audio 01"
  shuffle: true

Hope it helps!

More Info on SpotifyPlus

The SpotifyPlus integration can do everything that the HA Spotify integration can do, supports Spotify Connect enabled devices (Bose, Sonos, Google Chromecast, Amazon Alexa, Denon, JBL, and more), and provides 95+ custom services that can be used in HA automations and scripts. It also has 10 voice assistant intents that allow you to control the player, play content, manage favorites, etc - all with your voice.

There is also a SpotifyPlus Card user-interface that allows you to control the player, manage your Spotify favorites, as well as search the Spotify catalog. You have to install the SpotifyPlus integration first though, and get it configured before you can use the SpotifyPlus Card.

Both are easily installed via HACS.

Thanks Todd! So much to learn. Having issues now getting Music Assistant loaded and connected but apparently that is a known issue with the version. I will digest your notes, again much appreciated. A steep learning curve but hopefully rewarding in the end

1 Like