This is a Home Assistant Component that pulls playlist data from your Spotify accounts. To integrate with Spotify Playlist Card. Requires a Spotify Premium account.
Please note I am not actively updating this sensor anymore. I recommend using spotify-card by user @fondberg for a much better Lovelace card implementation (and no need for a separate Spotify sensor). I'll update this sensor for small changes and for programming practice.
This component will set up the following platforms.
Platform | Description |
---|---|
sensor |
Show Spotify playlist data from Spotify user. |
- Include this repository as a custom integration in the HACS settings.
https://github.com/dnguyen800/spotify-playlist-sensor
- If added correctly, the repository should be listed like below:
- Access the HA config directory (where you find
configuration.yaml
). - If you do not have a
custom_components
directory (folder) there, you need to create it. - In the
custom_components
directory (folder) create a new folder calledspotify-playlist-sensor
. - Download all the files from the
custom_components/spotify-playlist-sensor/
directory (folder) in this repository. - Place the files you downloaded in the new directory (folder) you created.
Your HA configuration directory (folder) should have the following files:
custom_components/spotify-playlist-sensor/__init__.py
custom_components/spotify-playlist-sensor/manifest.json
custom_components/spotify-playlist-sensor/sensor.py
-
Setup Spotify Developer account and follow directions from the Prerequisite section of Spotify Media Player component to create a Spotify app specifically for this sensor. Don't forget to fill out the redirect URI.
-
Add the sensor in your
configuration.yaml
sensor:
- platform: spotify-playlist-sensor
client_id: 'your_id'
client_secret: 'your_secret'
- Restart Home Assistant.
- Check the Notifications tab in Lovelace UI to finish Spotify authorization.
- Locate the sensor in the Home Assistant UI, view
more info
and confirm your playlists are loaded. - (Optional) Setup the Spotify-Playlist-Card to make use of this sensor.
sensor:
- platform: spotify-playlist-sensor
client_id: 'your_id'
client_secret: 'your_secret'
Key | Type | Required | Default | Description |
---|---|---|---|---|
client_id |
string |
True |
test |
The Spotify client ID for the Spotify app you created during instructions. |
client_secret |
string |
True |
test |
The Spotify client secret for the Spotify app you created during instructions. |
name |
string |
False |
SpotifyPlaylist |
Name of the sensor, such as playlists . |
number_of_playlists |
integer |
False |
6 | Selects the top x number of recent playlists. Most recent playlists start from the top to bottom in the Spotify app. |
offset |
integer |
False |
0 | The index of the first playlist to return. Default: 0 (the first object). Maximum offset: 100.000. |
- I previously used this sensor and I don't see my curated playlists (e.g. Discovery Weekly, Release Radar) created by others. Is this fixed?
The scope used to communicate with Spotify API was updated with release v0.1.1. Delete the .spotifyplaylist-token-cache
and re-authenticate again to get a proper token. Thanks to user @bretteldridge for pointing this out.
- How often does the sensor refresh?
I set it to two minutes. You can change the SCAN_INTERVAL in the sensor.py
file to whatever you like.
- After I finish authorizing in the Home Assistant UI, a blank screen pops up.
Authorization should be complete and the sensor should be pulling data from Spotify now.
I am studying Python as a hobby and this is my first public project. Some fixes/requests may be out of my scope but I'll try my best. I hope you find it useful!
- Spotify Media Player Home Assistant component - I re-used the token authorization code.
- Feed Parser component - Used as a starting point to write the playlist sensor. Thanks!
- Blueprint component - Used to standardize HA component and card documentation.
If you want to contribute to this please read the Contribution guidelines