on
2022-11-02
5:19 AM
- edited on
2025-08-01
1:19 AM
by
Laurids_PETERSE
This article extends the integration of turning on a relay and activating devices using GPIO pins by adding Alexa support. This document will guide you through required software installations, as well as linking your account to Alexa to be able to properly activate the skill.
For this article, we will be using the repository linked here. This repository has two different approaches to activation, automatic and manual. For this article, we will only be focusing on manual device activation using Alexa.
In this article, the smart home device we will be using is a fan, light bulb, humidifier, and door lock.
Clone the repository either by downloading the zip files directly, or use a unix-like command line operation with Git support.
git clone https://github.com/STM-Capstone-2022/stm-capstone-aws.git
We will also need some other external development tools to be able to get the project running on Alexa. The software we need is AWS CLI, Node.js npm, AWS CDK, and Maven.
For AWS CLI, it should already be installed on your development environment from the first requirement.
For Node.js npm, there are different ways to install depending on your OS.
For AWS CDK, type in the command line npm install -g aws-cdk.
If there is a permission error, it means that npm was installed onto your entire system, rather than the user. To fix this, find the Node.js installation and place it into your user root directory
For Maven, there are different ways to install depending on your OS
Two things are needed to finish the project setup.
on the command line. Keep the same IAM user access and secret access keys, but change the region to us-east-1. The reason for this is that the Alexa skill can only communicate with the US market in this region.
to set up a CDK. For $ACCOUNT_NUMBER, make sure that you use the ROOT account number, not the IAM account.
Within the application.properties files, there are softcoded constants. A sibling file application-override.properties is gitignore'd to hold sensitive information and may supersede application.properties when they both contain the same key.
These keys should be modified to fit your project:
Within the project directory, run the following lines in command line
When creating an Alexa skill, you need to only create it once, and it needs to be reattached to the lambda function whenever it is deleted and recreated. Redeploying through CDK does not require this unless the original stack is deleted.
To attach the Alexa skill, follow this set of instructions.
Finally, set up Account Linking in the AWS documentation: https://developer.amazon.com/en-US/docs/alexa/smarthome/set-up-account-linking-tutorial.html
At this point, Alexa is ready to use with your devices.