DYI Sonos - play custom messages on Sonos
Great news! From now on, Conrad Connect also supports Sonos products which allows you to use sensors on our platform to control a variety of Sonos speaker functions: change the song, pause/resume playback and control the audio volume.
What’s more, today, we’d like to take things one step further and show you how to achieve even more using Conrad Connect. What about linking your Google calendar to Sonos, and get recommendations for where to go for lunch? Yes, it’s doable. Check out the video below:
Means every time you put a lunch appointment on our calendar, a Sonos voice message script will be activated via Conrad Connect. Pretty neat, right? Particularly if you are still undecided on where you want to have lunch.
Don’t worry, we’ll guide you through the entire setup procedure step by step. If you’ve got some basic Python coding skills, that’s great and helps you with regard to the tutorial. However, you don’t need programming knowledge to set up the system.
The overall procedure looks like this:
- Download the Python script for executing text-to-voice commands on Sonos
- Use the TRIGGERcmd web service to remotely execute the above script
- Connect a Conrad Connect project to Triggercmd via the CC maker channel
Step 1: Download our Python script for executing text to voice commands on Sonos
If you don’t have the Python software installed on your computer yet, get it here. Then download the Python script file created by our team here. However, you will need to download the SoCo library through pip, to make things work. Moreover, you need to replace the IP address that comes with the script with the IP address of your Sonos product (available in the Settings tab of the Sonos App).
Step 2: Use the TRIGGERcmd web service to remotely execute above script
Executing the Python script requires an app that allows receiving a web call from Conrad Connect. In order to do so, either set up a small web server yourself, or use a ready-to-roll solution called TRIGGERcmd which is what we did. This software handles the request and activates a program on your computer. For demonstration purposes, we are using a Windows device.
If you choose TRIGGERcmd, you first need to create an account at https://www.triggercmd.com. Afterwards, install the software on your PC following the guidelines provided in ‘Instructions’.
After installing the software, right-click the GUI Command Editor in the TRIGGERcmd dropdown menu:
Add a new command. Make sure you copy-paste the path to the Python script (see Step 1) into the other form field.
Save the command, go to the TRIGGERcmd homepage and log in. The List menu shows your PC and the triggers available to you. You’ll end up on a page which looks like this:
After that press on the Bookmark Button for your Sonos trigger.
Generate a URL clicking the button. Copy the URL (since needed in Step 3).
Step 3: Connect a project to TRIGGERcmd via the Maker Channel
Go to “Products & Services” and authenticate Sonos by clicking the brand icon.
Create a new project and connect the Google Calendar sensor to the Maker Channel button (N.B. Make sure you authenticate your Google Calendar beforehand. Otherwise it won’t work).
Go to the Maker Channel and paste the URL you generated in Step 2 into the relevant box. Then complete the other fields as shown below.
Done! From now on, your Sonos device will recommend a selection of places you can go for lunch every time a lunch appointment pops up in your Google calendar. By the way, it only takes some rudimental Python programming knowledge to customize the message content by replacing the default text of the Python script (see Step 1) with our own.
Share your thoughts with others on this thread in our community.