ZHA - Philips Hue Dimmer Switch (RWL020, RWL021)

This is a blueprint for the Philips Hue Dimmer Switch specifically for use with ZHA.

Control lights with a Philips Hue Dimmer Switch.

The top "on" button will turn the lights on to the last set brightness
(unless the force brightness is toggled on in the blueprint).

Dim up/down buttons will change the brightness smoothly and can be pressed
and hold until the brightness is satisfactory.

The bottom "off" button will turn the lights off.

Get started

Click the badge to import this Blueprint: (needs Home Assistant Core 2021.3 or higher)

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Or import this Blueprint by using the forum topic URL:

blueprint:
  name: ZHA - Philips Hue Dimmer Switch
  description: 'Control lights with a Philips Hue Dimmer Switch.


    The top "on" button will turn the lights on to the last set brightness

    (unless the force brightness is toggled on in the blueprint).


    Dim up/down buttons will change the brightness smoothly and can be pressed

    and hold until the brightness is satisfactory.


    The bottom "off" button will turn the lights off.

    '
  domain: automation
  input:
    remote:
      name: Philips Hue Dimmer Switch
      description: Pick either RWL020 (US) or RWL021 (EU)
      selector:
        device:
          integration: zha
          manufacturer: Philips
          entity:
            domain: sensor
            device_class: battery

    light:
      name: Light(s)
      description: The light(s) to control
      selector:
        target:
          entity:
            domain: light
    force_brightness:
      name: Force turn on brightness
      description:
        'Force the brightness to the set level below, when the "on" button
        on the remote is pushed and lights turn on.

        '
      default: false
      selector:
        boolean: {}
    brightness:
      name: Brightness
      description: Brightness of the light(s) when turning on
      default: 100
      selector:
        number:
          min: 0.0
          max: 100.0
          mode: slider
          step: 1.0
          unit_of_measurement: "%"
  source_url: https://community.home-assistant.io/t/zha-philips-hue-dimmer-switch/255048
mode: restart
max_exceeded: silent
variables:
  force_brightness: !input "force_brightness"
trigger:
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input "remote"
action:
  - variables:
      command: "{{ trigger.event.data.command }}"
      cluster_id: "{{ trigger.event.data.cluster_id }}"
      endpoint_id: "{{ trigger.event.data.endpoint_id }}"
      args: "{{ trigger.event.data.args }}"
  - choose:
      - conditions:
          - "{{ command == 'on' }}"
          - "{{ cluster_id == 6 }}"
          - "{{ endpoint_id == 1 }}"
        sequence:
          - choose:
              - conditions: "{{ force_brightness }}"
                sequence:
                  - service: light.turn_on
                    target: !input "light"
                    data:
                      transition: 1
                      brightness_pct: !input "brightness"
            default:
              - service: light.turn_on
                target: !input "light"
                data:
                  transition: 1
      - conditions:
          - "{{ command == 'off_with_effect' }}"
          - "{{ cluster_id == 6 }}"
          - "{{ endpoint_id == 1 }}"
          - "{{ args == [0, 0] }}"
        sequence:
          - service: light.turn_off
            target: !input "light"
            data:
              transition: 1
      - conditions:
          - "{{ command == 'step' }}"
          - "{{ cluster_id == 8 }}"
          - "{{ endpoint_id == 1 }}"
          - "{{ args == [0, 30, 9] }}"
        sequence:
          - service: light.turn_on
            target: !input "light"
            data:
              brightness_step_pct: 10
              transition: 1
      - conditions:
          - "{{ command == 'step' }}"
          - "{{ cluster_id == 8 }}"
          - "{{ endpoint_id == 1 }}"
          - "{{ args == [0, 56, 9] }}"
        sequence:
          - service: light.turn_on
            target: !input "light"
            data:
              brightness_step_pct: 25
              transition: 1
      - conditions:
          - "{{ command == 'step' }}"
          - "{{ cluster_id == 8 }}"
          - "{{ endpoint_id == 1 }}"
          - "{{ args == [1, 30, 9] }}"
        sequence:
          - service: light.turn_on
            target: !input "light"
            data:
              brightness_step_pct: -10
              transition: 1
      - conditions:
          - "{{ command == 'step' }}"
          - "{{ cluster_id == 8 }}"
          - "{{ endpoint_id == 1 }}"
          - "{{ args == [1, 56, 9] }}"
        sequence:
          - service: light.turn_on
            target: !input "light"
            data:
              brightness_step_pct: -25
              transition: 1

16 Likes

Had to change the model

 model: RWL021

reload automations

and it works

1 Like

Where did you change that? I can’t find the file

Edit: I found it, there is a blueprints folder :man_facepalming:

I’ve updated the root blueprint to make it slightly more generic. There’s a small chance for some confusion. But the criteria should be tight enough to generally only surface supported philips remotes. Once I figure out how to allow for a defined enum of model numbers I’ll provide another update.

