How to use Alexa to control your smart home by voice?

How to use Alexa to control your smart home by voice?

overview
In the past, we had to control a hardware device, such as a TV, and we needed to walk to the TV to operate or press the button of the remote control, and if we wanted to search for a favorite program, we might have to press the remote control many times to achieve it, which was very unpleasant.

In 2014, Amazon released the Echo speaker, the first to explode the smart speaker market, and in the following years, a variety of smart speakers appeared on the market, and smart speakers have been accepted by consumers. Among so many speakers, the Echo is undoubtedly one of the best, it has changed people's perception of human-computer interaction, making people familiar with and accepting the way of controlling hardware devices by voice.

By now, people are no longer satisfied with just using their voice to control the speaker to play a song, or check the weather. We can do more with voice interaction, such as smart TVs, connected cars, and other scenarios. If all the electrical appliances and devices in the home are networked and controlled by voice interaction, isn't this a smart home? Yes, Amazon is already ahead of the curve, and today we are going to introduce the Alexa Smart Home platform.

Alexa is Amazon's voice service platform and the brain of thousands of devices like the Echo. Alexa offers powerful capabilities that allow for many skills that personalize experiences. If you are a smart hardware manufacturer, after accessing Alexa's built-in smart home voice interface, you can let users control smart home devices such as cameras, door locks, light bulbs, air conditioners, and home theaters through Alexa. In addition, once certified and published to the Alexa Skill Store, more users can discover and use our products.

Introducing Alexa Smart Home
Alexa Smart Home integrates Alexa voice interaction services, Alexa Skills Kit, Alexa Smart Home API, and AWS Lambda to allow us to quickly build cloud-based one-stop skills to add voice interaction capabilities to smart devices.

Alexa Smart Home has several features:
Built-in VUI. When using Alexa to control devices, we don't need to redesign VUI, using the built-in VUI can speed up development and make it more acceptable to users. In addition, when Alexa becomes more powerful or supports more languages, we and our users benefit as well.

Multiple connection methods. We can connect smart devices to Alexa through the Internet, Smart Home Skill, Echo Plus and ZigBee, or a smart home hub. This gives us the flexibility to support almost any variety of user scenarios, from new users who have just bought their first device to older users who want to expand their existing devices.

Low threshold use. Integrating Alexa allows users to control home devices from any terminal that integrates with Alexa services, such as the Echo, Echo Show, Echo Spot, and Fire TV that thousands of users already own. Of course, third-party products that integrate Alexa's voice services are also supported.

Rich, multi-device experiences. We can use Alexa Routines and Groups to simplify users. Routines allows users to customize the scene, saying a single voice command can trigger a series of actions of multiple smart devices, or it can be triggered at different times of the day. Groups allow users to group multiple devices in a room as if they were controlling an Echo device, without having to remember the name of each device.

The interaction process of Alexa Smart Home is as follows:

How the Smart Home Skill API Works Smart Home Skills provides a simple way to control and inspect connected devices through Alexa voice interaction. Alexa understands the user's intent and sends a message to the skills associated with it. In addition, the Smart Home Skill API allows us to display the status of configured devices in real time on the Alexa app. Here's how it works:

First, the user enables Smart Home Skill on the Alexa App and associates it with a device cloud account to discover the devices associated with this account.

Then, when Alexa hears the user say, "Alxea, help me turn up the kitchen light by 50%," or the user changes the brightness of the light on the Alexa app, Alexa understands the user's intent and changes the state of the specified device. Alexa generates these received messages into a request instruction that includes user authorization information, unique device identification, and new setup data. The request instructions are then sent to the skill deployed in AWS Lambda to control the lamp, where the instructions are parsed and sent to the device cloud associated with the lamp. The skill then replies to Alexa with a message called event to tell whether the request was successful, and Alexa uses the information in the event to reply to the user.

In addition, to support voice requests, the API allows us to easily provide updates when the device status changes, which means that users can see and control the device status in real time on the Alexa App.

Supported device types

