How to trigger Alexa routines from Home Assistant

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.

Thanks

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: https://www.patreon.com/posts/examples-31398929

# Virtual Buttons API call
rest_command:
  press_virtual_button:
    url: https://api.virtualbuttons.com/v1?accessCode=ACCESS_CODE
    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!


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

Can Alexa skills be exposed into HA?
For example I have skylink alarm that is connected to Alexa…would like it to communicate back to HA

I have a similar issue - my binary_sensor is of device_class ‘opening’ and it is shown in the Alexa app. I can see the status change in the Alexa app as well, so it looks like the communication from HA to Alexa works. However, the routines that I created never trigger.The trigger looks like this: when ‘First Amazon Plug opens’. The routine works fine if I trigger it manually. I have another routine with a trigger when ‘First Amazon Plug closes’. That works fine as well.
Is this just a matter of waiting for the routines to be enabled? Or is something else going on?

Have you enabled proactive events in the skill setup?

1 Like

I am using Amazon Alexa Smart Home Skill - Home Assistant (home-assistant.io) which is basically a lambda function running on AWS. Have not seen proactive events as an option, but I will take a look.

On that page you refered, see https://www.home-assistant.io/integrations/alexa.smart_home/#proactive-events

1 Like

yeah, I see it now. I had to enable it, did not have it enabled previously. Did not know it was a thing :slight_smile: Thanks. It works!!

Hi,

So I was able to get this kind of working but am stumped at whats wrong.

I setup an inputboolean switch on lovelace, I have a binary door sensor setup to check the state of the input boolean. Alexa is seeing the status of the sensor as open or closed when I toggle the switch. I have a routine in Alexa to turn a smart plug on/off depending if the state is open or closed. But the routine in Alexa is not triggering the powerbar outlet to turn on/off for some reason.

I have a smart power bar that I cant integrate natively into HA but has an Alexa skill.

EDIT: realized I didn’t have the Alexa report states turned on, in the cloud settings.

Thanks.

does anyone have any extra information on this? i do use haaska… but i removed it all to try this as i’m looking to trigger routines via HA. however, after deleting and starting over multiple times… i’m stuck on unable to link my HA with alexa… any tips?

Update: i have not fixed it yet, but i think i may have figured out the issue is probably because of the beginning of the directions which states “The Alexa Smart Home API requires your Home Assistant instance to be accessible from the internet via HTTPS on port 443 using an SSL/TLS certificate.” I have not set my forwarding to this port which is probably the issue. if someone could inform me of this that’d be great…

Update 2: after reading the documentation further i found that it was the port number that i had to correct in order to link my account.

Can anyone explain what exactly “expose” the sensor to Alexa means?

I have my Echos connected to HA already. It’s syncing my scenes created in HA but that’s it.

I created a binary sensor that detects whether a boolean switch is on:

binary_sensor:
  - platform: template
    sensors:
      door:
        friendly_name: "sensor - trigger for alexa"
        value_template: '{{ is_state("input_boolean.trigger_for_alexa","on") }}'

I was hoping to use that to trigger an Alexa routine but my Echo is not discovering the sensor. I’m knew to HA so maybe I just don’t know how to “expose” things to Alexa properly. I’ve restarted HA and clicked sync entities to Amazon several times.

Any ideas?


Well I figured out what expose means. If any other noobs like me happen across this, you have to open “manage entities” under home assistant cloud to see what’s exposed and what isn’t. As soon as I did that I got a notification on my phone that Alexa discovered a new device.

It shows up in the list of all devices but it doesn’t show up as an option for routine triggers though which is frustrating.

Have you enabled proactive reporting?

1 Like

I did, didn’t make a difference. But I just found out I can trigger routines directly with Alexa Media Player so I’m giving up on the virtual binary sensor for now anyway. Thanks for trying to help!

Another way to trigger an Alexa routine from anything that can do an http request:
https://www.virtualsmarthome.xyz/url_routine_trigger/

Contact sensors and motion sensors aren’t supported in all regions: List of Alexa Interfaces and Supported Languages | Alexa Skills Kit

1 Like

It works perfectly for me.