Automation script for smooth dimming lights?

Hey Everyone,

I’m working on dual-purposing my Ikea STYRBAR remote to either turn up/down the media player volume or dim/brighten the lights depending on what function I have selected. The media player part works fine, but the lights stutter when continuously holding the button to dim/brighten. I’ve tried adjusting the delay between dimming steps, but I haven’t been able to dial in good results.

What would be a better script to have the lights smoothly brighten/dim when continuously holding the button?

Thank you!!

Dim portion of the automation:

- service: light.turn_on
  entity_id: light.bedroom_ikea_lights
  data_template:
    brightness: >-
      {{ state_attr('light.bedroom_ikea_lights', 'brightness') - 10 }}

Entire continuous down automation:

alias: Bedroom Ikea remote continuous down
description: ""
trigger:
  - device_id: 65dd36b4ea273d4e3fa2eac4389dc74f
    domain: deconz
    platform: device
    type: remote_button_long_press
    subtype: dim_down
condition: []
action:
  - service: input_boolean.turn_on
    data: {}
    target:
      entity_id: input_boolean.bedroom_ikea_remote_repeat_down
    alias: Turn on the repeater flag "Bedroom Ikea remote repeat down"
  - if:
      - condition: state
        entity_id: input_text.bedroom_ikea_remote_current_function
        state: Music
    then:
      - repeat:
          until:
            - condition: state
              entity_id: input_boolean.bedroom_ikea_remote_repeat_down
              state: "off"
          sequence:
            - service: script.bedroom_volume_down
              data: {}
            - delay:
                hours: 0
                minutes: 0
                seconds: 0
                milliseconds: 50
        alias: Turn down the volume
    else:
      - repeat:
          until:
            - condition: state
              entity_id: input_boolean.bedroom_ikea_remote_repeat_down
              state: "off"
          sequence:
            - service: light.turn_on
              entity_id: light.bedroom_ikea_lights
              data_template:
                brightness: >-
                  {{ state_attr('light.bedroom_ikea_lights', 'brightness') - 10
                  }}
            - delay:
                hours: 0
                minutes: 0
                seconds: 0
                milliseconds: 50
        alias: Dim the lights
    alias: Do the down
mode: single