Moode Forum
[How to do instruction] Modding moOde: Switching amps - Printable Version

+- Moode Forum (https://moodeaudio.org/forum)
+-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3)
+--- Forum: FAQ and Guides (https://moodeaudio.org/forum/forumdisplay.php?fid=9)
+--- Thread: [How to do instruction] Modding moOde: Switching amps (/showthread.php?tid=335)

Pages: 1 2


Modding moOde: Switching amps - Highsider - 07-21-2018

Hello,

as I already posted some time ago my "moOde mod" for switchin amps in the old thread I updated this to the latest version (moOde 4.2 07-19-2018)

With the modified files I have  an additional "Amplifier" menu entry . I am using two amps which can be switched On/Off from here.
This happens by two relais connected to the GPIO connectors (I am using a cheap China relais platine for this - connected to GPIO 23 and 24).

Additionaly the amp gets switched off, when music is paused, stopped or muted for more than 5 minutes.
They are switched on again (last amp selection) when the music is resumed.

To use this mod, the attached files have to be replaced and two additional settings have to be added to the moode-sqlite3.db:

Code:
insert into cfg_system VALUES(100, amp-1, Off);
insert into cfg_system VALUES(101, amp-2, Off);

 
The amps name and description of the amps are hardcoded in the footer.php file.
The used GPIOs are set in the gpio.sh file

Maybe it is usefull for others, too.
Download Link


Regards
Hans.

Edit:
added Dropbox link


RE: Modding moOde: Switching amps - Tim Curtis - 07-21-2018

Hi Hans,

I remember this nice mod :-) I was going to try and integrate it and offer it as an option but never got to doing it.

Are you trying to add zip files and how large are they?

-Tim


RE: Modding moOde: Switching amps - Highsider - 07-22-2018

Hi Tim,

I tried, *.zip, *.tar *.txt - even renaming the achive to *.jpg isn't possible.
The size is quite small - 55kB.

This forum software is quite clever :-)


RE: Modding moOde: Switching amps - TheOldPresbyope - 07-22-2018

(07-22-2018, 09:47 AM)Highsider Wrote: Hi Tim,

I tried, *.zip, *.tar *.txt - even renaming the achive to *.jpg isn't possible.
The size is quite small - 55kB.

This forum software is quite clever :-)

Maybe use a cloud service like DropBox, Google Drive, Microsoft OneDrive?


RE: Modding moOde: Switching amps - Highsider - 07-22-2018

Never used Dropbox & co. before.
But thanks for the hint... Dropbox is quite easy to register.
Download link is added at first posting


RE: Modding moOde: Switching amps - Tim Curtis - 07-23-2018

Hi Hans,

Just a heads up that the next moOde update will likely have some new cfg_system rows starting at 100 (there are already 99 rows. Just to be safe I would recommend starting at 200 otherwise the update will will not be able to insert the new rows.

delete from cfg_system where id='100';
delete from cfg_system where id='101';
insert into cfg_system values (200, amp-1, Off);
insert into cfg_system values (201, amp-2, Off);

-Tim


RE: Modding moOde: Switching amps - Highsider - 07-24-2018

Hi Tim,

thank you for the information - i supose, it would have cost me quite some time to figure this out after next update :-)


RE: Modding moOde: Switching amps - Prince - 07-26-2018

Hi guys,

@Highsider: Sorry for hijacking your thread. (Reithalle und Stall, wo die Raspis überall arbeiten :-)

my solution for switching the amplifier is using the popular SONOFF-Wifi-devices with the great Tasmota-Firmware . In my case the Sonoff will power up the Raspberry-Pi and the amplifiers simultaneously. After shutting down MoodeAudio the Sonoff will switch the power off with a delay of 20 seconds. In this time period the RaspberryPi has gone down safely. I wanted a remote hardware button for controlling MoOde and starting/shutting down the Pi, so this is my Tasmota-modification running on a cheap Sonoff-S20-Wifi-smart-switch. The webinterface-modification allows to control moOde rudimentary and own a link to the moOde-webinterface. The Sonoff has only one button, so a multipress function is used. It is nothing big, but maybe an inspiration or useful to someone.

[attachment=2596] [Image: 600px-S20_smart_socket_uk_us_eu_cn.jpg][attachment=2606]
  • 1 long press      -> Booting / Shutting down the Raspberry Pi

  • 1 short press     -> Next / Booting the Pi
  • 2 short presses  -> Previous
  • 3 short presses  -> Mute
  • 4 short presses  -> Pause
  • 5 short presses  -> Play
