Forked from hobbe/zha_blueprint_philips_hue_dimmer_swith_rwl021_fast_setup.yaml
Last active
October 14, 2023 15:02
-
-
Save ropg/47febebb670db686023128170eef37db to your computer and use it in GitHub Desktop.
Blueprint for easy setup of Philips Hue Dimmer Switch v1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
domain: automation | |
name: Philips Hue Dimmer Switch v1 (RWL021), ZHA integration, simple yet versatile. | |
description: " | |
\_ | |
Set up a house full of these dimmer switches quickly and without going crazy. All you | |
need to select is the dimmer switch and one or more lights or light groups. The default | |
behaviour of the buttons is as follows: | |
- **single click 'on'**\n\_\_\_\_on, brightness and color same as before turning off | |
- **single click 'dim up' or 'dim down'**\n\_\_\_\_7% brighter or dimmer | |
- **single click 'off'**\n\_\_\_\_off | |
- **hold 'dim up' or 'dim down'**\n\_\_\_\_15% brighter or dimmer every step | |
- **double click 'on'**\n\_\_\_\_on, white (3000K), 100% brightness | |
- **double click 'dim up'**\n\_\_\_\_on, white (3000K), 60% brightness | |
- **double click 'dim down'**\n\_\_\_\_night light: on, yellow-ish (2300K), 10% brightness | |
- **double click 'off'**\n\_\_\_\_baby sleep: off, but with a 20 minute transition | |
If you want, you can replace any of these default behaviours with one or more actions of | |
your choice. You can set actions for single, double and triple clicks, as well as the | |
repeated actions when holding the buttons. | |
\_ | |
Pro tip: if you create a helper text called 'target_lights', this blueprint will fill it | |
with the light(s) the current button press applies to. That way you can use the same script | |
for many different switches: use ``input_text.target_lights`` to refer to the lights | |
configured for the button pressed. | |
" | |
source_url: https://gist.github.com/ropg/47febebb670db686023128170eef37db | |
input: | |
switch: | |
name: Philips Hue Dimmer Switch v1 | |
description: "The dimmer switch to be used. RWL021 type switches only (rectangular, four buttons, no button marked 'Hue'.)" | |
selector: | |
device: | |
integration: zha | |
model: RWL021 | |
multiple: false | |
target_lights: | |
name: (Optional) Light(s) and/or light group(s) | |
description: "Light(s) or light group(s) to be controlled. If nothing is supplied, the default actions for the buttons will do nothing, meaning only custom actions set below will be executed." | |
default: [] | |
selector: | |
entity: | |
multiple: true | |
domain: | |
- light | |
action_on: | |
name: (Optional) 'on' action | |
description: "Action(s) when clicking the 'on' button.\nDefaults to turning the light(s) on, same color and brightness as before it was turned off." | |
default: [] | |
selector: | |
action: {} | |
action_up: | |
name: (Optional) 'up' action | |
description: "Action(s) when clicking the 'dim up' button.\nDefaults to making the light(s) 7% brighter." | |
default: [] | |
selector: | |
action: {} | |
action_down: | |
name: (Optional) 'down' action | |
description: "Action(s) when clicking the 'dim down' button.\nDefaults to making the light(s) 7% dimmer." | |
default: [] | |
selector: | |
action: {} | |
action_off: | |
name: (Optional) 'off' action | |
description: "Action(s) when clicking the 'off' button.\nDefaults to turning the light(s) off." | |
default: [] | |
selector: | |
action: {} | |
action_hold_on: | |
name: (Optional) Hold 'on' action | |
description: "Action(s) when holding down the 'on' button.\nAny action(s) here will be run repeatedly while the button is pressed." | |
default: [] | |
selector: | |
action: {} | |
action_hold_up: | |
name: (Optional) Hold 'up' action | |
description: "Action(s) when holding down the 'dim up' button.\nAny action(s) here will be run repeatedly while the button is pressed.\nDefaults to making the light 15% brighter repeatedly while button is held." | |
default: [] | |
selector: | |
action: {} | |
action_hold_down: | |
name: (Optional) Hold 'down' action | |
description: "Action(s) when holding down the 'dim down' button.\nAny action(s) here will be run repeatedly while the button is pressed.\nDefaults to making the light 15% dimmer repeatedly while button is held." | |
default: [] | |
selector: | |
action: {} | |
action_hold_off: | |
name: (Optional) Hold 'off' action | |
description: "Action(s) when holding down the 'off' button.\nAny action(s) here will be run repeatedly while the button is pressed." | |
default: [] | |
selector: | |
action: {} | |
action_double_on: | |
name: (Optional) Double click 'on' action | |
description: "Action(s) when double-clicking the 'on' button.\nDefaults to turning on light(s) at full brightness, 3000 Kelvin." | |
default: [] | |
selector: | |
action: {} | |
action_double_up: | |
name: (Optional) Double click 'up' action | |
description: "Action(s) when double-clicking the 'dim up' button.\nDefaults to turning on light(s) at 60% brightness, 3000 Kelvin." | |
default: [] | |
selector: | |
action: {} | |
action_double_down: | |
name: (Optional) Double click 'down' action | |
description: "Action(s) when double-clicking the 'dim down' button.\nDefaults to turning on light(s) at 10% brightness, 2300 Kelvin." | |
default: [] | |
selector: | |
action: {} | |
action_double_off: | |
name: (Optional) Double click 'off' action | |
description: "Action(s) when double-clicking the 'off' button.\nDefaults to baby-sleep mode: turning the light(s) off with a transition time of 20 minutes." | |
default: [] | |
selector: | |
action: {} | |
action_triple_on: | |
name: (Optional) Triple click 'on' action | |
description: "Action(s) when triple-clicking the 'on' button." | |
default: [] | |
selector: | |
action: {} | |
action_triple_up: | |
name: (Optional) Triple click 'up' action | |
description: "Action(s) when triple-clicking the 'dim up' button." | |
default: [] | |
selector: | |
action: {} | |
action_triple_down: | |
name: (Optional) Triple click 'down' action | |
description: "Action(s) when triple-clicking the 'dim down' button." | |
default: [] | |
selector: | |
action: {} | |
action_triple_off: | |
name: (Optional) Triple click 'off' action | |
description: "Action(s) when triple-clicking the 'off' button." | |
default: [] | |
selector: | |
action: {} | |
mode: restart | |
max_exceeded: silent | |
variables: | |
switch: !input switch | |
target_lights: !input target_lights | |
action_on: !input action_on | |
action_up: !input action_up | |
action_down: !input action_down | |
action_off: !input action_off | |
action_hold_on: !input action_hold_on | |
action_hold_up: !input action_hold_up | |
action_hold_down: !input action_hold_down | |
action_hold_off: !input action_hold_off | |
action_double_on: !input action_double_on | |
action_double_up: !input action_double_up | |
action_double_down: !input action_double_down | |
action_double_off: !input action_double_off | |
action_triple_on: !input action_triple_on | |
action_triple_up: !input action_triple_up | |
action_triple_down: !input action_triple_down | |
action_triple_off: !input action_triple_off | |
trigger: | |
- platform: event | |
event_type: zha_event | |
condition: '{{ trigger.event.data.device_id == switch }}' | |
action: | |
- service: input_text.set_value | |
continue_on_error: true | |
target: | |
entity_id: input_text.target_lights | |
data: | |
value: "{{ target_lights }}" | |
- variables: | |
command_type: '{{ trigger.event.data.command }}' | |
- service: logbook.log | |
data: | |
name: Command | |
message: '{{ command_type }}' | |
- choose: | |
# | |
# Single click custom actions if set | |
# | |
- conditions: '{{ command_type == "on_press" and action_on != [] }}' | |
sequence: !input action_on | |
- conditions: '{{ command_type == "up_press" and action_up != [] }}' | |
sequence: !input action_up | |
- conditions: '{{ command_type == "down_press" and action_down != [] }}' | |
sequence: !input action_down | |
- conditions: '{{ command_type == "off_press" and action_off != [] }}' | |
sequence: !input action_off | |
# | |
# Long press (hold) custom actions if set | |
# | |
- conditions: '{{ command_type == "on_hold" and action_hold_on != [] }}' | |
sequence: !input action_hold_on | |
- conditions: '{{ command_type == "up_hold" and action_hold_up != [] }}' | |
sequence: !input action_hold_up | |
- conditions: '{{ command_type == "down_hold" and action_hold_down != [] }}' | |
sequence: !input action_hold_down | |
- conditions: '{{ command_type == "off_hold" and action_hold_off != [] }}' | |
sequence: !input action_hold_off | |
# | |
# Double click custom actions if set | |
# | |
- conditions: '{{ command_type == "on_double_press" and action_double_on != [] }}' | |
sequence: !input action_double_on | |
- conditions: '{{ command_type == "up_double_press" and action_double_up != [] }}' | |
sequence: !input action_double_up | |
- conditions: '{{ command_type == "down_double_press" and action_double_down != [] }}' | |
sequence: !input action_double_down | |
- conditions: '{{ command_type == "off_double_press" and action_double_off != [] }}' | |
sequence: !input action_double_off | |
# | |
# Triple click custom actions if set | |
# | |
- conditions: '{{ command_type == "on_triple_press" and action_triple_on != [] }}' | |
sequence: !input action_triple_on | |
- conditions: '{{ command_type == "up_triple_press" and action_triple_up != [] }}' | |
sequence: !input action_triple_up | |
- conditions: '{{ command_type == "down_triple_press" and action_triple_down != [] }}' | |
sequence: !input action_triple_down | |
- conditions: '{{ command_type == "off_triple_press" and action_triple_off != [] }}' | |
sequence: !input action_triple_off | |
# | |
# DEFAULTS - The actions below will only execute if no custom actions for their respective | |
# button presses were found. | |
# | |
# | |
# Single click action defaults | |
# | |
- conditions: '{{ command_type == "on_press" }}' | |
sequence: | |
- service: light.turn_on | |
data: | |
transition: 0.3 | |
target: | |
entity_id: !input target_lights | |
- conditions: '{{ command_type == "up_press" }}' | |
sequence: | |
- service: light.turn_on | |
data: | |
brightness_step_pct: 7 | |
transition: 0.1 | |
target: | |
entity_id: !input target_lights | |
- conditions: '{{ command_type == "down_press" }}' | |
sequence: | |
- service: light.turn_on | |
data: | |
brightness_step_pct: -7 | |
transition: 0.1 | |
target: | |
entity_id: !input target_lights | |
- conditions: '{{ command_type == "off_press" }}' | |
sequence: | |
- service: light.turn_off | |
data: | |
transition: 0.3 | |
target: | |
entity_id: !input target_lights | |
# | |
# By default, holding up or down dims fast | |
# | |
- conditions: '{{ command_type == "up_hold" }}' | |
sequence: | |
- service: light.turn_on | |
data: | |
brightness_step_pct: 15 | |
transition: 0.2 | |
target: | |
entity_id: !input target_lights | |
- conditions: '{{ command_type == "down_hold" }}' | |
sequence: | |
- service: light.turn_on | |
data: | |
brightness_step_pct: -15 | |
transition: 0.2 | |
target: | |
entity_id: !input target_lights | |
# | |
# Double click defaults if no actions set | |
# | |
- conditions: '{{ command_type == "on_double_press" }}' | |
sequence: | |
- service: light.turn_on | |
data: | |
brightness_pct: 100 | |
kelvin: 3000 | |
transition: 0.3 | |
target: | |
entity_id: !input target_lights | |
- conditions: '{{ command_type == "up_double_press" }}' | |
sequence: | |
- service: light.turn_on | |
data: | |
brightness_pct: 60 | |
kelvin: 3000 | |
transition: 0.3 | |
target: | |
entity_id: !input target_lights | |
- conditions: '{{ command_type == "down_double_press" }}' | |
sequence: | |
- service: light.turn_on | |
data: | |
brightness_pct: 10 | |
kelvin: 2300 | |
transition: 0.3 | |
target: | |
entity_id: !input target_lights | |
- conditions: '{{ command_type == "off_double_press" }}' | |
sequence: | |
- service: light.turn_off | |
data: | |
transition: 1200 | |
target: | |
entity_id: !input target_lights |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment