💿 Play music on speakers using NFC tags.
🚧 For the moment:
- artist, album and URI must be pre-populated in a JSON file
- only works with Spotify URIs
- as soon as the NFC tag is removed, the music pauses, then resumes when the NFC tag is replaced
💡 Inspired by:
Installing dependencies with Poetry
poetry install
Add SONOS_HOST
to env with IP address of your Sonos Zone Player. To do this you can use a .env
file with poetry-dotenv-plugin
Create a library.json
file (cp sample_library.json library.json
) and complete it with the desired artists and albums.
{
"library": {
"artist a": {
"album 1": "uri",
"album 2": "uri"
},
"artist b": {
"album 2": "uri"
}
},
"tags": {…}
}
Show help message
poetry run python jukebox/sonosplayer.py --help
Play a specific album
poetry run python jukebox/sonosplayer play --artist "Your favorite artist" --album "Your favorite album by this artist"
Artist and album must be entered in the library's JSON file. This file can be specified with the --library
parameter.
This script works with an NFC reader like the PN532 and NFC tags like the NTAG2xx. It is configured according to the Waveshare PN532 wiki.
Complete the tags
part of the library.json
file with each tag id and the expected artist and album.
{
"library": {…},
"tags": {
"ta:g1:id": {"artist": "artist a", "album": "album 1"},
"ta:g2:id": {"artist": "artist a", "album": "album 2", "shuffle": true},
}
}
Start the script (show help message with --help
)
poetry run python jukebox/nfcreader.py
🎉 By approaching a NFC tag stored in the library.json
file, you should hear the associated music begin.