[Solved] Volumio + Mausberry Switch

thanks to yjo my mausberry switch is working!

  1. Install Volumio 1.2 (or newer)
  2. Follow the instructions for RaspBMC/Raspbian/Debian distributions on Mausberry Circuits without rebooting
  3. sudo nano /etc/rc.local
  4. change the last lines from exit 0 /etc/switch.sh & to /etc/switch.sh & exit 0
  5. sudo reboot
  6. enjoy!

Which version are you using? There was a problem with version and shutdown command due to some kernel issues, could you try it with 1.1?

I’m already on VolumioBeta1.1. :confused:

Hi,

The power button control using GPIO requires a daemon for monitoring the event.
Usually, the daemon starts when the system starts up, and the setting is described in /etc/rc.local file (or appropriate scripts placed and registered in /etc/init.d/ directory).
The Mausberry kit also includes such a daemon (switch.sh) and the start of this daemon is registered in /etc/rc.local for most of Raspberry pi Linux packages.
However, in Volumio, /etc/rc.local file is overwritten when the system is shutdown (or restarted), so no one can automatically start the GPIO monitoring daemon by modifying /etc/rc.local file.

I am also worrying this problem…

Yes, the rc.local gets overwritten due to security mechanism. I’m building a new version, with security mechanism disabled… Just wait for that and then we can see how to get this sorted out…

Has the 1.2beta the security mechanism disabled?
I wish to try to get the power button working

thankyou
V

OK, I succeeded.
Volumio overwrites /etc/rc.loocal with /var/www/_OS_SETTINGS/etc/rc.local file, when the system starts up.
By modifying the latter file as I would like, I did successfully auto-start the daemon that controls the shutdown button.

Hi,
How do I modify that file and what part of it do I modify?

Thanks!

First, I didn’t try with the Mausberry kit, but with a more simple GPIO extension.
So the description bellow is “NO WARRANTY” and “IN YOUR OWN RISK”.

Login as root.
Install the kit as usual under the instruction.
Run the setup script (files.mausberrycircuits.com/setup.sh)
after modification of the last line as
before: sudo sed -i ‘$ i /etc/switch.sh &’ /etc/rc.local
after: sudo sed -i ‘$ i /etc/switch.sh &’ /var/www/_OS_SETTINGS/etc/rc.local

Then reboot.
Good luck!

Another solution is to disable Volumio’s “protection” of rc.local. I prefer this method, so that I’m free to edit rc.local again in the future without having to remember some weird location.

sudo nano +1167 /var/www/inc/player_lib.php Comment out these 5 lines by adding two slashes to the beginning like this:

// $a = '/etc/rc.local'; // $b = '/var/www/_OS_SETTINGS/etc/rc.local'; // if (md5_file($a) != md5_file($b)) { // sysCmd('cp '.$b.' '.$a); // }

Oh, that’s very important info and a very good means.
Thx!!!

can’t get the mausberry script to work. :frowning:
neither with yjos nor elliotts method

Are you using a momentary switch or regular? It needs to match the circuit from Mausberry.
Troubleshooting:
Look in /sys/class/gpio to see which pins are active. Mine uses 23 and 24.
Run this command:

while true; do cat /sys/class/gpio/gpio23/value; done

It’s an infinite loop that shows 0 when the button is not pressed, and it shows 1 when the button is pressed.

ok, i really don’t know what i am doing, but that’s what i did:

  • clean volumino 1.1 installation (tried with 1.2, too)
  • commented out the 5 lines (not necessary with 1.2)
  • installed mausberrys debian script (i use a regular on-off switch)
  • ran this command:

cat /sys/class/gpio/gpio23/value with this result:

cat: /sys/class/gpio/gpio23/value: No such file or directory so i had to activate the gpios first with these commands:

sudo sh -c 'echo "23" > /sys/class/gpio/export' sudo sh -c 'echo "24" > /sys/class/gpio/export'-the gpio folders appeared but value was always 0 even though i’m using these pins (works fine with openelec)
-after a restart the directions disappeared again

greets

First, check /etc/rc.local file:
cat /etc/rc.local
Can you find a line “/etc/switch.sh &” at the END of the file?
If the line exist AFTER a line “exit 0”, move the line “exit 0” to the last of the file.
Good luck.

PS.
Volumio 1.2beta works well with my script and a very simple shutdown button extension.
1.2 allows the direct modification of /etc/rc.local.

@yjo: i had to move the “exit 0” line to the end of the file and now it’s working. thanks a lot!! :slight_smile:

Congratulations!!

Hi everyone,

thank you very much for this very usefull thread. I had the same problem especially with the rc.local file (I´am still on 1.1) and the not existing gpio folder. It works flawlessly now.

There is only one thing I can suggest …

I found on a blog a modified version of the script which makes a “cleaner” shutdown. Thanks to astronomydomine, I could adjust it for Volumio.

[code]#!/bin/bash
#this is the GPIO pin connected to the lead on switch labeled OUT
GPIOpin1=23
#this is the GPIO pin connected to the lead on switch labeled IN
GPIOpin2=24
echo “$GPIOpin1” > /sys/class/gpio/export
echo “in” > /sys/class/gpio/gpio$GPIOpin1/direction
echo “$GPIOpin2” > /sys/class/gpio/export
echo “out” > /sys/class/gpio/gpio$GPIOpin2/direction
echo “1” > /sys/class/gpio/gpio$GPIOpin2/value
oldpower=$(cat /sys/class/gpio/gpio$GPIOpin1/value)

while [ 1 = 1 ]; do
sleep 2
power=$(cat /sys/class/gpio/gpio$GPIOpin1/value)
if [ $power = 1 -a $oldpower = 0 ]; then
oldpower=1
sudo mpc stop
sleep 5
sudo shutdown -h now
fi
done[/code]

You will notice that the power off with the switch needs so more seconds because makes a more safely shutdown.

Maybe you like it :wink:

Just wondering whether people are using the LED illuminated shutdown switch or the rocker from Mausberry? I have one connected to a Pi running Raspbmc, and want to use it on another one with Volumio. Will modifying the script work in the same way? I haven’t actually got it yet, but I just happened to be checking around to see if anyone else had used the illuminated switch, and I can’t tell.

Thanks for any help in advance.

Yes, it will work in the same way.