SONOS: notificationsound and TuneIn-Radio


I’ve got some problems with the method “notificationsound” while SONOS is playing radio from TuneIn.
While notificartionsound delivers, when I’m listening to eg Spotify (Track is paused, Volume changes to NotificationVolume, Sample is played, Volume is restored and Track continues) it works.
While listening to a radio-station from TuneIn just nothing happens.

I also tried “notificationsound” with SONOS just playing nothing and an empty playlist: here the notificationsound also works as supposed.

I started playing around in a sample-rule, eg by using the “tuneinstationid”-method to circle in on the problem, but still without a success.

Does anyone of yours had a similar problem and was able to solve it?

Thanks in advance,



Thing sonos:PLAYBAR:RINCON_5CAAFD16124201400 "Sonos Playbar (Arbeitszimmer)" [udn="RINCON_5CAAFD16124201400", refresh=60, notificationVolume=100]
Thing sonos:PLAY1:RINCON_949F3E72A57C01400 "Sonos Play:1 1/2 (Arbeitszimmer)" [udn="RINCON_949F3E72A57C01400", refresh=60, notificationVolume=100]
Thing sonos:PLAY1:RINCON_949F3E72A61201400 "Sonos Play:1 2/2 (Arbeitszimmer)" [udn="RINCON_949F3E72A61201400", refresh=60, notificationVolume=100]
Thing sonos:PLAYBAR:RINCON_B8E9377F8BB501400 "Sonos Playbar (Kinderzimmer)" [udn="RINCON_B8E9377F8BB501400", refresh=60, notificationVolume=100]
Thing sonos:PLAY1:RINCON_949F3E07EAEA01400 "Sonos Play:1 (Badezimmer)" [udn="RINCON_949F3E07EAEA01400", refresh=60, notificationVolume=100]
Thing sonos:CONNECT:RINCON_B8E9379B6FD401400 "Sonos Connect (Wohnzimmer)" [udn="RINCON_B8E9379B6FD401400", refresh=60, notificationVolume=100]


Group  Sonos "Sonos Soundsystem" <"speaker-black"> (Home)

Group WZ_Sonos (Sonos)
Group AZ_Sonos (Sonos)
Group KZ_Sonos (Sonos)
Group BZ_Sonos (Sonos)

Group:Number:AND Sonos_Coords (Sonos)
Group:Dimmer:AVG Sonos_Volumes (Sonos)

String Sonos_Summary "Sonos [%s]"

