[SOLVED] Shell Command from Alexa API

I have an alexa.yaml file for a custom interaction model with Alexa, but am having trouble calling shell commands directly from it.

I am able to call shell commands if I have an intermediary script, but not directly. My working code is below, as well as the code I would like to use. I want to avoid having a script call the shell_command, is that possible?

Working alexa.yaml:

  TVControlIntent:
    action:
      - service: homeassistant.turn_on
        data_template:
          entity_id: script.tv_{{ Action }}

Desired configuration:

  TVControlIntent:
    action:
      - service: shell_command.tv_{{ Action }}

The configuration above results in an a ..does not match format <domain>.<name>.. error.

Is this only to turn the tv on? Or is there a matching one to turn it off?

The possible completions are:
on
off
cable
chromecast
etc…

These shell commands are all known in HASS as tv_something. Eg: tv_off, tv_cable, etc.

Alexa API is passing the correct command based on my voice input, and as mentioned, it works when calling the script that calls the shell_command, just not when calling the shell command directly.

I think you need “service_template:” rather than “service:” (to have it render the template).

1 Like

SOLVED! Thank you so much. Not sure how I missed this.

That’s an obscure one and easy to miss. I don’t see much discussion of service_template.

Reference:

You must use service_template in place of service when using templates in the service section of a service call.