Sonos Cloud API - Better alerts & TTS

It seems like the custom component hasn’t loaded, so your sonos_cloud entry in the configuration isn’t considered valid. Comment that out, restart, and ensure the component is loading. You’ll see something like this in your log if it’s working correctly:

We found a custom integration sonos_cloud which has not been tested by Home Assistant.

If not, you may want to ensure the custom component files contain the correct content.

2 Likes

Thanks so much for your super quick response - I got it working. I did what you said - commented out the config.yaml entry (which for me meant disabling the file in my package). Then I could restart, and the component did load. I re-enabled the config. I could see the integration, but could not add it - it didn’t think it was ready to set up. I restarted again, and then I could add the component and authenticate. Have quickly tested using Dev Tools - this is absolutely brilliant, now I can do TTS and not lose my Spotify queue! Thank you so much for developing this! :star:

Now to go update a bunch of TTS automations… :slight_smile:

1 Like

@jjlawren Any suggestions on getting S1 vs S2 clients into this integration or choosing a location? I can connect successfully but it only adds my single S1 device (which is at my office at work) and none of my S2 devices (all at my home). Maybe prompt the user to select a household as documented here: https://developer.sonos.com/build/direct-control/discover/

This only works with Sonos v2 devices I think. Is that as expected ?

I have two accounts on Sonos , one with my v1 players and another with my v2. If I log into my V2 account I see all those v2 players and TTS works. If I log into my v1 account again I see all my v1 players but TTS doesn’t work at all.

It’s only supported on speakers which report the AUDIO_CLIP capability, which I’m not currently validating. That shouldn’t be difficult to add.

I don’t think it’s a S1 vs S2 thing, but based on the capabilities of the speaker hardware itself. For example, the docs report that Play:1 speakers do not support the feature. The One, Amp, Play:5 (gen 2), Beam, One SL, Move, and Symfonisk lamp/bookshelf are all supported.

Edit: It works fine on Play:1 speakers in my own testing.

Right now it just chooses the first “household” if multiple are available (e.g., separate S1 and S2 setups in the same location). I only have one myself, so that feature didn’t make it into the initial release.

It should be easy enough to add players from all available households. I’ll make an update and push a new release.

I’ve updated the custom component to version 0.0.2:

  • Support multiple households for multiple locations or split S1/S2 setups
  • Validate the AUDIO_CLIP capability for players and warn if a given speaker is not supported
1 Like

Interesting … it’s a Play1 that didn’t work for me…. Will see if 0.0.2 offers it as supporting AUDIO_CLIP

It would be really nice if I could load two instances of the integration. One for my S1 account and one for S2. Is that really awkward ? Actually I have two HA systems so could split this over the two. S1 on one and S2 on the other.

I don’t have a split S1/S2 system. I was under the impression they could exist under the same Sonos account. Is this not true?

Thanks for getting that so fast! I didn’t get prompted to choose which household but the one that was selected was the one I wanted. One household is all S2 and the other (at work) is on S1 software. Not sure if that helps fore adding features but works great for me now. Much better solution than all the snapshots, play, restore I was doing before!

They can coexist but they get considered separate households (at least in my case).

Great. As of 0.0.2 it will attempt to add speakers from all households linked to the Sonos account. Previously it just assumed there was one household.

I have a really stupid question…

What do I need to do to have HACS aware of this?
I have had it installed manually for some time now but see it is now available directly through HACS. Do I need to remove and reinstall it?

It was just recently added to the default HACS repo list. I’m not sure of the proper way to migrate. In my local setup, I removed the custom repo from HACS, restarted, and then re-installed the integration via HACS.

1 Like

Not sure if you fixed it or not but all I did was tell HACS to download the file (without removing the old one first) and it just overwrote the existing folder with the new contents. And HACS is also happy with doing it like that too.

1 Like

I’m not sure where else to post this. I can’t get the tts.cloud_say part to work with this. I was able to use it successfully with a local sound and the built-in chime.

I’ve been using this custom addon for a long time, which works great in general. Not only does it attempt to sync the sound across multiple devices, (which it’s pretty good at, especially given how many speakers I have across the house), but it used to work with the Nabu Casa tts.cloud_say as well.

Sometime in the last few months, it stopped working with cloud_say. It still works with normal Google translate, and custom sounds I have hosted on my setup.

I thought switching to this component might work, and I like that it’s easier to use (no rest commands), but I can’t seem to get it to work with cloud_say either.

Has something changed in how the cloud_say setup recently that could be breaking it? I can’t see any errors in the log, I just never hear anything.

TTS in HA works by downloading/caching an audio file from the TTS service, and then serving that audio file from your HA instance to the media player. Is the local sound that still works hosted by your HA instance or on a different host? I would think that if the audio file works when served by HA, then TTS should also work.

You may also need to validate your base_url config for the NC TTS service. I noted this briefly in the known limitations in the readme, but I’m not sure that description is totally accurate. That setup works for me, however.

If there are other SSL certs in play here, you may want to make sure your CA is supported by the Sonos speakers themselves. Sonos publishes a (somewhat limited) list of CAs that they package in their firmwares. They also have suggestions for things to check in case failures occur.

1 Like

Thank you! I thought it was picking up the external URL using the external_url property within HASS, and I didn’t see that bit about base_url at the bottom of the docs.

What’s crazy is it used to work without issue (using the add-on), it only stopped working recently. But I was able to test that tonight, and had no issue. It even fixed the add-on for me, so now I have both solutions!

I’m not sure exactly how the add-on works, but it definitely has some magic to try to synchronize the speakers when playing a sound on multiple ones. It works well enough that I can ring my doorbell on all speakers (that’s 11 zones) and it’s only slightly out-of-sync.

Anyway, thanks for this great component, this is a lot easier to integrate for performing room-specific announcements.

You can try to call all the speakers in the same cloud_say/play_media service call (just list all the media_player entities). The Sonos API only allows to call one speaker at a time and doesn’t provide any way to group/synchronize, but that will call the endpoint repeatedly and should get playback to start at approximately the same time on all of them.

I think I was mistaken. I thought the developer had added some minor hack in to try to synchronize them externally, but looking through to docs & code there, I don’t see anything that is doing anything special.

I can’t test broadcasting the sounds right now (it’s late, and my daughter is asleep), but I’ll give it a shot tomorrow. (I’m excited because this will make it much easier to have a smarter doorbell that only chimes in certain rooms at certain times.)