i running openhab on raspberry pi 3
I’m trying to play sound from mp3 file
i create this rule:
rule "Audio Test"
Item test_mp3 changed from OFF to ON
pressing the switch play no Sound !
if i run the command via linux cli ( omxplayer barking.mp3), it play sound no problem
if i change the audio setting in Default Sink from “system speaker with mp3 support” to “web audio”
it play sound on my browser no problems
What i’m doing wrong ?
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.
You should also se java
sound.properties - see this post: How to select audio output device?
That did the trick for me.
Strangely enough I’m very sure that I didn’t make that change on the old RPi (with OH2.0 instead of 2.2 and Jessie instead of Stretch).
I think a good next step is to get this from the community area into the documentation area.