spotify media player platform allows you to control Spotify playback from Home Assistant.
- Spotify account.
- Spotify Application, properly configured
Controlling the Spotify component (pause, play, next, etc) requires a Premium account. If you do not have a Premium account, the component in the frontend will not show the controls.
To create the required Spotify Application:
- Login to Spotify Developer
- Visit the My Applications page
- Select Create An App. Enter any name and description. Once your application is created, view it and copy your Client ID and Client Secret, which are used in the Home Assistant configuration file.
- Add a Redirect URI in the following forms:
If using SSL:
The URL is whatever you use to access Home Assistant from outside your network (including port if applicable).
- Click Save after adding the URI. You may also need to set the
base_urlattribute of the HTTP Component.
To add Spotify to your installation, add the following to your
# Example configuration.yaml entry media_player: - platform: spotify client_id: <your client id> client_secret: <your client secret> aliases: abc123def456: 'Living Room' 9183abas000: 'Bed Room'
- client_id (Required): Client ID from your Spotify Application.
- client_secret (Required): Client Secret from your Spotify Application.
- cache_path (Optional): Path to cache authentication token (defaults to configuration directory).
aliases (Optional): Dictionary of device ids to be aliased, handy for devices that Spotify cannot properly determine the device name of. New devices will be logged to the
infochannel for ease of aliasing.
After the prerequisites and configuration are complete, restart Home Assistant. A Spotify configurator element will be available. Follow the instructions to authorize Home Assistant to access your Spotify account. A Spotify media player will then appear. If Spotify prompts you to download a file after completing authorization, discard the download. It is not needed.
The sources are based on if you have streamed to these devices before in Spotify. If you don’t have any sources, then simply stream from your phone to another device in your house, Bluetooth, echo, etc. Once you do the sources will show up in the developer console as a device to cast/stream to. Also know that the devices won’t show up in the dev-console as sources unless they are powered on as well.
You can send playlists to spotify via the “media_content_type”: “playlist” and “media_content_id”: “spotify:user:spotify:playlist:37i9dQZF1DWSkkUxEhrBdF” which are a part of the media_player.play_media service, you can test this from the services control panel in the Home Assistant frontend.
In this example this is a URI link to the Reggae Infusions playlist, this support document from Spotify explains how to get this URI value to use for playlists in the Spotify component.