A lightweight Lambda function for proxying requests from an Amazon Alexa skill to Home Assistant.
- Amazon Developer account
- AWS Account
- Public Home Assistant URL (must be secured with TLS)
- Home Assistant Alexa Smart Home component configuration
Also see https://developer.amazon.com/de/docs/smarthome/understand-the-smart-home-skill-api.html and https://www.home-assistant.io/components/alexa/#smart-home
HASS_URL
: URL to Home Assistant (e.g.https://your-home-assistant-url.io
)BEARER_TOKEN
: Long lived acces token (optional)VERIFY_SSL
: Has to be false for self signed certificates. (default:true
)
-
Create a new Amazon Alexa skill on https://developer.amazon.com/alexa/console/ask/create-new-skill
- Enter a Skill name, e.g. "Home Assistant"
- Set your Default language
- Select Smart Home as model
- Click Create skill
-
Create an AWS Lambda function on https://console.aws.amazon.com/lambda/home#/create in your AWS region
- Select Author from scratch
- Enter a function name, e.g. "home_assistant_proxy"
- Select Python 3.8 as runtime
- Select a lambda role, e.g. "lambda_basic_execution"
- Click Create function
-
Configure AWS Lambda function
- Copy and paste the code from hass_proxy.py into the function code editor and click the "Deploy" button
- Add a HASS_URL environment variable which is set to the public base URL of your Home Assistant, e.g. "https://your-home-assistant-url.io"
- (optional) If you are using a self signed certificate for your Home Assistant, set the VERIFY_SSL environment variable to
false
- Add Alexa Smart Home trigger
- Enter the Skill ID from your Alex skill in the Application ID field
- Select Enable trigger
- Click Add
-
Configure Amazon Alexa Skill
- Enter the ARN of the AWS Lambda function
- Click Save
- Click Setup Account Linking
- In Authorization URI enter the authorize URI of your Home Assistant, e.g. "https://your-home-assistant-url.io/auth/authorize"
- In Access Token URI enter the access token URI of your Home Assistant, e.g. "https://your-home-assistant-url.io/auth/token"
- Enter a redirect URL of Amazon Alexa as Client ID, e.g. "https://layla.amazon.com" (see Redirect URLs)
- Enter anything in Client Secret (is not used by Home Assistant)
- Select "HTTP Basic" as Client Authentication Scheme
- Add any Scope, e.g. "API" (is not used by Home Assistant)
- Click Save
-
Activate your Skill in the Amazon Alexa app or in the web interface
-
Discover devices
Differences to Haaska
- Makes use of Home Assistant's Authentication API. There is no need to configure an oAuth provider or to create a long lived token.
- No dependencies to additional Python packages. It is not necessary to create a deployment package and upload it to AWS Lambda. Just copy the code from the
hass_proxy.py
file and paste into the AWS Lambda function editor. - No config files. All configuration is done using environment variables.