Step 1: Create the play list from the web interface of Volumio. Let’s say you named it ‘Wake-up’
Step 2: You need to create a shell script to load this play list. Like this…
#!/bin/bash
mpc stop
sleep 5
mpc clear
sleep 5
mpc load Wake-up
sleep 10
mpc play
sleep 600
mpc stop
Save this file anywhere with extension .sh …I saved it in my home directory (i.e., /home/volumio and called it morning-play-songs.sh)
and then make this file executible by
chmod 755 /home/volumio/morning-play-songs.sh
Step 3: You need to schedule this to play at the wake up time by adding this line to the crontab file
29 5 * * * /bin/bash /home/volumio/morning-play-songs.sh > /dev/null 2>&1
Step 4: You also need to enable the cron daemon which is disabled by default in Volumio
For this you have to go to a file called orion_optimize.sh in the /var/www/command folder
Here, in this file there is a section called
## kill useless system processes
in this list please comment out the line referring to cron like this…
#killall -9 cron
…that is all…Now you should be able wake up to your favourite songs…
Its also possible to control the volume of the mpc player via commandline…so if you wish you can write the shell script in such a way that when the playlist starts playing, it starts with a low volume and then increases gradually …
Make sure crontab is started at boot (ps -A | grep cron)
If not, try: update-rc.d cron enable
if still not running, check /var/www/command/orion_optimize.sh and remark the line that kills crontab
Install mpc with sudo apt-get install mpc
Create the following files in /var/www/command:
play
stop
calendar.cron
and chmod them to 755 or 777
play has the following content:
mpc stop
mpc clear
mpc load "$1"
mpc play
stop has the following content:
mpc stop
or, if you want it to stop when the current song is finished:
calendar.cron will be filled by the webpage, just make sure it’s there and everyone can write to it.
After all that, change directory to /var/www and enter the following command: sudo wget digitalhifi.nl/tmp/calendar.tar
unpack it with tar -xvf calendar.tar
You can then change any paths that is used in this file but it should run as it is… using /var/www/command/calendar.cron as inputfile for the crontab command.
Since nginx is running under the account of www-data you can check the cron with: sudo crontab -l -u www-data
The schedular can be called by volumio.local/calendar.php (or by using the ip address of your RPI). You can also consider changing the _header.php so it will be in the pull-down menu.
If your site is accessable from the outside world you might want to tighten the security a bit
If any questions, post them here…
this is really great stuff . . . would be even greater if the very first seconds after it started to play, the volume would be kind of muted and increases slightly to a predefined maximum ( especially if you intend to use it as an alarm clock ) But anyway some issues I have
the time setting on volumio seems to be wrong mine is an hour back, I guess ntp is not enabled
where is the calendar icon set ( at least I can see it in your menu )
NTP isnt the problem, NTP is the only reason that the time is just 1 hr off. I bet you’re located in a GMT+1 region or Central Europe (CET). By default all Raspbian images are set on GMT (England). You can change this using either:
It calculates the remaining time of the song, goes to sleep for that remaining time and then stop playing. By doing this, the current song will be played completely instead of stopping in the middle of it.
Perhaps you can think of a function that uses the ‘mpc volume’ command to increase the volume a few times by 10 percent until you reach the desired volume? I see if I can come up with something like this, and maybe even use something like it to fade out as well…? On a rainy day though…
However, it also depends on your hardware. If you use something like HifiBerry DAC make sure your volume control is enabled.
Thank you for posting a guide on how to implement a calendar in Volumio.
This is very helpful and I finally got it to work after a few hours of head scratching since I am not to experienced with Linux and Terminal.
I got quite frustrated at first because every thing looked good. I even got the Calendar section in the main menu and was able to solve the time zone and that it actually sees my playlists.
But it still did not work so I spend a few more hours learning about cron and trying to figure out where the problem was.
This morning when I got up I finally realised what the issue was.
I made a playlist called “Swiss Jazz”. It was not able to load to playlist because I used two words. When I made a new playlist called Swiss.Jazz it finally worked
I have setup the scheduler perfectly on one of my pi’s and done exactly the same setup on another pi running the latest verison but when testing I cannot get it to work??
I cannot understand why?
The cron job is there and the stop play and calendar files are all there and writeable, so I cannot really understand why its not working? I can see the cron job in the calendar.cron file so I know its saved and I have commented on the cron kill line in the orion_optimize.sh
I’ve restarted several times just in case, but still no luck