Using a script variable as an entity_id

I made my script as simple as possible to isolate the question:

alias: Test Template
sequence:
  - variables:
      alarm_speaker: media_player.dressing_room_speaker
  - action: media_player.volume_set
    metadata: {}
    data_template:
      volume_level: >
        {{ (state_attr(alarm_speaker, "volume_level") | float - 0.05) if state_attr(alarm_speaker, "volume_level") > 0.05 else 0 }}
    target:
      entity_id: "{{ alarm_speaker }}"
description: ""

Running the script does nothing. Running the action returns: “Template rendered invalid entity IDs:”

Is this a scope issue?

Thanks
Seth

1 Like