Skip to content

Instantly share code, notes, and snippets.

@matheusl02
Forked from dverb20/philips_hue_dimmer_v22.yaml
Last active July 16, 2025 18:51
Show Gist options
  • Select an option

  • Save matheusl02/b7428c38cc7cb1c5de486cd0479133a4 to your computer and use it in GitHub Desktop.

Select an option

Save matheusl02/b7428c38cc7cb1c5de486cd0479133a4 to your computer and use it in GitHub Desktop.
Home Assistant Philips Hue Blueprint 2025 RWL022
blueprint:
name: Philips Hue Dimmer Remote RWL022 (bridge)
description: >-
Control lights and scenes with a Philips Hue dimmer remote RWL022 using ZHA.
Features:
- Power button press detection
- Up/Down dimmer with press and hold detection
- Hue button with cycling scene functionality using a helper number
- Configurable actions for each button interaction
domain: automation
input:
remote:
name: Philips Hue Dimmer Remote
description: Select your Philips Hue dimmer remote
selector:
device:
integration: hue
# Scene cycling configuration
scene_helper:
name: Scene Counter Helper
description: >-
Number helper to track current scene ID. This will be incremented
when the Hue button is pressed and reset when max is reached.
selector:
entity:
domain: input_number
max_scenes:
name: Maximum Number of Scenes
description: >-
The scene counter will cycle from 1 to this number, then back to 1.
For example, if set to 4, scenes will cycle: 1, 2, 3, 4, 1, 2...
default: 4
selector:
number:
min: 2
max: 10
mode: box
# Power button actions
power_press:
name: Power Button Press
description: Action to execute when power button is pressed
default: []
selector:
action: {}
# Dimmer up actions
dimmer_up_press:
name: Dimmer Up Press
description: Action to execute when dimmer up is pressed once
default: []
selector:
action: {}
dimmer_up_hold:
name: Dimmer Up Hold
description: Action to execute when dimmer up is held
default: []
selector:
action: {}
# Dimmer down actions
dimmer_down_press:
name: Dimmer Down Press
description: Action to execute when dimmer down is pressed once
default: []
selector:
action: {}
dimmer_down_hold:
name: Dimmer Down Hold
description: Action to execute when dimmer down is held
default: []
selector:
action: {}
# Single release action for both up and down
dimmer_release:
name: Dimmer Release
description: Action to execute when either dimmer is released after holding
default: []
selector:
action: {}
# Hue button actions
hue_press:
name: Hue Button Press
description: >-
Action to execute when Hue button is pressed.
The current scene ID is available as {{ scene_id }} in your action.
default: []
selector:
action: {}
# Blueprint mode
mode: restart
max_exceeded: silent
# Variables for easier access
variables:
scene_counter: !input scene_helper
max_scene_count: !input max_scenes
# Trigger on any ZHA event from the selected device
trigger:
- platform: event
event_type: hue_event
event_data:
device_id: !input remote
# Main action logic
action:
# Log that we triggered
# - service: system_log.write
# data:
# message: "login 1: {{ trigger.event.data.params.step_mode.value == 0 }}, logic 2: {{ trigger.event.data.params.step_size == 30}}"
# level: warning
- variables:
command: "{{ trigger.event.data.command }}"
- choose:
# Power button (commands: on or off_with_effect)
- conditions:
- condition: template
value_template: "{{ command in ['on', 'off_with_effect'] }}"
sequence: !input power_press
# Dimmer step commands - using args directly
- conditions:
- condition: template
value_template: "{{ command == 'step' }}"
sequence:
- choose:
# UP PRESS
- conditions:
- condition: template
value_template: "{{ trigger.event.data.params.step_mode.value == 0 and trigger.event.data.params.step_size == 30 }}"
sequence: !input dimmer_up_press
# UP HOLD
- conditions:
- condition: template
value_template: "{{ trigger.event.data.params.step_mode.value == 0 and trigger.event.data.params.step_size == 63 }}"
sequence: !input dimmer_up_hold
# DOWN PRESS
- conditions:
- condition: template
value_template: "{{ trigger.event.data.params.step_mode.value == 1 and trigger.event.data.params.step_size == 30 }}"
sequence: !input dimmer_down_press
# DOWN HOLD
- conditions:
- condition: template
value_template: "{{ trigger.event.data.params.step_mode.value == 1 and trigger.event.data.params.step_size == 63 }}"
sequence: !input dimmer_down_hold
# Stop command (release after hold)
- conditions:
- condition: template
value_template: "{{ command == 'stop' }}"
sequence: !input dimmer_release
# Hue button (command: recall)
- conditions:
- condition: template
value_template: "{{ command == 'recall' }}"
sequence:
# Increment the scene counter
- service: input_number.increment
target:
entity_id: !input scene_helper
# Check if we've exceeded max and need to reset
- if:
- condition: template
value_template: "{{ states(scene_counter) | int > max_scene_count | int }}"
then:
- service: input_number.set_value
target:
entity_id: !input scene_helper
data:
value: 1
# Get the current scene ID for use in the action
- variables:
scene_id: "{{ states(scene_counter) | int }}"
# Execute the configured action with scene_id available
- choose:
- conditions: []
sequence: !input hue_press
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment