ZHA- Philips Hue Dimmer V2 Smooth Dimming And Multi Tap Support

blueprint:
  name: ZHA - Hue Dimmer v2 
  description: >
    Controller for Philips Hue Dimmer Switch v2 (RWL022) via ZHA.
  domain: automation
  input:
    remote:
      name: Hue Dimmer Switch
      description: Select the Philips Hue Dimmer v2 device.
      selector:
        device:
          integration: zha
          manufacturer: Signify Netherlands B.V.
          model: RWL022
    light:
      name: Light(s)
      description: The light(s) to control.
      selector:
        target:
          entity:
            domain: light

    # --- Configuration ---
    dim_step:
      name: Dimming Step
      description: Percentage to change brightness per loop cycle.
      default: 10
      selector:
        number:
          min: 1
          max: 50
          unit_of_measurement: "%"
    dim_delay:
      name: Dimming Speed (ms)
      description: Delay between dimming steps.
      default: 400
      selector:
        number:
          min: 100
          max: 1000
          unit_of_measurement: "ms"

    # --- Power Button (Top) ---
    action_power_press:
      name: Power - Single Press
      default:
        - service: light.toggle
          target: !input light
      selector:
        action: {}
    action_power_double:
      name: Power - Double Press
      default: []
      selector:
        action: {}
    action_power_triple:
      name: Power - Triple Press
      default: []
      selector:
        action: {}
    action_power_hold:
      name: Power - Hold
      default: []
      selector:
        action: {}

    # --- Up Button ---
    action_up_press:
      name: Up - Single Press
      default:
        - service: light.turn_on
          target: !input light
          data:
            brightness_step_pct: !input dim_step
            transition: 0.2
      selector:
        action: {}
    action_up_double:
      name: Up - Double Press
      default: []
      selector:
        action: {}
    action_up_triple:
      name: Up - Triple Press
      default: []
      selector:
        action: {}

    # --- Down Button ---
    action_down_press:
      name: Down - Single Press
      default:
        - service: light.turn_on
          target: !input light
          data:
            brightness_step_pct: -!input dim_step
            transition: 0.2
      selector:
        action: {}
    action_down_double:
      name: Down - Double Press
      default: []
      selector:
        action: {}
    action_down_triple:
      name: Down - Triple Press
      default: []
      selector:
        action: {}

    # --- Hue Button (Bottom) ---
    action_hue_press:
      name: Hue Button - Single Press
      default: []
      selector:
        action: {}
    action_hue_double:
      name: Hue Button - Double Press
      default: []
      selector:
        action: {}
    action_hue_triple:
      name: Hue Button - Triple Press
      default: []
      selector:
        action: {}
    action_hue_hold:
      name: Hue Button - Hold
      default: []
      selector:
        action: {}

mode: restart
max_exceeded: silent

trigger:
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input remote

action:
  - variables:
      command: "{{ trigger.event.data.command }}"
      step_pct: !input dim_step
      delay_ms: !input dim_delay
      # Store device ID to use in wait_for_trigger without re-using !input
      device_id: "{{ trigger.event.data.device_id }}"

  - choose:
      # --- POWER BUTTON ---
      - conditions: "{{ command == 'on_short_release' }}"
        sequence: !input action_power_press
      - conditions: "{{ command == 'on_double_press' }}"
        sequence: !input action_power_double
      - conditions: "{{ command == 'on_triple_press' }}"
        sequence: !input action_power_triple
      - conditions: "{{ command == 'on_hold' }}"
        sequence: !input action_power_hold

      # --- UP BUTTON ---
      - conditions: "{{ command == 'up_short_release' }}"
        sequence: !input action_up_press
      - conditions: "{{ command == 'up_double_press' }}"
        sequence: !input action_up_double
      - conditions: "{{ command == 'up_triple_press' }}"
        sequence: !input action_up_triple
      # SMOOTH DIMMING UP
      - conditions: "{{ command == 'up_hold' }}"
        sequence:
          - repeat:
              while:
                - condition: template
                  value_template: "{{ repeat.index < 20 }}"
              sequence:
                - service: light.turn_on
                  target: !input light
                  data:
                    brightness_step_pct: "{{ step_pct }}"
                    transition: "{{ delay_ms / 1000 }}"
                - delay: 
                    milliseconds: "{{ delay_ms }}"
                - wait_for_trigger:
                    - platform: event
                      event_type: zha_event
                      event_data:
                        device_id: "{{ device_id }}"
                        command: "up_short_release"
                    - platform: event
                      event_type: zha_event
                      event_data:
                        device_id: "{{ device_id }}"
                        command: "up_long_release"
                  timeout: 
                    milliseconds: 50
                  continue_on_timeout: true
                - if:
                    - condition: template
                      value_template: "{{ wait.trigger != none }}"
                  then:
                    - stop: "Button released"

      # --- DOWN BUTTON ---
      - conditions: "{{ command == 'down_short_release' }}"
        sequence: !input action_down_press
      - conditions: "{{ command == 'down_double_press' }}"
        sequence: !input action_down_double
      - conditions: "{{ command == 'down_triple_press' }}"
        sequence: !input action_down_triple
      # SMOOTH DIMMING DOWN
      - conditions: "{{ command == 'down_hold' }}"
        sequence:
          - repeat:
              while:
                - condition: template
                  value_template: "{{ repeat.index < 20 }}"
              sequence:
                - service: light.turn_on
                  target: !input light
                  data:
                    brightness_step_pct: "-{{ step_pct }}"
                    transition: "{{ delay_ms / 1000 }}"
                - delay: 
                    milliseconds: "{{ delay_ms }}"
                - wait_for_trigger:
                    - platform: event
                      event_type: zha_event
                      event_data:
                        device_id: "{{ device_id }}"
                        command: "down_short_release"
                    - platform: event
                      event_type: zha_event
                      event_data:
                        device_id: "{{ device_id }}"
                        command: "down_long_release"
                  timeout: 
                    milliseconds: 50
                  continue_on_timeout: true
                - if:
                    - condition: template
                      value_template: "{{ wait.trigger != none }}"
                  then:
                    - stop: "Button released"

      # --- HUE BUTTON ---
      - conditions: "{{ command == 'off_short_release' }}"
        sequence: !input action_hue_press
      - conditions: "{{ command == 'off_double_press' }}"
        sequence: !input action_hue_double
      - conditions: "{{ command == 'off_triple_press' }}"
        sequence: !input action_hue_triple
      - conditions: "{{ command == 'off_hold' }}"
        sequence: !input action_hue_hold

Hello jeff,

Thanks for contributing to the community with a new Blueprint.
I have a suggestion for you. Many people who are not familiar with directory structures will have problems installing this without the Home Assistant MY tools.

Adding a MY link for this Blueprint to your top post would help them a lot.
Here is the link to make that.
Create a link – My Home Assistant

Note: if the original is in the forums here, it has to be in the top post in the topic and has to be the only code block there or the link will not work.

Hi I tested this but wasn’t able to get smooth dimming working. Maybe doing something wrong.