Deconz - Philips Hue Dimmer Switch (RWL021)

Same as ZHA - Philips Hue Dimmer Switch (RWL020, RWL021) but for deconz

blueprint:
  name: Deconz - 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: Remote
      description: The remote to use
      selector:
        device:
          integration: deconz
          manufacturer: Philips
          model: RWL021
    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
          max: 100
          mode: slider
          step: 1
          unit_of_measurement: "%"

mode: restart
max_exceeded: silent

variables:
  force_brightness: !input force_brightness

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

action:
  - variables:
      event: "{{ trigger.event.data.event }}"
  - choose:
      - conditions:
          - "{{ event == 1000 }}"
        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:
          - "{{ event == 4000 }}"
        sequence:
          - service: light.turn_off
            target: !input light
            data:
              transition: 1

      ###########
      # Raise Dim
      ###########
      # Press
      - conditions:
          - "{{ event == 2000 }}"
        sequence:
          - service: light.turn_on
            target: !input light
            data:
              brightness_step_pct: 10
              transition: 1

      # Hold
      - conditions:
          - "{{ event == 2001 }}"
        sequence:
          - service: light.turn_on
            target: !input light
            data:
              brightness_step_pct: 25
              transition: 1

      ###########
      # Lower Dim
      ###########
      # Press
      - conditions:
          - "{{ event == 3000 }}"
        sequence:
          - service: light.turn_on
            target: !input light
            data:
              brightness_step_pct: -10
              transition: 1

      # Hold
      - conditions:
          - "{{ event == 3001 }}"
        sequence:
          - service: light.turn_on
            target: !input light
            data:
              brightness_step_pct: -25
              transition: 1
9 Likes

Nice! You should be able to support both the US and EU variants of the switch. The devices are identical outside of the reported model numbers.

I solved for it like this: ZHA - Philips Hue Dimmer Switch (RWL020, RWL021)

I will implement that too. Only other thing is by clicking the on button should change white balance (maybe color) as it does original

2 Likes

Oh nice! I had no idea. I’ll mimic whatever you come up with.

Another solution is to have multiple buttons control multiple lights. Brightness control can then be done by different button presses. This is my implementation (not a blueprint yet)

  - alias: '[bedroom|light] Toggle independent bedroom lights'
    mode: single
    trigger:
      platform: event
      event_type: deconz_event
    action:
      - choose:
          - conditions:   ################## CONDITIONS BELOW ARE FOR QUICK PRESS-RELEASE ##################
              - condition: template
                value_template: "{{ trigger.event.data.event == 1002 }}" # X000 means quick-press X002 means quick-press release
            sequence:
              - service: light.toggle
                entity_id:
                  - light.bedroom_ceiling_lights
              - delay:
                  milliseconds: 100
              - condition: state
                entity_id: light.bedroom_1
                state: 'on'
              - service: switch.flux_bedroom_fast_update
          - conditions:
              - condition: template
                value_template: "{{ trigger.event.data.event == 2002 }}"
            sequence:
              - service: light.toggle
                entity_id:
                  - light.bedside_left
              - delay:
                  milliseconds: 100
              - condition: state
                entity_id: light.bedside_left
                state: 'on'
              - service: switch.flux_bedroom_fast_update
          - conditions:
              - condition: template
                value_template: "{{ trigger.event.data.event == 3002 }}"
            sequence:
              - service: light.toggle
                entity_id:
                  - light.bedside_right
              - delay:
                  milliseconds: 100
              - condition: state
                entity_id: light.bedside_right
                state: 'on'
              - service: switch.flux_bedroom_fast_update
          - conditions:
              - condition: template
                value_template: "{{ trigger.event.data.event == 4002 }}"
            sequence:
              - service: light.toggle
                entity_id:
                  - light.ledstrip_bed
              - delay:
                  milliseconds: 100
              - condition: state
                entity_id: light.bedside_right
                state: 'on'
              - service: switch.flux_bedroom_fast_update
          - conditions: ################## CONDITIONS BELOW ARE FOR LONG PRESS ##################
            - condition: template
              value_template: "{{ trigger.event.data.event == 1001 }}"
            sequence:
              - service: light.turn_on
                data:
                  brightness_step_pct: 10
                  entity_id:
                    - light.bedroom_1
                    - light.bedroom_2
                    - light.bedroom_3
              - delay:
                  milliseconds: 100
              - service: switch.flux_bedroom_fast_update
          - conditions:
              - condition: template
                value_template: "{{ trigger.event.data.event == 2001 }}"
            sequence:
              - service: light.turn_on
                data:
                  brightness_step_pct: 10
                  entity_id:
                    - light.bedside_left
              - delay:
                  milliseconds: 100
              - service: switch.flux_bedroom_fast_update
          - conditions:
              - condition: template
                value_template: "{{ trigger.event.data.event == 3001 }}"
            sequence:
              - service: light.turn_on
                data:
                  brightness_step_pct: 10
                  entity_id:
                    - light.bedside_right
              - delay:
                  milliseconds: 100
              - service: switch.flux_bedroom_fast_update
          - conditions:
              - condition: template
                value_template: "{{ trigger.event.data.event == 4001 }}"
            sequence:
              - service: light.turn_on
                data:
                  brightness_step_pct: 10
                  entity_id:
                    - light.ledstrip_bed
              - delay:
                  milliseconds: 100
              - service: switch.flux_bedroom_fast_update

Thanks @aleksander.lyse and I can add these elements for those who want to have random color and white lights by pressing one of the two middle buttons

  - conditions:
    - '{{ event == 2003 }}'
    sequence:
    - service: light.turn_on
      target: !input 'light'
      data:
        hs_color:
          - "{{ range(360)|random }}"
          - "{{ range(80,101)|random }}"
  - conditions:
    - '{{ event == 3003 }}'
    sequence:
    - service: light.turn_on
      target: !input 'light'
      data:
        rgb_color: [255,255,255]```

Hi, I feel stupid asking this but I have an issue. I imported blue print, added a title, and selected my switch and light entity from the drop down menu. Then I hit save.

What is strange is that the automation is not in the list of all automation. I searched for it in config and dev/tools. What I’m missing?

Do you have a file called automations.yaml in your home directory? Automations condigured in the UI can only be written to automations.yaml and if you split up your setup with packages or similar it won’t work.

Like this you get the best of both worlds:

homeassistant:
  packages: !include_dir_named packages/
automation: !include automations.yaml
1 Like

wow. That was easy! Thank you very much. Works like a charm!

I really appreciate your hard work on this. Big thank you from me.
Sorry if this is missed somewhere, but is there a way to set a default colour temperature when turning on the light? I use the default brightness, which is fantastic, but if the light was 2500 Kelvin when turned off, this is the colour temperature it turns back on at.
Is there a way to set a default colour temperature, like you set a default brightness, or could this be a feature request?

Needed This! Thanks!