Control your TV (and other devices) with Alexa

Logitech recently updated their Alexa skill to simplify voice commands, instead of saying "Alexa, Ask Harmony to Turn on the TV" you say Alexa, Turn on the TV. This is great and I love the Harmony remotes but I've had a similar setup running for a few weeks now, and much cheaper.

My solution uses a Broadlink RM Mini 3 wifi enabled IR remote. For less than 1/5th the price of a Logitech Harmony Hub in Australia, you can achieve a surprising amount of automation with devices that have an IR receiver. You'll also need an Android device, perhaps a phone, or a TV box. You could potentially run this setup off of an Android emulator like Andy or KOPLAYER but I haven't tried that, so you're mileage may vary. The last piece of the setup is Broadlink RM Plugin from the Google Play store.

You'll need to setup the Broadlink RM Mini to connect to your home wifi (using the official e-Control APP. Don't configure any devices or remotes in this app).

Once setup, Broadlink RM Plugin should be able to see your RM Mini 3 on the network this is where the fun begins. This app allows you to open an HTTP bridge and if you have enough time, you could create a skill with custom intents to have Alexa respond to any phrase you’d like.

Or, enable the Alexa bridge and have your devices become available to Alexa.

Like the Logitech Harmony app, you can control a single command or chain multiple IR device commands together to create complex macros. e.g. I have a command set for "Kids TV". ON saying, Alexa, turn on Kids TV, my TV is switched on, the app waits for 21 seconds to allow the TV to connect to my wifi, sends the SmartHub command, waits 1 second, send the "Right" direction command and "Select" to launch Plex. This gives me enough time to fetch the TV remote from under the couch to play my kids' favourite "Paw Patrol" episode. And when the episode is over, say "Alex, turn off TV" and boom! no more running from the kitchen to turn off TV before the next episode auto plays. I have a more complex macro setup for my Xbox to launch the Foxtel app, watch TV and a few simple ones to mute Sonos or go to a certain TV channel.

This is one of my very few setups where the WAF is extremely high, no complex commands to remember, unlike my Sonos & Alexa integration, which I’m the only one who uses in our household.

There's only one downside so far that I've found, the commands aren't customisable, so to mute/unmute my speakers, I have to say Alexa, turn on mute or Alexa, turn off mute.

I've been thinking of getting the Broadlink remote with IR/RF which perhaps I could use for controlling the garage door with voice commands & geolocation using IFTTT or through Tasker. e.g. when I enter a geolocation, open the garage door, or if my phone connects to my home wifi, open the garage door.

Creating an Alexa skill for tracking chores

My son loves talking to Amazon Echo, and now he can ask Alexa what his chores are.

This is still in the test phase, not in the Skills store yet. The roadmap I'm working on -

  • Adding/Tracking chores through a mobile app
  • Adding chores through Echo
  • Marking chores as done through Echo
  • Notifications to mobile app when chores marked done
  • Reminders when chores missed
  • Gamification - Stars & Achievements for completing chores, linked to a goal/reward

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.

How to integrate Amazon Echo and Sonos

Sonos is a fantastic product, the speakers sound great and no one has done multi-room audio better. Having said that, it does have a minor annoyance - the Sonos app. It does a decent job of managing the connected services and speakers, but searching for and playing music sometimes involves too many steps.

So when Sonos announced integration with Amazon Echo late 2016, I immediately bought an Echo Dot. Echo devices are not officially supported in Australia, so to setup there was some 'hackery' involved but process wasn't difficult. Since the announcement howerver, owners of these devices have been waiting for the Sonos/Echo integration without an official word on timeline.

So, if like me, you are too impatient for the beta to drop and want to control your Sonos speakers with voice commands right now, here are a few options.

Option 1: The Easy Option

You will need

  • an Amazon Echo Dot
  • Sonos Play:5
  • 3.5mm male-to-male audio cable

Steps

  1. Plug one end of the audio cable into the Play:5 and the other end into Echo Dot. For best results, keep them at-least 3ft apart, further the better.
  2. Using the Sonos app, set the Play:5 to line-in and enable AutoPlay
    • Launch the Sonos app on your phone or tablet, tap the menu in the top left corner
    • Scroll to the last option in the menu, tap on Settings, tap on Room Settings
    • On the next screen, tap the Sonos device that your Echo Dot is plugged into (for example, mine is named Kitchen)
    • Tap Line-In
    • Tap Autoplay Room and select the name of your Sonos device
  3. That's it, all audio from Echo Dot will now streams through your Sonos speaker.

How well does it work?

As long you're operating within the confines of music services supported by Amazon on the Echo, you'll be happy. Voice commands to control music only work if you have Spotify or Amazon Prime music.

You do not get control over your Sonos music integrations, so if you have Apple Music, Google Play Music or any other non supported service, this is not the best option.

You also cannot group or switch rooms.

Option 2: Sonos API with IFTTT

Alexa, trigger big beats in the kitchen

You will need

  • Amazon Echo (any)
  • 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 Amazon Alexa as the service
      • Choose Say a specific phrase as the trigger
      • Type in a phrase e.g. big beats 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/bigbeats
      • Choose method Get
      • Click Create Action
      • Click Finish
    3. Say "Alexa trigger big beats in the kitchen", the favourite "bigbeats" should start playing in the kitchen.
    4. You now have limited control of Sonos with Alexa.

Follow the above steps to create applets for each favourite/playlist that you want to trigger through Alexa.

The 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?

Surprisingly well, provided you have a manageable number of devices and have created favourites and playists in the Sonos app. You also cannot group or switch rooms as long you have the right triggers created and remember the trigger phrases.

The downside is that it's not dynamic, i.e. you have create a trigger for every action you want to perform which can and will get messy.

Option 3: Connecting with an Alexa Skill

Alexa, ask Sonos to play playlist history of rock

You will need

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

Steps

This is based on Ryan Graciano’s echo-sonos repository where he has provided very clear instruction on how to set this up. But before you start, below are the steps at a high level of what you'll need to do.

  1. Setup jishi's node-sonos-http-api on an always-on computer accessible over the web.
  2. Create a free Amazon Developer account.
  3. Create an Alexa Skill (this will not be published and will remain in test mode)
  4. Configure the AWS Lambda servers to talk to the Alexa Skill and your home server running the Sonos API.
  5. You're done.

These steps above are an oversimplification, it took me over an hour to do and I know may way around the command-line. Just remember, if something doesn't seem like it's working, you can just wipe it all out and start again. When you get it working, rejoice - you've just achieved voice control over your Sonos system.

How well does it work?

Extremely well. The ability to say, “Alexa, tell Sonos to play playlist history of rock in the kitchen” or “Alexa, tell Sonos to add the lounge to the kitchen.” is pure bliss, and it mostly works.

Everything is configured dynamically, the zones, playlists, favourites and you can also group or switch rooms.

I highly recommend setting this up So, head over to rgraciano's echo-sonos repository and follow the instructions. If you run into trouble, let me know at @tchdhry, I may be able to help you out.