Cannot create AudioDevice

Hi!

I recently got into openhab and am now trying to set up my first rule. Openhab runs on the Raspberry Pi Model B. I simply want a song to play when a Switch is activated. The rule looks as follows:

when
Item InstantParty changed from OFF to ON
then
sendCommand(DiscoMode, 100)
playSound(“What_is_love.mp3”)
end

However, I always get the log
2016-03-26 09:17:35.899 [ERROR] [.o.io.multimedia.actions.Audio] - Cannot play sound ‘What_is_love.mp3’: Cannot create AudioDevice

The song is in the sounds/ folder and I can play it via the terminal directly using omxplayer What_is_love.mp3, so in theory the Pi is able to play it.

The other thing I tried was using the executeCommandLine() method, but I’m not sure what exactly to type there. A simple omxplayer What_is_love.mp3 just gives me the log
2016-03-26 09:21:37.843 [INFO ] [g.openhab.io.net.exec.ExecUtil] - executed commandLine ‘omxplayer What_is_love.mp3’

But nothing happens. I also tried various combinations using the @@ documentation as referred to in other posts.

Any help would be greatly appreciated, as I’m really stumped. Thanks!

The user which starts openHAB has to belong to the group audio. If you installed through apt-get, you have to call once

sudo adduser openhab audio

from commandline.

1 Like

Thanks, I just got that and it worked! Do you happen to know if there is a command to stop the sound that’s being played? Openhab doesn’t seem to have a method call for this, I expect since it’s made for short sounds rather than songs. And even if I did get the executeCommandLine() method to work for me, I couldn’t find a command to stop all audio…

I think there is no such command like stopSound, as you guessed playSound() is mainly used to give short audio signals to notice something, e.g. as a doorbell, an alarmsound or something like that.

To play music I use squeezelite (OSS) and squeezeserver from logitech (CSS) - you can get it for free. However, I don’t use it on the same Machine as openHAB, so maybe this is a bit oversized if you have no other use for squeezeserver - mpd is a small alternative though and works nice at Raspberry Pi. Keep in mind that there are bindings for both squeezeserver and mpd in openHAB. :slight_smile:

Yeah, on my extensive searches I’ve now come acress mpd, though I don’t really get how it will work. Is it possible to have it run on the Raspberry Pi (I’m installing it right now via apt-get) and then access that one song via an openhub mpd binding, even though it’s both running on the same device? Would I just specify the Pi’s IP in the openhab.cgf?
Thank you so much for your time! :slight_smile:

Hi @TomMP I just setup Max2Play ( http://www.max2play.com/en/ ) and integrated it with OH. It works great and is an awesome Squeezserver and client. It should probably run on it’s own PI, but you can try lumping it all together. Integrates nicely with OH. Please see this post, and remember to use lowercase MAC addresses. :wink:
Squeezbox OpenHab Binding issue

Yeah, looks like you need this to run on its own Pi … My new one should arrive tomorrow so maybe I’ll just try that! Thanks :slight_smile:

Hi, if you find the time, I have just a quick question since you seem to have mpd and openhab all set up and working. So I have it downloaded, set the host to localhost and port to 6600. A connection seems to be established, and this is what the mpd.log shows after receiving the play command:

Mar 26 18:06 : client: [1] process command "status"
Mar 26 18:06 : client: [1] command returned 0
Mar 26 18:06 : client: [1] process command "ping"
Mar 26 18:06 : client: [1] command returned 0
Mar 26 18:06 : client: [1] process command "outputs"
Mar 26 18:06 : client: [1] command returned 0
Mar 26 18:06 : client: [1] process command "play"
Mar 26 18:06 : client: [1] command returned 0
Mar 26 18:06 : client: [1] process command "status"
Mar 26 18:06 : client: [1] command returned 0
Mar 26 18:06 : client: [1] process command "status"
Mar 26 18:06 : client: [1] command returned 0
Mar 26 18:06 : client: [1] process command “status”

As you can see, play seems to be in there, but other than that nothing happens :frowning: is there a way to test whether mpd is actually able to play music given the current setup via the command line? Or does the mpd.cfg need any more configuration? Thank you so much!

1 Like

Nevermind I got it to work! I think it was yet another permission problem, but tried out so many things at once that it’s difficult to put a finger on now haha

Hi,

I have a similar issue.

I am trying to play the doorbell sound, via a call to playSound in a rule, triggered my an incoming MQTT publication;

playSound(“doorbell.mp3”)

I have a vanilla OpenHAB install of 1.8.3 via apt-get install on the Raspberry Pi 2. UG and Owner is therefore openhab:openhab.
I added OpenHAB to the audio group. via;

usermod -a -G audio openhab

Though I did try (sudo adduser openhab audio) to cover my bases, but Linux moaned saying openhab was already a member. I checked /etc/group, which showed;

audio:x:29:pi,openhab

Looking good so far.

I triggered the doorbell rule and got the following debug log but no sound;

2016-07-09 09:19:14.688 [ERROR] [.o.io.multimedia.actions.Audio] - Cannot play sound ‘doorbell.mp3’: Cannot create AudioDevice

I know sound works on the Pi as I have played the doorbell.mp3 via PuTTY SSH and omxplayer.

omxplayer /usr/share/openhab/sounds/doorbell.mp3

Any help or pointers would be greatly appreciated.

Regards

Steve

Update

The changed suggested by Jeroen van Bussel on Oct '15 worked


https://community.openhab.org/t/problem-getting-exec-binding-to-execute-command/2872/35

Namely

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
    User=root
    Group=root
    sudo service openhab restart

Regards

Steve

I have the same Error with openhab-docker…how can I resolve it there? Because I can play sounds over the command-line…

Sorry, I’m lost in question of docker, I’m using LXC :slight_smile: