starkillerOG 66b1f77555
Add Spotify retrive URI instructions (#12012)
* Add Spotify retrive URI instructions

* correction to retrieving media_content_id

examle playlist: "Love Songs & Chill"
"Copy Spotify URI" gives: spotify:playlist:4QuJ2DbcTe7R8lzqfNXz7v
this works as `media_content_id`
"Copy Playlist Link" gives: https://open.spotify.com/playlist/4QuJ2DbcTe7R8lzqfNXz7v?si=cUKngvAER3KK3BHgNayOEA
this does not work as `media_content_id` and gives an error in HomeAssistant
However if you remove everthing after the question mark ? is does work:
https://open.spotify.com/playlist/4QuJ2DbcTe7R8lzqfNXz7v

* Capital Spotify

Co-Authored-By: Franck Nijhof <frenck@frenck.nl>

* Not needed anymore since this has been fixed

Co-authored-by: Franck Nijhof <frenck@frenck.nl>
2020-03-21 09:23:13 +01:00

3.4 KiB

title, description, ha_category, ha_release, ha_iot_class, ha_config_flow, ha_quality_scale, ha_codeowners, ha_domain
title description ha_category ha_release ha_iot_class ha_config_flow ha_quality_scale ha_codeowners ha_domain
Spotify Instructions on how to integrate Spotify into Home Assistant.
Media Player
0.43 Cloud Polling true silver
@frenck
spotify

The spotify media player integration allows you to control Spotify playback from Home Assistant.

Prerequisites

  • Spotify account
  • Spotify application, properly configured (see below).
Controlling the Spotify integration (pause, play, next, etc.) requires a Premium account. If you do not have a Premium account, the integration 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 one of the following forms:
    • If you are not using SSL: http://<your_home_assistant_url_or_local_ip>/auth/external/callback
    • If you are using SSL: https://<your_home_assistant_url_or_local_ip>/auth/external/callback
  • Click Save after adding the URI.

If you are using an externally accessible address, you will likely also need to set the base_url attribute of the HTTP Integration. 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 base_url.

Configuration

To add Spotify to your installation, add the following to your configuration.yaml file:

# Example configuration.yaml entry
spotify:
  client_id: YOUR_CLIENT_ID
  client_secret: YOUR_CLIENT_SECRET

{% configuration %} client_id: description: Client ID from your Spotify application. required: true type: string client_secret: description: Client Secret from your Spotify application. required: true type: string {% endconfiguration %}

Activating the Spotify integration

After you have set up the above:

  • Go to the integrations page in the Home Assistant frontend
  • Go to Integrations
  • Add a new Spotify integration.
  • Follow the steps shown to authenticate Home Assistant with your Spotify account.

If you receive an INVALID_CLIENT: Invalid redirect URI error while trying to authenticate with your Spotify account, make sure to check the Redirect URI in the address bar after adding the new integration. Compare this value with the Redirect URL defined in the Spotify Developer Portal.

You can send playlists to Spotify using the "media_content_type": "playlist", which are part of the media_player.play_media service. The media_content_id can be obtained from the Spotify desktop-app by clicking on the more options ("...") next to the album art picture, selecting "share" and then "Copy Spotify URI" or "Copy Playlist Link" (also available in the Spotify phone and web app).

Unsupported Devices

  • Sonos: Although Sonos is a Spotify Connect device, it is not supported by the official Spotify API.