GithubHelp home page GithubHelp logo

fabsrc / home-assistant-alexa-proxy Goto Github PK

View Code? Open in Web Editor NEW
11.0 3.0 1.0 9 KB

:mega::house_with_garden: Lambda function for using Amazon Alexa with Home Assistant

License: MIT License

Python 100.00%
home-assistant amazon-alexa aws-lambda home-automation

home-assistant-alexa-proxy's Introduction

Home Assistant Proxy for Amazon Alexa

A lightweight Lambda function for proxying requests from an Amazon Alexa skill to Home Assistant.

Requirements

  • 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

Configuration

  • 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)

Setup

  1. Create a new Amazon Alexa skill on https://developer.amazon.com/alexa/console/ask/create-new-skill

    1. Enter a Skill name, e.g. "Home Assistant"
    2. Set your Default language
    3. Select Smart Home as model
    4. Click Create skill
  2. Create an AWS Lambda function on https://console.aws.amazon.com/lambda/home#/create in your AWS region

    1. Select Author from scratch
    2. Enter a function name, e.g. "home_assistant_proxy"
    3. Select Python 3.8 as runtime
    4. Select a lambda role, e.g. "lambda_basic_execution"
    5. Click Create function
  3. Configure AWS Lambda function

    1. Copy and paste the code from hass_proxy.py into the function code editor and click the "Deploy" button
    2. 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"
    3. (optional) If you are using a self signed certificate for your Home Assistant, set the VERIFY_SSL environment variable to false
    4. Add Alexa Smart Home trigger
      1. Enter the Skill ID from your Alex skill in the Application ID field
      2. Select Enable trigger
      3. Click Add
  4. Configure Amazon Alexa Skill

    1. Enter the ARN of the AWS Lambda function
    2. Click Save
    3. Click Setup Account Linking
      1. In Authorization URI enter the authorize URI of your Home Assistant, e.g. "https://your-home-assistant-url.io/auth/authorize"
      2. In Access Token URI enter the access token URI of your Home Assistant, e.g. "https://your-home-assistant-url.io/auth/token"
      3. Enter a redirect URL of Amazon Alexa as Client ID, e.g. "https://layla.amazon.com" (see Redirect URLs)
      4. Enter anything in Client Secret (is not used by Home Assistant)
      5. Select "HTTP Basic" as Client Authentication Scheme
      6. Add any Scope, e.g. "API" (is not used by Home Assistant)
      7. Click Save
  5. Activate your Skill in the Amazon Alexa app or in the web interface

  6. 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.

home-assistant-alexa-proxy's People

Contributors

fabsrc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

minimad-diver

home-assistant-alexa-proxy's Issues

Question: Support for Thermostats

Hi,

Does this proxy support thermostats? I am currently using haaska which does. However I am looking to change my dns which would require some effort with haaska. I tested home-assistant-alexa-proxy last night and managed to discover some of my devices but the thermostats did not appear.

Thanks

Chris

Error: invalid client id or redirect uri

In the account linking section of the skill, I have one of my Alexa redirect URLs as mentioned in the readme, e.g.: https://layla.amazon.com/api/skill/link/XXXXXXXXXXXXXXX

I've also tried not appending the /api/skill/link/CODE, and still receive the following error from my Home Assistant authorization page Error: invalid client id or redirect uri when linking the account in the Alexa app.

It does successfully navigate and show my home assistant authorization page, but no login form is present, only the error.

Relavent log info:

  • HA shows a notification stating Login attempt or request with invalid authentication from X.X.X.X
  • 2020-06-07 11:46:54 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from X.X.X.X

If anyone has any advice on how to resolve this - please let me know!
I assume this is more of a problem with home assistant, and likely not an issue with this skill, but any help would be appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.