The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.34 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Instruction Guide Power management for Audiophonics I-Sabre ES9023 V3
#1
[Note: This excellent write-up by @rikardo1979 was first posted in 2018 for moOde 4.x. As moOde has evolved, so have the instructions. For moOde 6.5.1, see @maartin's summary in his followup post downthread.]

1 / Installation of WiringPi:

You’ll need WiringPi to communicate withe the GPIO pins on the Pi.
To do so you’ll need to install gcc:

Code:
sudo apt-get install gcc

now on to wiringPi:

Code:
cd /home/pi
git clone git://git.drogon.net/wiringPi
cd wiringPi
./build


If all goes well you can now get an overview of the GPIO pins by typing 

Code:
gpio readall




2 / Creating the script for the command from the power button:
First we need to go back to /home/pi

Code:
cd /home/pi

Then we can get the script

Code:
wget https://raw.githubusercontent.com/audiophonics/Raspberry-pwr-management/master/sds.sh


3 / Add the script button at startup: Editing the startup file:
Now edit rc.local. This will make the script run at startup.

Code:
sudo nano /etc/rc.local

Add this line before "exit 0”. Don’t delete or change anything else in this file, just add the extra line.

Code:
sudo bash /home/pi/sds.sh &



4 / Creating command scripts for moOde restart and shutdown:
softshutdown recovery script:

Code:
sudo wget https://raw.githubusercontent.com/audiophonics/Raspberry-pwr-management/master/softshutdown.sh

softreboot recovery script:

Code:
sudo wget https://raw.githubusercontent.com/audiophonics/Raspberry-pwr-management/master/softreboot.sh

I don’t know if the scripts need to be executable, but I don’t think it can hurt to do so:

Code:
sudo chmod +x sds.sh
sudo chmod +x softshutdown.sh
sudo chmod +x softreboot.sh


5 / Make moOde work with the scripts.
First make a backup of the original worker.php file in case you mess things up:

Code:
cd /var/www/command
sudo cp worker.php worker.sav


We can now edit the original:

Code:
sudo nano worker.php

Search for ‘reboot’ until you find the part that reads this:
     
Code:
case 'reboot':
         sysCmd('mpc stop');
         sysCmd('systemctl stop nginx');
         sysCmd('reboot');
         break;
      case 'poweroff':
         sysCmd('mpc stop');
         sysCmd('systemctl stop nginx');
         sysCmd('poweroff');
         break;


Here we will replace the reboot and poweroff commands with the scripts that now reside in /home/pi.
Change the text so it reads:

Code:
      case 'reboot':
         sysCmd('mpc stop');
         sysCmd('systemctl stop nginx');
         sysCmd('sudo bash /home/pi/softreboot.sh');
         break;
      case 'poweroff':
         sysCmd('mpc stop');
         sysCmd('systemctl stop nginx');
         sysCmd('sudo bash /home/pi/softshutdown.sh');
         break;


Reboot the Pi and if all goes well your LED should stop blinking and you should be able to power down with the button as well as through the moOde web UI.


[video]https://youtu.be/HsJU91o_yHw[/video]
<marquee behavior="alternate" scrolldelay=150
~~~~>>>Please always follow rules and read before you post<<<~~~~

</marquee>
Reply


Messages In This Thread
Power management for Audiophonics I-Sabre ES9023 V3 - by rikardo1979 - 05-01-2018, 08:41 PM

Forum Jump: