hassio-addons icon indicating copy to clipboard operation
hassio-addons copied to clipboard

Sync workaround

Open Letrab opened this issue 4 years ago • 5 comments

Hi @kevinvincent,

Thanks for your work on this plugin. Is it still maintained? Would it be possible to share your (pseudo) way of syncing audioClips?

(Would be nice if Sonos would add it to the groups API interface, in addition to players separately)

Additionally it would be nice to be able to support clipType to play the embedded chime sound, as described in https://developer.sonos.com/reference/control-api/audioclip/cliptype/. Happy to make a PR if this is still under development.

I see an interesting PR which could be merged as well.

Letrab avatar Apr 20 '20 11:04 Letrab

Implementing it myself. Will raise a PR when finished/cleaned up

Letrab avatar May 14 '20 06:05 Letrab

Implemented in my own fork. Happy to PR if @kevinvincent agrees: https://github.com/Letrab/hassio-addons

Letrab avatar May 14 '20 14:05 Letrab

Hi I never really got the syncing to work well. Can you point me to where in your fork you added the syncing? Definitely would like to pull it into this.

kevinvincent avatar May 14 '20 17:05 kevinvincent

Ah nevermind I found the method. My toy implementation did the following:

  1. User provides the audio stream url.
  2. Addon downloads the audio file in full to HA first
  3. Addon calls SONOS api but gives it a url to the addon instead of the audio file
  4. The addon runs a webserver and waits for X number of sonos speakers to connect
  5. The addon responds with the audio file at the same time to all the connected speakers.

It worked okay... but a few times there would be a slight delay between two speakers.

kevinvincent avatar May 14 '20 17:05 kevinvincent

See the playClipAll API call. Used the async library to achieve this parallel fetch calling.

You could use this same method for an array of players given in the playerId parameter.

It is not 100% accurate, but in my testing case about 99%, which is highly acceptable for me.

I agree on merging my whole branch. Did not validate on a hass.io setup though, I don't have it...

Many thanks for your work on this. Kick-started me to achieve what I was looking for a long time!!

Letrab avatar May 14 '20 17:05 Letrab