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. |
https://github.com/dnguyen800/spotify-playlist-sensor
configuration.yaml
).custom_components
directory (folder) there, you need to create it.custom_components
directory (folder) create a new folder called spotify-playlist-sensor
.custom_components/spotify-playlist-sensor/
directory (folder) in this repository.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'
sensor
listKey | 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. |
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.
I set it to two minutes. You can change the SCAN_INTERVAL in the sensor.py
file to whatever you like.
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!
If you want to contribute to this please read the Contribution guidelines