How to use Home Assistant with Alexa | Tips and Tricks

How to use Home Assistant with Alexa
– Learn these tips and tricks on how to use your devices in a much easier way as well as solved some of your common problems that are difficult.

Home Assistant is a free open source software that allows you to control and automate your home automation through a single interface. Simply put, it is a personal hub for home automation able to integrate different devices together and – above all – made by different manufacturers. Among the many integrations available, there is also the one with Amazon’s voice assistant.

In this article we will explain how to use Home Assistant with Alexa, illustrating the step-by-step guide to carry out a free integration (thanks to the colleagues of inDomus for the procedure and the codes shown below). We tell you right away that this is the most complex way to integrate your personal HUB with Amazon Alexa, but in this way you will avoid paying 5 euros a month for the subscription to Nabu Casa, the Home Assistant cloud service that makes integration with the Alexa voice assistant much simpler but for a fee.

Prerequisites for using Home Assistant with Alexa

Before starting, check that you have the prerequisites to successfully complete the Home Assistant integration with Alexa:

  • updated version of the Home Assistant software
  • configuration of the personal HUB for remote control via the HTTPS protocol
  • account Amazon
  • smart speaker with integrated Alexa (e.g. Amazon Echo)
  • app Amazon Alexa

Activation of the Api and Alexa components

The first step to integrate Home Assistant with Alexa involves activating the Api and Alexa components through a simple change to the file configuration.yaml of the HUB:

api:
alexa:
   smart_home

Once you have saved the changes to the configuration.yaml file, you need to restart Home Assistant.

Creating a long-lived token

Continue with creating a long-lived access token, also known as a long-life token, being an access key that is valid for up to 10 years. If you are wondering what it is for, just know that thanks to this key, scripts can interact with the Home Assistant instance.

To create a long-lasting access token, first access the Home Assistant interface, then select the colored circle containing the first letter of your username and wait for a new page to open; now locate the header “Long life access token”then click on “Create Token” and give the key whatever name you want. Once this is done, keep the string generated by the personal hub on one side.

Read This Now:   Enable disable Parental Control in Android Play Store (Downloads)

Amazon Developer Console Subscription

The next step is to create an account on the Amazon Developer Console, the portal for Amazon services and technologies for developers. To do this, go to the developer.amazon.com page, log in with your Amazon account credentials, then fill out the registration form and click on the button “Submit” to complete the procedure.

In the new screen that appears, click on “Setting”select “Security Profiles” and then click on the button “Create a new security profile”. At this point, fill in the fields as you wish “Name of the security profile” e “Description of the safety profile”then presses the button “Salva” to store the information just transcribed.

Create Amazon Developer Security Profile

Now click on the section “Web settings” to access the “Security profile management” page which contains all the coordinates you will need at a later time. Then leave the page open and go to the next step.

Creating a skill via the Alexa Developer Console

The time has come to create an ad hoc skill for our environment through Alexa Developer Console, the tool dedicated to Amazon’s voice assistant developers. First, go to developer.amazon.com/alexa/console/ask, then click on the button “Crea skill”.

Crea Skill Alexa

Now type a name of your choice for the skill in the box under “Skill name”, then select the box “Smart Home” and click on the button “Create skill” top right to continue. On the new page that opens, leave the check mark next to “v3 (preferred)” and stores the string placed below “Your Skill ID” helping you with the link “Copy to clipboard”.

Skill Alexa Per Home Assistant

Lambda Resource Definition Using Amazon Web Services

The next step involves defining a Lambda resource on Amazon Web Services, the on-demand platform owned by Amazon that delivers cloud computing services. Go to console.aws.amazon.com/console/home and log in as “Root User” as per default.

Login Aws

If you’ve never used AWS before, click the button “Create a new AWS account” to register a new account: among other things, you will need a credit or debit card for payment information, plus a phone number to receive a text message to confirm your identity.

Note: Using AWS to integrate Home Assistant with Alexa is within the limits of the free tier.

Once logged in, from the “AWS Services” section select “All the services”then locate “Security, identity, compliance” and click on “IAM”. In the new page that opens, presses on “Roles” from the side menu, then click the button “Create role” then select the box “AWS Service” and the link “Lambda”.

Lambda Aws Function Creation

Remaining on the same page, go to the bottom and click on the button “Next: Authorizations” to move forward. Now locate the writing under “Policy Name” “AWSLambdaBasicExecutionRole” (help yourself with the search filter), and once you find it add a check mark next to it, then click on the button “Next: Tag” to continue (since this is an optional step, you can go directly to the fourth and last step “Verify”).

