MQTT Dimmer Transition with Shelly devices

Hi I am gloriously failing in trying to create a automation or script, to dim my lights with a transition time. I drive all my shelly dimmers with mqtt. Right now i have a automation to dim “hard” on sunset and ssunrise from the maximum brightness value (255 on home assinstant sinde 100 on shelly side) to the dimmed one and vice versa in one step.

Now i thought i can run a looped script or automation, an in each iteration i dim by a certain value and also include a little delay to get a lovely transition. But im failing in every approach, because the syntax and other things are so tricky for me to undrstand.

My two approaches are:

  - alias: Repeat the sequence AS LONG AS the conditions are true
        - condition: state
          entity_id: input_boolean.do_something
          state: 'on'
        # Don't do it too many times
        - condition: template
          value_template: "{{ repeat.index <= 100 }}"
        - service:
          - data:
              payload_template: '{"brightness": repeat.index }'
              topic: shellies/shellydimmer-XXXXXX/light/0/set
              service: mqtt.publish
          - delay:
              milliseconds: 200


- id: 'gaga'
  alias: Dimmtest
  - event: sunrise
    platform: sun
  condition: []
#  condition:
#    - condition: state
#      entity_id: sensor.brightness_state
#      state: 'off'
  mode: single
    - alias: Repeat the sequence UNTIL the conditions are true
          # Run command that for some reason doesn't always work
          - delay:
              milliseconds: 200
          - service: mqtt.publish
          - data:
              payload_template: '{"brightness": sensor.brightness_state + 1 }'
              topic: shellies/shellydimmer-XXXXXX/light/0/set
          # Give it time to complete
          # Did it work?
          - condition: state
            entity_id: sensor.brightness_state
            state: '255'

i know that these codes wont work as they are right know in the first place, but i think you can read my idea and approach out of it.

so please, help me with formatting one of these examples, to fit to the syntax, and thank you very much.