6.1 KiB
RFID Cards Trigger
This project is a fork of Music Card from hoveeman/music-cards forked from fsahli/music-cards.
It has been updated to be able to trig actions on others servers on rfid swipe. List of actions:
- sonos Api node-sonos-http-api
- home assistant (todo, change from hoveeman/music-cards)
Requires
Hardware:
- 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 https://github.com/hoveeman/music-cards for printable rfid cards
Raspberry basis:
- 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
Linux basic
Update your distrib to be up to date
sudo apt-get update
sudo apt-get upgrade -y
software setup:
- You need git to clone the project repository
sudo apt install git-all
git clone https://github.com/acatoire/music-cards music-cards
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
sudo pip3 install -r requirements.txt
--default-timeout=1000 for pip helps if the raspberry or the connection is too slow
Start the application
Configure your database
- 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
Configure the rfid reader
Run python3 modules/rfid_reader/setup_reader.py to select the reader from the detected inputs inputs
Steps to Run without AutoStart
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.
Install Service to AutoStart
- Change directory to music-cards/
- Copy the musiccards.service file to systemd
- Reload the Daemon
- Enable the musiccards.service
- Start the musiccards.service
cd 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
Manage Running 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
Install node-sonos-http-api
The sonos Api node-sonos-http-api can be setup on a dedicated server.
Locally setup
- 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 node-sonos-http-api
cd node-sonos-http-api
npm install --production
npm start
TODO auto start
Docker
##Possibles Errors and solution
Missing your app token in database
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.
Missing your card in database
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
urllib3
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.
HomeAssistant Setup for Google Music
TO BE CHECKED
- Add the configs from homeassistant_files in the config of your Homeassistant.
- You will need to create custom_components/switch directory in your config directory and place
gmusic.pyin there. - Follow this forum post to install gmusicapi, find your device id, and set up the component.
For Dev
Unit test
Run all unit test of the project
python -m unittest discover -p "*_test.py"
Run unit test with coverage on it
Specific file:
coverage run xxx_Test.py
All unit test:
coverage run -m unittest discover -p "*_test.py"
Generate coverage report
coverage erase
coverage run -m unittest discover -p "*_test.py"
coverage report --omit "*_test.py"
coverage html --omit "*_test.py"