Getting Alexa to Trigger Automations Through Cloud?

I have the Alexa skill working through Nabu Casa. I have the automation exposed to Alexa (it shows as a “scene”), and it is definitely doing something with HomeAssistant, but it doesn’t actually trigger the automation.

In the logbook, it shows this:
Amazon Alexa sent command Alexa.PowerController/TurnOn for Test Automation triggered by service automation.turn_on

I assume what’s happening is it’s not triggering the automation, but literally just “enabling” the automation (which it is already always enabled), and the automation does not actually run. I also assume I have to somehow find the event trigger (is that what it would be?) to listen for the command that is coming in from Alexa or something and use that as the trigger in the Automation?

Obviously the message is coming through, but I don’t know how to make it actually trigger the automation to run.

This is what it looks like in the Alexa app for the routine:

1 Like

Use a script instead.

Automations are things that start automatically, scripts are basically the same as the action part of an automation, but are intended to be started by automations, other scripts, voice assistants, etc.

2 Likes

Ah that worked perfectly, thanks.

For anyone coming from Google, if you go to the Automations menu, look at the top and go to the “Scripts” tab.

Then I made a new one with an action to “Call Service”, then “Automation: Trigger”. Then I clicked “Choose Entity” and selected the automation I want to trigger. Then I set the Script to be exposed to Alexa, and it also showed up as a Scene. Adding it to an Alexa routine and activating it worked, and it triggered the Script which triggered the automation.

3 Likes

That’s… really not what I was recommending, but if it works for you…

The sane option would have been to move the actions to the script, and call the script from the automation too (f you really needed one).

5 Likes

This made me chuckle haha

a bit of a necro, but if you have more than one thing triggering this automation, then it woujld make sense to do it the way @TJoe did unless i am missing something more subtlle here. At any rate, this is good enough for me for now.

No it wouldn’t, and yes you are.

Your automation can have multiple triggers and call the script.

Your voice assistant can call the same script.

Calling the trigger service outside of testing is almost never a good idea.

1 Like

im glad I responded to this then. I will look for a way to do it properly so I dont run into issues later.

I guess then i just need to move this automation to a script instead?

Move the actions, yes, if there’s other triggers in there for non-voice use.

Then the automation can call the script, or you can run the script from a voice assistant.

1 Like

Yea I have since figured out about using scripts instead of automations which makes a lot more sense

1 Like

perfect thanks for that, exactly what I needed!