alexa smart home skill
TRANSCRIPT
![Page 1: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/1.jpg)
Alexa Smart Home SkillJAWS-UG IoT 専門支部IoT サロン 2016-11合同開催スペシャル
![Page 2: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/2.jpg)
@sparkgene市川 純 (Jun Ichikawa)
favorite services :Route 53 、 Lambda 、 AWS IoT
Recruit Marketing Partnersinfrastructure engineer
![Page 3: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/3.jpg)
![Page 4: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/4.jpg)
Alexa Skill types• Custom Interaction Model(Custom
Skill)
• Smart Home Skill
• Flash Briefing Skill
![Page 5: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/5.jpg)
Custom Skill• Build a skill with a custom interaction
model
• Customers say invocation name to use it. “Alexa, ask Uber to request a ride”
• Most flexible, but most complex to customers.
![Page 6: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/6.jpg)
Smart Home Skill• Easy to use for customer.
• Customers say “Alexa, turn on living room lights”
• This skill is for cloud connected smart home devices.
![Page 7: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/7.jpg)
Flash Briefing Skill• It can be integrated into "Alexa Flash
Briefing”
• Customers can simply ask “Alexa, what’s my Flash Briefing” to hear your content
• Currently Flash Briefing is only available for the English (U.S.) language
![Page 8: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/8.jpg)
DIFFERENCEBETWEENCUSTOM SKILL
![Page 9: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/9.jpg)
Custom Skill• design your own interaction model
• interaction name is required
• customer need to remember interaction name or invocation phrase
• you can use any server to host skill
![Page 10: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/10.jpg)
Smart Home Skill• built-in interaction model
• natural utterances to control device
• Alexa need a grant permissions (OAuth) to retrieve device information and control device
• Skill must use AWS Lambda function
![Page 11: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/11.jpg)
Mange devices on cloud
Customer need to register their devices to the device makers cloud.
![Page 12: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/12.jpg)
On personal use, you don’t need to register devices. Just hard code in your lambda function.
![Page 13: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/13.jpg)
HOW TO MAKE IT
![Page 14: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/14.jpg)
Demo Video
https://youtu.be/nT20o2uv2h0
![Page 15: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/15.jpg)
demo’s architecturethis slide explain
only here
see here to create custom skill version architecturehttps://www.hackster.io/sparkgene/alexa-makes-home-smarter-7e1981
![Page 16: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/16.jpg)
Prerequisites to Smart Home Skill Development
• Amazon developer account– https://developer.amazon.com/
• AWS account• Knowledge of Java, Node.js, or
Python as Lambda functions can be written in any of these language
• A basic understanding of OAuth 2.0
![Page 17: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/17.jpg)
Three steps to create Skill• Create “Login With Amazon”(LWA)
security profile
• register Smart Home Skills
• Create Lambda function
step-by-step article・ https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/steps-to-create-a-smart-home-skill・ http://qiita.com/sparkgene/items/055d7864c92a80b0c040
![Page 18: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/18.jpg)
Create Login With Amazonhttps://developer.amazon.com/home.html
![Page 19: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/19.jpg)
• enter “Allowed Return URLs” in the Web Settings after register skill Account Linking.
![Page 20: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/20.jpg)
register Smart Home Skillshttps://developer.amazon.com/edw/home.html#/skill/create/
• Update “End point” after creating lambda function
![Page 21: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/21.jpg)
Account Linkinghttps://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/steps-to-create-a-smart-home-skill#finish-registering-your-skill-in-the-developer-portal
• To finish registering your skill, you must configure OAuth 2.0 for your skill, which is used for account linking. You can use Login with Amazon or another provider for this section.
• Use “Redirect URL” to allow redirect at OAuth provider
![Page 22: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/22.jpg)
Authoization URL:https://www.amazon.com/ap/oa?redirect_uri=https://pitangui.amazon.com/api/skill/link/<ID>
![Page 23: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/23.jpg)
Create Lambda function• Alexa skill is only available on us-
east-1 and eu-west-1 region
• Node.js blue print is available– alexa-smart-home-skill-adapter
![Page 24: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/24.jpg)
Smart Home Skill API• Smart Home Skill API communicate
with your skill(skill adapter) with same basic structure.
• Skill adapter directives contain two top-level objects– header– payload
![Page 25: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/25.jpg)
"header": { "messageId": "6d6d6e14-8aee-473e-8c24-0d31ff9c17a2", "name": "DiscoverAppliancesRequest", "namespace": "Alexa.ConnectedHome.Discovery", "payloadVersion": "2”},"payload": { "accessToken": "OAuth Token here"}
header and payload
accessToken always include in request.use the access token to know who’s request.
![Page 26: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/26.jpg)
DiscoverAppliancesRequestThe request come on• When you say “Alexa, discover
devices”
• hourly after your device register on Alexa (device health check)
![Page 27: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/27.jpg)
{ "header": { "messageId": "6d6d6e14-8aee-473e-8c24-0d31ff9c17a2", "name": "DiscoverAppliancesRequest", "namespace": "Alexa.ConnectedHome.Discovery", "payloadVersion": "2" }, "payload": { "accessToken": "OAuth Token here" }}
![Page 28: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/28.jpg)
DiscoverAppliancesResponse
{ "header": { "messageId": "ff746d98-ab02-4c9e-9d0d-b44711658414", "name": "DiscoverAppliancesResponse", "namespace": "Alexa.ConnectedHome.Discovery", "payloadVersion": "2" }, "payload": { "discoveredAppliances": [] }}
![Page 29: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/29.jpg)
discoveredAppliances"discoveredAppliances": [ { "actions": [ ”turnOn", ”turnOff” ], "additionalApplianceDetails": { "extraDetail1": "optionalDetailForSkillAdapterToReferenceThisDevice” }, "applianceId": "unique Device Id", "friendlyDescription": "description that is shown to customer", "friendlyName": " Bedroom Light", "isReachable": true, "manufacturerName": "your Manufacturer Name", "modelName": "fancyThermostat", "version": "your software version number here." }]
The action which device support
![Page 30: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/30.jpg)
actions• turnOff
– “Alexa, turn off the <device name>”• turnOn
– “Alexa, turn on the <device name>”• setTargetTemperature
– “Alexa, set the <room name> to <number> degrees”• incrementTargetTemperature
– “Alexa, increase the <device name> by <number> degrees”• decrementTargetTemperature
– “Alexa, decrease <device name> by <number> degrees”• setPercentage
– “Alexa, set <name> to <number> percent”• incrementPercentage
– “Alexa, increase <device name> by <number> percent”• decrementPercentage
– “Alexa, decrease <device name> by <number> percent”
![Page 31: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/31.jpg)
TurnOnRequest{ "header": { "messageId": "01ebf625-0b89-4c4d-b3aa-32340e894688", "name": "TurnOnRequest", "namespace": "Alexa.ConnectedHome.Control", "payloadVersion": "2" }, "payload": { "accessToken": "[OAuth Token here]", "appliance": { "additionalApplianceDetails": {}, "applianceId": "[Device ID for Ceiling Fan]" } } }
![Page 32: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/32.jpg)
TurnOnConfirmation { "header": { "messageId": "26fa11a8-accb-4f66-a272-8b1ff7abd722", "name": "TurnOnConfirmation", "namespace": "Alexa.ConnectedHome.Control", "payloadVersion": "2" }, "payload": {} }
![Page 33: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/33.jpg)
Error Response• TargetOfflineError
– target device is not connected to the customer’s device cloud or is not on.• BridgeOfflineError
– target device is connected to a home automation hub or bridge, which is powered off.
• NoSuchTargetError– target device cannot be found, meaning it was never configured by the end-user.
• ExpiredAccessTokenError– the access token used for authentication has expired and is no longer valid.
• ValueOutOfRangeError– customer request would set a target value to a value out of its supported range.
• and more..
skill adapter should respond with the appropriate error type, and supporting information
![Page 34: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/34.jpg)
ValueOutOfRangeError{ "header":{ "namespace":"Alexa.ConnectedHome.Control", "name":" ValueOutOfRangeError", "payloadVersion":"2", "messageId":"697fe957-c842-4545-a159-8a8c75fbe5bd" }, "payload":{ "minimumValue":15.0, "maximumValue":30.0 } }
![Page 35: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/35.jpg)
DISCOVERY DEMO
- enable skill- Login with Amazon- discover device- Turn on request
![Page 36: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/36.jpg)
Questions?
![Page 37: Alexa Smart Home Skill](https://reader036.vdocuments.net/reader036/viewer/2022062523/58712a251a28abe4448b6ef5/html5/thumbnails/37.jpg)
appendix• slide demo skill– https://github.com/sparkgene/
smart_home_skill/blob/master/aws_iot_device.py
• Raspbery Pi setup guide for the demo– https://www.hackster.io/sparkgene/
alexa-makes-home-smarter-7e1981