0

I've built a home automation system that is currently being used by many customers. The home automation system consists of a central hub which always connected to a cloud server and also it controls various node devices.I've also developed a mobile app to control home devices remotely.

Now I want to add a voice control functionality to my system.I think Amazon Alexa is the perfect choice for my need because most of my customers own an Alexa. I will give an overview of what I want to implement.

Let's say a customer is giving a voice command to Alexa like Alexa, turn on living room's floor light. After receiving such a command Alexa should do a POST request to my cloud server with the parameters: Turn On, Living Room, Floor Light via an API. The server gives an API response to Alexa as a string like Turned on floor light of living room, which should be played back on Alexa.

So here are my questions. How can I configure Alexa to call an API and playback API responses? and how can I provide this functionality to every user who owns an echo and my home automation system?

albin antony
  • 189
  • 1
  • 3
  • 13

3 Answers3

1

You'll want to build an Alexa Skill using the Alexa Smart Home Skill API.

The API was designed specifically for what you are trying to do.

All the gory details can be found here:

https://developer.amazon.com/docs/smarthome/smart-home-skill-api-message-reference.html

The short story is:

  1. You'll create an AWS Lambda that gets called by Alexa
  2. The first call your Lambda will get is a "Discovery" call. You'll return a list of all of your home automation devices, along with the names by which you want to refer to them (e.g. Device Id=7 is referred to as "Floor Light").
  3. When you say "Alexa, turn on the Floor Light" Alexa will call your Lambda saying "turn on device ID #7". You'll then need to reach into your home and do whatever it takes to cause that device to change from off to on.
tig
  • 3,424
  • 3
  • 32
  • 65
  • I want the user to be authenticated before using the service. How can I prompt the user to login into my system using Alexa? – albin antony Oct 12 '17 at 05:48
1

I actually made a SDK, that helps simplify the process on GitHub. It walks you through step by step how to use the kit. Good luck, lmk if you are having any issues.

Aidan H
  • 124
  • 9
1

I agree with tig; an Alexa smart home skill is the way to go.

You'll need to decide how you want to authenticate your users. If your server already provides OAuth2, then you can use account linking to authenticate your users when they install the Alexa skill.

Alexa smart home handles all the dialog for you. You will just expose the functionality: endpointId identifies the device to your code (ie. "lrfloor"), friendlyName is what Alexa will respond to (eg. "living room floor light"). Alexa then handles the "Alexa, turn on ..." etc.

Beware that Amazon recently announced V3 of the smart home API, so be sure that any tutorials or examples you look at are supporting the new API and not the older V2. The APIs are very different, and you probably don't want to invest a bunch of time learning an API thats going to be deprecated.

Ron Lisle
  • 1,164
  • 6
  • 11