Long-pressing a IKEA Trådfri dimmer to cont dimming

I’m using a IKEA Trådfri dimmer with deconz to dim certain lights. I’ve got it configured to turn on and off for short press (event 1001 and 2001) and to dim for long press (event 1002 and 2002). As seen in the code snippet below I’m using fixed steps of 75 to step through the dimming.
However this means that if I want to dim it down quite low, e.g. 3 steps I then have to long-press and release x3.
How can I change this to continue dimming while the button is being pressed (either say 1 fixed step per 0,5s… or just continuously dim in a seamless way while its being pressed).

I’ve seen node red solutions, but I was thinking there might be a yaml solution too?

# Hall on/off dimmer
- alias: Hall dimmer up
  initial_state: 'on'
  trigger:
    - platform: event
      event_type: deconz_event
      event_data:
        id: switch_4
        event: 1001
  action:
    - service: light.turn_on
      data_template:
        entity_id: 
          - light.nya_hallen
        brightness: >
          {% set bri = state_attr('light.nya_hallen', 'brightness') | int %}
          {{ [bri+75, 255] | min }}

- alias: Hall dimmer down
  initial_state: 'on'
  trigger:
    - platform: event
      event_type: deconz_event
      event_data:
        id: switch_4
        event: 2001
  action:
    - service: light.turn_on
      data_template:
        entity_id: 
          - light.nya_hallen
        brightness: >
          {% set bri = state_attr('light.nya_hallen', 'brightness') | int %}
          {{ [bri-75, 0] | max }}

# Button press up
- alias: Hall dimmer on
  initial_state: 'on'
  trigger:
    - platform: event
      event_type: deconz_event
      event_data:
        id: switch_4
        event: 1002
  action:
    - service: light.turn_on
      data_template:
        entity_id: 
          - light.nya_hallen
        brightness_pct: 100 

# Button press down
- alias: Hall dimmer off
  initial_state: 'on'
  trigger:
    - platform: event
      event_type: deconz_event
      event_data:
        id: switch_4
        event: 2002
  action:
    - service: light.turn_off
      data_template:
        entity_id: 
          - light.nya_hallen
5 Likes