2 m

A white Amazon Echo Dot on a wooden countertopSince I’m using Home Assistant, I tried to get my Amazon Echo speakers properly integrated. My ultimate goal is to integrate music into my light scenes. Luckily, the Alexa Media Player integration in the Home Assistant Community Store (HACS) did all I wanted and much more. However, there was one big issue. Every two weeks or so, I had to enter a captcha to reenable the integration. I couldn’t figure out why that happened; maybe I was a little too excited with the amount of service calls. However, in my opinion: not smart at all since I’m blind and can not read those things. Besides that, a smart home which needs support every two weeks??? Time to work around this Alexa Integration!

There are two methods to let Home Assistant and Amazon Alexa communicate with each other. The first is the Alexa Media Player integration, which tells Alexa what to do. It’s possible to call a service to play music, start routines, use Alexa guard as an alarm panel and many things more. It is a really great integration. If it wasn’t for the captcha every two weeks, I still would have been using this integration. The second method is the Alexa skill for Home Assistant from, with which you can control your devices, such as lights, switches and thermostats. This is a one-way communication. However, since it is possible to report the state of an entity in Home Assistant to Amazon Alexa, we can also talk the other way around using binary motion and door sensors to trigger routines. It’s a little more work for much more reliability.

In order for this second method to work, I needed to add some template binary sensors into my configuration file. There are two types of binary sensors supported by Alexa: door and motion. The sensor type is defined in the ‘device_class’ in the binary sensor entry. It doesn’t really matter which one you are going to use. One says open or closed and the other says motion detected or not detected. The state of each sensor is decided by the state of a switch, light, input Boolean, ext. Below are some example sensors:

# Binary sensor examples
  - platform: template
        friendly_name: "Coffee Ready Sensor"
          minutes: 6
        device_class: motion
        value_template: "{{ is_state('switch.coffeemachine', 'on') }}"
        friendly_name: "Sun is shining"
        value_template: >-
          {{ is_state('sensor.br_condition', 'clear')
             and is_state('sun.sun', 'above_horizon') }}
        friendly_name: "FerryMug is at home"
        value_template: "{{ is_state('device_tracker.pixel_2_xl', 'home') }}"

A collections of sensors in the Alexa appYou can be as creative as you want with these binary sensors. Below you’ll read some plus sides of this method:

  1. Faster response times
  2. Reliable
  3. No captcha every two weeks

Of course, there are also some down sides:

  1. It involves more work to set it up
  2. For each action you need a sensor and a separate Alexa routine

For me, reliability is very important. So I will stick with the binary sensor method, until there is a better integration,

How do you use Alexa and Home Assistant together?