String Sonos_CONNECT_Wohnzimmer_Add                     "Add [%s]"                  <sonos_add>          (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:add"}
Switch Sonos_CONNECT_Wohnzimmer_SetAlarm                "Set Alarm"                 <sonos_alarm>        (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:alarm"}
String Sonos_CONNECT_Wohnzimmer_AlarmProperties         "Alarm Properties [%s]"     <sonos_alarm_prop>   (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:alarmproperties"}
Switch Sonos_CONNECT_Wohnzimmer_AlarmIsrunning          "Alarm is running"          <sonso_alarm_run>    (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:alarmrunning"}
Player Sonos_CONNECT_Wohnzimmer_Control                 "Control"                   <sonos_control>      (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:control"}
String Sonos_CONNECT_Wohnzimmer_CurrentAlbum            "Album [%s]"                <sonos_album>        (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:currentalbum"}
String Sonos_CONNECT_Wohnzimmer_CurrentArtist           "Artist [%s]"               <sonos_artist>       (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:currentartist"}
String Sonos_CONNECT_Wohnzimmer_CurrentTitle            "Title [%s]"                <sonos_title>        (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:currenttitle"}
String Sonos_CONNECT_Wohnzimmer_CurrentTrack            "Track [%s]"                <sonos_track>        (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:currenttrack"}
Switch Sonos_CONNECT_Wohnzimmer_Shuffle                 "Shuffle"                   <sonos_shuffle>      (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:shuffle"}
String Sonos_CONNECT_Wohnzimmer_Repeat                  "Repeat [%s]"               <sonos_repeat>       (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:repeat"}
String Sonos_CONNECT_Wohnzimmer_Favorite                "Favorite [%s]"             <sonos_favorite>     (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:favorite"}
Switch Sonos_CONNECT_Wohnzimmer_Led                     "Led"                       <sonos_led>          (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:led"}
Switch Sonos_CONNECT_Wohnzimmer_LocalCoordinator        "Local Coordinator"         <sonos_coordinator>  (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:localcoordinator"}
Switch Sonos_CONNECT_Wohnzimmer_Mute                    "Mute"                      <sonos_mute>         (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:mute"}
String Sonos_CONNECT_Wohnzimmer_NotificationSound       "Notification Sound [%s]"   <sonos_notification> (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:notificationsound"}
Dimmer Sonos_CONNECT_Wohnzimmer_Notificationsoundvolume "Notification Sound Volume" <soundvolume>        (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:notificationvolume"}
String Sonos_CONNECT_Wohnzimmer_PlayPlaylist            "Play Playlist [%s]"        <sonos_playlist>     (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:playlist"}
Switch Sonos_CONNECT_Wohnzimmer_PlayQueue               "Play Queue"                <sonos_que>          (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:playqueue"}
Number Sonos_CONNECT_Wohnzimmer_PlayTrack               "Play Track"                <sonos_play_track>   (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:playtrack"}
String Sonos_CONNECT_Wohnzimmer_PlayURI                 "Play URI [%s]"             <sonos_play_uri>     (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:playuri"}
Switch Sonos_CONNECT_Wohnzimmer_PublicAddress           "Public Address"            <sonos_publiv>       (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:publicaddress"}
String Sonos_CONNECT_Wohnzimmer_Radio                   "Radio [%s]"                <sonos_radio>        (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:radio"}
String Sonos_CONNECT_Wohnzimmer_Remove                  "Remove [%s]"               <sonos_remove>       (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:remove"}
Switch Sonos_CONNECT_Wohnzimmer_Restore                 "Restore"                   <sonos_restore>      (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:restore"}
Switch Sonos_CONNECT_Wohnzimmer_RestoreAll              "Restore All"               <sonos_restore_all>  (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:restoreall"}
Switch Sonos_CONNECT_Wohnzimmer_Save                    "Save"                      <sonos_save>         (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:save"}
Switch Sonos_CONNECT_Wohnzimmer_SaveAll                 "Save All"                  <sonos_save_all>     (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:saveall"}
Number Sonos_CONNECT_Wohnzimmer_Snooze                  "Snooze"                    <sonos_snooze>       (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:snooze"}
Switch Sonos_CONNECT_Wohnzimmer_StandAlone              "Stand Alone"               <sonos_stand_alone>  (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:standalone"}
String Sonos_CONNECT_Wohnzimmer_State                   "State [%s]"                <sonos_state>        (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:state"}
Switch Sonos_CONNECT_Wohnzimmer_Stop                    "Stop"                      <sonos_stop>         (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:stop", autoupdate="false"}
Dimmer Sonos_CONNECT_Wohnzimmer_Volume                  "Volume"                    <soundvolume>        (WZ_Sonos,Sonos_Volumes)  {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:volume"}
String Sonos_CONNECT_Wohnzimmer_ZoneGroupID             "Zone Group ID [%s]"        <sonos_zone>         (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:zonegroupid"}
String Sonos_CONNECT_Wohnzimmer_ZoneName                "Zone Name [%s]"            <sonos_zone>         (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:zonename"}
String Sonos_CONNECT_Wohnzimmer_Coordinator             "Coordinator [%s]"          <sonos_coordinator>  (WZ_Sonos,Sonos_Coords)   {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:coordinator"}
Number Sonos_CONNECT_Wohnzimmer_SleepTimer              "Sleep Timer"               <sonos_sleep_timer>  (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:sleeptimer"}
String Sonos_CONNECT_Wohnzimmer_CurrentAVtransportURI   "AV transport URI [%s]"     <sonos_uri>          (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:currenttransporturi"}
String Sonos_CONNECT_Wohnzimmer_CurrenttrackURI         "track URI [%s]"            <sonos_uri>          (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:currenttrackuri"}
String Sonos_CONNECT_Wohnzimmer_tuneinstationid         "TuneIn Station [%s]"       <sonos_tuneinid>     (WZ_Sonos)                {channel="sonos:CONNECT:RINCON_B8E9379B6FD401400:tuneinstationid"}


rule "Sonos Test Rule"

        Item GF_Sonos_Test changed
        if (GF_Sonos_Test.state == ON) { //
                logInfo("sonos_test.rules", "Sonos-Test spiele Notification")
                if (Sonos_CONNECT_Wohnzimmer_tuneinstationid.state === NULL) {
                } else {
                        logInfo("sonos_test.rules", "Sonos-Test spielt Radio - Sonderbehandlung")
        } else {
                logInfo("sonos_test.rules", "Sonos-Test spiele Sound")

I’ll be honest and say that I’ve only played with one Sonos unit at a client’s home, just to see what could be done with OpenHab2.

We used the Play & Say commands in rules for notifications.

If memory serves…
He was listening to a TuneIn station.

It stopped.

Played the notification

Returned to the TuneIn station.

I hope that helps you.



Alternatively the playSound() function can be used in DSL rules:

playSound("doorbell.mp3", 25)
playSound("sonos:PLAY5:kitchen", "doorbell.mp3")
playSound("sonos:PLAY5:kitchen", "doorbell.mp3", 25)



In order to use text-to-speech, you need to install at least one TTS service. Once you have done so, you will find voices available in your system:

openhab> smarthome:voice voices
mactts:Jorge Jorge (es_ES)
mactts:Moira Moira (en_IE)
mactts:Alice Alice (it_IT)
mactts:Ioana Ioana (ro_RO)
mactts:Kanya Kanya (th_TH)

You can define a default TTS service and a default voice to use either by textual configuration in conf/services/runtime.cfg or in the Paper UI in Configuration->System->Voice .

In order to say a text, you can enter such a command on the console (The default voice and default audio sink will be used):

openhab> smarthome:voice say Hello world!

Alternatively you can execute such commands within DSL rules by using the say() function:

say("Hello world!")
say("Hello world!", 25)
say("Hello world!", "voicerss:enGB")
say("Hello world!", "voicerss:enGB", 25)
say("Hello world!", "voicerss:enUS", "sonos:PLAY5:kitchen")
say("Hello world!", "voicerss:enUS", "sonos:PLAY5:kitchen", 25)

You can select a particular voice (second parameter) and a particular audio sink (third parameter). If no voice or no audio sink is provided, the default voice and default audio sink will be used

1 Like

Hi Stuart,

thanks for the advice!
“PlayURI” (or TTS) is my last ressort :slight_smile: It will work, but also will increase the lines of code, while the notificationsound-method delivers very convenient in two of my three recent usecases (Spotify and no playback).



Why PlayURL?

If you use the playSound command it will reference sound files in your
/etc/openhab2/sounds folder

Like the default
doorbell.mp3 & barking.mp3

I’m sure you’ll find a solution now :slight_smile:

Good luck


Because playURI is the only way right now to make Sonos stop the playback of a radio-station using TuneIn.
Notifications just dont work without using workarounds.

Accessing the samples by using http:// or smb:// is no problem.


That’s odd.

I’m certain that I only used the playsound & say commands at my clients place a few weeks ago to get his Sonos to interrupt the radio station he was listening to and I’m sure it continued when the notification finished.

We had to define the Sonos device as the audio sink in the command, but I’m sure I didn’t spend much time trying to get it working.

I can call him in the morning to confirm if you’d like me to.

I’m sorry to hear that you’re having to create a work around.

I’ve also always just used the playSound("doorbell.mp3") without any problems, seems like the easiest to use. I have to admit though I’m not sure I ever got visitors while listening to radio (I don’t do that very much). I have tro try that out when I get home from work :slight_smile:

1 Like

:slight_smile: I’m pretty sure it’s also in my situation a usecase which won’t happen often, if at all.
I just cannot stand to have something not work as it is supposed to (probably) :-).

1 Like

Completely understandable. After all, you’re in a community full of home automation nerds here :wink:

I forgot to check my doorbell and now my kids are about to sleep, but I’ll get back tomorrow…

1 Like

My standard use case for Sonos is playing a radio station and I’m using the say-command in a rule to notify ( my guests/kids If breakfast is ready). That is working without any problem, radio stops, sound is played radio resumes.

You are using audio-sink? I have not figured out yet to use all of my sonos-devices (6) as an audiosink.

Yep, works for me too. It took like 15 seconds after the doorbell sound before radio resumed though…

1 Like

I’m sure there are other ways to get the sink id that you need, but these instructions helped me / my client.

Additionally, certain bindings register their supported devices as audio sinks, e.g. Sonos speakers.

To check, which audio sinks are available, you can use the console:

openhab> smarthome:audio sinks

Your list will include all of your Sonos devices that you’ve previously added.

If you’re talking about the Sonos grouping stuff, it’s worth searching this forum as I’m sure I’ve read posts about how to group and ungroup, or at least other people’s experiences :smile:

Yes, all my Sonos Boxes are setup via PaperUI, therefore they are identified as an AudioSink and can be selected on PaperUI as the default sink for example.
I’m using a rule like (although the useage of NotificationVolume is still as in the older version of the Sonos Binding ) :

val Number NotificationVolume = 20
rule "SagEtwas"

  Item SayCommand received update
  var String AudioSink
  switch AudioSink {
    case Lautsprecher.state.toString=="Küche" : AudioSink="sonos:PLAY1:RINCON_B8E937E0C16201400"
    case Lautsprecher.state.toString=="Wohnzimmer" : AudioSink="sonos:PLAY1:RINCON_B8E937BDEF0E01400"
    case Lautsprecher.state.toString=="Büro" : AudioSink= "sonos:PLAY1:RINCON_949F3E7D2EF401400"
    case Lautsprecher.state.toString=="Gästezimmer" : AudioSink= "sonos:PLAY1:RINCON_B8E937E0C14201400"
  gPlayer_NotificationVolume.allMembers.filter(s | s.state!=NotificationVolume ).forEach [item | item.sendCommand(NotificationVolume)]
  logInfo("SayCommand","Es ist alles gesagt!")

The item “Lautsprecher” holds a string with the human readable name of the box, the item SayCommand holds the string that should be said. The “Lautsprecher” gets gets selected on a HABPanel dashboard as well as the “SayCommand” string gets set on there.


As a curve ball, would you chaps be interested in something like this idea of a message announcement…

As I don’t own any Sonos kit, I can’t say if they will return to previous playing media.
ChromeCasts don’t :frowning_face:

This is actually pretty cool, as I was thinking about a pattern to pass arguments to my rules. Also was going to use an item, but did not know yet I can change items like String to a custom value (eg typing something in) from the Dashboard :slight_smile:

One question regarding audiosinks - the last time Ive checked all my Sonos-Device where listened, but it was a single-select. Is it possible to define a group of sonos-things as audiosink?
As far Ive checked your solution you change the audiosink on the fly by passing a string.

I had the idea two years ago when Ive installed my first SONOS-device (no OpenHAB then).
As I remember it is possible, when you have a SONOS-device with line-in (like the CONNECT).
SONOS can push the line-in signal to all SONOS-devices (I did not follow up with the idea, because the WAF as not as good :-)).
But connecting a quite typical bluetooth-audio-receiver to the line in of the CONNECT + an app on your smartphone which is passing the audio-input from the phone to the bluetooth speaker should suffice (imho).

1 Like

I’m not not using my boxes in groups when passing those notifcations (execpt for the two paired as stereo couple).
And on the fly looks like:

very nice! Ive already implemented the solution suggested here:

And wrote a quick and dirty Alexa-based rule (Kida are going mad :slight_smile: ).

How did you achieve it in habpanel?

That’s the code in my widget.

<div class="form-inline">
  <div class="form-group">
    <input type="text" class="form-control" no-snap-drag="true"
           ng-model="myvalue" ng-value="itemValue('SayCommand')"></input>
    <button type="button" class="btn btn-primary"
           ng-click="sendCmd('SayCommand', myvalue)">Sag es!</button>
  <div class="btn-group" uib-dropdown>
  <button id="single-button" type="button" class="btn btn-primary" uib-dropdown-toggle>
    {{itemValue('Lautsprecher')}} <span class="caret"></span>
  <ul class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="single-button">
    <li role="menuitem"><a ng-click="sendCmd('Lautsprecher', 'Küche')">Küche</a></li>
    <li role="menuitem"><a ng-click="sendCmd('Lautsprecher', 'Wohnzimmer')">Wohnzimmer</a></li>
    <li role="menuitem"><a ng-click="sendCmd('Lautsprecher', 'Gästezimmer')">Gästezimmer</a></li>
		<li role="menuitem"><a ng-click="sendCmd('Lautsprecher', 'Büro')">Büro</a></li>

… although my kids are old enough to pull the power plug :face_with_raised_eyebrow:

1 Like