How to dim multiple output based on i.e. input_number?

As topic, I’m looking for a way of dimming multiple output lights with either value from an extra entity, for example input_number or dummy monocromatic light component. Only outputs ON should adjust, but other outputs later turned ON should also use this value.

Use case:
Im building a status board with many LEDs and want to adjust these for “day/night”

Having lights turn on a certain way, based on a command given before is only possible if you turn it on from Home Assistant using a dedicated script. So it kind of depends what way you use to turn the lights om if it is at all possible. What way is used?

For the rest, setting a certain brightness can be done with action light.turn_on, and you should test if it is already on before sending the new brightness. As a trigger you could react on changes of the input number.

The same action will also turn the light on with the desired brigghtness, as long as the button calls the action and uses no other way to turn the light on.

  - action: light.turn_on
    target:
      entity_id: light.somelight
    data:
      brightness_pct: "{{ states('input_number.desired_brightness')|int(0) }}"

You could maybe use templates to determine the list of lights that are on, but we’d need to know more on how you select the lights you want to control in the first place.

Hmmm… I might have explained too little.

Use case:

Input buttons setting states on relays and associated LED status indicators. All done on the ESP, but also showing the states in HA. In HA I also want to set a number_input for the dimming and use this for the existing LED on, and also those turning on later. Preferably doing most of the action on the ESP.

Ah, sorry, missed the esphome category. Not that much of an expert in that regard I’m afraid.

Check description of template nunmer:

Then You’ll be able to change number value in HA and do some automations on ESPHome device on change.

How to do that? If using the lights action on_state, that only does something if the light changes itself.