Hook your Sonos system to IFTTT and control it with the cloud


Badge +1
For those unfamiliar, If This Then That (IFTTT) is a service that lets you hook two internet services together, with the first acting as a trigger and the second as a destination. For instance, you can say IF a new Instagram photo is posted in a certain area, THEN save it to my dropbox folder.

I've written an app that (with some work) hooks a Sonos system to IFTTT. So you can do things like IF someone tweets with a hashtag, THEN speak the tweet through my Sonos, or IF I arrive home, THEN play a specific Sonos Favorite.

It's pretty cool to ponder the neat things you can do with the scores of channels that IFTTT offers.

Check it out, and let me know if you have any questions. And certainly let me know how you end up using it.

If This Then Sonos

This topic has been closed for further comments. You can use the search bar to find a similar topic, or create a new one by clicking Create Topic at the top of the page.

22 replies

Cool! Thanks.
Badge +1
Messing around with recipes, I hooked up my Fitbit scale to my Sonos, and had my weight spoken throughout the house whenever I stepped off the scale.

Quickly disconnected that recipe.
Badge +1
One last note on this hack. Launch Center Pro, a neat action and app launcher for iOS, recently received an update that features IFTTT integration. Naturally, I made actions that start up various Favorites on various Zones. Pretty handy.

Launch Center Pro to Sonos, via IFTTT
Userlevel 4
Badge +14
One last note on this hack. Launch Center Pro, a neat action and app launcher for iOS, recently received an update that features IFTTT integration. Naturally, I made actions that start up various Favorites on various Zones. Pretty handy.

Launch Center Pro to Sonos, via IFTTT


Seems like a pretty big roundtrip to have Launch Center invoke a IFTTT command, which invokes an XMLRPC proxy to talk to your raspberry pi.

Instead of just using the Google chrome support to open url and return to a http action directly on your raspberry pi... 🙂
Badge +1
Seems like a pretty big roundtrip to have Launch Center invoke a IFTTT command, which invokes an XMLRPC proxy to talk to your raspberry pi.

Instead of just using the Google chrome support to open url and return to a http action directly on your raspberry pi... :)


Of course you're right, though I'm not sure what you mean by "using Google chrome support to open url".

A more direct route would be to use LCP to call your sonos-api rest endpoint running on the pi. This was more a proof of concept. You could use Launch Center's extensible actions to do bigger things than simply playing a favorite.
Userlevel 4
Badge +14
Of course you're right, though I'm not sure what you mean by "using Google chrome support to open url".

A more direct route would be to use LCP to call your sonos-api rest endpoint running on the pi. This was more a proof of concept. You could use Launch Center's extensible actions to do bigger things than simply playing a favorite.


The chrome support was the only plausible http request support that I could find according to docs, although I would have expected LCP to have native webhook support. Obviously it has.

I have been experimenting with on{x} on android to achieve similar features. Very handy. For instance, I have the following rule:

When connecting to home wifi:
pause spotify playback on mobile
regroup all players and set predefined volumes
start playback on Sonos instead
Badge +1
OK, Jishi, you'd have to admit that THIS would be useful:

Using today's new Nest Protect Smoke Detector IFTTT channel, you could set up a recipe to announce "Carbon Monoxide detected" on every speaker in the house. That would be pretty cool (except for the whole mortal danger from carbon monoxide part).
Userlevel 4
Badge +14
I didn't mean to sound negative, sorry if I gave that impression :)

IFTTT is a very cool service, and that nest stuff sounds awesome.

It was more the triple round trip through 2 external services that I was skeptical about. Your SMS stuff and other cool interactions that you could create from twitter or whatever using IFTTT is really cool, and opens up a lot of new possibilities, I am sure.

Like song requests during a party through a facebook group/event, autopopulate tracks from last.fm, start playing soundcloud likes (or a new upload from a followed user) directly on your sonos (they expose direct mp3 links but requires a key from your session it seems)
Badge +1
I didn't mean to sound negative, sorry if I gave that impression :)


I know you were just kidding. I was kidding back. I have found a good use for the LCP to IFTTT to Sonos path though. I've got an LCP action that accepts text input, which is then sent to a Sonos to be spoken. I can do this from anywhere in the world, not just in my house. With this, I can remotely yell at my teenager to get out of bed!

I like a lot of the examples you give. So many great ideas out there. I know Sonos is thinking about these too.
Userlevel 2
Hi. I've been working through your set up to try and integrate IFTTT LCP and my Sonos together, but can't seem to get the hang of it. Is there a way to dummy explain it to help me out?
Badge +1
I'll be glad to help, if you can give me specifics of where things are going wrong. In order to spare everyone the long thread, please contact me via the "Contact" page of my site. Thanks!
I'd pay good money for a little device e.g. From a Pii or something that was a bit more plug and play for me to add IFTTT to Sonos. I only have the play 1 but I'm not buying anymore Sonos kit if I can't get IFTTT to work.

