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.
firmware.zip (Size: 901.12 KB / Downloads: 0)
Detach the button from the relay (Tasmota-console-command):
Set some "moOde-like" color-changes (Tasmota-console-command):
The used script (for Raspberry-Hostname "moode"):
moOde-modification: add to /var/local/www/commandw/restart.sh
moOde-modification: add to /var/www/vol.sh
Greetings
@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.
firmware.zip (Size: 901.12 KB / Downloads: 0)
- 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
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