Skip to content

Instantly share code, notes, and snippets.

@sandervv
Last active March 18, 2024 05:20
Show Gist options
  • Save sandervv/f326ff3b2bcb945b5a9dc0bfb82e3308 to your computer and use it in GitHub Desktop.
Save sandervv/f326ff3b2bcb945b5a9dc0bfb82e3308 to your computer and use it in GitHub Desktop.
blueprint:
name: ZHA - Philips Hue Dimmer Switch Config - V2023.12.15
description: |
Control lights with a Philips Hue Dimmer Switch (only RWL020 (US) and RWL021 (EU), RWL022, the one that says 'hue' on the bottom, has a different button layout.)
This blueprint is a simplified version of stefanroelofs's `ZHA - Philis Hue Dimmer Switch V2', but this one has no default inputs and with full configuration available. This makes the remote easily configurable for purposes other than controlling lights.
If you are intending to just use it for use as a light switch, I recommend using his blueprint, which you can find at https://gist.github.com/stefanroelofs/775e2e0a3cdb3d72a9451fb247492d59
It includes customizable 'on' button behaviour and default setup of the dimmer buttons to dim as they normally would. To make the configuration available for other automations, I had to remove these very useful functionalities.
Please note that the Philips Hue Dimmer Switch also supports triple, quadruple, and even quintuple button presses. It's fairly easy to configure these yourself by editing this blueprint.
Please also note that I am not much good at python and therefore probably cannot help you if this does not work. All credit for figuring out how all this works goes to stefanroelofs, vanstinator and warriorrocker. I just adapted their work to make the dimming buttons free to execute other actions.
Does this blueprint not work for you? Did you add your Hue dimmer to ZHA before July 2020?
It might help to press the 'Reconfigure device' button on the ZHA Device info page.
The naming of the command attribute in the zha_event was changed back then.
domain: automation
source_url: https://gist.github.com/sandervv/f326ff3b2bcb945b5a9dc0bfb82e3308
# Define the inputs for the blueprint
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
# inputs for custom actions
button_on_short_press:
name: On button short press
description: Action to run on short on button press.
default: []
selector:
action:
button_on_long_press:
name: On button long press
description: Action to run on long on button press.
default: []
selector:
action:
button_on_double_press:
name: On button double press
description: Action to run on double on button press.
default: []
selector:
action:
button_up_short_press:
name: Up button short press
description: Action to run on short up button press.
default: []
selector:
action:
button_up_long_press:
name: Up button long press
description: Action to run on long up button press.
default: []
selector:
action:
button_up_double_press:
name: Up button double press
description: Action to run on double up button press.
default: []
selector:
action:
button_down_short_press:
name: Down button short press
description: Action to run on short down button press.
default: []
selector:
action:
button_down_long_press:
name: Down button long press
description: Action to run on long down button press.
default: []
selector:
action:
button_down_double_press:
name: Down button double press
description: Action to run on double down button press.
default: []
selector:
action:
button_off_short_press:
name: Off button short press
description: Action to run on short off button press.
default: []
selector:
action:
button_off_long_press:
name: Off button long press
description: Action to run on long off button press.
default: []
selector:
action:
button_off_double_press:
name: Off button double press
description: Action to run on double off button press.
default: []
selector:
action:
mode: restart
max_exceeded: silent
# Trigger the automation when the selected dimmer remote sends an event
# Also only trigger on cluster_id 64512. This ignores the 'old' events with cluster_id 8.
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input 'remote'
cluster_id: 64512
action:
- variables:
command : '{{ trigger.event.data.command }}'
- choose:
- conditions: '{{ command == ''on_press'' }}'
sequence: !input button_on_short_press
- conditions: '{{ command == ''on_hold'' }}'
sequence: !input button_on_long_press
- conditions: '{{ command == ''on_double_press'' }}'
sequence: !input button_on_double_press
- conditions: '{{ command == ''off_press'' }}'
sequence: !input button_off_short_press
- conditions: '{{ command == ''off_hold'' }}'
sequence: !input button_off_long_press
- conditions: '{{ command == ''off_double_press'' }}'
sequence: !input button_off_double_press
- conditions: '{{ command == ''up_press'' }}'
sequence: !input button_up_short_press
- conditions: '{{ command == ''up_hold'' }}'
sequence: !input button_up_long_press
- conditions: '{{ command == ''up_double_press'' }}'
sequence: !input button_up_double_press
- conditions: '{{ command == ''down_press'' }}'
sequence: !input button_down_short_press
- conditions: '{{ command == ''down_hold'' }}'
sequence: !input button_down_long_press
- conditions: '{{ command == ''down_double_press'' }}'
sequence: !input button_down_double_press
@aapo1974
Copy link

I have a RWL021 EU version of the dimmer. I am having problems with my HA/ZHA setups with double presses. I can see the double button presses and call for automation in the log but my service calls do not happen. Any Ideas?

@sandervv
Copy link
Author

Hi Aapo, I'm not sure, as the blueprint has been working for me flawlessly since I set it up. I also use double presses. If they are showing up on the log, it sounds to me like there might be an issue in your automation. Have you looked at the trace to see if it completes correctly?

@aapo1974
Copy link

Hi, yep the automation works correctly. I set the automation to run on a double press with the on and off buttons. It works there...quite strange.

@sandervv
Copy link
Author

sandervv commented Dec 15, 2023

Well, I'm dumb. I just had another look at the blueprint and realised I didn't get the commands right. The down and up double press were still linked to the 'on' button instead of their respective buttons.

If you're on the newest version of HA you can update the blueprint and it should work. I'm really sorry!

@aapo1974
Copy link

Nice, thanks a lot! I will update. Thanks for your contribution!!!

@aapo1974
Copy link

Looking at the changes you made, I should have noticed those commands too =)

@sandervv
Copy link
Author

Well, it's not your responsibility to troubleshoot my blueprint, and it's such a dumb mistake it's easy to miss, evidently... haha

@moffermann223
Copy link

My Hue Dimmer Switch is firing the short-press event every time. Even if I do a long or double press, the short press action is triggered anyway. That's a bit annoying.
Therefore, I changed the command to the appropriate release event, means:
on_press --> on_short_release
up_press --> up_short_release
down_press --> down_short_release
off_press --> off_short_release

Now, every event can be used independently from each other.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment