Integrate Sonos with Google Assistant through IFTTT

I've been playing around with ways to control my Sonos speakers with voice command for a while now, see here. I recently moved from an iPhone to a Google Pixel XL which brings with it the Google Assistant.

Google Assistant is integrated with IFTTT, so you can use the Maker service to call the node-sonos-http-api running within your network. Here's how.

Sonos API with IFTTT

Ok Google, launch toddler tunes in the kitchen

You will need

  • Google Assistant enabled device
  • Sonos device (any)
  • an always on computer capable of running node.js (RasPi, NAS, Mac/PC)
  • to be comfortable with terminal/command line

    Steps

    1. Setup jishi's node-sonos-http-api on a computer on the same network as your Sonos. A RasPi is a great device for this or run this on your NAS through docker. (I have this running on a QNAP NAS).

    For this to work, computer must be always on and accessible over the web. To find out how to enable this, look for instructions here.

    When you're able to reach http://your-ip-address:5005/zones and get a response back, move to the next step.

  1. Create Favourites or Playlists in your Sonos app
  2. Log in (or sign up) to IFTTT

    • Click on My Applet > New Applet
    • Click on +this
    • Choose Google Assistant as the service
    • Choose Say a specific phrase as the trigger
    • Type in a phrase e.g. launch $ in the kitchen
    • Click on Create Trigger
    • Click on +that
    • Choose Maker as the action service
    • Choose Make a web request as the action
    • In the URL field, enter the sonos-api url as like so -http://your-ip-address:5005/kitchen/favorite/{{TextField}}
    • Choose method Get
    • Click Create Action
    • Click Finish
  3. Say "OK Google, launch classic rock in the kitchen", the favourite "classic rock" should start playing in the kitchen.
  4. You now have limited control of Sonos with Google Assistant.

The difference between this and the Echo integration, is that you can call favourite/playlist dynamically using the applet ingredient define by '$' above.

AThe URL format to follow is http://your-ip-address:5005/{room name}/favorite/{favorite name} or http://your-ip-address:5005/{room name}/playlist/{playlist name}

For other actions such as pause/play the URL format is http://your-ip-address:5005/{room name}/{action}

e.g.

  • Classic rock in the lounge (http://your-ip-address:5005/lounge/favorite/classicrock)
  • Pink floyd in the bedroom (http://your-ip-address:5005/bedroom/playlist/pink floyd)
  • To pause, use a phrase like "living room stop" http://your-ip-address:5005/living room/pause

Checkout node-sonos-http-api for more examples.

How well does it work?

Same conditions apply, if you have a manageable number of devices and have created favourites and playists in the Sonos app, this gives you limited voice control. Similarly, you cannot group or switch rooms as long you have the right triggers created and remember the trigger phrases.

On the plus side, you can pass the favourites/playlists dynamically.