spotify media player platform allows you to control
Spotify playback from Home Assistant.
- Spotify account
- Spotify application, properly configured (see below)
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 one of the following forms:
If you are not using SSL:
If you are 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 will likely also need to set the
base_url attribute of the HTTP Component. This should be set using the same base URL as the redirect URI, e.g., if you used a domain name (not local IP) in the redirect, then use the same domain name in your
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 from your Spotify application.
Client Secret from your Spotify application.
Path to cache authentication token.
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.
The name of the device used in the frontend.
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 you are prompted 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 Spotify developer console as a device to cast/stream to.
Go to https://developer.spotify.com and login. Click on “Console” in top menu and then “Player” in the left menu. Select “/v1/me/player/devices” in the list. Then click “Get token”, accept the terms and click “Try it”. Your active Spotify devices will then be listed in the right panel, beneath the curl-line (for example, “name”: “Web Player (Chrome)”).
These names can then be used in for example an input selector:
spotify_source: name: 'Source:' options: - [email protected] - Web Player (Chrome)
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 something like (depending on your content ID)
which are part of the
service. You can test this from the services
control panel in the Home Assistant frontend.
Extra services besides the default ones in component Media Player component.
Play a Spotify playlist with an option to start on a random position of the playlist.
|Service data attribute||Optional||Description|
||no||Spotify URI of playlist. Must be playlist kind of URI.|
||yes||True to select random song at start, False to start from beginning.|
The above playlist example 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.
- Sonos: Although Sonos is a Spotify Connect device, it is not supported by the official Spotify API.