Skip to content

Instantly share code, notes, and snippets.

@chhantyal
Last active July 20, 2017 14:50
Show Gist options
  • Save chhantyal/2651ad9330b24d72c0446e6024be7d4f to your computer and use it in GitHub Desktop.
Save chhantyal/2651ad9330b24d72c0446e6024be7d4f to your computer and use it in GitHub Desktop.
AWS Lambda to DynamoDB integration (can be used with Alexa)
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