How to trigger Alexa routines from Home Assistant

Thank you, just what I have been looking to do.

Hi all!
I am trying to get a sensor in to Alexa to trigger a routine, have defined as follows:

binary_sensor:
  - platform: template
    sensors:
      amazon_smart_plug_1:
          friendly_name: "Hall Lamp - HA Binary Sensor"
          device_class: 'door'
          value_template: '{{ is_state("input_boolean.amazon_smart_plug_1", "on") }}'

It appears in Alexa fine, and when I toggle my input boolean it changes state in Alexa, but there is no option to add to a routine and it does not show in the available Smart Home devices as a trigger.

Within Alexa it shows as a ‘Contact Sensor’ which I believe is correct?

Any advice really appreciated! Have tried adding / removing / restarting / changing device_class so many times, but nothing seems to work :frowning:

Thanks!

in the release notes of release 2022.07 it says that triggering Alexa Routines is now possible via input_booleans, input_buttons etc

input boolean work fine for me but I can’t get buttons to work. I get an Error in the Alexa App that says that this device is not supported.

1 Like

I am trying to get this to work, but am a little bit confused. I get the basic idea of exposing a binary value to alexa that can trigger a routine, I have created a template device as follows.

binary_sensor:
  - platform: template
    sensors:
      master_curtain_sensor:
        friendly_name: "MasterCurtain"
        value_template: 
        device_class: 'door'

The problem I am confused by is what I need to put into value_template, I don’t have a an actual device in HA to track the actual state of the scene. such as a light within the scene. The curtains can’t be connect to the HA., which is why I am trying to use Alexa routine.

What should I put into value_template here?

Is an input_boolean what I want?

1 Like

This seems to work.

binary_sensor:
  - platform: template
    sensors:
      sun_up:
        friendly_name: "Sun is up"
        value_template: "{{  is_state('input_boolean.curtain_master', 'on') }}"

@Jeffrey_Ellin
Are you able to see the device in the Alexa app, and also trigger a routine based on the device’s state?

Are you using Nabu Casa?

For me (not using nabu casa), I can add the input_boolean and binary_sensor to the alexa app, but I don’t see any device listed as a trigger when I tried to go “When this happens” → “Smart Home”.

So I have worked around based on voice command sent by the Alexa Media Player. I described my workaround in my post here.

thanks

I’ve read though most of the posts in this thread trying to figure out where I’m going wrong. I’m using the Alexa Skill rather than Nabu Casa and have had the skill successfully linked for a while now. I have only recently needed to create a routine where I want it to toggle a binary sensor.

I have added the required entries into configuration.yaml - there are no errors in the logs relating to this so I assume everything is setup correctly. I’ve also restarted HA and relinked the skill.

I have created a door sensor from a template and it shows up in the Alexa device list after a rescan. The only issue I have is that when create the route and I try to select the binary sensor under devices, it is displayed right at the bottom of the list under the unsupported section.

Essentially you need three things to make this work:

  1. You need a helper in Home Assistant: a Toggle helper

  2. You need a way for things in Home Assistant to be visible to Alexa: the simplest solution is a Nabu Casa subscription and the Home Assistant Alexa Skill. You will then need to expose the toggle helper to Alexa.

  3. A Routine in your Alexa app: This will respond to the change in state of the helper toggle and do whatever you set the routine to do.

1 Like

I should have mentioned that I’ve tried this with a toggle helper as well. The strange thing there is that running the routing from the Alexa app on my phone via voice control works perfectly. If I ask any of my echo’s the same thing, I just get a ‘dum dum’ like response and it doesn’t work.

This did prompt me to do some more testing today though and I’ve found that for whatever reason, the voice command I was using just wouldn’t work. I tried changing it to something else that is similarly worded and it works without any issue!

I can use some help… I want to have an Automation whereby a TIME Trigger and a CALENDAR Condition runs a Alexa Routine. How do I do that ? I am not very familiar with Yaml and by far prefer the Visual Editor. Thanks !!!

Hi,

I’ ve tried to create a binary sensor with device class “door” to act as a door sensor. It’s OK with HA but if I attempt to expose to Alexa trought Emulated Hue or HA Bridge, always detected as a light and can’t create a routine event.

My Goal is to be able to launch an Alexa routine from a virtual button on HA

I didn’t use Nabu Casa

Many Thanks

EDIT : " The Emulated Hue integration provides a simpler alternative to use utterances such as “Alexa, turn on the kitchen light” . However, it has some limitations since everything looks like a light bulb."

D’oh !

That does not require anything but the Alexa Media Player custom integration.

service: media_player.play_media
data:
  media_content_id: Lacrimas Button Routine
  media_content_type: routine
target:
  entity_id: media_player.den_echo_dot

The value for media_content_id is the name of the routine in the Alexa app. It must match exactly.

1 Like

I tested it too but it didn’t work either, no error on the HA side but nothing happened on my echo dot. I therefore thought that it was necessary to trigger via the routine event

Is it possible to ENABLE/DISABLE (not trigger!) an Alexa rountine from HA?
I have configured a routine that detects motion through the built-in ultrasonic motion sensing of echo dot. I’d like to enable the routine when I’m not at home and disable it when I am at home.

service: media_player.play_media
data:
  media_content_id: enable <ROUTINE NAME> routine
  media_content_type: custom
target:
  entity_id: media_player.echo_dot
1 Like

@Didgeridrew
Just for the readers: your suggestion only works in some countries (it should in US and UK) but not in other countries (e.g. Italy, but I’ve seen many others complaining it does not work in their country too).
So in those other countries, you can’t enable/disable a routine just sending a voice command to Alexa, the only option is doing it through the app.

1 Like

Maybe I am missing something here but I have set up the routine in Alexa as test, then created the below:

alias: Robovac Test
sequence:

  • service: media_player.play_media
    target:
    entity_id: media_player.office_echo_15
    data:
    media_content_id: Test
    media_content_type: routine
    metadata: {}
    mode: single

There is an Alexa routine called test thats starts my Eufy Robovac. I would use the Eufy Custom Integration, but for some reason it finds my vacuum but all entities are unavailable.

The script in HA says its run, but nothing actually happens

Any help would be appriciated.

  1. The value for media_content_id must match the routine’s name exactly including capitalization, punctuation, and spaces. Double check that they match.

  2. Please format your configuration properly, so we can tell if that is contributing to the problem.

  3. As mentioned above by skydado, some functions may be region-locked by Amazon.

Hi Drew, thanks for the reply.

  1. Correct all matches. Why I choose something as simple as test, as a test.

  2. screenshot attached as my formating comes out as above when I copy and paste.
    example attached

  3. Tried something at first as triggering a light to turn on however no dice.

hy, i try this but not works, can help me , alias: Test alexa
description: “”
trigger:

  • platform: event
    event_type: “”
    condition:
    action:
  • service: media_player.play_media
    metadata: {}
    data:
    media_content_id: Buongiorno
    media_content_type: routine
    target:
    entity_id: notify.alexa_media_echo_dot