What's the best way to turn a light on only if the new brightness would be brighter than the current setting?

I have lights that I turn on at night to a dim 25% setting to serve as soft lighting in certain areas. The thing is, if someone is already in that room, and has the lights fully on at 100%, the automation will dim them down to 25%, which is a bad experience. I realize I could add a condition to check if the light was lower than 25% before calling the light.turn_on service, but that has a few issues:

  1. It will require separating all my lights out into their own condition check/service call pairs. Right now I have one script I call which calls light.turn_on on a bunch of entities at once (and then switch.turn_on on a few smart switches).
  2. It requires me to update the x% setting in two places, the condition and the service call.
  3. Checking if lights are either off or on but set to a lower brightness level is clunky. The brightness attribute isn’t available when they’re off, so instead of just saying < x%, you have to use an or around two conditions, one checking if they’re off and the other checking if the brightness attribute is < x%.

I suspect there is no better way to do this than a bunch of scripts, one for each light, where I take in the desired brightness level, and both check against that, and then set the light to that. Actually, it’s just occurring to me that I could take in the light entity as an argument too and just have the one script. Still I’d need to make a bunch of calls to it, rather than a single call where I just list entities, but perhaps that is good enough.

Anyone have any other approaches they use for this? Is there some option to the light.turn_on service that I’m missing that would do this for me?

I ended up writing a script to do this, and figured I’d post it here in case anyone comes across this in the future. This script is a “one way” version of lights.turn_on, which only turns the light up, never down.

alias: Turn Light Up
mode: single
description: >-
  A script that turns on lights to a given brightness level only if they are
  currently lower than that level (or off).
    description: The entity id of the light you want to turn on
    example: light.living_room_lights
    description: The brightness level to turn the light up to, as a percentage
    example: 75
    description: Transistion time, in seconds
    example: 3
icon: mdi:lightbulb-on-80
  - condition: or
      - condition: template
        value_template: "{{ is_state(light_entity, 'off') }}"
      - condition: template
        value_template: >-
          {{ state_attr(light_entity, 'brightness') / 255.0 * 100.0 <
          brightness_pct }}
  - service: light.turn_on
      brightness_pct: "{{ brightness_pct }}"
      transition: "{{ transition|default(3) }}"
      entity_id: "{{ light_entity }}"

Which I call from automations with something like this:

service: script.turn_light_up
  light_entity: light.living_room_lights
  brightness_pct: 25
  transition: 0