How to trigger Alexa routines from Home Assistant

Since version 0.85, the Home Assistant’s Alexa component supports proactive reporting of devices’ states to Alexa. What this means is that when a device’s state changes, Home Assistant will let Alexa know of that change. Previously, Alexa would only query devices states when you look at them on the Alexa app, or when you asked Alexa about a device.

While at first this doesn’t look like something very useful, it opens up a new possibility: allowing Home Assistant to trigger Alexa’s routines! With a routine you can make Alexa say something , play the Flash Briefing, tell the weather, change the volume of the Echos , and some more other actions that are supported by routines!

So, how can you do this? Its pretty simple, actually. First, make sure you’ve setup the SmartHome Alexa Component to allow proactive reporting (make sure you have endpoint and client_id/client_secret specified). Next you just need to expose a binary sensor (it can be a normal door sensor, or even a Template Binary Sensor) to Alexa, and ask Alexa to scan for devices. Finally, create a routine in the Alexa app, and on the “When this happens” choose “Device” and then choose the new device! You can then specify the actions for this routine as desired.

That’s it! When the sensor changes to the state you specified on the routine, the routine will automatically trigger!

Please note that the Alexa component will only recognise binary sensors that have one of the following device classes: door, garage_door, opening, window.

The Cloud Component does not support this as of version 0.85, but should support it soon.

I’ve posted this and some other ideas related to HA on my blog: https://ledstripsandcode.blogspot.com/2019/01/how-to-trigger-alexa-routines-with-home.html

15 Likes

This is very cool! I will have to wait for the Cloud Component to support this before testing but I can see a lot of cool possibilities once this support is added.

Thanks for the heads up!
Carlo

So do I have everything ready for this when I have the emulated_hue component?
I‘m interested in changing the volume of the devices.

This only works with the SmartHome Alexa config, not with emulated_hue.

You must then create an Amazon developer account with an Alexa skill and Lambda function

Is there a documentation about this? Don’t know how to do this and what a „lambda function“ is?

take a look here

I’ve all setup and in the Alexa app I can see my door sensors (binary sensor) as contact sensor.
However when I try to setup a routine and select one of my sensor I get the error “device not supported at the moment” (translated from Italian).
There is something I can try?

Have you enabled the “Send Alexa Events” permission on the Alexa Dev Console?
You can enable it in https://developer.amazon.com/alexa/console/ask then edit your skill. On the “Build” tab, go to “PERMISSIONS” and enable “Send Alexa Events”.
You need to disable and re-link the skill on the Alexa app after that.

2 Likes

Yeah, I’ve been looking for this… Any chance to be notified once it’s activated for the cloud?

Sorry for the late reply.
yep, it’s all set as per instruction on your first post.
Maybe the app give me the error cause I don’t have an echo?
I’m just testing various Alexa stuff through the app.

1 Like

What’s the issue with the cloud component? Is it that it doesn’t properly expose binary sensor types?

No. The problem is that the auth between the alexa skill and the alexa component is not completely implemented in the cloud component.

Meaning what exactly? That Alexa can’t see any sensors? Is it that proactive mode is disabled?

Yes, proactive mode is disabled. HA can’t send updates to alexa without alexa asking for a status.
Alexa could already see sensors, even before proactive mode was implemented.

Darn. Hopefully they update soon; makes the cloud service a lot less appealing.

I trigger Alexa routines with this component:

I’m been using Haaska for a couple of months now, and thought I would give this a try, but my first problem is that my binary sensors are not being discovered. To make sure the discovery was still working, I added a light and the light does get discovered and it is in the same filter include list as my binary sensors (I have no exclude filter). I’m on 0.85.1. Am I missing something simple?

OK, got the binary sensor figure out…

Now I can’t get the Alexa routine to trigger.
The routine sees the binary sensor, and I can add the binary sensor to the routine and can set the state the routine is to look for (in my example to “open”). I can “play” the routine and see that it performs the action (saying “hello”).
When the binary sensor state changes in in HA, Alexa sees it change to “open”, but the routine is not triggered.

I have followed the steps best I can tell:

  1. Enabled Send Alexa Events in my haaska skill; and relinked the skill on Alexa app.
  2. Added to configuration.yaml the endpoint, client_id and client_secret (copied from “Send Alexa Events”)
    Not sure where else to look/do?

Got it working…had to relink the skill on Alexa App (disable/enable the haaska skill) yet again.

I can’t get this to work either.
Alexa app can see the binary_sensor, it’s state changes when i open the door, but the Routine refuses to trigger. Rarely, it does trigger (alexa app notification) but notification is delivered ~30 minutes after the event.
I’ve tried disabling / enabling the skill, deleting / recreating routines, devices etc etc all to no avail.
I am using HomeAssistant skill, and hassio 0.87.1