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
software:
- python pip. To install:
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install python3-pip
- python evdev. To install:
sudo pip3 --default-timeout=1000 install evdev
--default-timeout=1000 helps if the raspberry is too slow
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 Limitaion 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.
Test has to be done with node-sonos-http-api and rfid scanner, they should run together on all raspberry.
#####Raspberry Config Config the wifi on boot partition
Steps to Configure and/or Run once without AutoStart
- Copy/Downloar/Clone the project in home/pi
- Run
python3 setup_reader.pyto select the reader from the inputs - Run
python3 add_card.pyto scan cards and enter your Google Play Music Playlist Name - Make .sh scrypts executables :
chmod +x sonosplay.sh - Run
python3 box.pyto start the application and verify that it is reading your cards and csv list properly
Install Service to AutoStart
- Change directory to music-cards/
cd music-cards/
- Copy the musiccards.service file to systemd
sudo cp /home/pi/music-cards/musiccards.service /etc/systemd/system/musiccards.service
- Reload the Daemon
sudo systemctl daemon-reload
- Start the musiccards.service
sudo systemctl enable musiccards.service
sudo systemctl start musiccards.service
- Check if musiccards.service is running
sudo systemctl status musiccards.service
- Restart service after file update
sudo systemctl restart musiccards.service
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"