Is there a Sonos alternative that supports IFTTT?
The link to the website is dead. Has anyone achieved this solution and can provide details
Userlevel 4
Badge +14
I'm using ifttt with my sonos. Since this post, they've introduced the maker channel which allows you to invoke arbitrary http calls. By having an exposed computer at home, with the appropriate software, you can now trigger actions on Sonos.

I run my own http api, use a dynamic dns service and have mapped a hostnamn with a ssl certificate via let's encrypt for extra security (it's not required).

Primarily I'm using it to apply presets via Amazon echo, which means I can say "Alexa, trigger music" to start playback and "Alexa, trigger bedtime" to pause all players. But any trigger supported by ifttt can be used.

If you skip ssl it is much simpler, but you probably should use some sort of authentication to avoid abuse if someone finds your endpoint. Dynamic dns is also recommended unless you rarely change IP. However, it is not a plug and play solution, never will be. If you don't understand port forwarding, and basic routing, don't try it.

Given that Sonos already introduced cloud control of the sonos system, I however think that ifttt will come eventually.
Thanks jishi for your response. That all sounds great but a little above my experience level I'm afraid. If I can't work it out I guess I'll have to wait for Sonos to catch up.

Thanks
Userlevel 3
Badge +2

Given that Sonos already introduced cloud control of the sonos system, I however think that ifttt will come eventually.


Has Sonos introduced cloud control? I was not aware of this and would be very interested to learn more about it.
Userlevel 4
Badge +14

Given that Sonos already introduced cloud control of the sonos system, I however think that ifttt will come eventually.


Has Sonos introduced cloud control? I was not aware of this and would be very interested to learn more about it.


Not generally available for you as a user, but the Spotify Direct solution is based on cloud control. That's why you can start playing via Spotify Direct, and continue to control it even though you leave your home network (in the Spotify app). It is also evident in the status pages of the players, where it list info about cloud connections (basically, websockets) and what control capabilities it have.
I'm using ifttt with my sonos. Since this post, they've introduced the maker channel which allows you to invoke arbitrary http calls. By having an exposed computer at home, with the appropriate software, you can now trigger actions on Sonos.

I run my own http api, use a dynamic dns service and have mapped a hostnamn with a ssl certificate via let's encrypt for extra security (it's not required).

Primarily I'm using it to apply presets via Amazon echo, which means I can say "Alexa, trigger music" to start playback and "Alexa, trigger bedtime" to pause all players. But any trigger supported by ifttt can be used.

If you skip ssl it is much simpler, but you probably should use some sort of authentication to avoid abuse if someone finds your endpoint. Dynamic dns is also recommended unless you rarely change IP. However, it is not a plug and play solution, never will be. If you don't understand port forwarding, and basic routing, don't try it.

Given that Sonos already introduced cloud control of the sonos system, I however think that ifttt will come eventually.


Hello Jishi,

I am running your API and have a dynamic dns service with all the port forwarding and all configured. I am trying to integrate to Google Home, instead of Alexa, but I cannot get the IFTTT commands to work. The http api server is running and I can control Sonos locally using commands, but cannot via IFTTT. Any recommendations that you can make for me?
Userlevel 4
Badge +14

Hello Jishi,

I am running your API and have a dynamic dns service with all the port forwarding and all configured. I am trying to integrate to Google Home, instead of Alexa, but I cannot get the IFTTT commands to work. The http api server is running and I can control Sonos locally using commands, but cannot via IFTTT. Any recommendations that you can make for me?


Start by verifying that your public endpoint is actually up and running (meaning, test a request against your dynamic DNS name, and some request that you expect to work). You might need to do this over a cellular network or somewhere outside of your LAN, since your router might not respond to traffic for your external IP from within your network.
I did this from work today and the command works externally. I think it must be something in my IFTTT setup.
Userlevel 4
Badge +14
Hm... I have this setup in IFTTT, I'm using HTTPS with let's encrypt and have authentication on (through nginx, but that's irrelevant).

Maker channel, Make a web request: https://username:password@dynamic.host.name/preset/discover
Method: GET
Content Type: application/json
Body: (empty, not necessary)

However, they do occasionally fail for me, according to the IFTTT logs, it says "There was a problem with the Amazon Alexa service"
Userlevel 4
Badge +14
Anyone that is still interested in this, I made it super simple for anyone to get IFTTT support without having to be a hacker. See https://en.community.sonos.com/advanced-setups-229000/easiest-way-to-get-robust-ifttt-support-6790436