The local UPnP-based API used in the built-in Sonos integration does not (seem to) have access to all features developed by Sonos. One example of this is their audioClip API. This API allows you to play a short audio clip over the currently playing music without needing to go through the snapshot/restore dance. The music volume is lowered to allow the clip to be heard, and then automatically restored when the clip is finished. It’s a much simpler and nicer experience.
Unfortunately this is only available via their cloud-based API which requires registration of an app through their developer website, can only use publicly-accessible audio files, etc. It’s also likely not supported on every device, but all of mine on S2 currently work.
It’s still in the (very) early development stages, but I wanted to share some testable code since the feature has been so useful to me already.
Note: this is not intended to replace the built-in Sonos integration, but to work in tandem. As of now it creates duplicate media_player entities which can accept media_player.play_media service calls. That’s it. If I’m able to figure out how to call this using the local API then this project will be abandoned basically immediately.
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):
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.
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 .
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.
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
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?
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:
But I can’t restart, my config is 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!