Skip to main content

Spotify

Integration of the Spotify streaming service, which allows you to control music playback directly from Home Assistant.

Is a Spotify subscription required?

For full control - pause, play, next, etc. - you need to have a paid Spotify account. However, you can still listen to music through HA without it.

Alexa

Registering Our Developer Application

To be able to configure Spotify in HA, you will first need to have a so-called developer application in Spotify.

  1. First, log in to the developer page just like you would to the regular Spotify service.

    Spotify Dev Create App

  2. Fill out the form and save it (Save button).

    Spotify Dev Create App 2

    tip

    Thanks to smart redirection in HA, we can all use the same Redirect URI: https://my.home-assistant.io/redirect/oauth. The only thing you need to have correctly set up at this address is the path to your HA.

  3. In the list of applications, select yours and click on Settings.

    Spotify Dev Update App

  4. Copy the values of Client Id and Client Secret.

    Spotify Dev Update App 2

Integrating Spotify into HA

In most cases, Spotify will probably not be in the list of automatically discovered integrations, so it will need to be added manually.

  1. Adding the Spotify Integration: - The integration needs to be added manually:

    • Go to the Settings -> Devices & Services menu and make sure you are on the Integrations tab.
    • Click on Add Integration and search for Spotify.

    Spotify Integration Add

    or click on:

    Open your Home Assistant instance and start setting up a new integration.
  2. Fill in the login details of the application based on the registration above.

    Spotify Integration Add

  3. Agree to grant access to our application to the Spotify account.

    Spotify Integration Add

  4. And we should be done.

    Spotify Integration Add

Note for Sonos

Although Sonos products are of the Spotify Connect type, they are not supported by the official Spotify API.

Services

Selecting a Source

By calling the media_player.select_source service, you need to select the source on which the music will be played.

# Playing from a preset
- service: media_player.select_source
entity_id: media_player.spotify
data:
source: "Bose speaker"

Playing Music

By calling the media_player.play_media service, you can start a specific Spotify playlist.

# Playing from a preset
- 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

UI Control in Lovelace

Just like with the Bose integration, I recommend using the Mini Media Player from the HACS store.

HACS Mini Player

Thanks to it, we can change sources - where Spotify will be played directly from the UI, and we can also browse playlists and artists directly from HA.

Comments