Download - Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

Transcript
Page 1: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

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

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

Page 2: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

tado°

Control from anywhere Smart Schedule Location-based heating control

Page 3: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

Smart Home Skill API

Page 4: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

Smart Home Skill Setup

Link Discover Command

Page 5: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

Linking user accounts

Page 6: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

“Alexa, discover my devices”

Alexa Skill Adapter

λ

Home

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

Page 7: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

Basic Commands

Thermostats Lights

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

Page 8: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

Basic Message Format

Header

Payload

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

Page 9: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

Basic Message Format

Header

Payload

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

Page 10: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

Device Discovery

"accessToken": "<VALIDATED_OAUTH_TOKEN>"

Appliance "Living Room"

DiscoverAppliancesRequest DiscoverAppliancesResponse

Appliance "Kitchen"

Appliance "Bedroom"

Appliance "Bathroom"

More Appliances

Page 11: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

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"}

Page 12: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

Scenes

“Alexa, turn on bedtime”

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

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

Page 13: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

tado° Smart Home Skill

Page 14: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

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

Page 15: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

“Alexa, set the temperature to 25 degrees”

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

SetTargetTemperatureRequest

λ

Page 16: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

“Alexa, set the temperature to 25 degrees”

Request

λStart manual control

Retrieve current state

Page 17: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

“Alexa, set the temperature to 25 degrees”

Request

λ"targetTemperature": {

"value":25.0

},

"temperatureMode": {

"value":"HEAT"

},

"previousState": {

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

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

}

Confirmation

Page 18: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

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"));

}

}

Page 19: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

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

Page 20: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

“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

Page 21: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

Boost ModeImplementing a simple scene

Page 22: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

Request

λ

Timeout

Response

Lambda Cold Starts

Page 23: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

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

Page 24: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

Lessons learned

Temperature Unit Error Handling Smart Home Java SDK

Page 25: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

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”

Page 26: Alexa, I’m cold!aws-de-media.s3.amazonaws.com/images/_Munich_Loft... · AWS Pop-up Loft & Innovation Lab München November 14th 2016 Timo Müller (@elmiOne) Alexa, I’m cold! Developing

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

www.tado.com