How to trigger Alexa routines from Home Assistant

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?

        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

1 Like

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.


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:

I am still having an issues with Alexa routines and my motion sensors. I am using philips hue motion sensors that are linked to HA via Phoscon integration. Sensors work great in HA but i need them to work in Alexa and the motion sensor is just not picking up.

I have verified the sensor is setup as “motion”, configuration below:
‘on’: true
friendly_name: Kitchen
device_class: motion

When i select the motion sensor under devices in the Alexa app, it says the device is unresponsive.

Any help to troubleshoot would be great.


sorry my bad, i was looking at the wrong motion sensor.

in any case, the routine doesnt work. I was reading on another forum that motion sensors are hit and miss with Alexa routines and that only SmartThings motions sensors really work.

Has anybody had success using motion sensors (from HA) as a trigger for an Alexa routine?

You can also trigger Alexa Routines in Home Assistant using the Virtual Buttons skill. There is a sample script in Virtual Button’s Examples post here:

# Virtual Buttons API call
    method: POST
    verify_ssl: true
    content_type:  'application/json'
    payload: '{"virtualButton":{{virtualButton}}}'

You must replace ACCESS_CODE with the personalize access code you get when you enable and link the skill, and then specify which button you want to press in the data field. For button 1 that would be: {"virtualButton": 1}

Note that while you have to create a Patreon account to enable and link the skill, you do not have to join a membership tier unless you want more than one Virtual Button.

Hi abmantis…any idea if this has changed, have a binary switch which I can set as the trigger in Alexa but can’t seem to get the HA update of the switch to kick the Alexa routine into action (sorry newbie and still finding my feet). Came across this post which explains things but given its a year old was hoping it might have changed (using Nabu Casa as my link between HA and Alexa). Thanks in advance!

Hey. As noted in the first post:

Are you sure the binary_sensor has one of those classes?

Hi! Yup, it is a ‘door’, but that wasn’t the problem. As often with something, you spend hours & hours trying to work it out, ask for help and then figure it out yourself. Reading your reply and checking my config, spotted I didn’t have “Enable State Reporting” toggled on in Home Assistant Cloud (next challenge will be to only allow state reporting for this one sensor!).

Feel bit of a fool now and really appreciate the speedy reply!

  - platform: template
        friendly_name: "GoveeLightSensor"
        value_template: '{{ is_state("light.govee_light","on") }}'
        device_class: 'door'