Help with Alexa Media Player (& templates)

Hi all,

First poster, and fairly new to HA in general.

I’m looking to eventually get a bit clever with getting various Alexa Routines allowing me to have sensor data read back to me by Alexa. I’ve got a dummy light exposed through a template, and have Alexa Media Player fully installed and working.

Where I’m stuck is trying to run a really basic test of those components working together. I’m confident where I’m failing is not having enough experience or understanding of the yaml syntax. Below, I’ve got a bit of code that I’m putting into automations.yaml, but turning on the dummy light (button press in Alexa iOS app) to trigger the readout. I’ve pared down the config to be a super-basic example in the interests of simplifying testing.

So, who can tell me what I’m doing wrong?

- id: test id
  alias: Test Autom
  initial_state: "off"
  trigger:
    platform: state
    entity_id: light.alexa_virtual
    to: 'on'
  condition: []
  action:
    - service: media_player.play_media
      data:
        message: 'The battery is currently at {{ states(''sensor.lsjwh4093pn104681_soc'') }} percent'
      target:
        entity_id: media_player.kitchen_echo
    - entity_id: light.alexa_virtual
      action: light.turn_off
  mode: single

You need to use the notify.alexa_media service/action, not media_player.play_media.

- id: test id
  alias: Test Autom
  initial_state: "off"
  trigger:
    platform: state
    entity_id: light.alexa_virtual
    to: 'on'
  condition: []
  action:
    - action: notify.alexa_media
      data:
        message: "The battery is currently at {{ states('sensor.lsjwh4093pn104681_soc') }} percent"
        target: media_player.kitchen_echo
    - action: light.turn_off
      entity_id: light.alexa_virtual
  mode: single