@tom_l: this works perfectly, thank you.
I have a third state/input boolean which I would like to use in this same automation/action.
The brightness percentage is the same (5/90), depending if this boolean is on or off.
How can I combine these 2 because if the first is off and the second on, this will not work.

@avd706: out of curiosity, could you elaborate a little on your solution please?

What a coincidence to land on a topic twice a day where the same person provides the answer @tom_l, would you also be able to explain how a template would work where I have two booleans? If the first is true, it would be 1%, if the second is true it would be 20% and in all other situations it would be 50%.