Notificationsound - Sonos Binding - OH2

As a noob, I’m trying to figure out how to make my Sonos play a doorbell mp3 file, that I share on a webserver on my RPI at //192.168.1.90/share/doorbell.mp3.

I have read the binding documentation.

Here I stumble on the following under binding configuration:

callbackUrl - Callback URL - URL to use for playing notification sounds, e.g. http://192.168.0.2:8080

I also found the following which looks to be exactely what I need:

All supported Sonos devices are registered as an audio sink in the framework. Audio streams are treated as notifications, i.e. they are fed into the notificationsound channel and changing the volume of the audio sink will change the notificationvolume, not the volume. Note that the Sonos binding has a limit of 20 seconds for notification sounds. Any sound that is longer than that will be cut off.

The only thing I’m missing is some help under the “full example” :slight_smile:
How to utilize:

  • notificationsound String Play a notification sound by a given URI ?
  • notificationvolume Dimmer Set the volume applied to a notification sound ?

What to write in things, items and sitemaps? And what if I want a rule to make my Sonos play the doorbell sound whenever a physical switch is pushed?

Can someone provide a simple guide on this, and maybe update the binding documentation sometime in the future?

Thanks in advance :slight_smile:

/K

The correct documentation for audio is here: http://docs.openhab.org/configuration/multimedia.html
You should have setup your Sonos players with OPENHAB via PaperUI.

Using PaperUI you can link also the .NotificationVolume.
Then setup one of your players as default audio sink.
After that the examples from the docs page will play the doorbell.mp3 which is saved by OPENHAB, not the one in your folder.

Thanks for your quick reply. I come from OH1, still as a noob. Thought that PaperUI did not yet support advanced stuff and only simple play, pause, playing, etc.

I will have to look into the link you provided and try to figure it out.

Still it would be great with a step by step guide, as more are probably trying to make a doorbell using Sonos, when working with OH for starters.

Hi

this is my setup

item part

String Playuri_Sonos_Stue { channel="sonos:PLAY1:RINCON_949F3E13BE9201400:playuri" }

Rules part

rule "Nicolai afsted til bussen "

when
      Time cron "0 10 7 ? * MON-FRI"
	   
then 
      sendCommand(Playuri_Sonos_Stue, "//192.168.0.75/Musik/alarm/nicolaibus.mp3")

end

this rule plays nicolaibus.mp3 every day MON-FRI at 7.10 but you can use this

when
        Item Doorbell<your doorbell swith> changed from OFF to ON

Read through that post: Sonos ... Audio Sink ... Say?
I think you’ll all info needed there.

Thanks Paulmann and Opus.

I think I’ve got what I need for now. I’ll be giving it a try and get back with the results very soon.

1 Like

Ok - great progress has been made. When I’m finished and it’s all working, I’ll produce a simple how-to guide.

I’m using the IHC binding, as my doorbell pushbutton is attached through my Intelligent House Control.

I have now done the following, but I’m one step away from success:
Manually created a default.items file containing the following

Switch IHC_Ringetryk {ihc=“<0x1D5B5A”}

Manually created a default.sitemap file containing the following

sitemap default label=“My House” {
Frame label=“Test” {
Switch item=IHC_Ringetryk
}
}

Manually created a default.rules file containing the following

rule “IHC_Ringetryk”
when
Item IHC_Ringetryk changed
then
if(IHC_Ringetryk == ON){
// gør ikke noget
}
else {
sendCommand(IHC_Ringetryk,OFF)
}
end

Added my Sonos as a thing i Paper UI.
Linked the notificationvolume and set it to 80% under controlpanel
Added the rule engine (experimental)
Created a rule

When… IHC_Ringetryk changes to ON
Then… Play a sound…notificationsound…doorbell.mp3

When I test run the rule in Paper UI, it all works fine. When I push the button on my Android app it all works fine. When a track is playing on my Sonos and the notificationsound is triggered, the music track is paused, the doorbell.mp3 is played, and afterwards the music track is resumed. Success!

But when I push my physical button at my house, Karaf logs a change in states, going from OFF to ON and back but nothing happens…no rule is triggered, no sound is played? Any clues?

That should be IHC_Ringetryk.state==ON, I think.
Why do you have code only in the following ELSE branch? Additionallythe code you run there doesn’t make sense ( why send command OFF to the item when it is OFF, why even send a command???)
There is no way to sayi f the rule is triggered unless you have something in each branch (IF or ELSE)!
I’d use a

logInfo(“IHC_Rntryk”, " IHC_Ringetryk.state: {}", IHC_Ringetryk.state)

in each branch, that way the log will show which branckh was run!

I found that if my Paper UI rule is set to “state changed to ON” instead of “command send ON”, then it seems to work. That way I also don’t need my default.rules entry anymore.

More testing is needed, but a lot of progress has been made these two days.

Thanks again.