OpenHAB PlaySound


I’m now trying to set up rule that play same mp3 when an event happened. Openhab runs on the Raspberry Pi 2. The rule looks as follows:

rule "Test_ON"
Item Flag_1 changed from OFF to ON
sendCommand(Flag_2, ON)

rule "Test_OFF"
Item Flag_1 changed from ON to OFF
sendCommand(Flag_2, OFF)

It’s works fine but sound not play. At first I was getting an error - “Cannot play sound FireAlarm.mp3: Cannot create AudioDevice” .

Then I found this tip:

JeroenJeroen van Bussel:

1> /etc/default/openhab - change to root (USER_AND_GROUP=root:root)
2> /usr/lib/systemd/system/openhab.service

  • change user and group inside the file
  • systemctl daemon-reload
  • systemctl start openhab

and after that the error does not appear, but the file still does not sound. Which way to look?


You first will need to set up an audio sink. It’s fairly easy and well explained here:

Thanks, Oli!

I use RP2 for OpenHAB and there are already installed audio sinks:

openhab> smarthome:audio sinks

and it’s play sound by command on the console to the server sound interface:

openhab> smarthome:audio play doorbell.mp3

Then I defined the default audio sink to use in conf/services/runtime.cfg

My rules file here:

rule "corLightOn"
Item Flag_1 changed from OFF to ON
sendCommand(Flag_2, ON)

rule "corLightOff"
Item Flag_1 changed from ON to OFF
sendCommand(Flag_2, OFF)

The available options for

I could not find.

But I do not get sound on mobile devices nor on the web interface.

Ok, so you want to play the sound on the Webbrowser/the app(Android/iOS).
If your test playing on the server itself was OK, maybe you should check if your remote devices can play sound in general?

Obviously, the browser needs to be opened and have a compatible openHAB UI running. Currently, this feature is supported by Paper UI and HABPanel.


Thanks, rossko57!

You’re right, when I used the classic web interface and on Windows PC Firefox browser I had a sound. But in Firefox or Safary on the iPad or Android tablet, there is no sound (of course, the sound volume on the tablets is enabled), but in this case, the sound appears in parallel on the on the Win PC.

Hi @vismart

just a suggestion regarding your upper post: do not put root as User and Group in your service file. It’s not necessary to run OpenHAB as root, and you actually do not want to.

Try to limit processes to a minimum, that run as root. A bug or harmful code could have much impact to your system otherwise.

supported by Paper UI

maybe you mean Basic UI ? which based on googles paper material design web interface ?


I’ve a problem with playSound and webaudio. My Openhab is running on a Raspi 3. Only when I use Chrome on a Win10 PC I can hear the sound, with all other browsers ( Edge, Firefox and Safari on Ipad) I can’t hear it.
Anyone any idea?

Same problem here, with chrome it also works on a tablet with android, if that maybe helps.

Has anyone found a solution which works with other browsers?

Hi again. Currently I have the same issue and I have not been able to find a solution.

Has anyone found how to play a sound from the server on safari, in an iPad with Habpanel? It only works in a windows 10 computer with Chrome.