translator module

class translator.Translator[source]

Responsible for translating from Alexa commands to commands for IoT and replies of IoT devices to Alexa responses to users

static translateToEcho(iotMessage, echoMessage)[source]
docstring here
param iotMessage:
 the message received from and IoT device
param echoMessage:
 the echo message originally received by the lambda handler
return:the final dict to be returned as return result of the lambda handler
static translateToIoT(echoMessage)[source]
docstring here
param echoMessage:
 message to be translated to IoT
return:the translated dict to be sent to IoT
translator.echoPropertiesPrototype = {'name': 'powerState', 'namespace': 'Alexa.PowerController', 'timeOfSample': '2017-09-27T18:30:30.45Z', 'uncertaintyInMilliseconds': 200, 'value': 'OFF'}

A skeleton dictionary represents a typical member of the properties list in the Discovery response to Alexa

translator.echoResponsePrototype = {'context': {'properties': []}, 'event': {'header': {'payloadVersion': '3', 'correlationToken': 'dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==', 'namespace': 'Alexa', 'name': 'StateReport', 'messageId': '5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4'}, 'endpoint': {'scope': {'token': 'access-token-from-Amazon', 'type': 'BearerToken'}, 'endpointId': 'endpoint-001'}, 'payload': {}}}

A skeleton dictionary representing a response to Alexa, translator will fill this out with appropriate details and then return as the lambda final responses(if it passes the json validate test)

translator.iotMessagePrototype = {'name': 'TurnOff', 'namespace': 'Alexa.PowerController', 'payload': {}}

Contain a skeleton dictionary of a message to be sent to the IoT Devices, translator base on this for the final message

translator.iotReplyPrototype = {'name': 'brightness', 'namespace': 'Alexa.BrightnessController', 'value': 50}

A skeleton dictionary that represents typical reply by IoT devices, the translator copy this, extract the data from the IoT reply into the copy, and then attach into the final response to Alexa