Skip to content

madmooose/spoty-rfid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spoty-rfid

aka Kühniebox aka spoty-box At some point I need a better name.

This is a simple hacky rfid-box to trigger any spotify-player (incl. Raspotify. It's build with raspberry pi in mind.

At the moment it can only trigger playlists on a specific device. More commands will eventually follow.

Work is based on https://gist.github.com/sonicdee/bf5f655669ef6900b72c54f0c7696d32

clone to home-directory

   git clone https://github.com/madmooose/spoty-rfid

and install all requirements.

   sudo apt-get install python3-pip
   sudo pip install spotipy

Create a cards.txt

Format is like that

[number of rfid-tag] play # play-tag
[number of rfid-tag] pause # pause-tag
[number of rfid-tag] playpause # toggle-tag
[number of rfid-tag] next # play next track in playlist
[number of rfid-tag] prev # play previous track in playlist
[number of rfid-tag] volUp # volume up tag
[number of rfid-tag] volDown # volume down tag
[number of rfid-tag] [spotify-uri] # here's some space for comments

Create udev-rule to own the rfid-reader

Run

  lsusb

and remember both numbers behind ID. In /etc/udev/rules.d create a file called 50-usb-rfidreader.rules and and the following line

   SUBSYSTEMS=="usb", ATTRS{idVendor}=="[numer1]", ATTRS{idProduct}=="[number2]", MODE="0666"

Now reload udev.

   sudo udevadm control --reload-rules
   sudo udevadm trigger

Check if you have read-and-write-access.

   ls -l /dev/usb/hidraw0

Configure the spotify

Visit Spotify Devoloper Dashboard and create an app. Remember Client ID and Client Secret. Also edit settings and add http://localhost:8080 to Redirect URIs. Now switch to the cosole-tab on the Developer Dashboard and choose Player. Click on /v1/me/player/devices, get token (user-read-playback-state is enough) and try it. Grab the ID of the client you what to control.

Now you have to add the collected values to config.py.

CLIENT_ID: str = 'xxx'
CLIENT_SECRET: str = 'xxx'
REDIRECT_URI: str = 'http://localhost:8080'

DEVICE_ID = 'xxx'

We will now run

   ./RfSpoty.py

for the first time to create the .cache file where the access token is stored. You have to follow the URL and paste the URL of your browser back into your command line.

Daemonize it

Copy spoty-rfid.service to /etc/system.d/system/ and activate it

  sudo cp spoty-rfid.service /etc/system.d/system
  sudo systemctl enable spoty-rfid
  sudo systemctl start spoty-rfid

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages