Integrate for free Amazon Echo (Alexa) with Home Assistant (via haaska e AWS)

12 minutes of reading
Guide purposes:
Concepts dealt with:
  • Software configuration
Software components used:
  • Home Assistant configured and working (minimum 0.62 version)
  • Home Assistant remote via HTTPS (explained later)
  • Amazon Echo / Alexa configured and working and related account Amazon connected to it
  • A personal account Amazon
Physical devices used:
  • The computer on which it is running Home Assistant
  • Smartphone on which to run theapp "Amazon Alexa ”(Android and / or iOS)
  • Amazon Echo (any model or any model of smart speaker you mount Amazon Alexa as integrated software)
GUIDE more indicated for:

All environments

Notes and disclaimer
  • qualsiasi eventuale modifica agli impianti domestici dev'essere progettata ed realizzata SOLO da personale qualificato;
  • any changes implemented in probefore is a propersonal responsibility as well as a profirst risk and danger (the contents of the present page are purely educational);
  • any changes implemented in proprior to a device it voids the guarantee, quality approvals and certifications.
Driving review: 1.9

Home Assistant Amazon-Echo-Plus


The advent on the market of Smart Speaker is slowly changing the habits of many who, everydaynamente, they become familiar and familiar with the possibility of interacting with a real e profirst personal assistant simply using voice and natural language.

Amazon Echo It is one of device of wider and more recognized success. As we explained, this smart speaker uses the software to work Alexa, which is available, even for smart speakers proproduced by third parties, as well as how appstand-alone communication for Android and iOS smartphones / tablets.

Any smart speaker you use Amazon Alexa can be easily integrated with Home Assistant.
But why, since many domotic components declare compatibility with Amazon Echo - and therefore can be controlled "by factory" by such Smart Speaker - it is useful to integrate them with the latter Home Assistant? [Before answering the question, who reads have clear the concept of integration in home automation.]

Simple: why through a personale HUB like Home Assistant we are able to define scenarios, virtual accessories, automations otherwise not definable with the separate use of the single components. As explained also in a episode of our podcast, some simply evolved scenarios they cannot be realized without the aid of a common platform, or a personale HUB.

The moment it integrates itself like this personal HUB(therefore Home Assistant in the specific case of this guide) with Amazon Echo, you can check all the components and the entity - which scenarios (and others) - defined in it through my personal assistant. One of the many reasons to adopt a personale HUB for the profirst home automation. A focus on this important topic is available here.

The elements (defined of) defined in the configuration Home Assistant and controllable through integration with Amazon Alexa (Amazon Echo and compatible speakers) are:

  • alert (alarm alerts)
  • automation (automation) - on / off
  • climate (air conditioners and thermostats) - target temperature setting.
  • cover (dark)
  • fan (fans) - on / off
  • group (Groups)
  • boolean input (boolean input)
  • and "light", too (Lights)
  • lock (locks) - opening and closing
  • media_player (repromultimedia players) - riproduction, pause, stop, set volume, adjust volume, track forward / backward
  • scenes
  • script - activation / activation only
  • sensor (Sensors)
  • Switch (switches)
N.b. To integrate Amazon Alexa with Home Assistant exist two roads:

This guide shows you how to make the second chance, the free one.

Finally, it is good to know that Alexa can be integrated to Home Assistant also how to repromultimedia producer and how voice notification system, or "making it talk" automatically when certain conditions arise in home automation.

It starts


As shown above, the main pre-requisites they are two:

  • version of Home Assistant greater than or equal to 0.62;
  • Home Assistant configured for remote control via HTTPS.

The second point is that the proinstance Home Assistant is reachable remotely and by proHTTPS tocol. In case you are using Home Assistant installed on Raspberry (installation as applicativo) it's available a detailed guide to prosubsidence.
There is also another card dedicated to users who use the distribution HASSIO.

There are also pre-requisites to corollary.

RASPBIAN USERS (or Linux)Users who use Home Assistant installed on Raspbian they only need to appurge to be able to connect to the Raspbian file system via SFTP (using Filezilla or other tools) to recover a file that will be generated by Raspbian.
USERS HASSIOUsers who use HASSIO they must necessarily have installed SSH o Samba server (HASSIO Add-on) to retrieve a file that will be generated by HASSIO same.
USERS Windows Users who use Home Assistant installed on Windowsin addition to the advice to change the operating environment on which to run it - it is necessary to have a computer with Raspbian operating systemmacOS/ Linux, needed to generate the expected file in one of the following steps.
USERS MACUsers who use Home Assistant installed on Mac must appurge that, via "Terminal", the following commands are available:

  • apt-get
  • wget
  • make

If they are not present, install them. Alternatively, use a Linux / Raspbian computer, needed to generate the expected file in one of the following steps.

Finally, it is (obviously) necessary that su Home Assistant no is operational paid integration via Nabu Casa.
If necessary, deactivate it before to begin with the execution of this guide.

Activate API and Alexa

First of all it is necessary to indicate to Home Assistant to activate the "API" component and the "Alexa" component.
the configuration of the configuration.yaml file it's trivial:


Restart Home Assistant.
Nb Notice how these are two distinct blocks. The first activates the component "API", The second one "Alexa"

At this point Home Assistant will exhibit profirst API at


Address that will be used by the integration to interface the cloud AWS with our instance of Home Assistant.
The address that we are going to expose towards AWS it will be only the first part, that is:


TOKEN creation long life

At this point it is necessary to create a "TOKEN long life", Or an access key valid for 10 years.
To do this, from an interface Home Assistant click on colorful circle containing the first letter of your username mail bottom left in the interface column Home Assistant:

Username on Lovelace UI Home Assistant

Once you have accessed the page, unstick the bottom until you find it the following box:

Home Assistant - Long life access token

Click now on "CREATE TOKEN"And, at the request of the name of the token to be created, enter"haaska"
At this point save the string that will come prodeveloped by Home Assistant.

Creating the package for AWS

At this point it is necessary to generate a package containing “haaska”Pre-configured with TOKEN appena created (and its connection URL a Home Assistant).

This file can be generated:


from Terminal, execute:

sudo apt-get install python3 python3-venv python3-pip zip unzip -y
cd ~
mkdir temp
cd temp
sudo wget

In case of error on command wget and / or unzip, to execute:

sudo apt-get update
sudo apt-get install zip wget -y

and then re-run the wget.

cd haaska-master/config
sudo cp config.json.sample config.json
sudo nano config.json

At this point you will be faced with a configuration of this type:

  "url": "http://localhost:8123/api",
  "bearer_token": "",
  "debug": false,
  "ssl_verify": true,
  "ssl_client": []

At this point take care to change the configuration by entering:

  • in the field "url", The API address (as explained above, example address red modified according to proyour configuration - be careful https and not http);
  • in the field "bearen_token“, The string generated in the step concerning TOKEN long life.

Nb Notice how the address changes from "http" to "https".

Save and exit (CTRL + X, Y, enter).

cd ..

At this point one will be performed proautomatic cedura that will generate a file called
This file it must be recovered and put aside: you can do it through Filezilla (using SFTP) by targeting that customer directly to the IP of the Raspberry.


Same proabove procedure, but using the following alternative commands to be entered via SSH terminal (the service must be installed How add-on HASSIO):

mkdir temp
cd temp/
apk add make
apk add zip
apk add wget
apk add nano
apk add py-pip
cd haaska-master/config/
cp config.json.sample config.json
nano config.json

at this point make the configuration changes explained above, then conclude with:

cd ..
cd /
cp ~/temp/haaska-master/ /share

