#Script Field Parsing Question

11 messages · Page 1 of 1 (latest)

sullen bramble
#

So I've been trying to build a script to run easily control my media players in my house. I have a field where I allow someone in my house to individual select (multiple) speakers and the artist playlist they want to hear. For the life of me, I cannot figure out how to take this script field output array and display it as a list to dynamically insert into the action as:

  • media_player.[1]
  • media_player.[2]
leaden hedge
#

Post the script as YAML please.

sullen bramble
#

script isn't complete and I threw the mobile phone notification in there so I could see the output that {{media_player_group}} was sending from the field.

#

It’s sending what appears to be a normal array, but I’ve tried a ton of different templating tricks and can’t seem to get it to output as something I can place in the action to join only the speakers selected.

leaden hedge
#

Why not just use an entity list and scope it to the Sonos integration?

#

This is how I do mine:

speakers:
  selector:
    entity:
      multiple: true
      filter:
        domain: media_player
        integration: sonos
#

Then you get a list of the entity_ids in a list that you can pass to join/unjoin.

sullen bramble
leaden hedge
#
action: media_player.join
data:
  group_members: "{{ speakers | default[] }}"
target:
  entity_id: media_player.main_sonos
sullen bramble
#

Ok thanks! Will give this a shot. Appreciate the support