PDA

View Full Version : Control vol with script on RPI squeezeslave, need help



TheD6Bel
2014-03-07, 00:33
hello,

I want to control the volume with buttons, I bought this keyboard (http://www.audiophonics.fr/audiophonics-clavier-controle-xbmc-raspyfi-htpc-p-8435.html) to test but it does not work on squeezeplug only on xbmc (and work very well on xbmc)

So I thought connected to the GPIO buttons and launch scripts. On the WIKI (http://wiki.slimdevices.com/index.php/SqueezeSlave), there are commands to control the volume but I can not do it when i send command i have errors.

Does someone can help me to create scripts to control the volume + / - and power if possible (not for the command on the wiki)

Big thanks for your helps ;)

mherger
2014-03-07, 00:51
> I want to control the volume with buttons, I bought this 'keyboard'
> (http://www.audiophonics.fr/audiophonics-clavier-controle-xbmc-raspyfi-htpc-p-8435.html)
> to test but it does not work on squeezeplug only on xbmc (and work very
> well on xbmc)

If I understand this correctly, that device acts like a keyboard
connected to the computer, right? In this case the keys are only
evaluated by the application running in the foreground. Squeezeslave is
running in the background, thus the keys won't work directly.

> So I thought connected to the GPIO buttons and launch scripts. On the
> 'WIKI' (http://wiki.slimdevices.com/index.php/SqueezeSlave), there are
> commands to control the volume but I can not do it when i send command i
> have errors.

I have no idea about how to interface with GPIO. But if you can trigger
scripts using it, then you simplest solution might be sending some CLI
commands to the controlling LMS. See
http://yourserver:9000/html/docs/cli-api.html#mixer%20volume

Your script would basically have to send a command like this over telnet
to port 9090 of your LMS (netcat can do that iirc):

04:20:00:12:23:45 mixer volume +10

Power is similar. Just check the CLI documentation.

--

Michael

TheD6Bel
2014-03-07, 04:42
thanks for reply ;)

but when a star putty telnet on my squezeeplug ip, putty stop and close, i go make a new install of squezeeplug and try again for telnet connection

i try the keyboard on picoreplayer and is same problem don't work :(

mherger
2014-03-07, 04:52
> but when a star putty telnet on my squezeeplug ip, putty stop and close,
> i go make a new install of squezeeplug and try again for telnet
> connection

you'd have to telnet into port 9090 of your LMS, not the machine running
squeezeplug (unless it's the same, of course).

> i try the keyboard on picoreplayer and is same problem don't work :(

piCorePlayier is running the same squeezelite software player. The
keyboard will only work with an application running a user interface in
the foreground, waiting for keyboard input. squeezelite is running in
the background as a daemon.

--

Michael

TheD6Bel
2014-03-07, 11:51
for picoreplayer, je pensais, I thought, as it is a special distribution that was not running in the background

squezeeplug don't have telnet fonction, i install and try command to night or tomorow ;)

DJanGo
2014-03-07, 12:14
Hi,

not a big deal but a bit suboptimal...

With the wiringPi lib some phytonscripting and a NC command to the playercli its not that Big Deal.

i didnt have your keyboard so i cant write a script 4 u - just find out which Ports its using and wrap some code around...

http://wiringpi.com/reference/priority-interrupts-and-threads/


cheers

TheD6Bel
2014-03-07, 12:22
now is working

telnet 127.0.0.1 9090
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
b8:27:eb:53:6f:47 mixer volume +10

now i need make 3 script for 3 buttons +5 -5 -100(for mute) and find how run script when i touch button ;)

mherger
2014-03-07, 13:42
> now i need make 3 script for 3 buttons +5 -5 -100(for mute) and find how
> run script when i touch button ;)

You'll need netcat (http://netcat.sourceforge.net), which will allow you
to run a simple one-liner:

echo "00:04:20:.... volume +5" | nc -i 1 yourserver 9090

--

Michael

TheD6Bel
2014-03-07, 14:33
Big thanks for your helps it's work perfectly, a little bit slow but works ;)

echo "b8:27:eb:53:6f:47 mixer volume +5" | nc -i 1 127.0.0.1 9090

TheD6Bel
2014-03-09, 14:10
Hello,

i make 3 script

volplus10.sh


#!/bin/bash
echo "b8:27:eb:53:6f:47 mixer volume +10" | nc -i 1 127.0.0.1 9090


volmoins10.sh


#!/bin/bash
echo "b8:27:eb:53:6f:47 mixer volume -10" | nc -i 1 127.0.0.1 9090


and mute.sh


#!/bin/bash
echo "b8:27:eb:53:6f:47 mixer volume -100" | nc -i 1 127.0.0.1 9090


after, script to read my 3 button:

boutons.sh

#!/usr/bin/env python
from time import sleep
import os
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN)
GPIO.setup(22, GPIO.IN)
GPIO.setup(23, GPIO.IN)

while True:
if ( GPIO.input(17) == False ):
os.system('bash /home/pi/script/volplus10.sh')
inputval = GPIO.input(17)
sleep(0.1);
if ( GPIO.input(22) == False ):
os.system('bash /home/pi/script/volmoins10.sh')
inputval = GPIO.input(22)
sleep(0.1);
if ( GPIO.input(23) == False ):
os.system('bash /home/pi/script/mute.sh')
inputval = GPIO.input(23)
sleep(0.1);
sleep(0.1);

now i need start automaticly this script on boot AND TRY :D
i don't have now button and no have idea for resistors, I continue my research