Franck Nijhof c464056402
Making our website faster, cleaner and prettier (#9853)
* 🔥 Removes octopress.js

* 🔥 Removes use of root_url var

* 🔥 Removes Octopress generator reference from feed

* 🔥 Removes delicious support

* 🔥 Removes support for Pinboard

* 🔥 Removes support for Disqus

* 🔥 Removes support for Google Plus

* ↩️ Migrate custom after_footer to default template

* ↩️ Migrate custom footer to default template

* ↩️ Migrate custom header to default template

* 🔥 Removes unused template files

* 🚀 Places time to read directly in post template

* 🚀 Removes unneeded capture from archive_post.html template

* 🔥 🚀 Removes unused, but heaving sorting call in component page

* 🚀 Merged javascripts into a single file

* 🔥 Removes more uses of root_url

* 🚀 Removal of unneeded captures from head

* 🔥 🚀 Removal of expensive liquid HTML compressor

* 🔥 Removes unneeded templates

* 🚀 Replaces kramdown with GitHub's CommonMark 🚀

* 💄 Adds Prism code syntax highlighting

*  Adds support for redirect in Netlify

* ↩️ 🔥 Let Netlify handle all developer doc redirects

* ✏️ Fixes typo in redirects file: Netify -> Netlify

* 🔥 Removes unused .themes folder

* 🔥 Removes unused aside.html template

* 🔥 Removes Disqus config leftover

* 🔥 Removes rouge highlighter config

* 🔥 Removes Octopress 🎉

* 💄 Adjust code block font size and adds soft wraps

* 💄 Adds styling for inline code blocks

* 💄 Improve styling of note/warning/info boxes + div support

* 🔨 Rewrites all note/warning/info boxes
2019-07-15 22:17:54 +02:00

4.9 KiB

title, description, logo, ha_category, ha_release, ha_iot_class, redirect_from
title description logo ha_category ha_release ha_iot_class redirect_from
Spotify Instructions on how to integrate Spotify into Home Assistant. spotify.png
Media Player
0.43 Cloud Polling
/components/media_player.spotify/

The spotify media player platform 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>:<port>/api/spotify

If you are using SSL: https://<your_home_assistant_url_or_local_ip>:<port>/api/spotify

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 base_url.

Configuration

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

# 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'

{% 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 cache_path: description: Path to cache authentication token. required: false type: string default: .spotify-token-cache aliases: description: "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 info channel for ease of aliasing." required: false type: map name: description: The name of the device used in the frontend. required: false type: string default: Spotify {% endconfiguration %}

Setup

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.

Sources

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:
      - Spotifyd@rock64
      - 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) "media_content_id": "spotify:user:spotify:playlist:37i9dQZF1DWSkkUxEhrBdF" which are part of the media_player.play_media service. You can test this from the services control panel in the Home Assistant frontend.

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.

Unsupported Devices

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