Skip to content

extazy173/spotify-playlist-sensor

 
 

Repository files navigation

Spotify Playlist Sensor

GitHub Release GitHub Activity License

Project Maintenance

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.

header

HACS Installation

  1. Include this repository as a custom integration in the HACS settings.
https://github.com/dnguyen800/spotify-playlist-sensor
  1. If added correctly, the repository should be listed like below:

hacs

Manual Installation

  1. Access the HA config directory (where you find configuration.yaml).
  2. If you do not have a custom_components directory (folder) there, you need to create it.
  3. In the custom_components directory (folder) create a new folder called spotify-playlist-sensor.
  4. Download all the files from the custom_components/spotify-playlist-sensor/ directory (folder) in this repository.
  5. 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

Configuration

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

  2. Add the sensor in your configuration.yaml

sensor:
  - platform: spotify-playlist-sensor
    client_id: 'your_id'
    client_secret: 'your_secret'
  1. Restart Home Assistant.
  2. Check the Notifications tab in Lovelace UI to finish Spotify authorization.
  3. Locate the sensor in the Home Assistant UI, view more info and confirm your playlists are loaded.
  4. (Optional) Setup the Spotify-Playlist-Card to make use of this sensor.

Example configuration.yaml

sensor:
  - platform: spotify-playlist-sensor
    client_id: 'your_id'
    client_secret: 'your_secret'

Configuration options for sensor list

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.

FAQ

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

Support

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!

Credits

Contributions are welcome!

If you want to contribute to this please read the Contribution guidelines


About

Spotify Playlist Sensor for Home Assistant

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%