Last active
July 20, 2017 14:50
-
-
Save chhantyal/2651ad9330b24d72c0446e6024be7d4f to your computer and use it in GitHub Desktop.
AWS Lambda to DynamoDB integration (can be used with Alexa)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
dynamodb = boto3.resource('dynamodb', region_name='eu-central-1') | |
table = dynamodb.Table('roomtemp') | |
def set_temperature(current_temp, session): | |
table.put_item(Item={'currentTemperature': current_temp, 'userId':session['user']['userId']}) | |
return {"currentTemp": current_temp} | |
def get_temperature(session): | |
userId = session['user']['userId'] | |
response = table.get_item(Key={'userId': userId}) | |
item = response.get('Item') | |
if item: | |
current_temp = '{0}'.format(item['currentTemperature']) | |
return None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment