MiczFlor / RPi-Jukebox-RFID

A Raspberry Pi jukebox, playing local music, podcasts, web radio and streams triggered by RFID cards, web app or home automation. All plug and play via USB. GPIO scripts available.
http://phoniebox.de
MIT License
1.37k stars 398 forks source link

Multiple RFIDs for Jukebox controls #39

Closed der-turmfalke closed 6 years ago

der-turmfalke commented 6 years ago

More of a question than an issue:

My plan is to have cards represent songs while key chain tokens represent controls.

My son will get a key chain with (some) volume control and stop. In addition there is an "admin" key chain for us parents that contains the whole set of controls.

This would require me to set more than one ID for certain levels of volume. Is that currently possible? I can think of a workaround for this by distributing the range of volumes between two key chains but I would much rather prefer to have two stop commands handy.

Using the web app is an option if we are not outside our wifi, I know. But on vacation it would be a different thing.

MiczFlor commented 6 years ago

Hi @der-turmfalke

this is possible, you need to tweak the script a little bit. After you installed the box and it works, to be safe, make a backup of the daemon script:

cp /home/pi/RPi-Jukebox-RFID/scripts/rfid_trigger_play.sh /home/pi/RPi-Jukebox-RFID/scripts/rfid_trigger_play.sh.backup

If you make a mistake, you can revert your changes with this command:

cp /home/pi/RPi-Jukebox-RFID/scripts/rfid_trigger_play.sh.backup /home/pi/RPi-Jukebox-RFID/scripts/rfid_trigger_play.sh

Then open the script in a text editor. At the top of the script you need to add new variables for the master keychain. As an example, let's say the volume setting for 95% is on both chains. Currently there is only one:

CMDVOL95="%CMDVOL95%"

You will add another:

CMDVOL95="%CMDVOL95%"
CMDMASTERVOL95="%CMDMASTERVOL95%"

Once you filled in your IDs, it will look something like this:

CMDVOL95="123456789"
CMDMASTERVOL95="987654321"

Now you also duplicate the section in the script below and do the same thing for both cards. Now it says:

elif [ "$CARDID" == "$CMDVOL95" ]
then
    # amixer sset 'PCM' 95%
    $PATHDATA/playout_controls.sh -c=setvolume -v=95

Once you made the changes, it will say this:

elif [ "$CARDID" == "$CMDVOL95" ]
then
    # amixer sset 'PCM' 95%
    $PATHDATA/playout_controls.sh -c=setvolume -v=95

elif [ "$CARDID" == "$CMDMASTERVOL95" ]
then
    # amixer sset 'PCM' 95%
    $PATHDATA/playout_controls.sh -c=setvolume -v=95

Feel free to play around with the script, you have a backup. I am happy if this not only works for you but also gives you some insight into programming.

Good luck, micz