How to select audio output device?

  • Platform information:
    • Hardware: Raspberry Pi 3
    • OS: Openhabian 2.2.0-1
    • Java Runtime Environment: openjdk version “1.8.0_152”


I have a USB audio device plugged in and working as a default audio device, ie.

aplay soundfile.wav

works and plays audio through the USB speaker.

USB audio as first audio device:

openhabian@openHABianPi:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: CX100 [Polycom CX100], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 1: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Problem is that OH still plays audio through the 3.5mm jack. Anyone know how to change that?

I think java tends to default to using the default hardware audio device. You need to add the following to the java configuration file which makes it use the default ALSA audio device:

The configuration file on a raspberry pi can usually be found in /usr/lib/jvm/java version/jre/lib

You will need to restart OH after changing the file.


And it works! That’s pretty amazing, I went through a lot of threads but couldn’t find this answer anywhere, awesome :slight_smile:

Hello MikeJMajor, hello autoit,

i have the same problem with my audio device. Could you please tell me the steps, how i ad the config file, because i´m not so the linux crack.
Many thanks


Hello luckymallari,

thanks for the google search links.
The audio out works fine under linux, i tested it with “aplay” and “speaker-test …“
The problem is, under openhab there is no audio output for example …say(””).

Like MikeJMajor said above, just add the code to file /usr/lib/jvm/java version/jre/lib/ and reboot HA.

yeah works! I commented the first set of lines to disable them and then enabled the lines you had above and now sound is playing after a reboot.

Not working for me. My Java installs don’t have JRE folders. I tried placing in lib folder but that did not work. Still sound heading to HDMI monitor that has no speakers. I then found a file in /etc/java-11-openjdk/ and modified it. But still no luck.

Raspberry Pi 4B, latest OS

Default sound from other apps is AV Jack. But OH3 keeps sending to HDMI.

Any other ideas?

I got it working:
using Setting the default device - AlsaProject

This seems to set the default for Java too.