Sonos Grouping

@JDogg016 - I could really use your help. I am struggling with Sonos and Hubitat. When I group speakers in the Sonos app, they seem to ungroup when I play an announcement through RM.

The other thing that happens is that sometimes after playing the announcements, they will continue playing the music (or radio station they were playing previously. While other times this doesn't happen.

Hubitat also doesn't provide any way to play my favorites on Sonos, so I took your advice and installed node-sonos-http-api. I can get all the basic commands to work on each of my two Sonos speakers individually, but I am completely lost on how to group them.

This is my settings.json:

{
  "all": {
    "playmode": {
      "shuffle": true
   },
   "players": [
     {
       "roomName": 'Master Bedroom',
       "volume": 15
     },
     {
       "roomName": 'Living Room',
       "volume": 15
     }
  ],
  "pauseOthers": true
}
}

Could you please tell me how to modify my settings.json so I can control both speakers with a single http command, so music plays synchronously on both.

Thank you very much!

One thing to note when using Sonos groups guys.

When you use an app (rm?) to ‘speak’ to the speakers.. only configure it for the ‘master’ of the group.
If you select more than 1 speaker, it will split the group.

I have had my group stay together for a number of months now by only sending tts to one of the group.

Andy

3 Likes

Are you insisting the Sonos api?

I don't know what that means - illustrating my naivette.

@JDogg016

I guess what would really help is seeing a sample configuration file and an example http command to send to a group of speakers.

Many thanks!

Sorry. Auto correct. I meant are you using the Sonos API. I don’t recall doing Anything withRespect to the config.json file.

So I have a rule that triggers after certain events that use my kitchen Sonos. The point of the rule is to regroup two speakers in Sonos by sending the following command:

http://[IP Address of Sonos API Server:5005]/Kitchen%20Overhead/join/Kitchen%20TV%20Speaker

@Cobra @JDogg016

Thanks a lot - I got this figured out with your help. First off, I've stopped sending commands to both of my Sonos. Second, after I start playing something on one, I can "join" the other if necessary.

Works great!

1 Like

How do you group 3 speakers together?

1 Like

Same as two, you send a 2nd HTTP command with the other speaker name. Just make sure you join it to the same master as you joined the first one to.

1 Like

It would still be a better solution to create the ability to create a group in HE instead of yet another connected device. I had a thought about how to actually create a rule to use Sonos groups I have created in Alexa but so far none of my IFTTT tricks has worked!

Most people use a local Node.js server with the following Node.js app

It works very reliably without going out to the cloud. In rules, you can send HTTP commands to this node server to group or ungroup

I hear you about the native support, I know it has been requested before, I am not sure how high it is on the priority list....

Ok. So I can have two http statements to put three SONOS into a group! That's great. Is there a way to use the presets.json to achieve the same thing?

1 Like

If you find one, could you share it? Many thanks!

Are you trying to speak on ALL Sonos players? The node-sonos-api also offers the "sayall" endpoint and uses it's internal TTS. It will join all the players to a group and restore the original state after the TTS was spoken.

Just an alternative.

I haven't used the presets.json, but I'll take a look at the documentation

So here is a http command that I send to node-sonos-api with a preset:

http://192.168.10.63:5005/preset/{"players":[{ "roomName": "Office", "volume": 15},{"roomName": "Outside", "volume": 25}]}

This joined the two players that I have specified there. I am sure you can also put that JSON into a preset file and call it by name. This made my Office speaker the master. Basically the first one will become the master

I just created a preset file called group.json that is stored in the preset folder and has the following content

{"players":[{ "roomName": "Office", "volume": 15},{"roomName": "Outside", "volume": 25}], "state": "stopped"}

It creates the group and also leaves it in a "stopped" state, meaning nothing is playing.
You can then send a HTTP command

http://IP/preset/group

and it does the grouping for you

EDIT: BTW, the presets.json is deprecated and you should use individual files in the preset folder.

2 Likes

My thought is that I could probably remove the Sonos app from HE if I can get a few of these things down. I'm trying to use the preset to group the speakers and then play a news feed from radio.com. I think I'm about ½ way there. I created a preset called news.json:

{
"players": [
{
"roomName": "Bedroom",
"volume": 20
},
{
"roomName": "Office",
"volume": 20
},
{
"roomName": "Kitchen",
"volume": 20
}
],
"favorite": "localNews"
}

Update: This works! Thank you @dan.t for the favorite tip. It's working great. Now I'll just put that in my RM app and then another one to pause it.

One interesting quirk is that with the player, even though the stop button is pressed, the Sonos App and the devices in HE still show them as playing.

There are a few ways to do that but in all my playing I found the following as the most reliable:

  1. In the Sonos App, search radio.com for the station you want to play
  2. Click that little arrow next to the station and add it to your Sonos favorites.
  3. Give it an "easy" name in your favorites. With easy I mean easy from an HTTP perspective (e.g. no blanks or special characters)
  4. Call the following HTTP endpoint to play the station:
    http://[IP]/[ROOM]/favorite/[FAVORITENAME]
    e.g.: http://192.168.10.63:5005/Office/favorite/Mix1041

This has been working flawlessly for me for months.

I think you can also call the favorite within the preset with the entry:

  "favorite": "my favorite name",

but I have never tried that

I have not observed that but I only open the Sonos app to make favorites.
I use my MagicCube to control my Sonos and play/stop my favorite stations and control volume

I finally removed the Sonos App from HE. Now I have a virtual button which sends an HTTP GET http://IP_address:5005/pauseall and that stops things. I'm really loving the Node API solution. Well done.

1 Like