Spotify
Integration of the Spotify streaming service, which allows you to control music playback directly from Home Assistant.
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.
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.
-
First, log in to the developer page just like you would to the regular Spotify service.
-
Fill out the form and save it (Save button).
tipThanks 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.
-
In the list of applications, select yours and click on Settings.
-
Copy the values of Client Id and Client Secret.
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.
-
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.
or click on:
-
Fill in the login details of the application based on the registration above.
-
Agree to grant access to our application to the Spotify account.
-
And we should be done.
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.
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