Using FOR loop with multiple entities

I’m trying to create a simple blueprint that accepts different lights as input and when triggered by a Telegram command just sends a notification with their names - but it doesn’t work.

Here’s my simple blueprint code:

blueprint:
  name: Telegram Blueprint Test
  domain: automation
  input:
    light_entities:
      name: Light
      selector:
        entity:
          domain: light
          multiple: true
  
trigger:
  - platform: event
    event_type: telegram_command
    event_data:
      command: /test

action:
  - service: notify.telegram
    data:
      message: >-
        Here are the selected lights:
        
        {% for u in light_entities %}
            {{ u.name }}
        {% endfor %}

mode: single

When I use the /test command in Telegram, I just recieve “Here are the selected lights:”, but then nothing. I also tried it with

        {% for u in light_entities %}
            {{ u }}
        {% endfor %}

but that also didn’t work. So how do I need to create the for loop, or in general: How can I send a List of all the selected lights?

‘light_entities’ needs to be put in a variable. !inputs will not work in templates directly.
Look in the blueprint exchange for examples, most of the BP’s use these.

1 Like

Thanks. That removed one problem from the pile of other problems I have with this project!

1 Like