How to launch an Alexa skill from Home Assistant

Note: This post assumes that you have an account with Nabu Casa, and that you can expose your entities to Alexa via Home Assistant Cloud. You don’t need a custom integration.

In Home Assistant Alexa is used primarily as a voice assistant and as a media player. It can control devices that have been exposed to it, and it can launch Home Assistant scripts to perform more complex tasks. But it is also a smart device controller in its own right through its suite of “skills”.

Some Works with Alexa devices have no HA integration - this post shows how to exploit Alexa routines to control them.

A practical example is probably easiest…

Brewing morning coffee

Say you have a Works with Alexa coffee maker, but it doesn’t have a HA integration. You want to turn it on at 6:55am, five minutes before the alarm goes off. Normally you would give a voice command from the associated skill: Alexa, make the coffee - but you can’t, the alarm hasn’t gone off yet, you’re still asleep.

Never mind, HA will do it for you.

  1. First thing is to create a binary entity in HA that Alexa will recognise as a trigger for one of its routines. A toggle helper is easiest:
   input_boolean.coffee_maker
  1. Still in HA, go to Settings | Voice Assistants and expose the new entity to Alexa. It will appear in the Alexa app as a Smart Home device.

  1. In the Alexa app, go to Routines and create a new one.

  1. In the When this happens section, select Smart Home, then choose your new device, Coffee maker

  1. For historical reasons, the Alexa app regards all binary entities as door contact sensors, so the trigger for the routine will be When contact sensor is open - which corresponds to the HA input_boolean changing to “on”.

  1. In the Add action section choose Customised, and enter the skill command you would have given to Alexa - in this case Make the coffee.

Save, and now when input_boolean.coffee_maker is turned on in Home Assistant, the voice command Make the coffee from the Alexa skill will be issued (silently). Notice that turning the input_boolean off again will do nothing. If you want to turn the coffee maker off you have to create a second Alexa routine triggered by the “contact sensor” closing.

You can, of course, add other actions to the Alexa routine, including speech (Wake up and smell the coffee!). If you want to make things really complicated, you can launch Home Assistant scripts.

Alexa will only recognise some binary entities as triggers for its routines. Switches will work, but not lights. A template binary sensor will work if you give it device_class: door.

The fact that switches work as routine triggers means that you can build Alexa skills into HA automations.

description: "Wake up and smell the coffee"
mode: single
trigger:
  - platform: time
    at: "06:55:00"
condition: []
action:
  - service: switch.turn_on
    target:
      entity_id: switch.bedroom_socket_1

…could turn on power to the coffee maker and at the same time launch the Alexa skill to start a brew.


The Home Assistant Cookbook - Index.