Dim lights at a certain time but only if they're already on

Morning all, I’m trying to create an automation that loops through a group of lights, if any of those lights are on, change the brightness level to 250, if they’re not on, leave them alone. I’m a software developer by background, but relatively new to home assistant…I’ve got it working with just one light, and trying to figure out best how to loop through the group (haven’t yet been successful).

I’m trying to figure out whether it’s best to create an actual group of lights (I have one called group.downstairs) and loop thru with {% for light in lights.downstairs … etc. %} or whether I can have multiple entity_ids like entity_id: light.bathroom_1, light.bathroom_2 and then I can use the jinja loop to loop through the stated entities (I haven’t found in the docs how to do that).

Here is what I have for the one light that works great for me:

- id: "1600521261308"
  alias: Morning Lights
  description: ""
  trigger:
    - platform: time
      at: 06:00:00
  condition: []
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.guest_bathroom_1
        brightness:
          "{% if states.light.guest_bathroom_1.attributes.brightness < 250
          %} 250 {% endif %}"
  mode: single

An idea of what I’m aiming for:

- id: "1600521261308"
  alias: Morning Lights
  description: ""
  trigger:
    - platform: time
      at: 06:00:00
  condition: []
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.guest_bathroom_1, light.guest_bathroom_2
        brightness: >
          "{% for light in <entities_listed_above>" %}
            {% if light.attributes.brightness < 250%} 250 {% endif %}
          {% endfor %}"
  mode: single

You don’t need a template for this. Just use a numeric state condition.

What would that look like? Just add a condition that says above 1 but less than 250?

Yep, that would do it. However, you would have to have an or condition so you test both lights. And you would still need a template to determine which one to adjust. Unless you used an automation for each light. So I don’t think my original idea was a good one. Sorry.