Questions Community

Pass paramers / fields to script button

EisFrei

I have a home assistant script that randomly selects an artists album and plays it on a music assistant device. Both the artist and the device are fields that can be configured in home assistant. This is the script in question:

alias: Random Album
sequence:
  - action: music_assistant.search
    metadata: {}
    data:
      limit: 49
      name: '{{ artist }}'
      media_type:
        - album
      config_entry_id: ABCDEF #music assistant entity
    response_variable: results
  - action: music_assistant.play_media
    metadata: {}
    data:
      media_id: '{{ results.albums[range(1, results.albums | length) | random].uri }}'
    target:
      entity_id: '{{ player }}'
mode: single
fields:
  artist:
    selector:
      text: null
    name: Artist
    required: true
  player:
    selector:
      entity:
        filter:
          integration: music_assistant
          device_class: speaker
    name: Player
    required: true

When adding a button in Home Assistant I can set the artist and player individually. In tessera I've only found the option to add the script without setting values for the fields. This is the "read data"

{
  "entity": "script.random_album",
  "state": "off",
  "word": "Aus",
  "attributes": {},
  "options": {},
  "slot": 9
}

Is this possible and I just haven't found the option? If so, how can I add the fields? If not, I would very much like to add this as a feature request.

Thank you for a great project! Martin

Discussion 1

Add a comment
EisFrei

This is the tile configuration I see after selecting "Perform Action" "Turn on script"

image

Add your thoughts, a screenshot or a useful link.

Markdown & basic HTML
Paste or drop images Β· URLs on their own line become previews0 / 10,000
Create your account to join in

We need a verified email address to reach you about your contribution. Your address stays private.

Continue with GitHub

Your draft stays in this tab. Return here after verification.