Sonos Cloud API - Better alerts & TTS

Right now the TTS integration doesn’t pass extra parameters through. Should be possible to add that feature with a core PR, though.

1 Like

PR? :slight_smile:
Not sure if you mean on my site or on your addon

I mean a pull request on HA core. Supporting the volume param via TTS requires a new feature in the existing HA TTS integration(s).

Edit: Pass through extra dict from TTS to media_player.play_media by jjlawren · Pull Request #53630 · home-assistant/core · GitHub

1 Like

It looks like it’s working great so far.

the only question is is there support somehow for getting the tts/mp3 synchronized across all speakers if playing to multiple?

Right now it’s just slightly off.

If it could be synchronized like the sonos groups it would be pretty much perfect!

:grinning:

Unfortunately their API only allows you to target a single speaker (unless I’ve missed something). Faking it by calling it multiple times is the “solution” for now.

I’m not quite clear on what you mean by “calling it multiple times” but this works pretty well and there is only a slightly out of synch result (at least in the limited quick testing I did):

  notification_sonos_cloud_tts_all:
    alias: Sonos Cloud TTS 
    sequence:
      service: tts.cloud_say
      data:
        entity_id:
          - media_player.sonos_cloud_diningroom
          - media_player.sonos_cloud_kitchen
          - media_player.sonos_cloud_living_room
        message: "Hello there"

Unless you were meaning something different?

No, that’s exactly what I meant. That service call will actually make three separate calls to the Sonos API, one for each speaker. It’s almost in sync because it’s being called quickly in succession.

It would be nice (but is not currently possible) to be able to target the group to play across all speakers in sync with a single native call.

1 Like

OK, thanks for confirming it’s the best workaround.

And thanks for creating this.

I saw both yours and the other one at about the same time after recently reading the other thread after just getting my brandy-new Sonos One SL’s :slightly_smiling_face:.

i wasn’t sure which was going to work better but after looking a bit deeper at both of them yours seems WAY easier to set up (since I don’t use add-ons) and is actually maintained.

I’m really surprised this thread hasn’t gotten more attention, TBH. :man_shrugging:

Thanks again.

3 Likes

So am I but I just found it so that’s one more :slight_smile:

However…

I seem to have failed at the first hurdle as I don’t have a ‘Sonos Cloud’ integration available to add

image

I have the copied the files and added the entry to config (and restarted).

image

sonos_cloud:
  client_id: !secret sonos_cloud_client_id
  client_secret: !secret sonos_cloud_client_secret

You should see a message like this if the custom component is found:

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

If not, are there any other references to sonos_cloud in your logs?

Edit: Since there’s a __pycache__ directory in there, it implies to me that it’s been loaded at least once.

Yes, it is loaded, I have that message in my logs.

2021-09-16 16:12:26 WARNING (SyncWorker_7) [homeassistant.loader] We found a custom integration sonos_cloud which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

Any chance forcing a reload of the frontend in your browser fixes it?

Doh…
That did it.

How many times will that one catch me out?

Thanks, now to experiment…

Well that went well!

Amazingly simple.

I’m really surprised this thread hasn’t gotten more attention, TBH. :man_shrugging:
:wink:

2 Likes

Does this mean you think it might be at a later date?

And also, I just tried playing a TTS to a speaker in a group playing music. It seems to have faded the music on the whole group before playing the TTS on the single targeted speaker.

Is this intended or just a (current?) limitation to fade the whole group?

Both appear to be current limitations (or expected behavior) of the Sonos audioClip API.

As mentioned here it’s possible to send the same request to multiple speakers, but they will not be perfectly synced.

1 Like

I have no idea why I can’t get this working…I must be missing something obvious to everyone but me!

All files are in place, have put necessary sections in configuration.yaml and secrets.yaml:

sonos_cloud_dir

sonos_cloud_config

But I can’t restart, my config is invalid:

invalid

I do have my config broken up into packages, but even if I try to put the relevant section directly into the configuration.yaml file, it still can’t find the integration.

I can’t add the integration on the config page because it isn’t there. I’ve cleared my cache multiple times.

I would appreciate it very much if another set of eyes can see what I am missing - thank you!

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/