Finally, recover the file using "Configurator"(The file will be in the folder"share“).

Amazon Developer Console

At this point it is necessary to register (if you have not already done so) at the "Amazon Developer Console“, A satellite site to the classic / .it to which you must already be previously registered.

Go therefore to and use the profirst username/ password (of / .it) to enter. Then click on "Login with Amazon"

Amazon Developer Console - Login with AmazonIthe site will ask (if it has not already been done previously) to configure the service "Login with Amazon“, Which allows you to use the propria username/ password of / .it (among other things already used to configure the profirst Alexa environment) on all satellite sites such as, forappanointed, "Amazon Developer Console"

Amazon Developer Console - Login with Amazon

Once you have access, click on "Create new prosecurity thread"
In the required fields, enter:

  • Name of prosecurity thread"HASSIO"(Or whatever you prefer, it's just a descriptive name);
  • Description of the prosecurity thread"HASSIO"(Or whatever you prefer, it's just a description);
  • Privacy consent URL: what is believed, is indifferent, since the Skill that we will prepare will not be public but private:

Amazon Developer Console - New prosecurity thread

Click on "salvo"
In the finestthat will open. Click on the wheel on the bottom right and select "Web Settings"

Amazon Developer Console - Web Settings Prosecurity thread

The following page contains the coordinates of the proprio prosecurity thread:

Amazon Developer Console - Web Settings Prosecurity thread - Details

Leave the fi opennestra and move on.

Alexa Developer Console

Set aside the previous page, open a new tab / page and connect to the address then using the profirst use / .it to authenticate. The purpose is to go and define a skill for our environment.

At this point, the main page of the “openedDeveloper Console", Click on"Create Skill"

Amazon Developer Console - Create Skill

On the following page indicate the name of the skill ("Haaska" - or what you prefer) and "Smart Home" as typology:

Amazon Developer Console - New skill

On the next page, leave "selected"v3". Make a note of the string under the heading "Your Skill ID"(Will serve later).
Amazon Developer Console - New skill - Payload Version and Skill ID

Also leave this fi opennestra and move on.

Amazon Web Services (AWS)

Now you need to define a resource Lambda presso AWS.

Open a new tab / finestand log in (by creating an account, if you don't have one) at the address

Nb The possible creation of a new account requires the mandatory entry of a credit card validates, to which however no cost will be charged (the debit of 1 post-insertion dollar is fictitious - it is necessary to AWS only to verify the validity of the card itself). The configuration dictated by this guide does not include any expense, unless subsequent changes in the terms of use of AWS whose reading and acceptance is the responsibility of the user who subscribes to the service.

Furthermore, it is clear that if the user subsequently implement other features that absorb paid resources AWS, this card will be used for debits. If you want to stay calm, use a rechargeable card.

AWS Amazon Web Services - Access


Once authenticated click on "Services"(Top) and select the item"I AM"Below"Security, Identity & Compliance". Then, on the left, click on "Roles" and finally "Create Role"

AWS Amazon Web Services - IAM

On the page that opens, select "AWS Service" and "Lambda"

AWS Amazon Web Services - IAM - New role

Below, click on "Next: Authorizations"
On the following page, search in the search box “DatabaseAdministrator"; once found, select the item and finally click on "Next: Tag"

AWS Amazon Web Services - IAM - New role - 2

On the following page, enter "lambda_basic_execution"In the head"Role name"; finally click below "Create role"

AWS Amazon Web Services - IAM - New role - 3


Click on the item "Services"(Top) and select the item"Lambda"Below"Compute"

ATTENTION: Receiving a typical message in response "Your service sign-up is almost complete! Thanks for signing up with Amazon Web Services. Your services may take up to 24 hours to fully activate ...", The cause (9 on 10) is given from not having entered a valid credit card at the time of account creation.

Top right select "EU - Ireland"(caution not to forget this step):

AWS Amazon Web Services - Lambda

Click now on the orange button "Create a function"
The fields must be completed as follows:

  • Create from scratch;
  • Full Name: "Haaska";
  • Runtime: "Python 3.6";
  • Role: "Select an existing role";
  • Existing role: "Lambda_basic_execution "

AWS Amazon Web Services - Lambda - New feature

That done, click on "Create function", bottom right.

On the new page, go down about halfway and find the box "Function code". Click the drop-down menu "Type of code entry"And select"Upload a .zip file"

AWS Amazon Web Services - Lambda - Upload File

The voices "Runtime" and "Managermust be set respectively "Python 3.6" and "haaska.event_handler"
If these fields are not set in this way, correct them as indicated.

At this point click on the icon rappshowing an arrow pointing upwards for prosee send to AWS the package .zip file prolearned in proinitial cedure.

After that, go down even further and find the box "Execution role“, Which must be set as follows:

AWS Amazon Web Services - Lambda - Role of execution

Now head back to the page, to the box "Designer"And select the item"Alexa Smart Home"

AWS Amazon Web Services - Lambda - Designer

Nb if the item "Alexa Smart Homeis absent it is because previously the prothread toUS (Ireland)"

Get off and find the box "trigger"
In the editable field enter the "Skill IDpreviously obtained (eg. "amzn1.ask.skill.2e4e ....")

AWS Amazon Web Services - Lambda - Trigger

Then click on the "Add"
Finally, go to the top of the page and press the orange button "salvo"

Immediately above the button "salvo"There is a defined string"arn": Write it down.

Also leave this fi opennestra and move on.

Skill completion

Return to the skill recap and insert in the field "Default endpoint"The value of the field"arn”Copied in the previous point.
Select the checkbox belowEurope, India"(caution not to forget this passage). Here too copy the same "arn"

At the top right of the page, click on "Save"

Now click on the entry on the left columnACCOUNT LINKING"
On the page that opens, enter the following values:

  • Authorization URI: "Https://"
  • Access Token URI: "Https://"
  • customer ID: the value of the CLIENT ID obtained from recap page of proprio prosecurity thread;
  • CLIENT Secret: the CLIENT SECRET value obtained from the recap page of the proprio prosecurity thread;
  • Client Authentication Scheme: HTTP BASIC (Recommended);
  • Click on "+ Add Scope"And insert"profile".

At the top right of the page, click on "Save"

Also leave this fi opennestra: soon we will need the "Redirect URLs” appburned at the bottom of this page: return to recap page of proprio prosecurity thread, click on “Modification"And insert, under"Return URLs allowed", all and trand the "Redirect URLs"

Once completed, click on "salvo"


Return to the definition page of the "Lambda"And click on"Selection of test events" and then "Configure test events"
A fi will opennestsimilar to this:

AWS Amazon Web Services - Lambda - TEST

In the field "Event name" to insert "Test"
Then delete all the test lines and replace them with the following text:

  "directive": {
    "header": {
      "namespace": "Alexa.Discovery",
      "name": "Discover",
      "payloadVersion": "3",
      "messageId": "1bd5d003-31b9-476f-ad03-71d471922820"
    "payload": {
      "scope": {
        "type": "BearerToken",
        "token": "access-token-from-skill"

Finally click on "Crea"

At this point run the "Test"Clicking the button"Run tests": The response should be positive. Differently, check all the steps implemented so far.

Definition of domains

Before concluding the integration it is a good rule to specify in advance in the configuration Home Assistant what are the domains to be made available to Amazon Echo / Alexa, so what accessories, scenes, entity etc.

The list of exportable domains is as follows:

  • alert (alarm alerts)
  • automation (automation) - on / off
  • climate (air conditioners and thermostats) - target temperature setting.
  • cover (dark)
  • fan (fans) - on / off
  • group (groups)
  • boolean input (boolean input)
  • and "light", too (Lights)
  • lock (locks) - opening and closing
  • media_player (repromultimedia players) - riproduction, pause, stop, set volume, adjust volume, track forward / backward
  • scenes
  • script - activation / activation only
  • sensor (Sensors)
  • Switch (switches)

Then add a similar block to what follows the configuration Home Assistant:

        - light.cucina
        - switch
        - switch.terrazzo
        - lock
        name: Nome personalizzato per Alexa
        description: La luce della cucina
        display_categories: LIGHT

In this example block they are included in the domain Amazon Alexa the features of switching on kitchen and bedroom lights, they are included all switches, except that of the terrace. The domain "lock" (locks) is excluded in its entirety.
Furthermore, the behavior / name was customized of kitchen light and the switch of the stairs.

Field display_categories can be customized based on the categories available within Alexa.

Finally, after the modification of the configuration file of Home Assistant, remember to restart theHUB.

Add the skill to Alexa

Here we are: now it is possible to add the skill appena created al proprio proAlexa thread.

Since de facto we have created a Skill (private) ad hoc, just open theapp (Mobile or Web) Alexa, browse the section "Your skills"Under the heading"Skill". Once found the profirst car skillprolearned (called "haaska", Or differently how you chose to call it), select it and click"Enable". THE'app will ask to associate an account: use that of / .it.

At the end of the procedura, perform a full device search. This new one proprocedure provvederà to carry out the discovery automatic of the entity present on Home Assistant and exposed to Alexa based on the configuration of the previous paragraph.

In case of non-customization, Alexa will find all entities (not recommended).

This ended procedura, Alexa will be fully integrated into Home Assistant.

This slideshow requires JavaScript.

Home Assistant Official LogoATTENZIONE: remember that there is on our FORUM community an ad hoc section dedicated to Home Assistant, for any doubt, question, information on the specific merit of these components.

inDomus telegram channel

"Make people talk" Amazon Alexa as a home automation notification system on Home Assistant