Cooking equipment
Smart camera
Home entertainment equipment
Various lighting equipment
Lock
Thermostat
Other Alexa-connected devices

Create a Smart Home Skill
1. Requirements for creating a Smart Home Skill:
Amazon developer account
A networked smart device that can be controlled through the Device Cloud API, such as lighting, air conditioning, cameras, and more
Devices that can use Alexa services, such as the Amazon Echo
An AWS account number that is used to create an AWS Lambda function
Knowledge of JSON
Familiarity with Java, Node.js, C#, or any of Python for writing functions.
Learn about OAuth 2.0 authorization mechanisms

2. Create a Smart Home skill
On the Alexa Skill listing page, click the Add Skill button. On the Skill Information page, select the skill type as "Smart Home Skill API" and enter "SmartHome" for the skill name. Click Save, after success, see that the page generates an "Application ID";

3. Create a Lambda Function
Create a new Function in AWS Lambda and set the name, running environment, and role in the following figure.

Add the trigger type "Alexa Smart Home" to the Function Details page and set the skill ID created earlier. An ARN ID is generated after saving.

Select the runtime environment for Lambda, develop the skill function, and set up the invocation entry. The Smart Home device message protocol has a fixed schema, when developing skill functions, you only need to introduce the SDK corresponding to the development language to implement the request reply protocol, the following example shows the light on protocol.

{
   "directive": {
       "header": {
             "namespace": "Alexa.PowerController",
             "name": "TurnOn",
             "payloadVersion": "3",
             "messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
             "correlationToken": "dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg=="
        },
        "endpoint": {
           "scope": {
            "type": "BearerToken",
             "token": "access-token-from-skill"
         },
         "endpointId": "endpoint-001",
         "cookie": {}
       },
        "payload": {}
     }
}

Reply to the agreement:

{
       "context": {
             "properties": [
                          {
                              "namespace": "Alexa.PowerController",
                              "name": "powerState",
                              "value": "ON",
                              "timeOfSample": "2017-09-27T18:30:30.45Z",
                              "uncertaintyInMilliseconds": 200
                          },
                          {
                              "namespace": "Alexa.EndpointHealth",
                              "name": "connectivity",
                              "value": {
                              "value": "OK"
                         },
       "timeOfSample": "2017-09-27T18:30:30.45Z",
        "uncertaintyInMilliseconds": 200
                 }
                             ]
  },
      "event": {
                "header": {
                         "namespace": "Alexa",
                         "name": "Response",
                         "payloadVersion": "3",
                         "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
                         "correlationToken":                                                                                                     "dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg=="
              },
                "endpoint": {
                       "scope": {
                            "type": "BearerToken",
                            "token": "access-token-from-Amazon"
                           },
                       "endpointId": "endpoint-001"
                   },
             "payload": {}
       }
}

We choose the Java development language, after the development is completed, it is made into a JAR package and uploaded, and the handler processing entry can be configured.

 We choose the Java development language, 4. Configure ARNs and accountsReturn to the Smart Home Skill configuration page, and in the configuration items, set the ARN ID of Lambda so that the skill can be associated with the Lambda Function.

 

5. Test your skills
Once your skills and functions are developed, you can test the effect in the simulator provided by Alexa.

6. Certification Release
Once the skills are built and tested correctly, submit and pass the Works with Amazon Alexa certification, and users can see and use the skills we created in the Alexa Skills Store.
7. Statistical analysis
Alexa provides a powerful statistical analysis feature for the skills we create and publish, and if you want to see who is using it and how many times they are used, we can count the use of the technology based on various dimensions.

Conclusion The above is the specific method of realizing smart device control based on Alexa Smart Home.

Reference  https://developer.amazon.com/ale xa-skills-kit                                                            https://developer.amazon.com/alexa/smart-home

Fanxoo will explore more about the use of the Alexa with you,and if you have a better discovery, please share it with us. Thank you !

www.fanxoo.com     support@ifanxooo.com 

Back to blog

Leave a comment