Read This Now:   How To Fix Windows Cannot Connect To Printer - Easy Steps

Next to “Role name” type “lambda_basic_execution”finally click on the button “Create role” to confirm everything.

Lambda Basic Role Creation Execution Aws

Now go on “Services” at the top left, select “Calculation” and subsequently “Lambda” to open the “Functions – Lambda” page. Once here press on “Ohio” at the top right (next to your username) and select “Europe – Ireland”then click on the button “Create function” and continue like this:

  • Select the “Create from scratch” checkbox.
  • In “Function name” type the same name entered in the previous steps.
  • In “Runtime” select “Python 3.8”.
  • For “Architecture” leave the check mark next to x86_64.
  • Under “Execution role” put a check mark next to “Use an existing role”
  • In the empty field “Existing role” type “lambda_basic_execution”.
  • Complete the procedure by clicking on the orange “Create function” button.

Create Lambda Function On Aws

When done, click the checkbox “RNA copy” so as to save the string for later. We continue.

Under the heading “Function overview” click on the button “Add trigger”then click on the drop-down menu “Select a trigger” and choose “Alexa Smart Home”.

Alexa Smart Home Configurazione Trigger Aws

Now next to “Application ID” enter the Skill ID previously obtained in the Alexa Developer Console and click on the button “Add”.

Alexa Smart Home Trigger Configuration

In the new screen, move to the tab “Code”then click the button “Upload from” and choose the item “File.zip”. At this point select the key “Load”attach the haaska.zip file downloadable from this link and click on the button again “Salva”.

Upload Haaska Zip File

Then under “Code source” select the file “config.json” and modify it according to the instructions below:

  • Next to “url” replace the link with the address where Home Assistant exposes its API (see chapter “Activating the Api and Alexa components”), making sure that https: // and not http: // is reported
  • In the “bearen_token” field enter the string obtained after the creation of the long life token.
  • Click on the “Deploy” function to save the latest changes made.

Json Config Code Lambda function

Skill completion

We are nearing the end of the guide. One of the last steps involves completing the skill. To do this, go back to the skill summary screen and into the field “Default endpoint” paste the previously copied string into the “ARN” field. Now add a check mark next to “Europe, India”paste again the “ARN” value used in the previous step and click on the button “Save” to save the changes.

Read This Now:   Find System Settings in Windows 10

Once this step has also been completed, select the item from the left column “Account Linking” and in the new page that opens enter the following values:

  • Your Authorization URI: “https://www.amazon.com/ap/oa”.
  • Access Token URI: “https://api.amazon.com/auth/o2/token”.
  • Your Client ID: the Client ID string previously generated in your security profile.
  • Your Client Secret: the Client Secret string obtained earlier in your security profile.
  • Your Client Authentication Scheme: HTTP Basic (Recommended).
  • Click the button “+ Add Scope” and enter “profile”.

Click on the button “Save” to make the latest changes. Later, as soon as i “Redirect URLs”cheap with “Edit” and under “Return URL allowed” enter the three “Redirect URLs”.

Click the button “Save” to save the changes you just made.

Test setup and execution

Now go back to the Lambda function main page and select the tab “Run the test”. In the field “Name” enter a name of your choice (for example “Test”), then replace the selected lines of code with the ones you see below:

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

Lambda Function Test Configuration

Then click on “Save changes” select “Run the test”. If you have followed all the steps described above so far you should have gotten a positive response.

Definition of domains available for Amazon Echo / Alexa

Now that the integration procedure is almost finished, all you have to do is define the domains to be made available for Amazon Echo / Alexa. To do this, add the following code to the Home Assistant software configuration:

alexa:
  smart_home:
    filter:
      include_entities:
        - light.cucina
        - light.camera
      include_domains:
        - switch
      exclude_entities:
        - switch.terrazzo
      exclude_domains:
        - lock
    entity_config:
      light.cucina:
        name: "Nome personalizzato per Alexa"
        description: "La luce della cucina"
      switch.scale:
        display_categories: LIGHT

Adding the skill to the Alexa profile

All you have to do is add the skill to your Alexa profile. Open the Amazon voice assistant app, under “Skill” select “The kill skill”then select the skill you just created and tap on “Skills”. The next step involves associating with your Amazon account.

Once this is done, search for devices to complete the integration and start using Home Assistant with Alexa. That’s it: if something goes wrong, we suggest you repeat the steps in the guide without skipping a single point.

GiardiniShop

Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /home/gamefeve/bitcoinminershashrate.com/wp-includes/functions.php on line 5420

Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /home/gamefeve/bitcoinminershashrate.com/wp-includes/functions.php on line 5420