Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft &...

Post on 22-Aug-2020

0 views 0 download

Transcript of Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft &...

AWS Pop-up Loft & Innovation Lab MünchenNovember 14th 2016Timo Müller (@elmiOne)

Alexa, I’m cold!Developing a Smart Home Skill for tado°

tado°

Control from anywhere Smart Schedule Location-based heating control

Smart Home Skill API

Smart Home Skill Setup

Link Discover Command

Linking user accounts

“Alexa, discover my devices”

Alexa Skill Adapter

λ

Home

Image: https://www.amazon.de/Amazon-SK705DI-Echo-Schwarz

Basic Commands

Thermostats Lights

Image: https://www.flickr.com/photos/ume-y/75917384, CC-SA 2.0Some rights reserved by ume-y

Basic Message Format

Header

Payload

"header": { "messageId": "6d6d6e14-8aee-473e-8c24-0d31ff9c17a2", "name": "SetTargetTemperatureRequest", "namespace": "Alexa.ConnectedHome.Control", "payloadVersion": "2"}

Basic Message Format

Header

Payload

"payload": { "accessToken": "<VALIDATED_OAUTH_TOKEN>", "appliance": { "additionalApplianceDetails": { "customDetail1": "...", ... }, "applianceId": "<APPLIANCE_ID>" }, "targetTemperature": { "value": <TARGET_TEMPERATURE> }}

Device Discovery

"accessToken": "<VALIDATED_OAUTH_TOKEN>"

Appliance "Living Room"

DiscoverAppliancesRequest DiscoverAppliancesResponse

Appliance "Kitchen"

Appliance "Bedroom"

Appliance "Bathroom"

More Appliances

Appliance

"applianceId": "1","friendlyName": "Bedroom","friendlyDescription": "tado° Smart Thermostat",

"actions": [ "incrementTargetTemperature", "decrementTargetTemperature", "setTargetTemperature"],

"isReachable": true,"manufacturerName": "tado","modelName": "Smart Thermostat","version": "1",

"additionalApplianceDetails": { "homeId": "12345", "zoneType": "Heating"}

Scenes

“Alexa, turn on bedtime”

● “Fake” appliance that can be turned on or off

● Can perform multiple actions● Defined in the “device cloud”

tado° Smart Home Skill

Under the hood

Java 8 Libraries

● AWS Lambda Core● Google Guava● Google Gson

API Client

● Swagger API Specification● Generated Retrofit API Client● Apache Oltu● Google Gson

Persistence

● Dynamo DB

Logging

● ElasticSearch and Kibana

“Alexa, set the temperature to 25 degrees”

"accessToken": "<VALIDATED_OAUTH_TOKEN>","appliance": { "applianceId": "1", "additionalApplianceDetails": { "homeId": "12345", "zoneType": "Heating" }},"targetTemperature": { "value": 25.0}

SetTargetTemperatureRequest

λ

“Alexa, set the temperature to 25 degrees”

Request

λStart manual control

Retrieve current state

“Alexa, set the temperature to 25 degrees”

Request

λ"targetTemperature": {

"value":25.0

},

"temperatureMode": {

"value":"HEAT"

},

"previousState": {

"targetTemperature": { "value":21.0 },

"mode": { "value":"HEAT" }

}

Confirmation

Handling a request

public class AlexaSmartHome implements RequestStreamHandler {

@Override

public void handleRequest(InputStream input, OutputStream output, Context context)

throws IOException {

final Gson gson = new Gson();

final BufferedReader reader = new BufferedReader(new InputStreamReader(input));

CatchAllRequest request = gson.fromJson(reader, CatchAllRequest.class);

String requestName = request.getHeader().getName();

RequestHandler handler = getRequestHandler(request, context, requestName);

String response = handler.handleRequest();

output.write(response.getBytes("UTF-8"));

}

}

Error Messages

User Faults

The request cannot be fulfilled due to issues with content in the

request

Skill Adapter Faults Other Faults

The request is invalid due to a customer error

The request is valid but the skill adapter cannot complete the required task because of a

hardware issue or limitation

“Alexa, set the temperature to 80 degrees”

"accessToken": "<VALIDATED_OAUTH_TOKEN>","appliance": { "applianceId": "1", "additionalApplianceDetails": { "homeId": "12345", "zoneType": "Heating" }},"targetTemperature": { "value": 80.0}

"minimumValue": 5.0,

"maximumValue": 25.0

SetTargetTemperatureRequest ValueOutOfRangeError

Boost ModeImplementing a simple scene

Request

λ

Timeout

Response

Lambda Cold Starts

Lambda Cold Starts

Keeping the Lambda warm

● Regular CloudWatch Event● Regular Discovery Request

Speeding up the initial launch

● Increase available Memory● Decrease size of JAR

Image: https://www.flickr.com/photos/woodhead/16208577766/, CC-SA 2.0Some rights reserved by woodhead

Lessons learned

Temperature Unit Error Handling Smart Home Java SDK

Smart Home API Wishlist

“Alexa, what’s the current temperature in the kitchen”

“Alexa, set theliving room to 23.5°for two hours”

“Alexa, I’m cold”

tado° GmbH | Lindwurmstr. 76 | 80337 München

www.tado.com