How to control Alexa devices with Home Assistant?

I want to control an Alexa device (or run an Alexa routine) from Home Assistant, specifically creating a HA Automation triggered by a Toggle Helper that can be used to trigger an Alexa routine.

I have found the way to have an Alexa Routine turn on/off an HA toggle entity with the Amazon Alexa Integration within Nabu Casa (I subscribe). And it works. But that is the wrong direction for what I want.

I have also found information on Github alandtse/alexa_media_player custom Integration that is suppose to allow control of Amazon Alexa devices in Home Assistant using an unofficial Alexa API.

I haven’t been able to get this to run an Alexa Routine with a HA Automation with a toggle Helper trigger in Home Assistant. Based on some examples I created an Automation to turn an Alexa light on when my toggle helper “Office Brown Light HA” goes to “On”. The Alexa Routine is “Turn On Office Brown Light HA”.

alias: Test HA control of Alexa Light
description: ""
trigger:
  - platform: state
    entity_id:
      - input_boolean.office_brown_light_ha
    to: "on"
condition: []
action:
  - service: media_player.play_media
    target:
      entity_id: input_boolean.office_brown_light_ha
    data:
      media_content_id: turn on office brown light ha
      media_content_type: routine
mode: single

This runs when the toggle helper is set to On, but nothing happens on Alexa. I suspect I have gotten the Target incorrect, but have found anything that works there. Any Help is appreciated.

Alexa Media Player is intended to play music.

Media player apart, if you expose a Home Assistant entity to Alexa, you can use voice commands to control it, either directly in the case of switches and lights or with an Alexa routine.

You can’t control Alexa devices or routines from Home Assistant, other than to trigger routines with input booleans or switches. This is because Amazon don’t allow third party access to their system.

So in your example, the action block of the automation will do nothing. You could, however, use input_boolean.office_brown_light on its own (on a dashboard, say) to launch a routine in Alexa
which turned on the light.

That’s not correct. You can, in fact, trigger Alexa Routines using the method in OP’s post.

@BigBahJohn

Your media player action is targeted at an input boolean… that’s not gonna work. :wink: You can target it at any of the media_player entities supplied by AMP.

Beyond that, one important point when calling Alexa routines like this is that the value you use for media_content_id needs to exactly match the routine’s name including punctuation, capitals, spaces, etc.

3 Likes

Yes. And that… :laughing:

Sorry, it’s been a while since I used Alexa Media Player. Worth mentioning, perhaps, that the integration has been struggling lately - not sure what the latest is on its status.

If the input boolean is exposed to Alexa then you can use that in your Alexa routine to trigger the routine actions. I’ve never used a media player to trigger a routine but I use input booleans in the Alexa app to trigger routines.

you need to first expose the boolean to Alexa (either via the HA Cloud integration or something third party like HAASKA) then in the Alexa app you use that boolean to trigger the Alexa routine.

Many thanks to all that relied!

I followed @finity. Yes I had exposed the toggle Helper in HA to Alexa. Then I wrote 2 Alexa Routines. One that when the Helper closed (turned off) it would turn OFF the light and similar to turn it ON. This worked perfectly!. I can now either directly turn the Helper ON/OFF or write an Automation to do it. This is EXACTLY what I wanted.

Thank you.