Android Action Button Widget with Data

I am trying to create a few action button widgets for my phone where with one press I can play my preferred music on a given speaker. I have this working with a simple automation where the speaker is hardcoded into the automation. I thought it’d be “trivial” to extract the speaker name into a variable to be passed from the widget so I can hard code each widget with the speaker I want it to play on.

alias: Universal Music Toggle
description: Toggles music play/stop on selected speaker
triggers:
  - event_type: call_service
    event_data:
      domain: input_button
      service: press
    trigger: event
actions:
  - choose:
      - conditions:
          - condition: template
            value_template: |
              {{ is_state(target_speaker, 'playing') }}
        sequence:
          - target:
              entity_id: "{{ target_speaker }}"
            action: media_player.media_stop
    default:
      - target:
          entity_id: "{{ target_speaker }}"
        data:
          media_content_id: media-source://radio_browser/962cc6df-0601-11e8-ae97-52543be04c81
          media_content_type: audio/mpeg
        action: media_player.play_media
      - target:
          entity_id: "{{ target_speaker }}"
        data:
          volume_level: 0.1
        action: media_player.volume_set
mode: single
variables:
  target_speaker: |
    {% if trigger.event.data.service_data is defined and
          trigger.event.data.service_data.speaker is defined %}
      {{ trigger.event.data.service_data.speaker }}
    {% else %}
      media_player.office_big_speaker
    {% endif %}

I have tried numerous versions of passing the data through the widget but can’t seem to find the magic to get it to work.

Usually I get something along the lines of
extra keys not allowed @ data['service_data'] in the logs so I can’t even see what the body of the message looks like to process it.

what field is the automation expected? service_data does not sound valid

input button can only be pressed and will not have any additional data beeing sent with it.

https://www.home-assistant.io/integrations/input_button/

I’m not tied to a input button, that was just an idea. I’d love any way/idea to move forward.

my working hard coded automation looks like this:

alias: Office Music
description: ""
mode: single
triggers: []
conditions: []
actions:
  - metadata: {}
    data:
      media_content_id: media-source://radio_browser/962cc6df-0601-11e8-ae97-52543be04c81
      media_content_type: audio/mpeg
    target:
      entity_id: media_player.office_big_speaker
    action: media_player.play_media
  - metadata: {}
    data:
      volume_level: 0.1
    target:
      entity_id: media_player.office_big_speaker
    action: media_player.volume_set

one thing you can do is add the action to a script and then use the widget to execute each unique script?

this widget behaves just like Developer Tools > Actions so anything you can do there you should be able to do in the widget.

Thank you! This is exactly what I needed to do