Select multiple entities in blueprint, but then choose random entity from selected entities

Hi,

I’m creating a blueprint which helps me to create multiple, easy to use, script for dynamic light scenes.
I want to create a script for multiple lights, which then loops a part of the sequence and each loop selects a random entity from the selected entities in the blueprint.

Selecting multiple items is easy, as I can easily set the code to allow for it:

  input:
    target_light:
      name: Lights
      description: The light that you want to have switched
      selector:
        entity:
          domain: light
          multiple: true

However, selecting a random entity from the list provided is where I get stuck. When manually creating the script, I would use below code:

target:
  entity_id: light.{{["ki_afzuigkap_l","ki_afzuigkap_r","ki_cupboard","ki_strip"]|random}}

It would be nice if these 4 entities can be selected in the blueprint and a random entity can then be taken while looping the script.

I’d rather not create a group for each light group, because they are not always linked. It’s not always the kitchen lights, or the living room lights, but can also be a combination of many more zones/rooms. The amount of groups would sort of defy the reason for creating a blueprint in the first place.

Hope anyone has got a good idea. I couldn’t find any example over the past weekend.

That’s not the only place you are getting stuck. You have an entity selector in the input, and a target in the statement where you are using it…
Target Selector & Entity Selector Errors.

But I believe once you get the matching thing between the selector and the action statement, the template that might work is:

{{ target_light | list | random }}

That’s indeed another issue I didn’t think of. Thanks for that link.
I do not know how to come up with a solution for this yet. It’s easy to select multiple entities, it’s easy to create a random entity_id when doing it via the other method I provided, but the issue is that this is not usable in a blueprint. At least not when it needs to be dynamic in number of entities selected, etc.

Yes it is. Please post what you have tried and explain what your hang-up is.