Toggling between light brightness with single switch (button)

Hi,

Can someone help me set up my switch to cycle between brightness settings on my light? I’m trying to set it up so that upon a button push, the system will check the brightness state and based on that setting go up or down to the next brightness setting.

I found this link on Reddit https://www.reddit.com/r/homeassistant/comments/551iu1/help_ifthen_statements_in_scripts_time_variable/ that looks like it does what I want but it’s based on time instead of the light brightness. Here’s a snippit.

    data_template:
      brightness: >
        {% if (float(as_timestamp(now)) > 6) and (float(as_timestamp(now)) < 8) %}
          254
        {% elif (float(as_timestamp(now)) > 8) and (float(as_timestamp(now)) < 17) %}
          0
        {% elif (float(as_timestamp(now)) > 17) and (float(as_timestamp(now)) < 21) %}
          180
        {% else %}
          120
        {% endif %}
      entity_id: group.kitchen_lights