This is the block I changed

    remote:
      name: Philips Hue Dimmer Switch
      description: Pick either RWL020 (US) or RWL021 (EU)
      selector:
        device:
          integration: zha
          manufacturer: Philips
          entity:
            domain: sensor
            device_class: battery

And this is what it looks like to the user:

2 Likes

I think this is wonderful, thanks!
I hope version could be released some time that mimicks the advanced scene toggle function (choosing scenes based on amount of clicks on the on-button)

2 Likes

I’ll look in to it :slight_smile:

1 Like

Great Job!

BUT, is there a way to change the integration type? I use zigbee2mqtt. Is this a simple platform change in your blueprint, or a whole new thing?

4 Likes

Hi, thanks for sharing this. Big help for a newb like me.
The original scene select function is great, but I think it would be even better to have the “on” button step cycle through color_temp values (when light is on). Maybe with a selector for number of steps.
I have a very primitive automation doing this, but my lack of yaml skills prevent me from incorporating it with your blueprint and if your (very cool) brightness feature is on it’ll kick in whenever I press the “on” button. An additional feature could be a smooth transition through color_temp when “on” is held.

Just some thoughts. Thanks again.

3 Likes

Have a look at ControllerX, can do all sorts with that and really easy to set up.

1 Like

On / Off doesnt work for me :smiley: Only the dimming works

RWL021

1 Like

I’m looking at your code for minutes now, it’s awesome how easy blueprints would make automations for newcomers!

We’re using this dimmer switches in horizontal in the following way:
using the “I” button for light 1 & the “O” button for light 2

For both: on (short press) and off (long press)

I could thing of a way to use your blueprint to archive this.
But currently i’m using a variable to store the last changed light of this two and using the dim up/ down button to change the brightness of the last changed light. But I’ve got no idea how I could solve that using only one automation (currently having one for turning light 1 on/off, one for light 2 on/off, and one for each light to change the brightness) or make that available for others as a blueprint.

Maybe you find that helpful, too and are able to edit your blueprint and post that separately :slight_smile:
Greets

I think its best to make one general template for each speciality. One base that do the dame as philips default and one that can switch between lights. I do the deconz version and have the color temp mode fixed tomorrow (code can be exchanged) but its also possible to use same principle (long press) to change bulb or so.

But not one size fits all, that i do not suggest. Keep this one simple

With the greatest respect to yours and others work, check out the ControllerX add on as mentioned above, it will make your life so much simpler, out of the box it makes the Hue Dimmer work as nature intended and that’s literally just the most basic function…

1 Like

I am using ControllerX now, and it is working pretty good. But if I could ditch AppDaemon, without losing functionality that would be great.

Can I ask why you want to ditch AppDaemon? Doing it this way would normally be considered a backward step :slight_smile:

Fair question!

I have a wish to keep my setup as simple as possible, for instance:

Using ZHA instead of Deconz.
Using HA Automations instead of Node-Red.

Of course, it has to be without considerable loss of functionality (which is why I am using ControllerX now). But it is my experience, that a simpler setup brings less headaches down the road, and I am definitely going to test if this can replace ControllerX.

2 Likes

Thanks, man after my own heart, both examples are the same for me, other than came to ZHA from zigbee2mqtt, although I’ve also found they work better but must admit I just don’t get on with Node-Red, actually seems far more complicated than good old yaml for everything I want to do :slight_smile:

Also admit I avoided AppDaemon like the plague for ages and only installed it for ControllerX but hadn’t realised the add-on now makes it so simple and it’s like it’s not even there.

Good luck, whichever way you go.

1 Like

@Bobby_Nobble Thanks for the suggestion, but I think the new blueprint is the way to go. No additional software needed, fully integrated into the web interface, no editor needed, growing community.

It’s good to hear that ControllerX can do much more than this blueprint right now, however I’m sure this will evolve very quickly.

1 Like

I have ControllerX set up and working and it does everything I want - except step-cycling through color_temp.

I am the creator of ControllerX, and I agree on the fact that the setup process for ControllerX is tedious and relies on AppDaemon, which is not an official tool. I see that Blueprints are the official way towards something that ControllerX already does, but Blueprints are no more than parematrized automations that can be shared thrhough the community. They can be used for other use cases since they have a generic purpose, which is great.

ControllerX on the other hand, it is an specific tool that allows you to create controller-based automations. It can not be used for anything not related to controllers, this means that they don’t have a generic purpose, but focus well in the simple task of integrating controllers with your HA entities and services. ControllerX has the following functionality over Blueprints amongst others:

  • Integration with Z2M (state and mqtt), deCONZ and ZHA.
  • Easy to define a custom mappings through YAML code with predefined actions.
  • Smooth transition for brightness, color temp, volume.
  • Color loop for lights that support color.
  • Multiple click functionality for controllers with no hardware support for it.
  • Be able to define a very specific use case. For Blueprints if you want something specific, you need to change the blueprint yaml, which loses the purpose of using a Blueprint in my opinion.

Blueprints seem to be a beginning towards an easy way to create controller-based automations, but far to be fairly compared with ControllerX when it comes to functionality.

1 Like