Tasmota has to be compiled with:
Code:
#ifndef USE_SCRIPT
#define USE_SCRIPT
#endif
#ifndef USE_BUTTON_EVENT
#define USE_BUTTON_EVENT
#endif
#ifdef USE_RULES
#undef USE_RULES
#endif
#ifndef USE_SCRIPT_WEB_DISPLAY
#define USE_SCRIPT_WEB_DISPLAY
#endif


Detach the button from the relay (Tasmota-console-command):
Code:
SetOption73 1


Set some "moOde-like" color-changes (Tasmota-console-command):
Code:
WebColor {"WebColor":["#ffffff","#202020","#202020","#000000","#ffffff","#000000","#ffffff","#ff0000","#008000","#ffffff","#9ab87c","#82a361","#d43535","#931f1f","#931f1f","#9ab87c","#ffffff","#999999","#202020"]}


The used script (for Raspberry-Hostname "moode"):
Code:
>D
tmp=0
mu=0
st=0
pa=0
py=0
p=0
n=0
pw=0
vol=0
but=""

>E
but=Button1#Action

>F
if chg[mu]>0
then
=>WebSend [moode] /command/?cmd=vol.sh mute
endif
if chg[st]>0
then
=>WebSend [moode] /command/?cmd=stop
endif
if chg[pa]>0
then
=>WebSend [moode] /command/?cmd=pause
endif
if chg[py]>0
then
=>WebSend [moode] /command/?cmd=play
endif
if chg[p]>0
then
=>WebSend [moode] /command/?cmd=previous
endif
if chg[n]>0
then
=>WebSend [moode] /command/?cmd=next
endif
if chg[pw]>0
then
if pin[12]==0 {
=>power 1
} else {
=>WebSend [moode] /command/?cmd=vol.sh poweroff
}
endif
if chg[vol]>0
then
=>WebSend [moode] /command/?cmd=vol.sh %0vol%
endif

if upd[but]>0
then

if but=="HOLD" {
if pin[12]==0 {
=>power 1
} else {
=>WebSend [moode] /command/?cmd=vol.sh poweroff
}
}

if but=="SINGLE" {
if pin[12]==0 {
=>power 1
} else {
=>WebSend [moode] /command/?cmd=next
}
}

if but=="DOUBLE"
{
=>WebSend [moode] /command/?cmd=previous
}

if but=="TRIPLE"
{
=>WebSend [moode] /command/?cmd=vol.sh mute
}

if but=="QUAD"
{
=>WebSend [moode] /command/?cmd=pause
}

if but=="PENTA"
{
=>WebSend [moode] /command/?cmd=play
}
but=""
endif

>W
<center><form style="display: block;" action="http://moode/"><button style="font-size : 60px; height:180px; width:320px; background-color: #202020">m<span style="color: #d35400">oO</span>de™<br><span style="font-size : 35px">audio player</button></form></center>
bu(pw "Start/Shutdown moOde™" "Start/Shutdown moOde™")
bu(py "Play" "Play")bu(pa "Pause" "Pause")bu(st "Stop" "Stop")
bu(p "Prev" "Prev")bu(mu "UnMute" "Mute")bu(n "Next" "Next")
sl(0 100 vol "" "VOLUME: %0vol%" "")

moOde-modification: add to /var/local/www/commandw/restart.sh
Quote:if [[ $1 = "poweroff" ]]; then
curl -s -k "http://TASMOTA-IP-ADRESS/cm?user=admin&password=secure&cmnd=Backlog%20Delay%20200%3BPower%20off"
mpc stop
systemctl stop nginx
poweroff
fi


moOde-modification: add to /var/www/vol.sh
Quote:if [[ $1 = "poweroff" ]]; then
        sudo /var/local/www/commandw/restart.sh poweroff
        exit 0
fi

Greetings


RE: Modding moOde: Switching amps - miklau - 09-25-2018

Hi there

This Mod looks very nice Smile I would really like to implement this in my MoOde player. Should i replace all the files with yours from the Dropbox folder to implement/install this? Would I then have to create a new build with that "Stretch" like from the download section on moodeaudio.org? Could I use the automated builder for this or is there a guide anywhere on how to do this please? Not quite sure how it works without the automated builder...

My plan is to use this for a mute function that always pulls a pin when the music is paused (Link to other thread)

Regards Mikkel


RE: Modding moOde: Switching amps - MattOff491 - 10-13-2019

Hi everyone!

Thanks for this mod - I'd really love to see this implemented! :-)

Is this mod still valid for moode
Will it "survive" an update of moode or does one have to manuall re-edit the files?

MattOff491