How to trigger Alexa routines from Home Assistant

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.

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.