Dashboard brightness buttons of lights that are on

I’m pretty new to Home Assistant. Most of my questions I could figure out using this forum, but the next question I could not yet find the right answer.

I want to create two buttons in my dashboard to control the brightness op my lights that are on. One for turning down the brightness and one turning up the brightness. Each in steps of 20%. Only for the lights that are already on. Lights that are off should remain off. Brightness should never go lower than 1%. Bassicly I’m trying to immitate my Philips Hue dimmer remote brightness buttons.

Should I use a template to create something like this or can I do this with an automation or something else?

I tried to write it in some logic which may help understanding my goal.

Button 1 (brightness +)
lights = list lights in living room where brightness > 1%
For each light in lights
light.brightness + 20%

Button 2 (brightness -)
lights = list lights in living room where brightness > 1%
For each light in lights
if light.brightness <= 20% then light.brightness = 1%
else light.brightness - 20%
end if

Any help is appriciated!