Help with light and multiple predefined states

Hi there.
I am making a small nightlight with led strip. So far it’s all good - the strip is doing it’s job, the touch pin is also working fine - i can toggle the light with the help of it.

My question is how can i use the touch pin to toggle cycle few predefined states?
For example:
Current state: OFF → Touch → Activate Preset 1 - Brightness 20%
Preset 1 → Touch → Activate Preset 2 → Brightness 50%
Preset 2 → Touch → Activate Preset 3 → Brightness 100%
Preset 3 → Touch → Light off

I want to have this functionality purely on the ESP itself to still have some basic controls over the light if something is not connected / working at the time.

You could do it in lambda with help of static variable counting the touches.

Another option could be template number component with limit min 0, max 3
Update it with your touch pin:

- number.increment:
    id: my_number
    cycle: true

and in your template number use on_value automation to set corresponding brightness.