Behind the Sonos Integration with Yonomi

yonomi behind the integration-sonos.jpg

A Brief History on Sonos and Yonomi

Sonos has always been one of our most popular integrations -- but you might not know it's also one of our earliest. Yonomi has been supporting Sonos devices in one way or another for over 5 years now -- and was one of the first integrations we launched. So when Sonos launched their official "Works with Sonos" certification program in 2017, Yonomi was right there and one of the very first home automation apps to officially support Sonos.

We've always gone to great lengths to offer support and valuable features for Sonos products to our users For a time, we were the only 3rd-party solution to automate Sonos devices and control them remotely. This meant that, for a period of time, Yonomi was the only way to control your Sonos devices via Amazon Alexa and Google Assistant -- something that is still true in certain regions now.

Over time, Sonos has increasingly improved its support for developers and changed control methodologies. Yonomi originally integrated with Sonos unofficially via UPnP, then local WebSockets, and now finally supports a cloud-based HTTP API.

Why the New Sonos Cloud API Matters

We were very excited to hear of Sonos’ decision to release cloud API’s for a few reasons. Moving away from local area network (LAN) control gives users the freedom to operate their devices remotely and removes dependency on a LAN to communicate messages. This was a pain point due to varied network setups, device interference, and intermittently broken links. Any one of those reasons can cause a break in the communication chain resulting in lost commands. Transmitting messages through the cloud significantly increases reliability and efficiency.

Like with our Philips Hue integration, we’ve taken care to provide backward compatibility for existing users who already depend on our existing local integration. The Yonomi mobile app supports controlling a device via multiple routes -- in this case via local WebSockets or via the cloud-based HTTP API. Users can connect the new Sonos Cloud account in Yonomi and continue using their existing Routines without having to reconfigure all their settings.

Using Sonos Groups API and Improving User Experience

Most third-party integrations we’ve built are for devices that work as individual pieces reacting on triggers. These devices are not designed to interact with each other - but rather to directly respond to a user request. Sonos’ core advantage is that their speakers can be grouped together and talk to each other. Working this feature into Yonomi while keeping the user experience intuitive was very important to our team.

In this integration, we used the Sonos Group API to accurately make and break groups at the user’s whim. When a user wants to play the same item to multiple speakers, we use that item as the grouping indicator. We take stock to see if the group already exists, otherwise, we create the group and then pass along the play command. The key point here is that we break out the needed speaker/s from the existing group/s keeping the remaining members intact. This requires us to make multiple API calls to Sonos and do some involved data processing on our end.

Today, we can accomplish all of this within a significantly shorter time frame since we no longer rely on a LAN. The Yonomi mobile app interfaces with Yonomi’s backend, which in turn passes on a message to Sonos who can directly command the speaker. This is the only chain used to communicate messages, eliminating all the LAN specific nuances and enabling us to respond in a consistent time-frame for every request.

Hallelujah for Subscriptions

With this integration, we also have the luxury of subscriptions. Earlier, Sonos offered no mechanism to automatically receive state updates. When a user viewed a Sonos device in the Yonomi app, we’d make a real-time call to Sonos to get updates. This step added latency to our workflow and required the user to wait for the refresh to complete. With subscriptions, we asynchronously receive updates by providing a webhook to Sonos and subscribing to specific device updates such as favorites, playlists or group changes, therefore, eliminating the latency experienced.

What’s Next for Sonos and Yonomi

Along with the successful release for our Yonomi App customers, our Sonos integration may become available on our Yonomi One platform as well, allowing service providers to build innovative new solutions on top.  We continue to work on adding additional features that come as a part of the cloud-based HTTP API, including support for triggered Events made possible through subscriptions, and exciting new actions like announcements, sound effects, and more.

As always, our Sonos + Yonomi integration will continue to get better and better.  Stay tuned!


About the Author

Sheena is a backend engineer for Yonomi One and works on new integrations, core functionality and feature development. She has seven years of experience in web application development comprising mostly of cloud based software. Sheena graduated from the University of South Florida with B.S and M.S. in Management Information Systems.


Are you building a service or app for your industry?

Check out our Guide to Building a Smart Home Service to learn more about what it takes to get started.

Download Free Guide