AlexaPi
part 3
Amazon Web Services is a subsidiary of Amazon that provides on-demand cloud computing platforms and APIs to individuals, companies. The developer console organizes skill building into the following main tasks: Use Build to set up your skill, configure the interaction model, and specify the endpoints for your service In this part will use AWS to create lambda , iOT AWS and alexa intent.To signup for AWS click here , for alexa developer console click here.
iOT AWS SDK:
To create AWS iOT login to your AWS account => services => under Internet Of Things click on IoT Core => under Mange click on Things => create a thing => name it as "water_leak" => Next => create certificate => Download all certificate => root CA for AWS IoT Download => download Amazon Root CA 1 here => activate => Done. crate a folder on raspberry pi one name it as "AWS_iOT" and paste all certificates.
under Secure => Policies => Create a policy => name it as "rpi_control_policy" => Edit policy document => paste the flowing.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "iot:*",
"Resource": "*"
}
]
}
Manage => Things => water_leak => Security => certificate number => Policies => Action => Attach policies => select rpi_control_policy => Attach.
Make sure the code saved as AWS_IoT.py inside AWS_iOT folder. You will be provided with all sources code after you buy.
Alexa Developer Console:
To create intent login to your account => create skill => name it "Test" => create => Invocation => name it as "raspberry pi application" => save model => Add Intent (you will add 11 intend as shown on the images which are AMAZON.FallbackIntent ,Help, Temperature ,Water ,gas ,Air ,Door) => Sample Utterances (in each intent you will add Sample Utterances as shown on the images ) => Build model => endpoint.
AWS Lambda Function:
Login to AWS => services => lambda => create function name it as "test2" (Runtime: select python 3.6 ) => create function => Add trigger => select AWS Iot and Alexa skills kit. After you buy you will able to download file called lambda_function.py. Make sure to paste the lambda_function.py file to AWS lambda as following image.
Copy ARN (top-right of the page) => login to Alexa console => endpoint => AWS Lambda ARN => paste ARN to Default Region.
Flask Web Application:
Flask is a micro web framework written in Python. It is classified as a micro framework . Socket.O is a python library for real time web applications .We will use flask and socketio to post all the data sensors to web app as real time data as following images. Add you own path on file app.py line 20 and Make sure the code saved as app.py.
Testing Alexa and Flask:
in order to test Alexa go to "alexa developer console" ==> Build Started ==> test. You can say "Alexa start raspberry pi application" , "what is the temperature ". make sure you have those intent. To test web app run app.py.