bernedom / playbox

RFID player for raspberry pi

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

playbox

RFID player for raspberry pi. Using Mopidy/MPD to play back songs triggered by RFID cards. This is currently in very early development and should be considered a hack/learning project for me. There likely many security and stability issues with the code. Use at your own risk.

Installation & building

System tested on a raspberry pi 3 running a Raspian lite. Playbox is deployed using a docker container, so before starting docker has to be installed on the raspberry pi.

Since playbox is still under development the best way to find out needed system requirements is to look inside the Dockerfile. The container image is currently not available from dockerhub or similar, because the spotify credentials are currently stored within.

Building

First build the python package as a source distribution

python3 setup.py sdist

this will create the folder dist containing the python package

Next build the docker container. The client ID and client secret can be generated by registering mopidy-spotify.

export SPOTIFY_USER="your_spotify_username"
export SPOTIFY_PASS="your_spotify_password"
export SPOTIFY_CLIENT_ID="00000000-0000-0000-0000-000000000000"
export SPOTIFY_CLIENT_SECRET="00000000_00000000000000000_00000000000000000"

docker build . -t playbox --rm --build-arg SPOTIFY_USER=${SPOTIFY_USER} \
--build-arg SPOTIFY_PASS=${SPOTIFY_PASS} \
--build-arg SPOTIFY_CLIENT_ID=${SPOTIFY_CLIENT_ID} \
--build-arg SPOTIFY_CLIENT_SECRET=${SPOTIFY_CLIENT_SECRET}

Installing

The client ID and client secret can be generated by registering mopidy-spotify and then stored in /var/playbox/spotify.conf

[spotify]
username = your_spotify_username
password = your_spotify_password
enabled = true
client_id = 00000000-0000-0000-0000-000000000000
client_secret = 00000000_00000000000000000_00000000000000000

After the docker container is built and named playbox starting the container is done by systemd. copy the resource/playbox_container.service to /etc/systemd/system then reconfigure systemd.

sudo systemctl daemon-reload
sudo systemctl enable playbox_container.service

Registering audio

Matchings between RFID tag-IDs and audio URIs are stored in /home/pi/audio.csv the format is

|TagID|AudioURI|

Running the tests

pytest

Hints for myself

user should be member of group input to access devices evdev documentation https://python-evdev.readthedocs.io/en/latest/

python packaging help: https://docs.python.org/3/distutils/setupscript.html

Debian packaging intro: https://wiki.debian.org/Packaging/Intro?action=show&redirect=IntroDebianPackaging

Setting up VirtualEnv

It is suggested to set up a virtualenv to develop the playbox

pip3 install virtualenv
virtualenv .venv

About

RFID player for raspberry pi

License:GNU General Public License v3.0


Languages

Language:Python 89.8%Language:Dockerfile 6.0%Language:Shell 4.2%