Control to adjust the brightness only of lights that are already on


I have a room where typically only some of the lights are on. I want a slider control that adjusts the brightness, but only of the lights that are already on.

If I use the light card (or the mushroom light card) it will set the brightness of all lights in the room, turning them on if necessary.

Is there a way to solve my problem?