How to trigger Alexa routines from Home Assistant

Hey folks, totally new to Hass.io - trying it out purely because of this ability to trigger Alexa routines. I use EventGhost at the moment. Have managed to use EventGhost to create a binary sensor (via Python) and trigger its state in HA - I want to use this to trigger my Alexa routines if possible. Alexa finds the sensor, but it’s not selectable as the trigger when I create my Alexa routine. I have enabled the ‘Enable State Reporting’ in the HA cloud component, re-enabled the Alexa skill, etc. - no joy. I am completely new to HA, so please be gentle (and do talk to me like an idiot, because I need clear instructions). The sensor does not show as an entity in HA - could this be my problem? Many thanks in advance.

EDIT: Damn. Fixed the issue (just needed to include the ‘door’ device class attribute in the JSON payload. It now appears in the Alexa app as a smart home trigger for my routines, but when I select it, I get ‘This device is not currently supported’. A quick look here: https://developer.amazon.com/en-US/docs/alexa/device-apis/list-of-interfaces.html tells me that’s because I’m in the UK, not the US or Canada. Us Brits get left behind ALL THE TIME with Alexa and it’s so annoying!

Anyone know of a way I can simulate a button instead of a sensor?

I’m having similar problems. Using Nabu Casa Cloud to talk to Alexa. Alexa sees and controls my exposed devices perfectly (“Alexa, turn on the lights”). Now want to trigger a routine.

Created an input boolean and exported it to alexa as a contact sensor:

alexa:
  filter:
    include_entities:
     - input_boolean.cat_feeder_alert_go
  entity_config:
    input_boolean.cat_feeder_alert_go:
      name: Cat Feeder alert
      display_categories: CONTACT_SENSOR

(only relevant portions left in)

Added to Alexa. On the “all devices” screen in the Alexa iOS App, the sensor is there, and responds to changes in HA, although on its detail screen it displays a “There was a problem” banner. Nonetheless, it works.

There are probably 20-30 other devices visible under “all devices”.

However, when I go to create a routine, on the “When this Happens” -> “Smart Home”, I get “No devices found. To start a routine with a smart home device, add one in the Devices section of the Alexa app.” Absolutely no devices show up here at all.

The devices is also visible in the Alexa web app, but the web app doesn’t have routines…

Anyone have any ideas?

1 Like

Hey everyone!
I set up everything so far, but I am completely new to home assistant and I usually need some time too get comfy with all this.
I need help setting up a device tracker to be a template binary sensor for triggering alexa routines.
Can someone help me? I currently have the HA app on my phone and a ping setup for device presence, planning on going deeper into this later, so if you can provide me a little walkthrough of the code to create a template binary sensor with the required door class, that would be amazing. Thanks!

Nevermind figured it out. I have my binary sensor now in the Alexa app, working perfectly, reporting the open or close state, because device class is a door. But I can’t get it to trigger routines. I can set it as trigger for a routine, but it won’t trigger the routine.
I am not using Home Assisant Cloud, I saw someone suggested using the debugging tool in the alexa developer console, but I can’t get my head around this, need detailed instructoins please. I followed the tutorial carefully, went over it a few times now, everything is as it should be. No idea what to do. please help.

I’m having the same problem. The Alexa app discovers the boolean switch as a contact sensor but displays “There was a problem” when I attempt to utilize it? Did you ever sort this out?

Just for the record: I gave up on this approach and am just using the AlexaRemote palette in NodeRed. I’m not a fan of NodeRed, but this just works…

You can’t use an input_boolean, nor a switch, only binary_sensor.

As noted in bold in the first post:

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

You must use a binary_sensor entity, with one of those class types (or the CONTACT_SENSOR display category). But (as noted in the first post), it needs to be a binary_sensor.

1 Like

@abmantis - I’m trying to use an input_boolean configured as a contact_sensor as noted below in my config…I was under the impression this would work?

  alexa:
    entity_config:
      input_boolean.security_switch:
        name: Security Switch
        display_categories: CONTACT_SENSOR

Is there another way to accomplish this?

See the comment above yours.
I’m not sure why people are trying to use input_booleans for this :sweat_smile: please let me know if there’s some place or docs that says that so I can update it.

This may or may not be relevant as I am not sure if you are using Emulated Hue or the Nabu Casa thingy…
At one time you could expose input_booleans to Alexa using emulated hue, when that stopped working I created a template light based on my input_boolean, those can be exposed… also I have a “Virtual Light Bulb” as one of the threads linked above references… Alexa can set the brightness which HA watches… so you now have 100 possible brightness levels to trigger different things… you make an Alexa routine, which then sets the brightness, and HA responds accordingly based on the brightness level that Alexa set the bulb to

That is a different use case.
This is to trigger alexa routines from HA, and not to call HA actions from alexa.

I’m new to HA, so I’m still learning and perhaps I’m not going about this the way I should. My ultimate goal is to be able to press a toggle button and turn on/off a virtual switch (boolean_switch) that triggers an Alexa Routine. I was able to accomplish this in Hubitat through a virtual contact sensor device driver.

I assumed that if I created an input boolean and configured it as a contact sensor in the Alexa environment that it would see the open/close (or on/off) and trigger the routine accordingly.

Any suggestions how I might accomplish this?

You just need to create a template binary_sensor for example, and map it to the input boolean. Then expose the binary_sensor in alexa instead of the boolean.

2 Likes

Thanks…I’ll play with it tonight! Appreciate the help!

Has there been any success with this? I have a binary sensor classed as opening and an Alexa routine that should send a notification to my phone when the sensor switches to open. I can view the sensor in the Alexa app and watch it change from close to open back to close but the routine never triggers. I have disabled re-enabled the haaska skill multiple times I even disabled, cleared all devices and re-enabled and re add devices. The send events to alexa is enabled. I am lost as to what to try next.

Yes, It is working fine.
On the Alexa developer console, open your skill, go to the Test tab and enable de Device log widget. Check if anything appears on that log when the binary_sensor changes states.
Also, is there any error on the alexa app?

The event log does not show anything when the state changes. The app gives no error and it allows me to save the routine with the sensor as the trigger.

Can you post here how you are defining the sensor and how you are exposing it in the Alexa integration?

I solved it, I had the client id and secret in quotes in the configuration.yaml. everything works perfectly now.

Finally got round to looking at this. After some effort the solution is really simple.

The Nasa Casa alexa cloud now exposes binary sensors. all you have to is ensure the binary senor you want to expose to the alexa routines is in the correct device class ( I use motion).

I have a number of leak sensors , which are in the device class moisture. The alexa app sees these devices , but cannot trigger routines with them ( which would really useful for alexa to scream danger danger ! when activated)

so you simply change the device_class to motion using the customisation’s option in the configuration menu. Select the entity, pick an attribute to override, select other :-

attribute name device_class attribute value motion

enjoy :slight_smile: