SONOS: notificationsound and TuneIn-Radio

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

4 & 8 yrs,they totally got involved in a discussion with alexa right now :slight_smile:

works peferctly:

I havent implemented every room-setting yet.
Still I lack a solution for playback on all sonos-devices :slight_smile:

One bug in my setup, which I haven’t solved yet. When restarting OH the last string is/could be played. It is probably coming from the persistence-policy “restoronstartup”. Could be a killer for the WAF.

Im using the same policy. already had some not so WAF-situations :slight_smile:

Ive tried your suggestions - learned a lot - but still:
TuneIn still wont recover.

My testing-rule (Ive configured the Sonos in the living-room also as audiosink in paperui for testing the off-slahed line “say(Home_TTS_Message.state.toString,“voicerss:deDE”)” - the output works, but not the resume (SONOS is on the most recent firmware):

rule "TTS Textinput Rule"

        Item Home_TTS_Message changed
        var String AudioSink
        logInfo("TTS_textinput.rules", "Nachricht geaendert zu: "+ Home_TTS_Message.state.toString() + " mit geplanter Ausgabe auf: "+TTS_Ausgabe_Device.state.toString())
        switch(TTS_Ausgabe_Device.state.toString()) {
                case "Alexa": {
                case "Wohnzimmer": {
                default: {
                        logInfo("TTS_textinput.rules", "Unerwarteter Ausgabekanal: "+TTS_Ausgabe_Device.state.toString())

to make it worse:

  1. played a radio station from tunein
  2. used openhab to inject a TTS-message
  3. message was played, no resume of tunein
  4. started a spotify-playlist
  5. used openhab to iniect a TTS-message
  6. message was played and afterwards the playlist resumed
  7. started playeing a radio station from tunein
  8. used openhab to inject a TTS-message
  9. nothing happened
  10. emptied the playlist
  11. used openhab to inject a TTS-message
  12. continue at bullet 3.

Any ideas? Can you reproduce the behaviour?

Problem solved :slight_smile:

It was in the end a problem of my Sonos-configuration, especially the TuneIn-Part.
I deleted all the stations I have added some years ago to “my stations” and favourized them again (I had to remove them by using the IOS-app, the OSX-application did not offer the option).

Works now like a charm :slight_smile:

Thank you all for your support and the additional ideas for improving my setup!

1 Like

…and I just read the first post in that triple and started a recording on my boxes with “Good Morning Alexander”(or should that be …America).

Not need anymore, have fun with it.

Ive stumbled over another problem:
Using the say-command works fine on the Sonos-devices when in a “Sonos-mode”, eg playing TuneIn or Spotify.

A problem occured in my office-room, here the playbar is connected to the TV, the TV is connected to the dockingstation:
Play xyz using the Mac connected to the TV
Trigger TTS on the Playbar using the notificationvolume in the things-configuration
TTS is played on the Player (notificationvolume is used)
Playback from the Mac continues, but with the notificationvolume instead of the former volume

My guess is, that I can catch this by getting the “recentVolume”, playing the TTS and setting the “recentVolume” again, but this sounds a bit inconvenient.

Does anyone of you had a similiar situation and found a workaround?

thx in advance,
cheers, Alexander