My script for changing brightness on turned on lights

Hi all, just wanted to share my custom script that allows for changing brightness / kelvin for att lights in an area, but only for lights that are already turned on.

Im sure someone made this before but for myself I searched the web extensively without finding any solution even though it seemed to be a requested feature. This script can be used inside other automations for example dimming lights at evening but without turning on the lights that are off.

alias: Set Brightness for Lights that are turned on.
fields:
  light_areas:
    name: Light areas
    description: Select the area(s) or group of lights
    selector:
      area:
        multiple: true
        entity:
          domain:
            - light
    required: true
  brightness:
    name: Brightness
    description: Brightness level (1-100), 0 to leave unchanged.
    selector:
      number:
        min: 0
        max: 100
        mode: slider
    default: 0
    required: true
  warmth:
    name: Warmth
    description: Warmth level in kelvin (1-7000), 0 to leave unchanged. 
    selector:
      number:
        min: 0
        max: 7000
        mode: slider
    default: 0
    required: true
sequence:
  - variables:
      lights_areas_combined: "{{ light_areas | map('area_entities') | sum(start=[]) }}"
      on_lights: |
        {{ expand(lights_areas_combined)
           | selectattr('domain', 'eq', 'light')
           | selectattr('state', 'eq', 'on')
           | map(attribute='entity_id')
           | list }}
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ brightness | int != 0 }}"
        sequence:
          - action: light.turn_on
            data:
              brightness_pct: "{{ brightness }}"
            target:
              entity_id: "{{ on_lights }}"
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ warmth | int != 0 }}"
        sequence:
          - action: light.turn_on
            data:
              kelvin: "{{ warmth }}"
            target:
              entity_id: "{{ on_lights }}"