Rule to change volume

OH 3rpi 3b

hi i have a rule from this forum :
rule “volume”
when
Item Volume changed
then
executeCommandLine("amixer sset Headphone " + Volume.state.toString() + “%”)
end

when i upgraded to OH3 i cant use it enymore
from log :
2021-04-12 12:21:42.035 [WARN ] [rg.openhab.core.io.net.exec.ExecUtil] - Error occurred when executing commandLine ‘[amixer sset Headphone 98.0%]’
java.io.IOException: Cannot run program “amixer sset Headphone 98.0%”: error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1128) ~[?:?]
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1071) ~[?:?]
at org.openhab.core.io.net.exec.ExecUtil.executeCommandLine(ExecUtil.java:59) [bundleFile:?]
at org.openhab.core.model.script.actions.Exec.executeCommandLine(Exec.java:40) [bundleFile:?]

someone know what to do to fix it ?

executeCommandLine syntax has changed for OH3,it was advised in the release notes.
There are dozens of posts here about practical examples, most importantly you should use multiple parameters instead of spaces.
https://community.openhab.org/search?q=oh3%20executecommandline

1 Like

thx, and sorry for another topic :wink:

Let us know if you try and fail. It’s not a particularly easy command to sort out.

i try and now it works
executeCommandLine(“amixer”, “set” , “Headphone”, Volume.state.toString +"%")

1 Like