Skip to content

Commit 6865970

Browse files
committed
Add Philips Hue Dimmer v2 blueprint
Adapted from https://gist.github.com/cptkng/d7b61656ca0bb2679183cab6e6c6684a
1 parent c8babf0 commit 6865970

File tree

1 file changed

+321
-0
lines changed

1 file changed

+321
-0
lines changed
Lines changed: 321 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,321 @@
1+
blueprint:
2+
name: ZHA - Philips Hue Dimmer Switch v2 - Light Control
3+
description: |
4+
Control lights with a Philips Hue Dimmer Switch v2.
5+
6+
The top "power" button behaviour is adjustable. By default it toggles the light with the last set brightness.
7+
8+
Dim up/down buttons will change the brightness smoothly and can be pressed
9+
and hold until the brightness is satisfactory.
10+
11+
The bottom "scene" button will turn the light off.
12+
13+
The "power" and "scene" buttons can be assigned to an action when double
14+
or triple pressed. This allows you to assign e.g. a scene or something else.
15+
16+
The minimum brightness setting will limit how low you can set the brightness. This will
17+
prevent dimming down until the light turns off. Set this to zero to disable this feature.
18+
19+
Does this blueprint not work for you? Did you add your Hue dimmer to ZHA before July 2020?
20+
It might help to press the 'Reconfigure device' button on the ZHA Device info page.
21+
The naming of the command attribute in the zha_event was changed back then.
22+
23+
domain: automation
24+
25+
# Define the inputs for the blueprint
26+
input:
27+
remote:
28+
name: Philips Hue Dimmer Switch v2
29+
description: Pick RWL022 (v2 dimmer)
30+
selector:
31+
device:
32+
integration: zha
33+
manufacturer: Signify Netherlands B.V.
34+
entity:
35+
domain: sensor
36+
device_class: battery
37+
light:
38+
name: The light(s) to control
39+
description: >
40+
The light entity to control
41+
(only a single entity is supported; use light groups when needed)
42+
selector:
43+
entity:
44+
domain: light
45+
power_button_mode:
46+
name: The mode for the "power" button
47+
description: >
48+
Choose behaviour when pressing the "power" button.
49+
- Fixed brightness; Always turn on the lights with a fixed brightness
50+
- Fixed brightness when on; If light is off, turn on the light; If light is on, set it to a fixed brightness
51+
- Always toggle; Always turn on the light to the last set brightness
52+
- Always toggle fixed brightness; Always turn on the light with a fixed brightness
53+
default: always toggle
54+
selector:
55+
select:
56+
options:
57+
- fixed brightness
58+
- fixed brightness when on
59+
- always toggle
60+
- always toggle fixed brightness
61+
fixed_brightness:
62+
name: Fixed Brightness
63+
description: The fixed brightness of the light(s) when turning on
64+
default: 255
65+
selector:
66+
number:
67+
min: 0.0
68+
max: 255.0
69+
mode: slider
70+
step: 1.0
71+
min_brightness:
72+
name: Minimum Brightness
73+
description: >
74+
The minimum brightness of the light(s) when dimming down.
75+
Set this to zero to disable this feature.
76+
default: 1
77+
selector:
78+
number:
79+
min: 0.0
80+
max: 255.0
81+
mode: slider
82+
step: 1.0
83+
power_button_section:
84+
name: Power button
85+
icon: mdi:power
86+
collapsed: false
87+
input:
88+
button_power_double:
89+
name: Power button - Double press
90+
description: Action to run when double pressing the power button
91+
default: []
92+
selector:
93+
action:
94+
button_power_triple:
95+
name: Power button - Triple press
96+
description: Action to run when triple pressing the power button
97+
default: []
98+
selector:
99+
action:
100+
button_power_long:
101+
name: Power button - Long press (repeating)
102+
description: Action to run when holding down the power button
103+
default: []
104+
selector:
105+
action:
106+
scene_button_section:
107+
name: Scene button
108+
icon: mdi:palette
109+
collapsed: false
110+
input:
111+
button_scene_double:
112+
name: Scene button - Double press
113+
description: Action to run when double pressing the scene button
114+
default: []
115+
selector:
116+
action:
117+
button_scene_triple:
118+
name: Scene button - Triple press
119+
description: Action to run when triple pressing the scene button
120+
default: []
121+
selector:
122+
action:
123+
button_scene_long:
124+
name: Scene button - Long press (repeating)
125+
description: Action to run when holding down the scene button
126+
default: []
127+
selector:
128+
action:
129+
temperature_section:
130+
name: Colour temperature
131+
icon: mdi:lightbulb-on-50
132+
collapsed: true
133+
input:
134+
max_temperature:
135+
name: Max temperature
136+
description: The maximum colour temperature before looping round to the minimum.
137+
default: 450
138+
selector:
139+
number:
140+
min: 1.0
141+
max: 600.0
142+
step: 1.0
143+
mode: slider
144+
min_temperature:
145+
name: Min temperature
146+
description: The minimum colour temperature, set when the maximum has been reached and the temperature is changed.
147+
default: 225
148+
selector:
149+
number:
150+
min: 1.0
151+
max: 600.0
152+
step: 1.0
153+
mode: slider
154+
temperature_change_step:
155+
name: Temperature change step
156+
description:
157+
Step value to add to colour temperature for each change.
158+
default: 75
159+
selector:
160+
number:
161+
min: 1.0
162+
max: 600.0
163+
step: 1.0
164+
mode: slider
165+
temperature_transition_time:
166+
name: Temperature change transition time
167+
description:
168+
Number of seconds for temperature to transition over.
169+
default: 0.5
170+
selector:
171+
number:
172+
min: 0.0
173+
max: 10.0
174+
step: 0.1
175+
mode: slider
176+
177+
# mode: restart
178+
max_exceeded: silent
179+
180+
variables:
181+
light : !input light
182+
power_button_mode : !input power_button_mode
183+
fixed_brightness : !input fixed_brightness
184+
min_brightness : !input min_brightness
185+
min_temperature : !input min_temperature
186+
max_temperature : !input max_temperature
187+
temperature_change_step : !input temperature_change_step
188+
189+
# Trigger the automation when the selected dimmer remote sends an event
190+
# Also only trigger on cluster_id 64512. This ignores the 'old' events with cluster_id 8.
191+
trigger:
192+
- platform: event
193+
event_type: zha_event
194+
event_data:
195+
device_id: !input 'remote'
196+
cluster_id: 64512
197+
198+
action:
199+
- variables:
200+
command : '{{ trigger.event.data.command }}'
201+
cur_brightness : '{{ state_attr(light, "brightness") | default(0) }}'
202+
is_turned_on : '{{ states(light) == "on" }}'
203+
204+
- choose:
205+
- conditions: '{{ command == "on_press" }}'
206+
sequence:
207+
- choose:
208+
- conditions: '{{ power_button_mode == "fixed brightness" }}'
209+
sequence:
210+
- action: light.turn_on
211+
data:
212+
entity_id : !input 'light'
213+
transition: 0.5
214+
brightness: !input 'fixed_brightness'
215+
- conditions:
216+
- '{{ power_button_mode == "fixed brightness when on" }}'
217+
- '{{ is_turned_on }}'
218+
sequence:
219+
- action: light.turn_on
220+
data:
221+
entity_id : !input 'light'
222+
transition: 0.5
223+
brightness: !input 'fixed_brightness'
224+
- conditions:
225+
- '{{ power_button_mode == "always toggle fixed brightness" }}'
226+
- '{{ is_turned_on }}'
227+
sequence:
228+
- action: light.turn_off
229+
data:
230+
entity_id : !input 'light'
231+
transition: 0.5
232+
- conditions:
233+
- '{{ power_button_mode == "always toggle fixed brightness" }}'
234+
sequence:
235+
- action: light.turn_on
236+
data:
237+
entity_id : !input 'light'
238+
transition: 0.5
239+
brightness: !input 'fixed_brightness'
240+
default:
241+
- action: light.toggle
242+
data:
243+
entity_id : !input 'light'
244+
transition: 0.5
245+
246+
- conditions: '{{ command == "on_double_press" }}'
247+
sequence: !input button_power_double
248+
249+
- conditions: '{{ command == "on_triple_press" }}'
250+
sequence: !input button_power_triple
251+
252+
- conditions: '{{ command == "on_hold" }}'
253+
sequence: !input button_power_long
254+
255+
- conditions: '{{ command == "off_press" }}'
256+
sequence:
257+
- action: light.turn_on
258+
data:
259+
color_temp: "{% if state_attr(light, 'color_temp')|int >= max_temperature %}{{ min_temperature }}{% else %}{{ state_attr(light, 'color_temp')|int + temperature_change_step }}{% endif %}"
260+
transition: !input temperature_transition_time
261+
target:
262+
entity_id: !input light
263+
264+
- conditions: '{{ command == "off_double_press" }}'
265+
sequence: !input button_scene_double
266+
267+
- conditions: '{{ command == "off_triple_press" }}'
268+
sequence: !input button_scene_triple
269+
270+
- conditions: '{{ command == "off_hold" }}'
271+
sequence: !input button_scene_long
272+
273+
- conditions: '{{ command == "up_press" }}'
274+
sequence:
275+
- action: light.turn_on
276+
data:
277+
entity_id : !input 'light'
278+
brightness_step: 25
279+
transition: 0.5
280+
281+
- conditions: '{{ command == "up_hold" }}'
282+
sequence:
283+
- action: light.turn_on
284+
data:
285+
entity_id : !input 'light'
286+
brightness_step: 50
287+
transition: 0.5
288+
289+
- conditions: '{{ command == "down_press" }}'
290+
sequence:
291+
- choose:
292+
- conditions: '{{ (cur_brightness - 25) >= min_brightness }}'
293+
sequence:
294+
- action: light.turn_on
295+
data:
296+
entity_id : !input 'light'
297+
transition: 0.5
298+
brightness_step: -25
299+
default:
300+
- action: light.turn_on
301+
data:
302+
entity_id : !input 'light'
303+
transition: 0.5
304+
brightness: !input 'min_brightness'
305+
306+
- conditions: '{{ command == "down_hold" }}'
307+
sequence:
308+
- choose:
309+
- conditions: '{{ (cur_brightness - 50) >= min_brightness }}'
310+
sequence:
311+
- action: light.turn_on
312+
data:
313+
entity_id : !input 'light'
314+
transition: 0.5
315+
brightness_step: -50
316+
default:
317+
- action: light.turn_on
318+
data:
319+
entity_id : !input 'light'
320+
transition: 0.5
321+
brightness: !input 'min_brightness'

0 commit comments

Comments
 (0)