Single button press to cycle through 3 light brightnesses

Newbie here, firstly, I love what you can do with home automation. It’s a great project and I hope it gets better.

What I want is something like:
Sonoff button double click, light on at 10%
double click, light at 100%
double click, Light off

My problem is that I can create an automation, but don’t know how to do it. I found code, but whenever I change my automation to YAML and paste the code and save it, when I go back to the automation, it just loads up the visual editor, not the YAML and when I change it back to YAML, the additional code has disappeared.

I tried pasting this underneath the code generated by the visual editor:

action:
- service: light.turn_on
entity_id: light.your_light
data:
brightness: >
{% if is_state(‘light.your_light’, ‘on’) and state_attr(‘light.your_light’, ‘brightness’) | int <=42 %}
80
{% elif is_state(‘light.your_light’, ‘on’) and 43 <= state_attr(‘light.your_light’, ‘brightness’) | int <=80 %}
192
{% else %}
255
{% endif %}

Any suggestions?

https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16

action:
  - service: light.turn_on
    target:
      entity_id: light.your_light
    data:
      brightness_pct: >
        {% if is_state('light.your_light', 'off') %}
           10
        {% elif state_attr('light.your_light', 'brightness')|int  < 28 %}
           100
        {% else %}
           0
        {% endif %}