This repository contains the source code of the virtual-smart-home backend. It is published for users to inspect what happens behind the scenes.
Follow these steps in order to set up the virtual-smart-home backend in your own AWS account:
Download the source code of the vsh backend
git clone git@github.com:csuermann/virtual-smart-home.git
Switch to the 'sandbox' branch
git checkout --track origin/sandbox
Create a new AWS Account (or use your existing one)
export your newly created user credentials and default region as environment variables
export AWS_ACCESS_KEY_ID=XXXXXXXXXXXXXXXXXXXX
export AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
export AWS_DEFAULT_REGION=eu-west-1
Create an Amazon Developer Account (or use your existing one)
Create a new Alexa skill
Take note of 'Your Skill ID' and export it as an environment variable called 'SKILL_ID'
export SKILL_ID=amzn1.ask.skill.xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Open a new browser tab / window
Create a new Security Profile
In the Alexa Developer Console click on 'Permissions' in the side menu
Make sure that the 'Send Alexa Events' switch is toggled on
Take note of 'Alexa Client Id' and 'Alexa Client Secret' and export both as an environment variables
export ALEXA_CLIENT_ID=amzn1.application-oa2-client.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
export ALEXA_CLIENT_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Download and install the AWS CLI on your computer
Run the following command and note down the 'endpointAddress' for your AWS account
aws iot describe-endpoint --endpoint-type iot:Data-ATS
Export the value of 'endpointAddress' as an environment variable called 'IOT_ENDPOINT'
export IOT_ENDPOINT=xxxxxxxxxxxxxx-ats.iot.eu-west-1.amazonaws.com
Create an IoT Thing Type called 'virtual-smart-home-type'
aws iot create-thing-type --thing-type-name "virtual-smart-home-type"
Create an IoT Thing Group called 'virtual-smart-home-things'
aws iot create-thing-group --thing-group-name "virtual-smart-home-things"
Create an IoT Billing Group called 'virtual-smart-home-billing-group'
aws iot create-billing-group --billing-group-name virtual-smart-home-billing-group
Update the IoT index configuration
aws iot update-indexing-configuration --thing-indexing-configuration "thingIndexingMode=REGISTRY_AND_SHADOW, thingConnectivityIndexingMode=STATUS"
NOTE: See AWS pricing for IoT Device Management. Performing this step is not strictly needed to get VSH up and running. If you do not want to enable thing indexing, consider commenting out the
metrics
endpoint in serverless.yml to prevent your CloudWatch logs from being flooded with error messages.
Register for an Momento account and export the provided token as an environment variable called 'MOMENTO_TOKEN'
export MOMENTO_TOKEN=xxxxxxxxxx
Create 2 environment variable called 'HASH_SECRET' and 'VSH_ADMIN_API_KEY' containing random strings
export HASH_SECRET=foobar28429789
export VSH_ADMIN_API_KEY=unguessable8823472893472
Create additional environment variables used by the serverless deploy process
export IS_PROD=false
export LOG_LEVEL=debug
export STRIPE_API_KEY=abc
export STRIPE_WEBHOOK_SECRET=xyz
run npm install
install the serverless framework by running npm install -g serverless@3.38.0
run serverless deploy
Note down the POST endpoint printed as part of the serverless deploy
output
Run the following command and note down the 'FunctionArn'
aws lambda get-function --function-name virtual-smart-home-dev-skill
In the Alexa Developer Console click on 'Smart Home' in the side menu
Paste the value of the FunctionArn (from step 24) as 'Default Endpoint' as well as for 'Europe / India'
Click Save
Your own backend should now be set up! Congratulations!
Now you need to configure your Node-RED vsh-connection node to use your backend instead of the official one.
Open the settings.js
file of your Node-RED installation and add the following just before the closing "}"
vshConnectionShowSettings: true,
Restart Node-RED
Create a new vsh node and chose 'add new vsh-connection' from the connection dropdown
Replace the 'Backend URL' with the value you noted down in step 23, BUT WITHOUT THE trailing '/provision' !!!
Replace 'LWA Client ID' with the value you noted down as 'Client Id' in step 6.12
Click 'Add'
Come back to the previous page by clicking the pen-icon
Follow the account linking instructions, which should now go against your own backend