[SOLVED] Change Volume

Hey Guys,

i need your help: i want to change the volume on the RPi throw the openhab Interface. But it still not changing.

Selection item=Sender icon=“radio” mappings=[0=“off”, 1="…", 2="…", 3="…"]
Slider item=Volume icon=“soundvolume”

Number Sender “Radio”
Dimmer Volume “Volume [%.1f %%]”

rule “Volume”
Item Volume received command
if (receivedCommand instanceof PercentType) {
} else {
if (receivedCommand == INCREASE) increaseMasterVolume(20)
if (receivedCommand == DECREASE) decreaseMasterVolume(20)

Where is the error?


I’m changing the volume on my RPi using:

executeCommandLine("amixer set PCM " + NotificationVolume.state.toString +"%")


I changed my rules now in:

rule “Change Pi Volume"
Item Volume changed
executeCommandLine(“amixer set PCM " + NotificationVolume.state.toString +”%”)

But nothing happen. Can you send me your rules please?

I tried with
executeCommandLine("amixer set Headphone " + Volume.state.toString())
But the changes are very small


First, my item is NotificationVolume and I see that yours is Volume. So you should change the executeCommandLine accordingly. I see that your second example uses the right item, but the first one didn’t.
Second, as you can see, the volume is set in percent, so, if you Volume has states of 1, 2 and so on you can multiply the value by 10 or change the mappings to 10, 20, etc.

Now it works! Great, thank you!

One question:
The slider is at the moment in the middle, but the alsamixer shows -53,44db and 11. It should be by 50 or not?

Not sure about that.
Running amixer on my Pi shows:

Simple mixer control 'PCM',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 17152
  Front Left: Playback 1201 [7%] [4.69dB] [on]
  Front Right: Playback 1201 [7%] [4.69dB] [on]

And, if you do the math, 1201 is 7% from 17152 (max value).
As I’m not quite expert on Pi & sound I cannot explain you further.

do you use a separate soundcard?

Can you send me your config for alsa?

Try listing the controls your Pi has:

amixer scontrols 

Then use the info you got from that command to issue this command. Example:

amixer sset 'Master' 50%

So your rule will now be

executeCommandLine("amixer sset 'Master' " + Volume.state.toString() + "%")

don’t forget the percent sign

i have tried this. This is the result:

root@raspberrypi:/home/pi# amixer scontrols
Simple mixer control ‘PCM’,0
root@raspberrypi:/home/pi# amixer sset ‘PCM’ 100%
Simple mixer control ‘PCM’,0
Capabilities: pvolume pvolume-joined pswitch pswitch-joined
Playback channels: Mono
Limits: Playback -10239 - 400
Mono: Playback 400 [100%] [4.00dB] [on]

I think nothing changed

I see it’s on 100% already

But the screenshot from Mihai looks different.
I’m using a RPi 3 B

hi sorry im dig it :wink: i used this rule for long time but now when updated to openhab 3 when i try to use it log file says “cant find coomand” if i use command form terminal i can change volume