Robbie Trencheny 8ed8e53831 Merge pull request #358 from robbiet480/change-featured-page
Add 5 new items to the featured page
2016-03-29 21:17:47 -07:00

5.7 KiB

layout, title, description, date, sidebar, comments, sharing, footer, logo, ha_category, featured
layout title description date sidebar comments sharing footer logo ha_category featured
page Alexa / Amazon Echo Instructions how to connect Alexa/Amazon Echo to Home Assistant. 2015-12-13 13:02 true false true true amazon-echo.png Voice true

There are two ways that you can use Amazon Echo and Home Assistant together.

No matter which method(s) you decide to use, please remember that Amazon Echo requires an active Internet connection to function. If your Internet is down or experiencing issues (or Amazon's infrastructure is having issues), neither of these methods will work.

{% linkable_title I just want to turn devices on and off using Echo %}

If you just want to be able to turn anything with a switch (like lights, switches, media players, etc) on and off, check out Michael Auchter's Haaska which integrates the Alexa Lighting API into Home Assistant.

Implementing Haaska means you can turn things on and off by simply saying

Alexa, turn the living room lights on.

or

Alexa, set the living room lights to twenty percent.

instead of

Alexa, tell Home Assistant to turn the living room lights on.

or

Alexa, tell Home Assistant to set the living room lights to twenty percent.

In addition, you would need to build custom intents for each device and on/off combination using the below method, whereas everything just works without any extra work by using Haaska.

Please note that you can use Haaska and the built-in Alexa component side-by-side without issue if you wish.

{% linkable_title I want to build custom commands to use with Echo %}

The built-in Alexa component allows you to integrate Home Assistant into Alexa/Amazon Echo. This component will allow you to query information and call services within Home Assistant by using your voice. There are no supported sentences out of the box as of now, you will have to define them all yourself.

{% linkable_title Requirements before using %}

Amazon requires the endpoint of a skill to be hosted via SSL. Self-signed certificates are ok because our skills will only run in development mode. Read more on our blog about how to set up encryption for Home Assistant. If you are unable to get HTTPS up and running, consider using this AWS Lambda proxy for Alexa skills.

To get started with Alexa skills:

{% linkable_title Configuring your Amazon Alexa skill %}

Alexa works based on intents. Each intent has a name and variable slots. For example, a LocateIntent with a slot that contains a User. Example intent schema:

{
  "intents": [
    {
      "intent": "LocateIntent",
      "slots": [
      {
          "name": "User",
          "type": "AMAZON.US_FIRST_NAME"
        }]
    },
    {
      "intent": "WhereAreWeIntent",
      "slots": []
    }
  ]
}

To bind these intents to sentences said by users you define utterances. Example utterances can look like this:

LocateIntent Where is {User}
LocateIntent Where's {User}
LocateIntent Where {User} is
LocateIntent Where did {User} go

WhereAreWeIntent where we are

This means that we can now ask Alexa things like:

  • Alexa, ask Home Assistant where Paul is
  • Alexa, ask Home Assistant where we are

{% linkable_title Configuring Home Assistant %}

Out of the box, the component will do nothing. You have to teach it about all intents you want it to answer to. The way it works is that the answer for each intent is based on templates that you define. Each template will have access to the existing states via the states variable but will also have access to all variables defined in the intent.

You can use templates for the values of speech/text, card/title and card/content.

Configuring the Alexa component for the above intents would look like this:

{% raw %}
# Example configuration.yaml entry
alexa:
  intents:
    WhereAreWeIntent:
      speech:
        type: plaintext
        text: >
          {%- if is_state('device_tracker.paulus', 'home') and
                 is_state('device_tracker.anne_therese', 'home') -%}
            You are both home, you silly
          {%- else -%}
            Anne Therese is at {{ states("device_tracker.anne_therese") }} and
            Paulus is at {{ states("device_tracker.paulus") }}
          {% endif %}

    LocateIntent:
      action:
        service: notify.notify
        data:
          message: Your location has been queried via Alexa.
      speech:
        type: plaintext
        text: >
          {%- for state in states.device_tracker -%}
            {%- if state.name.lower() == User.lower() -%}
              {{ state.name }} is at {{ state.state }}
            {%- endif -%}
          {%- else -%}
            I am sorry, I do not know where {{ User }} is.
          {%- endfor -%}
      card:
        type: simple
        title: Sample title
        content: Some more content{% endraw %}