Say and playsound on webaudio plays sound twice

I’m running openhabian stable 2.3 on my Raspberry. My audio default sink is configured to Webaudio. While trying to play a sound via say or playsound I get the audio twice with a random gap between the start of the first and second ranging from 0-5 seconds.

simple example:

rule "test trigger"
    Time cron "0 0/1 * * * ?"   // every minute
   // playSound("barking.mp3") // test for double played sounds
    say("hello world")

The log file says once every minute:
2018-07-29 22:52:27.130 [arthome.event.PlayURLEvent] - Play URL ‘/audio/f0677304-0516-4f9c-b181-42f34702b87b’.

Could someone please give me a hint how to find out why this is happening?

Thanks in advance

Using your posted rule my system does say the text every minute only once.

I’ve seen this happen if I have multiple browser tabs open that have some kind of UI for OpenHab2 running.

IE, quite often I’ll have HabPanel and PaperUI open.

I could be wrong, but I assumed that both tabs were playing the audio.

1 Like

Multiple UIs running, but in the posted case the “say” command was triggered by a cron-rule, no UI involved!


Where do you think the say or play commands are coming from in my use case?

I quite often use say commands directed specifically at the WebAudio sink as a way to debug rules.


you are right. I can confirm this behaviour. I had PaperUI and HabPanel open and the sound was played twice. After closing PaperUI the sound is played only once.

Thanks for the hints.

1 Like

I’m far from questioning your observings, however having PaperUI, habpanel and BasicUI open while the above rule was triggered did NOT play the sound more then once on my system.
I would think a rule with a trigger related to a UI item COULD cause this, having that with a cron trigger sounds like a bug to me. IMHO that should be reported as an issue on github.

For the sake of completeness, I tested having Habpanel open on two PCs, same behaviour, both open browser tabs are playing the sound.

My goal is to change the string value of an item that holds the name of the sound to play (i.e. AnswerMachine), and that works pretty good. But I dont want it to play on any open Habpanel, but just on the one that triggered the itemchange, so it would be very helpfull if there was a way to inject an ID or something like that to the say/playsound to identify the specific webaudio sink.

I completely missed that point! Me stupid!
In this case, it is not a bug!
And I do not think you can specific the device for webaudio.

1 Like

These wouldn’t happen to be Android tablets that you’re using / want to use?

This might be an option -

It speaks the text sent in a HTTP request, or plays a locally stored file.
The developer wrote this for me to do something similar for a client, before I discovered OpenHab2


Have you looked into the http remote control side of VLC.

It’s reasonably easy to format a HTTP request that gets VLC to play a track , stream or playlist.

The only rediculous issue I had was that with security on, VLC requires (or did with V2.0) a NULL username (IE complete blank) and a valid password.

Thanks for the hints. TTS ist not an option bc i want to play the recordings of my answermachine. So I’ll give vlc a try

My mistake, I thought you only wanted to play an alert tone in each terminal.

So, yes, VLC might be the way forward for you.

Please do update this post with your success story, I for one would be very interested to know how you get on.

Version 2.0 of VLC can be set not to require user credentials for HTTP access.

I don’t know if they have resolved the null username issue in any recent versions as I stopped updating once I got a working solution :wink:

Hey .

I’ve just thought of a solution :slight_smile:

Within HabPanel, it’s possible to set an Item that is ‘read aloud’ whenever it changes.

So you could…

Setup an Item for each instance, then just send your announcement to that item, instead of WebAudio :slight_smile:

(I’ve tried it, it does work)

Good luck :smile:

Hold on, maybe not, as that’s not what you want to do… You wanted to play an audio file :frowning_face:


That said…

(And for reference, I have no idea how to achieve the following, as I’m a wires / hardware chap)

Is there a way to write a widget with a simple media player that links to an Item, so that when a file path is written to the OH Item, the media player then plays it?

There seem to be loads of JavaScript media players :slight_smile:

I think i’ll try to use the html5 player. i have a working example but havn’t integrated that into a widget yet.

<audio id="player" src="test.wav"></audio>
<a href="#" onclick="document.getElementById('player').play()">Play</a>

and sound files need to be in the static html folder

I’ll keep you updated when it’s working.

1 Like

I like what you’ve done there :slight_smile:

Purely for the crack, I had a hunt around the internet and played with what I found…

FYI, I copied doorbell.mp3 from /etc/openhab/sounds into the /etc/openhab/html folder

This works, but I have no idea how to vary the sound file, or build it into a widget.

I look forward to seeing what you come up with :smile:

<!doctype html> <html> <head> <meta charset="ISO-8859-1" />
<title>Auto play doorbell.mp3</title>
<EMBED SRC="doorbell.mp3" autostart="true" width=0 height=0 >


Now here’s an observation (remembering that I’m a wires guy, not a programmer, so anything I can make work in software feels like I’ve won a lottery)

If I create a SymLink from within the html folder of /etc/openhab/html like this

ln -s ../sounds sounds

Then the following html page also works…

<!doctype html> <html> <head> <meta charset="ISO-8859-1" />
<title>Auto play barking.mp3</title>
<EMBED SRC="sounds/barking.mp3" autostart="true" width=0 height=0 >


Is it possible to create a SymLink to a folder on another machine / drive that holds your answering machine messages?

00:20 late night ramblings… Feel free to ignore the following…

As the html file is tiny, is there a way to use an Exec Binding command to send the voicemail file name into a script that recreates the entire file into the html folder, for HabPanel to call when a (monitored) item changes?

Something like…

rule "new VM"
Item New_VM_Filename changed



and the command line script looks something like this…

#Usage :- --value={voicemail filename (& path)}

#Output will be a file called new_vm.html with the path to the voicemail file

while [ "$#" -gt 0 ]; do
  case "$1" in
  -v) value="$2"; shift 2;;
  --value=*) value="${1#*=}"; shift 1;;

  --value) echo "$1 requires an argument"
>&2; exit 1;;
  -*) echo "unknown option: $1" >&2; exit 1;;
  *) handle_argument "$1"; shift 1;;
echo $value
echo $(date +%F" "%T),$value >> new_vm.log

# recreate new_vm.html file from two halves of a donor 

rm new_vm.html
touch new_vm.html
cat new_vm.donor1 >> new_vm.html

echo $value >> new_vm.html

cat new_vm.donor2 >> new_vm.html


Where new_vm.donor1 looks like this

<!doctype html> <html> <head> <meta charset="ISO-8859-1" />
<title>Auto play barking.mp3</title>
<EMBED SRC="sounds/

And new_vm.donor2 looks like this

" autostart="true" width=0 height=0 >


It’s only WORKING ! :smile:

I have only tried it by swapping between

./ --value=doorbell.mp3


./ --value=barking.mp3

then refreshing a web browser, but that’s good enough for me right now :slight_smile: