This project is a fork of Music Card from hoveeman/music-cards forked from fsahli/music-cards.
It has been reworked to:
- use python 3 with a complete object-oriented rework
- read card info from bdd
- edit cards info on a website with basic auth bipbipzizik
- play music on sonos
- from spotify
- to be continued
- Raspberry Pi Zero
- Don't forget micro sd card and power supply
- USB OTG Hub
- RFID 125Khz Reader
- 125Khz Cards
Remark : see on original project hoveeman/music-cards for printable rfid cards
- Download and flash the las lite version of Raspbian
- Enable SSH by creating an empty "ssh" named file at the root of the boot partition (visible on Windows)
- Configure your wifi using the wpa_supplicant.conf template in the tools folder Config the wifi on boot partition
Update your distrib to be up to date
sudo apt-get update
sudo apt-get upgrade -y
- You need git to clone the project repository
sudo apt install git -y
git clone https://github.com/acatoire/music-cards /home/pi/music-cards
- Then you will be able to update with
cd /home/pi/music-cards
git pull
TODO procedure without git (wget?)
- You need python pip
- Then all python packages needed can be installed from requirements file
sudo apt-get install python3-pip -y
sudo pip3 install -r requirements.txt
- Setup the reader
cd /home/pi/music-cards/modules/rfid_reader/
sudo python3 setup_reader.py
--default-timeout=1000
for pip helps if the raspberry or the connection is too slow
- TODO Procedure create configuration for a new pi application
- Get your raspberry unique ID (16 numbers ex:0000XXXXXXXXXXXX) with the command
cat /proc/cpuinfo
- TODO procedure to add new cards
Run python3 modules/rfid_reader/setup_reader.py
to select the reader from the detected inputs inputs
Simply run the application with python 3
python3 box.py
This will loop reading rfid cards. But the application will not automatically restart. See the following procedure to setup the auto-start.
- Change directory to music-cards/
- Copy the musiccards.service file to systemd
- Reload the Daemon
- Enable the musiccards.service
- Start the musiccards.service
cd /home/pi/music-cards/
sudo cp /home/pi/music-cards/musiccards.service /etc/systemd/system/musiccards.service
sudo systemctl daemon-reload
sudo systemctl enable musiccards.service
sudo systemctl start musiccards.service
- Check if musiccards.service is running
sudo systemctl status musiccards.service
- Watch the full log of musiccards.service
sudo journalctl -u musiccards.service
- Restart service after file update
sudo systemctl restart musiccards.service
The sonos Api node-sonos-http-api can be setup on a dedicated server.
- Install nodejs
- Clone the repo
- Enter in the folder
- install the package and start it
sudo apt-get install nodejs
sudo apt-get install npm
git clone https://github.com/jishi/node-sonos-http-api /home/pi/node-sonos-http-api
cd node-sonos-http-api
npm install --production
npm start
TODO auto start found here
sudo npm install -g pm2
pm2 startup
pm2 will request you this
sudo env PATH=$PATH:/usr/bin /usr/local/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi
cd /home/pi/node-sonos-http-api
pm2 start npm -- start
pm2 save
##Possibles Errors and solution
Exception: The config for 0000XXXXXXXXXXXX is not present in the bipbipzizik database.
Did you create it?
You didn't register your raspberry unique ID (16 numbers ex:0000XXXXXXXXXXXX) in the database. Execute the procedure as described above.
Read card: XXXXXXXXX
Card not found in database
You didn't register the card passed on the reader. Execute the procedure as described above.
System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down
Firebase_Admin Error TypeError: __init__() got an unexpected keyword argument 'status'
try:
python3 -m pip install --upgrade urllib3
###Raspberry Limitaion ####node-sonos-http-api Test has to be done with node-sonos-http-api and rfid scanner, they should run together on all raspberry.
####Home Assistant Please note that Raspberry Pi Zero is insufficient to run both the Home Assistant and and the rfid scanner. It is recommend you use a Raspberry Pi 3 if you intend to run both at the same time.
python -m unittest discover -p "*_test.py"
Specific file:
coverage run xxx_Test.py
All unit test:
coverage run -m unittest discover -p "*_test.py"
coverage erase
coverage run -m unittest discover -p "*_test.py"
coverage report --omit "*_test.py"
coverage html --omit "*_test.py"