A few things you need to do:
in the menu: > 7 Advanced Options > A4 Audio > 1 Force 3.5mm > Save
sudo adduser openhab audio
The first two lines ensure that the 3.5mm plug has precedence.
The 3rd line ensure openhab is allowed to access the audio I/O.
On my old RPi3 (Jessie) this was sufficient.
On my new RPi3 (Stretch) this was not sufficient; I haven’t found the solution yet.
In the openHAB rule I execute the following command:
executeCommandLine("/usr/bin/amixer cset numid=1 100%");
This ensure the volume is set to 100%.
Of course there is another way, but that would be giving in and admitting that we can’t get the internal functionality working. (Where is a good description, that simply works?!?)
Instead of PlaySound() you can install mpg123
sudo apt install mpg123
and use the following command in your openhab rule to play the sound:
Of course I assume you’ll have the sound files (eg, mp3 files) in the default openhab sounds folder.